在ActionScript 3的外部配置文件 [英] External Config file in Actionscript 3
问题描述
我需要能够加载外部配置文件到我的Flex应用程序。我读过,这是使用EMBEDS可能的,只要MIMETYPE设置为应用程序/八位字节流。
I need to be able to load external configuration files into my flex app. I've read that this is possible using embeds, so long as the mimeType is set to application/octet-stream.
package learning {
import org.flixel.*;
public class PlayState extends FlxState {
[Embed(source = "../../data/tiles.png")] private var _tiles:Class;
[Embed(source = '../../data/map.txt', mimeType = "application/octet-stream")] private var ExternalMapData:Class;
public var txt:FlxText;
public var player:FlxSprite;
override public function create():void {
bgColor = 0xffaaaaaa;
super.create();
}
override public function update():void {
super.update();
}
}
}
当我使用 mxmlc的
编译这一点,编译成功没有任何错误。当我运行的SWF文件,它加载所有的Flixel菜单,然后挂起。
When I compile this using mxmlc
, it compiles successfully with no errors. When I run the SWF, it loads all the Flixel menus then hangs.
如果我注释掉 [嵌入(来源=../../数据/ map.txt
行,它编译并不会挂起。
If I comment out the [Embed(source = '../../data/map.txt'
line, it compiles and doesn't hang.
这是为什么嵌入导致冻结?
Why is this embed causing a freeze?
有关mxmlc的版本信息:
Version info for mxmlc:
Adobe Flex Compiler (mxmlc)
Version 4.0.0 build 14159
修改
原来并没有显示正确的错误,但是这是我从试图嵌入越来越:
It turns out errors weren't being displayed properly, but this is what I'm getting from attempting the embed:
的VerifyError:错误#1014:类mx.core :: ByteArrayAsset的找不到
谷歌变成了一堆人同样的问题,但没有明显的解决方案。
Google turns up a bunch of people with the same problem, but no apparent solution.
进口mx.core.ByteArrayAsset; ByteArrayAsset的
也没有帮助。
推荐答案
啊哈!原来的解决方案是非常简单 - 运行时共享库没有被静态链接到SWF和路径没有被正确设置以便实时访问。解决的办法很简单:
Aha! It turns out the solution was very simple - runtime shared libraries weren't being statically linked into the swf, and the path wasn't being set properly for access during runtime. The solution is simple:
要么修改柔性配置的说
<$c$c><static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>$c$c>
或手动传入参数MXMLC
or manually pass in the parameter to mxmlc
mxmlc的-static链接,运行时共享库=真-debug =真正的main.swf - Main.as
这篇关于在ActionScript 3的外部配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!