View comments | RSS feed

Adding component metadata

You can add component metadata tags in your external ActionScript class files to tell the compiler about component parameters, data binding properties, and events. Metadata tags are used in the Flash authoring environment for a variety of purposes.

The metadata tags can only be used in external ActionScript class files. You cannot use metadata tags in FLA files.

Metadata is associated with a class declaration or an individual data field. If the value of an attribute is a string, you must enclose that attribute in quotation marks.

Metadata statements are bound to the next line of the ActionScript file. When defining a component property, add the metadata tag on the line before the property declaration. The only exception is the Event metadata tag. When defining component events, add the metadata tag outside the class definition so that the event is bound to the entire class.

In the following example, the Inspectable tags define the flavorStr, colorStr, and shapeStr parameters:

[Inspectable(defaultValue="strawberry")]
public var flavorStr:String;
[Inspectable(defaultValue="blue")]
public var colorStr:String;
[Inspectable(defaultValue="circular")]
public var shapeStr:String;

In the Property inspector and the Parameters tab of the Component inspector, Flash displays all of these parameters as type String.


Flash CS3


Comments


mark_horsell said on Jun 14, 2007 at 3:09 AM :
can this be confirmed as working in flash9

I have been using this for a long time in AS2 but AS3 doesnt seem to want to work.
Ninja Squirrel416 said on Jul 25, 2007 at 8:37 AM :
They are working, but there is one problem; the values set in the Flash IDE are not picked up until after the constructor. You need to wait until the next frame before trying to access them, or it breaks everything. Either that or you can do some weird trickery with the Render event. You can dig into the source for the Flash UIComponent base class to see how Adobe handled it, if you can make sense of the beast.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00002496.html