linking symbol to class actionscript

走远了吗. 提交于 2019-12-13 06:52:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!