472
ActionScript classes
Parameters
name
:String
- The name of the custom action definition to install.
data
:String
- The text of the XML definition to install.
Returns
Boolean
- A Boolean value of
false
if an error occurs during installation; otherwise, a value
of
true
is returned to indicate that the custom action has been successfully installed.
Example
The following example installs information into the Actions panel from an XML file. Open a
text editor and save a new document called dogclass.xml. Enter the following code:
<?xml version="1.0"?>
<customactions>
<actionspanel>
<folder version="7" id="DogClass" index="true" name="Dog" tiptext="Dog
Class">
<string version="7" id="getFleas" name="getFleas" tiptext="gets number
of fleas" text=".getFleas(% fleas %)" />
</folder>
</actionspanel>
<colorsyntax>
<identifier text=".getFleas" />
</colorsyntax>
<codehints>
<typeinfo pattern=" _dog" object="Dog"/>
</codehints>
</customactions>
Then open a new FLA file in the same directory and select Frame 1 of the Timeline. Enter the
following code into the Actions panel:
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success:Boolean) {
trace(success);
CustomActions.install("dogclass", this.firstChild);
trace(CustomActions.list());
};
my_xml.load("dogclass.xml");
Select Control > Test Movie, and if the XML loads successfully, you will see
true
, and an
array containing the names of all the custom actions that are registered with the Flash
authoring tool in the Output panel. Close the SWF file, and open the Actions panel. You will
see a new item in the Actions toolbox called Dog, and inside that folder you see getFleas.
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...