SWF-PHP Documentation (v. 0.9.1)
Static Methods
setPrefix
Description
static void setPrefix ( [ string $prefix = 'swfphp' ] )Return Values
No value is returned.Notes
This function sets the prefix that is used to generate automatic id and name attributes if you do not explicitly specify any. You must use the character set [A-Za-z][A-Za-z0-9_]+. Although the additional charaters .\*- are valid for the id and name attributes in (X)HTML, you cannot use these characters because they are javascript operators (the id property is used in the fscommand javascript wrapper functions).The default value is swfphp.
Examples
setDoctype
Description
static void setDoctype ( [ string $doctype = 'XHTML 1.0' ] )Return Values
No value is returned.Notes
This method sets the doctype for the SWF-PHP class. The createHtml method will generate different code depending on which DTD you specify. Note that this method will simply search for the portion of the doctype that is necessary to determine output, so you can pass an entire <!DOCTYPE> declaration or merely the portion necessary. Specifically, SWF-PHP looks for the one of the following strings:- HTML 4.01
- XHTML 1.0
- XHTML 1.1
- XHTML Basic 1.0
- XHTML Basic 1.1
Examples
Methods
__construct
Description
Return Values
No value is returned.Notes
You have the option of specifying the src and dimensions in the constructor. The constructor will trigger user errors if you pass invalid values for the parameters. See src and width / height for details.Examples
createHtml
Description
bool createHtml ( void )Return Values
Returns TRUE if no errors, FALSE otherwise.Notes
Creates the HTML output without returning it. Useful if you want to make sure your SWF-PHP object will render correctly before you send any output to the browser. This method is called every time you access the html property.Examples
Properties
$id
Default
nullDescription
This is a string value that represents the id and name attributes in the <object> and <embed> tags. It is also used to identify the <div> container that surrounds the entire output.Notes
The id and name attributes of the <object> tag will be set to this value, while the <div> container tag will have an id value of $id followed by _container.
The id must be unique. If you enter a value that has previously been used in your script, a fatal error will be triggered. If you do not enter a value, SWF-PHP will automatically assign a unique value for you. SWF-PHP maintains a static internal registry of all ids to prevent you from accidentally using the same id twice.
See the setPrefix method for the acceptable character set for this property.
Examples
$src
Default
nullDescription
This is the path & filename of the compiled SWF file.Notes
The location of the actual SWF can be relative or absolute. If the path is relative, e.g. ../my-swfs/example.swf, keep in mind that the browser will consider the location of the file being requested over HTTP as the current path, which may or may not be the same file that actually instantiates the SWF class. Using an absolute path avoids this problem, e.g. http://www.example.com/my-swfs/example.swf.This property can be passed to the constructor as well.
Examples
Example #1. Assume you're working in the public_html directory of example.com with a file called `index.php'. Your SWF file is located in public_html/my-swfs$width, $height
Default
(string) "100%"Description
The width and height of the SWF object.Notes
The width and height of the SWF object have defaults of "100%", meaning they will span the dimensions of the immediate parent container. This is useful when you are using fluid dimensions in CSS and want your SWF to fill the space like any other DOM object. This is also useful for full-screen Flash apps that need to fill the entire browser window (or most of it).These properties will accept either integer values or a percentage. If you enter any other value, SWF-PHP will typecast the value as an integer. This may produce unexpected results.
Examples
$alt
Default
nullDescription
The $alt property can contain any HTML that you want to appear in the event that a user has javascript disabled AND cannot properly render the <object> tag.Notes
This should rarely be needed as most users have javascript enabled or can render <object> tags. Be careful what you put in here. SWF-PHP does not do any error checking on this value and it will not stop you from prematurely closing the </noscript> or </object> tags.Examples
$flashVars
Default
(array) emptyDescription
The FlashVars to pass to the SWF object. This is an associative array, with key-value pairs corresponding to variable names and values.Notes
FlashVars provide a way to pass variables to a SWF object at runtime. FlashVars should typically be short; if you need to load a lot of data dynamically, it should be moved into an external XML file and loaded through AS3's XML loading functions. FlashVars are useful for instances where creating an XML file would be a waste of time (e.g. you only need to pass a single variable).SWF-PHP will urlencode all the values; you do not need to urlencode them yourself.
Crucial points:
- Keep in mind that SWF-PHP will output all values as strings, so (bool) true will output as "1" and (bool) false will output as an empty string.
- The ActionScript virtual machine will interpret variables passed through FlashVars differently than PHP does. See the example below for more details.
Warning: you can manually set FlashVars by using the param property, but this is not advisable and may produce unexpected results.
Examples
As you can see, between PHP, HTML, and AS3, a (bool)true can quickly become (string)"1". Type juggling between these languages can get tricky, so keep this in mind when using FlashVars.
Back to top$param
Default
(array) emptyDescription
This is an associative array corresponding to the <param> tags that control the behavior of the SWF in the browser. It should contain key-value pairs corresponding to the name and value attributes of the <param> tag.Notes
Although the default value is an empty array, when you output the HTML, SWF-PHP will assign its own default values where necessary. You only need to explicitly define the values you want to override from the defaults. The table below lists valid parameters, the defaults and the possible values you can input. Note that all values are urlencoded.| Name | Default Value | Acceptable Values | Notes |
| allowScriptAccess | sameDomain | always | never | sameDomain | Not case-sensitive |
| allowFullScreen | true | true | false | These are string literals |
| swliveconnect | false | true | false | Whether the browser should start Java when loading the Flash Player for the first time. These are string literals |
| FlashVars | empty | Any string | You should ALWAYS use the $flashVars property to set this parameter, though you can set it manually. If $flashVars is not empty, the createHtml() method will concatenate the values of $flashVars with $param['FlashVars'], which may produce unexpected results. |
| menu | false | true | false | These are string literals |
| quality | high | low | autolow | autohigh | medium | high | best | |
| bgcolor | #ffffff | Any valid hex color | You cannot use CSS shorthand abbreviations, e.g. #ff0 |
| wmode | opaque | opaque | transparent | window | Controls appearance and positioning in the browser |
| scale | showall | showall | exactfit | Note that if you use percentages in your width OR height, SWF-PHP will automatically toggle to 'exactfit' regardless of what you do. |
See Adobe LiveDocs for more details