getDefinitionByName的替代方案(Alternative for getDefinitionByName)

编程入门 行业动态 更新时间:2024-10-13 12:19:53
getDefinitionByName的替代方案(Alternative for getDefinitionByName)

在过去,有一个简单的技巧 ,通过mxmlc下行添加到flash-cs4 makefile来包含flex mxmlc模块:

-include-libraries “/absolute/path/to/my/assets/assets.swc”

这使您能够使用getDefinitionByName ,一个帮助函数来访问嵌入式swc资产库(而不是创建手写类的所有资产)。

不幸的是,自flash-cs4以来,这已停止工作。 有人知道另一种解决方案吗?

In the past, there was a simple trick, to include the flex mxmlc module by adding the following line to the flash-cs4 makefile:

-include-libraries “/absolute/path/to/my/assets/assets.swc”

This gave you the ability to use getDefinitionByName, an helper function to access the embedded swc asset-library (instead of creating hand-written classes all assets).

Unfortunately, this has stopped working since flash-cs4. Does anybody know another solution?

最满意答案

不幸的是,我发现的唯一解决方法是在代码中的某处明确引用每个资产类。 您可以创建这样的虚拟类:

public class AssetsExporter extends Sprite { public static function export() { AssetClass1; AssetClass2; //etc trace( "DEBUG AssetsExporter.export()" ); } }

在Flash IDE中将此类指定为Document类,因此它将编译为生成的swc。 然后在您的应用程序调用的主代码中

AssetsExporter.export();

完成此操作后,您将能够使用getDefinitionByName()。

Unfortunately, the only workaround I have found is to explicitly refer each of asset classes somewhere in the code. You may create dummy class like this:

public class AssetsExporter extends Sprite { public static function export() { AssetClass1; AssetClass2; //etc trace( "DEBUG AssetsExporter.export()" ); } }

Specify this class as Document class in Flash IDE, so it will be compiled into the resulting swc. Then in the main code of your application call

AssetsExporter.export();

After doing this you will be able to use getDefinitionByName().

更多推荐

本文发布于:2023-08-07 17:21:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1465361.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方案   getDefinitionByName   Alternative

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!