Actionscript 3 中的外部配置文件

发布于 2024-09-08 01:37:20 字数 1254 浏览 2 评论 0原文

我需要能够将外部配置文件加载到我的 Flex 应用程序中。我读到,只要将 mimeType 设置为 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 菜单,然后挂起。

如果我注释掉 [Embed(source = '../../data/map.txt' 行),它会编译并且不会挂起。

为什么此嵌入会导致冻结?

版本信息对于 mxmlc:

Adobe Flex Compiler (mxmlc)
Version 4.0.0 build 14159

编辑

事实证明错误没有正确显示,但这就是我尝试嵌入时得到的结果:

VerifyError: Error #1014: Class mx.core::找不到 ByteArrayAsset。

Google 发现了很多人遇到同样的问题,但没有明显的解决方案

import mx.core.ByteArrayAsset; ByteArrayAsset

也无济于事。

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();
        }
    }
}

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.

If I comment out the [Embed(source = '../../data/map.txt' line, it compiles and doesn't hang.

Why is this embed causing a freeze?

Version info for mxmlc:

Adobe Flex Compiler (mxmlc)
Version 4.0.0 build 14159

EDIT

It turns out errors weren't being displayed properly, but this is what I'm getting from attempting the embed:

VerifyError: Error #1014: Class mx.core::ByteArrayAsset could not be found.

Google turns up a bunch of people with the same problem, but no apparent solution.

import mx.core.ByteArrayAsset; ByteArrayAsset

doesn't help either.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

芯好空 2024-09-15 01:37:20

啊哈!事实证明,解决方案非常简单 - 运行时共享库​​没有静态链接到 swf,并且没有正确设置运行时访问的路径。解决方案很简单:

修改 flex-config 为

true

或手动传入参数到 mxmlc

mxmlc -static-link-runtime-shared-libraries=true -debug=true Main.swf -- Main.as

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:

Either modify flex-config to say

<static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>

or manually pass in the parameter to mxmlc

mxmlc -static-link-runtime-shared-libraries=true -debug=true Main.swf -- Main.as

南汐寒笙箫 2024-09-15 01:37:20

我将用我对另一个问题的回答来回答这个问题:

[Embed(source = "ExampleText.txt", mimeType = "application/octet-stream")]
protected var AAAAAA:Class;

var tmp:ByteArray = new AAAAAA();
var result:String = tmp.readMultiByte(tmp.bytesAvailable, tmp.endian);

I'll answer this one with my answer to another question:

[Embed(source = "ExampleText.txt", mimeType = "application/octet-stream")]
protected var AAAAAA:Class;

var tmp:ByteArray = new AAAAAA();
var result:String = tmp.readMultiByte(tmp.bytesAvailable, tmp.endian);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文