ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > CustomActions > install (CustomActions.install method) | |||
Installs a new custom action XML definition file indicated by the name parameter. The contents of the file is specified by the string customXML.
The name of the definition file must be a simple filename, without the .xml file extension, and without any directory separators (':', '/' or '\').
If a custom actions file already exists with the name name, it is overwritten.
If the Configuration/ActionsPanel/CustomActions directory does not exist when this method is invoked, the directory is created.
Availability: ActionScript 1.0; Flash Player 6
name:String - The name of the custom action definition to install.
data:String - The text of the XML definition to install.
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.
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.
|
|
|
|