问题
There is a simple method of linking a symbol to a class in flash cs5 in the gui designer. But how can i do the same thing in actionscript alone using code because iam not using flash cs5. Iam using notepad++ and flex compiler.
回答1:
Hopefully this link will answer your question: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/MovieClip.html
The essence is this:
[Embed(source="logo.gif")]
[Bindable]
public var imgCls:Class;
and what this does is tell the compiler to add logo.gif as a symbol whose class name will be imgCls.
To then use this in your code, you just have to create an instance of it and work as normal:
var myImg:BitmapAsset = new imgClass() as BitmapAsset;
addChild(myImg);
来源:https://stackoverflow.com/questions/6805508/linking-symbol-to-class-actionscript