使用as3mxml编译Actionscript 3 Air项目时正确链接SWF库

问题描述

为了达到以下目的:

  • 编译包含不同常用脚本的library.swf
  • 编译链接library.swf的不同SWF,并使用这些通用脚本,而无需将代码复制到拥有的SWF中;

我试图使用acompcmxmlc,但是我无法实现上述方法

最近,我遇到了Visual Studio Code(VSC)的as3mxml插件,我尝试了一下,因为至少有一些示例。这是我的MVP:

构建librarylibrary.swflibrary.swc的项目catalog.xml

src/Common/Label.as

package Common {
    import flash.display.Sprite;
    import flash.text.TextField;
    
    public class Label extends Sprite {
        
        public function Label(text:String,x:Number,y:Number) {
            var display_txt:TextField = new TextField();
            display_txt.text = text;
            display_txt.x = x;
            display_txt.y = y;
            addChild(display_txt);
        }
    }
}

asconfig.json


{
    "type": "lib","compilerOptions": {
        "swf-version": 11,"source-path": [
            "src"
        ],"include-sources": [
            "src"
        ],"warnings": false,"debug": false,"use-network": false,"output": "bin/library.swc"
    }
}

该库以我想要的方式构建,因此这里似乎没有问题。

构建HelloWorld的项目HelloWorld.swf

src/HelloWorld.as

package {
    import flash.display.MovieClip;
    import flash.text.TextField;
    import Common.Label;
    
    public class HelloWorld extends MovieClip {
        public function HelloWorld() {
            var label:Label = new Label("Hello World",5,5);
            addChild(label);
        }
    }
}

asconfig.json

{
    "config": "air","external-library-path": [
            "../library/bin/library.swc"
        ],"static-link-runtime-shared-libraries": false,"output": "bin/HelloWorld.swf"
    },"mainClass": "HelloWorld"
}

通过此设置,VSC成功完成了Label类的代码完成,libraryHelloWorld的构建成功,但是HelloWorld.swf没有与库的链接。 / p>

但是,如果我要将external-library-path中的library-path更改为HelloWorld/asconfig.json,则来自library代码将被嵌入HelloWorld.swf内,而不是预期的方式。我期望HellowWorld.swf显式导入library.swf(通过ImportAssets标签)。我尝试了调整库导入方式和静态链接方法,但是没有一种方法导致想要的行为。

我该如何实现?

其他问题:编译器不断编译为CWS,我怎么能不压缩地编译它?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)