
415
EXTENDING FLASH CS4 PROFESSIONAL
swfPanel object
Description
Method; works in conjunction with the ActionScript ExternalInterface.addCallback() and MMExecute()
methods to communicate with the SWF panel from the authoring environment.
Example
The following example illustrates how to use ActionScript and JavaScript code to create a Window SWF panel and
communicate with it from the authoring environment.
1 Create an ActionScript 3.0 FLA file, set its color to a medium gray, and set its size to 400 pixels wide and 250 pixels
high.
2 Place a dynamic text box in the center of the Stage, set its Instance name to myTextField, and type the word
"Status" in the text box.
3 Set other text box properties similar to the following:
• Center aligned
• 355 pixels wide and 46 pixels high
• Times New Roman font, 28 points, red
4 Add the following ActionScript code:
// Here's the callback function to be called from JSAPI
function callMeFromJavascript(arg:String):void
{
try {
var name:String = String(arg);
myTextField.text = name;
} catch (e:Error) {
}
}
// Expose the callback function as "callMySWF"
ExternalInterface.addCallback("callMySWF", callMeFromJavascript);
// run the JSAPI to wire up the callback
MMExecute("fl.runScript( fl.configURI + \"WindowSWF/fileOp.jsfl\" );");
MMExecute("fl.trace(\"AS3 File Status Panel Initialized\");");
5 Save the file as fileStatus.fla, and publish the SWF file with the default Publish settings.
6 Close Flash.
7 Copy the fileStatus.swf file to the WindowSWF folder, which is a subfolder of the Configuration folder (see “Saving
JSFL files” on page 2). For example, on Windows XP, the folder is in boot drive\Documents and Settings\user\Local
Settings\Application Data\Adobe\Flash CS4\language\Configuration\WindowSWF.
8 Start Flash.
9 Create a JSFL file with the following code:
Comentários a estes Manuais