
213
EXTENDING FIREWORKS: DEVELOPING AN EFFECTIVE WORKFLOW USING JAVASCRIPT AND FLASH
ActionScript 3 still supports the concept of “including” external files, only you don’t need to include
the # symbol. So, the first thing we do is update the include statement:
// Import External JSF
include "jsf/jsfCode.as"
The rest of the code will be moved to the new Draw Rect.as file and will need to be modified slightly.
Start by defining the package and DrawRect class:
package {
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.external.ExternalInterface;
import adobe.utils.*;
public class DrawRect extends MovieClip
{
}
}
Note that the flash.external.ExternalInterface and adobe.utils.* packages have been imported.
These are required in order to communicate with Fireworks. Now assign event handlers to the but-
tons, this time using the addEventListener method:
public class DrawRect extends MovieClip
{
// Add Button Event Handlers
executeJSF_btn.addEventListener(MouseEvent.CLICK,
executeJSF_onRelease);
colorPicker_mc.addEventListener(MouseEvent.CLICK,
colorPicker_onRelease);
}
// Event Handlers
function executeJSF_onRelease(e:Event):void
{
// Execute the JSF, creating the CreateRectangle function
MMExecute(jsfCode);
// Calculate the CornerRadius value
var cornerRadius:Number = nsCornerRadius.value / 100;
// Call CreateRectangle
MMExecute("CreateRectangle(" + nsX.value + "," + nsY.value + "," +
nsWidth.value + "," + nsHeight.value + "," +
cornerRadius.toString() + ", '" + currentColor + "');");
}
Komentarze do niniejszej Instrukcji