MACROMEDIA FLASH 8-USING FLASH Use Manual page 650

Using flash
Table of Contents

Advertisement

Example
The following example uses the JavaScript API to create a new command that appears on the
Commands menu. Create two files, as described in this section, and place them in your
Commands folder in your user-level configuration folder. For more information, see
"Configuration folders installed with Flash" in Getting Started with Flash.
First, create a file named scale.jsfl in your Commands folder. Place the following code into the
file and save the file:
// Create an XML to UI dialog box using the XML definition
// in the scale.xml file
var scaleDlg = fl.getDocumentDOM().xmlPanel( fl.configURI + "Commands/
scale.xml" );
if (scaleDlg.dismiss == "accept") {
// Place the values of xScale and yScale from the dialog box
// into local variables. The code casts (converts) the values from the
// dialog box to a number before assigning them to the local variables
// because the scaleSelection() method takes numbers as parameters.
var xScale = Number(scaleDlg.xScale);
var yScale = Number(scaleDlg.yScale);
// check for valid input because sending 0 or undefined to
// scaleSelection() will cause the object to disappear.
var inputIsValid = true;
if (xScale == 0 || isNaN(xScale)) {
inputIsValid = false;
}
if (yScale == 0 || isNaN(yScale)) {
inputIsValid = false;
}
// Call scaleSelection to carry out the resizing command.
if (inputIsValid ) {
fl.getDocumentDOM().scaleSelection(xScale, yScale);
}
}
Second, create a file named scale.xml and place it in your Commands folder. Place the
following code into the file and save the file:
<?xml version="1.0"?>
<dialog id="scale-dialog" title="Scale Selection" buttons="accept, cancel">
<grid>
<columns>
<column/>
<column/>
</columns>
650
XML to UI

Advertisement

Table of Contents
loading

This manual is also suitable for:

Flash 8

Table of Contents