< Day Day Up > |
The Flash Objects API lets extension developers build objects that create simple Flash content through Flash Generator. This API provides a way to set parameters in a Flash Generator template and output a SWF or image file. The API lets you create new Flash objects as well as read and manipulate existing Flash objects. The Flash button and Flash text features are built using this API. The SWT file is a Flash Generator Template file, which contains all the information you need to construct a Flash Object file. These API functions let you create a new SWF file (or image file) from a SWT file by replacing the parameters of the SWT file with real values. For more information on Flash, see the Flash documentation. The following functions are methods of the SWFFile object. SWFFile.createFile()Description This function generates a new Flash Object file with the specified template and array of parameters. It also creates a GIF, PNG, JPEG, and MOV version of the title if filenames for those formats are specified. If you want to specify an optional parameter that follows optional parameters that you do not want to include, you need to specify empty strings for the unused parameters. For example, if you want to specify a PNG file, but not a GIF file, you need to specify an empty string before specifying the PNG filename. Arguments templateFile, templateParams, swfFileName, {gifFileName}, {pngFileName}, {jpgFileName}, {movFileName}, {generatorParams}
Returns A string that contains one of the following values:
Example The following JavaScript creates a Flash object file of type "myType", which replaces any occurrences of the string "text" inside the Template file with the string, "Hello World". It creates a GIF file as well as a SWF file. var params = new Array; params[0] = "dwType"; params[1] = "myType"; params[2] = "text"; params[3] = "Hello World"; errorString = SWFFile.createFile( "file:///MyMac/test.swt", params, "file:///MyMac/test .swf", "file:///MyMac/test.gif"); SWFFile.getNaturalSize()Description This function returns the natural size of any Flash content. Arguments fileName
Returns An array that contains two elements that represent the width and the height of the Flash content or a null value if the file is not a Flash file. SWFFile.getObjectType()Description This function returns the Flash object type; the value that passed in the dwType parameter when the SWFFile.createFile() function created the file. Arguments fileName
Returns A string that represents the object type, or null if the file is not a Flash Object file or if the file cannot be found. Example The following code checks to see if the test.swf file is a Flash object of type myType: if ( SWFFile.getObjectType("file:///MyMac/test.swf") == "myType" ){ alert ("This is a myType object."); }else{ alert ("This is not a myType object."); } SWFFile.readFile()Description This function reads a Flash Object file. Arguments fileName
Returns An array of strings where the first array element is the full path to the template SWT file. The following strings represent the parameters (name/value pairs) for the object. Each name is followed in the array by its value. The first name/value pair is "dwType", followed by its value. The function returns a null value if the file cannot be found or if it is not a Flash Object file. Example Calling var params = SWFFile.readFile("file:///MyMac/test.swf") returns the following values in the parameters array: "file:///MyMac/test.swt" // template file used to create this .swf file "dwType" // first parameter "myType" // first parameter value "text" // second parameter "Hello World" // second parameter value |
< Day Day Up > |