标签: mxmlc

如何让我的Ant生成的swf尽可能小?

我有一个flex项目,如果我在swf上使用带有RSL的Flash Builder构建应用程序的发行版本是115k.但是,如果我使用ant构建相同的应用程序,则swf为342k.没有RSL,swf是520k.

如何使swf与FlashBuilder构建的swf一样小?

这是我的ant文件,我有另一个复制rsls的任务.

<project name="EUI Client Application" default="compileClientApp">

<target name="compileClientApp" depends="compileClientBundles">
    <mxmlc 
        file="${CLIENT_PROJECT.dir}/src/${CLIENT_PROJECT.app}.mxml" 
        output="${DEPLOY.dir}/${CLIENT_PROJECT.app}.swf" 
        keep-generated-actionscript="false" 
        actionscript-file-encoding="UTF-8" 
        incremental="false"
        >

        <runtime-shared-library-path path-element="${FLEX_HOME}/frameworks/libs/framework.swc">
            <url rsl-url="flex4_4.0.0.7791.swf"/>
            <url rsl-url="framework_4.0.0.7791.swf"/>
            <url rsl-url="framework_textLayout_4.0.0.7791.swf"/>
            <url rsl-url="rpc_4.0.0.7791.swf"/>
            <url rsl-url="textLayout_451.swf"/>
        </runtime-shared-library-path>

        <source-path path-element="${CLIENT_PROJECT.dir}/src" />

        <compiler.library-path dir="${LIBS.dir}" append="true">
            <include name="*.swc" />
        </compiler.library-path>
        <compiler.library-path dir="${DEPLOY_BIN.dir}" append="true">
            <include name="*.swc" />
        </compiler.library-path>

    </mxmlc>
</target>

<target name="generateWrapper">
    <html-wrapper 
        title="${CLIENT_APP_TITLE}" 
        file="${CLIENT_PROJECT.app}.html" 
        height="100%" width="100%" 
        bgcolor="white" application="app" 
        swf="${CLIENT_PROJECT.app}" 
        version-major="10" version-minor="0" version-revision="0" 
        history="true" output="${DEPLOY.dir}" />
</target>

<target name="compileClientBundles">
    <compileBundle bundleName="Modules" source="${CORE_PROJECT.dir}/locale" />
</target>
Run Code Online (Sandbox Code Playgroud)

apache-flex ant mxmlc flex4

5
推荐指数
1
解决办法
5278
查看次数

Flex Compilier说源路径和包定义不匹配

这是问题所在:

我在同一个包中有三个文件:com.foobar

这些文件的目录是:

C:.. \在MyLibrary的\ src\COM\foobar的\

然后在里面我有foo.as和bar.as

当我尝试运行mxmlc C:..\mylibrary\src\com\foobar\foo.as时出现错误:

在源路径中找到的文件必须具有与定义的包"com.foobar"相同的包结构.

对此我说:确实如此.包是com.foobar.结构是../com/foobar/foo.as

我在网上发现了一些关于这个错误的其他论坛帖子,看起来用户必须使目录与我已经拥有的包名匹配.我错过了什么?

在此先感谢您提供任何帮助!

apache-flex actionscript-3 mxmlc

5
推荐指数
1
解决办法
6582
查看次数

mxmlc和框架链接 - 如何将链接指定为rsl

我正在尝试使用ant构建我的flex 4项目.在Flash Builder 4中,在项目属性中,可以将"框架链接"设置为"合并到代码","运行时共享库​​(RSL)"或"使用SDK默认(运行时共享库​​)"之一.如何在build.xml中将等效项设置为mxmlc选项?

我当前的build.xml如下所示:

<target name="myapp">
    <mxmlc 
        file="${PROJECT_ROOT}/myapp.mxml" 
        output="${DEPLOY_DIR}/myapp.swf"
        actionscript-file-encoding="UTF-8"
        keep-generated-actionscript="false"
        warnings="false" optimize="true" incremental="false" >

        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/> 

        <source-path path-element="${FLEX_FRAMEWORKS}"/> 

        <compiler.debug>true</compiler.debug>

        <runtime-shared-library-path path-element="${FLEX_FRAMEWORKS}/libs/framework.swc">
            <url rsl-url="framework_4.0.0.14159.swz"/>
            <url rsl-url="framework_4.0.0.14159.swf"/>
        </runtime-shared-library-path>                       

        <compiler.source-path path-element="src"/>

        <!-- List of external libraries -->
        <compiler.source-path path-element="${MY_LIB}/src" />

        <!-- List of SWC files or directories that contain SWC files. -->
        <compiler.library-path dir="libs" append="true">
            <include name="*.swc" />
        </compiler.library-path>

        <copy todir="${DEPLOY_DIR}" file="${FLEX_FRAMEWORKS}/rsls/framework_4.0.0.14159.swz"/>
        <copy todir="${DEPLOY_DIR}" file="${FLEX_FRAMEWORKS}/rsls/framework_4.0.0.14159.swf"/>

    </mxmlc>
</target>
Run Code Online (Sandbox Code Playgroud)

我假设设置runtime-shared-library-path指令并将框架swf,swz文件复制到我的目标文件夹会使事情有效,但事实并非如此.

我评估这是否有效的方式如下:我使用自定义预加载器,为了工作,我需要将框架链接作为RSL.使用"合并到代码",我的预加载器卡在某一点,并没有进展到我的应用程序SWF.这与我在使用上面的build.xml时看到的行为相同,这让我觉得SWF正在构建时将框架链接合并到代码中(而不是RSL链接).

与此相关的问题是如何确定我的swf是否使用RSL.我想我可以看一下编译输出的大小.但似乎应该有一种方法来判断我是否正在使用外部框架文件,或者在我不知情的情况下将其捆绑到SWF中.

ant mxmlc rsls flex4

5
推荐指数
1
解决办法
5891
查看次数

构建Flex的奇怪问题(在正确的代码上出现无关的错误)

注意:我已多次编辑此问题并重新格式化以更好地证明问题.

问题

我的构建有问题.当我向代码添加一个有效的语句时,它将不再编译,并且它会因无关文件的错误而失败.我在命令行中遇到了使用ant构建或使用mxmlc构建这些问题.

将有效语句添加到myLittleBox.mxml将导致此错误.注意:

  • 所有错误都在ViewerMain.mxml中.此文件不是主mxml文件,但它是从主mxml文件引用的.
  • 在更改myLittleBox.mxml之前,ViewerMain.mxml没有编译错误
  • 没有与myLittleBox.mxml相关的错误
  • myLittleBox.mxml没有对ViewerMain的引用,只使用spark组件
  • ViewerMain.mxml没有对myLittleBox.mxml的直接引用.它的孩子的孩子的孩子会引用myLittleBox.mxml
  • 添加到myLittleBox.mxml的有效语句可能是很多东西(它们都会破坏它),包括注释.

什么可能导致这些错误?我该如何解决这些问题?非常感谢提示或一点点洞察力.

编译错误(可选阅读)

[mxmlc] Loading configuration file PATH_1\flex-config.xml
[mxmlc] PATH-3\ViewerMain.mxml(207):  Error: Access of possibly undefined property p through a reference with static type com.....
[mxmlc]                 if(model.InfoBox && model.InfoBox.p) 
[mxmlc] PATH-3\ViewerMain.mxml(209):  Error: Implicit coercion of a value of type com.....InfoBox to an unrelated type flash.display:DisplayObject.
[mxmlc]                     InfoBoxContainer.addChild(model.infoBox);
[mxmlc] PATH-3\ViewerMain.mxml(228):  Error: Call to a possibly undefined method toggleWin through a reference with static type com.....:InfoBox.
[mxmlc]                         model.InfoBox.toggleWin();                      
[mxmlc] PATH-3\ViewerMain.mxml(231):  Error: …
Run Code Online (Sandbox Code Playgroud)

apache-flex mxmlc

5
推荐指数
1
解决办法
1176
查看次数

ASC 2.0是否识别[Frame]元数据标签(例如:对于Preloader factoryClass)?

我正在尝试在AIR SDK 3.7中使用新的ASC2.0编译器,但我似乎遇到了无法检测到我的预加载器类的问题.

如果我使用非ASC2.0编译器,它会识别并编译我的Main类中的Frame元数据标记中声明的Preloader类,如下所示:

[Frame(factoryClass = "Preloader")]
Run Code Online (Sandbox Code Playgroud)

但是一旦我用ASC2.0编译它,它就会忽略Frame元数据并只是尝试编译Main类并假设它必须是Sprite/MovieClip的子类(当它是它时它不一定必须是预装了Frame元数据标签),因此无法编译.

如果有人能够证实这一点很好,那么我已经将这个轮子旋转了一段时间.谢谢!

compiler-construction flash metadata frame mxmlc

5
推荐指数
1
解决办法
1645
查看次数

使用Flex4 SDK进行编译

我正在尝试使用Flex4 SDK编译现有的Flex3项目.我收到这个错误:

Warning: This compilation unit did not have a factoryClass specified in Frame metadata to load the configured runtime shared libraries. To compile without runtime shared libraries either set the -static-link-runtime-shared-libraries option to true or remove the -runtime-shared-libraries option.

生成的文件与我原来的Flex3编译的.swf文件大致相同.在Flash Player中播放生成的.swf文件也会出现以下错误:

An Actionscript error ocurred: VerifyError: Error #1014: Class spark.core::SpriteVisualElement could not be found

如果我将编译器属性设置static-link-runtime-shared-libraries为true,则错误消失,一切都很好.但是,由此产生的.SWF的大小是几个100K的大.这不是我想要的.

我并不完全理解运行时共享库​​的概念,但似乎通过将它们静态链接设置为true的选项,这些库包含在.swf中.但是,我喜欢将它们从.swf中排除,并且只在运行时加载所需的库,因为我的项目似乎与Flex3有关(顺便说一句,我不知道).

如果我理解正确的话,playerglobal.swc应该包含我的.swf必须加载的外部库的所有必要代码.Flex4编译的文件需要更多的库吗?我应该对Frame元数据标签中的factoryClass做些什么吗?

我想我的问题归结为:我如何编译一个与之前的Flex3编译的.swf大小相同的Flex4 .swf?

apache-flex flash actionscript-3 mxmlc flex4

4
推荐指数
1
解决办法
7221
查看次数

在 &lt;compc /&gt; ant 任务中使用编译器常量

我正在将现有的构建脚本从<mxmlc />to转换<compc />为生成 swc。

但是,构建失败,给出错误:

[compc] C:\xxxx\LogViewer.mxml(32):  Error: Access of undefined property VERSION.
[compc]
[compc] private static const VERSION:String = CONFIG::VERSION;
Run Code Online (Sandbox Code Playgroud)

在我的 ant 任务中,我定义了以下内容:

    <compc compiler.as3="true" output="${output.dir}/${swc.name}.swc" incremental="true" fork="true" maxmemory="512m" compiler.show-deprecation-warnings="false">
        <load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
        <source-path path-element="${srcdir}" />
        <include-sources dir="${srcdir}" includes="*" />
        <external-library-path dir="${swc.libs.dir}" append="true">
            <include name="*.swc" />
        </external-library-path>
        <external-library-path dir="${output.common.swc.dir}" append="true">
            <include name="*.swc" />
        </external-library-path>
        <compiler.define name="CONFIG::VERSION" value="${build.version}" />
        <compiler.define name="CONFIG::RELEASE" value="${config.release}" />
        <compiler.define name="CONFIG::DEBUG" value="${config.debug}" />
        <compiler.define name="CONFIG::AUTOMATION" value="false" />
    </compc>
Run Code Online (Sandbox Code Playgroud)

这种方法可以很好地完成任务,但现在失败了。

在 compc 中使用编译器常量的正确方法是什么?

apache-flex ant mxmlc compc

4
推荐指数
1
解决办法
4606
查看次数

不支持的flex/actionscript采样

我需要的动作脚本

  Loading configuration file /opt/flex/frameworks/flex-config.xml
  t3.mxml(10): Error: unsupported sampling rate (24000Hz)

        [Embed(source="music.mp3")]

     t3.mxml(10): Error: Unable to transcode music.mp3.

        [Embed(source="music.mp3")]
Run Code Online (Sandbox Code Playgroud)

代码是

         <?xml version="1.0"?>
   <!-- embed/EmbedSound.mxml -->
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

  <mx:Script>
    <![CDATA[

        import flash.media.*; 

        [Embed(source="sample.mp3")]
        [Bindable]
        public var sndCls:Class;

        public var snd:Sound = new sndCls() as Sound; 
        public var sndChannel:SoundChannel;

        public function playSound():void {
            sndChannel=snd.play();
        }   

        public function stopSound():void {
            sndChannel.stop();
        }   
    ]]>
</mx:Script>

<mx:HBox>
    <mx:Button label="play" click="playSound();"/>
    <mx:Button label="stop" click="stopSound();"/>
</mx:HBox>
</mx:Application>
Run Code Online (Sandbox Code Playgroud)

apache-flex mxml actionscript-3 mxmlc

4
推荐指数
1
解决办法
5851
查看次数

没有Flex Framework/Components的MXML

Flex编译器可以编译不包含任何Flex组件字节码的"纯AS3"SWF文件.所以,

是否有可能创建一个自定义组件框架(用于代替Flex框架),仍然可以使用MXML(读取:标记)进行可视化布局,并编译为SWF而不依赖于Flex Framework本身?

apache-flex flash mxml mxmlc

3
推荐指数
1
解决办法
1948
查看次数

使用ant mxmlc任务将runtime-library-path添加到flex构建配置

我正在尝试构建一个flex项目,将其链接到一些RLS.在Flex Builder中设置项目时,相应的"构建配置"(我通过将-dump-config添加到编译器选项中获得)生成(以及其他)标记,如下所示:

<runtime-shared-libraries>
  <url>some-lib.swf</url>
  <url>some-other-lib.swf</url>
</runtime-shared-libraries>
Run Code Online (Sandbox Code Playgroud)

现在,我正在尝试使用mxmlc ant任务构建项目,但我似乎无法添加对共享库的任何引用.我认为这样的事情会有所帮助,但它没有:

<!-- Skipping attributes that I don't think are relevant ... -->
<mxmlc ....>
 ...
 <runtime-shared-library-path>
<url rsl-url="some-lib.swf"></url>
<url rsl-url="some-other-lib.swf"></url>
 </runtime-shared-library-path>
</mxmlc>
Run Code Online (Sandbox Code Playgroud)

那么我在这里可以缺少什么呢?

谢谢

apache-flex ant mxmlc

3
推荐指数
1
解决办法
5771
查看次数