是否可以创建动态嵌入功能?
是否可以在 ActionScript3 中创建动态嵌入函数,
例如像这样
public function embedImage(path:String):Bitmap{
[Embed(source = path, mimeType = "image/png")]
var NewBitmapClass:Class;
var image:Bitmap=new NewBitmapClass();
return image;
}// tried it, it doesnt work
或以其他方式,或者即使它完全可能?
Is it possible to create dynamic embed function in ActionScript3
for example like this
public function embedImage(path:String):Bitmap{
[Embed(source = path, mimeType = "image/png")]
var NewBitmapClass:Class;
var image:Bitmap=new NewBitmapClass();
return image;
}// tried it, it doesnt work
or maybe in some other way, or even if it is at all possible?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以使用“动态”部分获得的最接近的是创建一个包装类,您可以在其中定义图像,并且稍后可以通过 id 将它们获取为位图。
不幸的是,这些属性是公共的,否则 hasOwnProperty 函数不会返回 true。 (如果有人找到更好的方法,请告诉我)
见下文:
The closest you can get with the "dynamic" part, is to create a wrapper class, where you define your images, and you can get them as Bitmap later on by an id.
Unfortunately the properties are public, otherwise the hasOwnProperty function doesn't return true. (If someone finds a better way, please let me know)
See below:
嵌入元素在编译时嵌入。您无法在编译时动态嵌入某些内容...如果您想动态加载资源,请使用
加载器
。Embedded elements are embedded at compile time. You can't dynamically embed something at compile time... If you want to load resources dynamically, use the
Loader
.不,嵌入源是在编译时嵌入的。您不能在运行时嵌入任何内容。这就是嵌入的意思,在构建 swf 期间嵌入。
No, embed source is embedded at compile time. You can not embed anything at run time. That's what embed means, embedding during building the swf.