问题
In my attempts to achieve the following:
- compile
library.swf
that contains different common scripts; - compile different SWFs that link
library.swf
and use these common scripts without copying code to own resulting SWFs;
I was trying to use acompc
and mxmlc
, however I couldn't achieve the approach above.
Recently I came up across as3mxml plugin for Visual Studio Code (VSC) which I gave a try as at least it had some examples. Here is my MVP:
Project library
that builds library.swf
, library.swc
and 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"
}
}
The library builds the way I want it to, so seemingly no problems here.
Project HelloWorld
that builds 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",
"compilerOptions": {
"swf-version": 11,
"source-path": [
"src"
],
"external-library-path": [
"../library/bin/library.swc"
],
"static-link-runtime-shared-libraries": false,
"output": "bin/HelloWorld.swf"
},
"mainClass": "HelloWorld"
}
With this setup, VSC successfully code-completes the Label
class, the library
and HelloWorld
are built successfully, but the HelloWorld.swf
has no linkage to library.
However, if I were to change external-library-path
to library-path
in HelloWorld/asconfig.json
, then the code from library
would be embed inside HelloWorld.swf
, which is not the intended way. I was expecting HellowWorld.swf
to explicitly import library.swf
(via ImportAssets
tag). I tried tweaking library imports ways and static link, but none of the ways lead to wanted behavior.
How can I achieve this?
Extra question: the compiler keeps compiling to CWS
, how can I compile it uncompressed?
来源:https://stackoverflow.com/questions/63641147/properly-link-swf-library-when-compiling-actionscript-3-air-poject-using-as3mxml