使用amxmlc从命令行将.as编译成.swf

时间:2013-11-26 23:26:50

标签: actionscript-3 flash air mxmlc

这就是我正在做的事情:

amxmlc -load-config obj\config.xml

这是我得到的:

  

错误:缺少内置类型对象

     

错误:无法构建SWF C:\ Users \ m \ work \ project \ bin \ ApplicationName.swf


以下是config.xml的内容:

<?xml version="1.0" encoding="utf-8"?>
<!--This Adobe Flex compiler configuration file was generated by a tool.-->
<!--Any modifications you make may be lost.-->
<flex-config>
  <target-player>11.8</target-player>
  <benchmark>false</benchmark>
  <static-link-runtime-shared-libraries>true</static-link-runtime-shared-libraries>
  <compiler>
    <define append="true">
      <name>CONFIG::debug</name>
      <value>false</value>
    </define>
    <define append="true">
      <name>CONFIG::release</name>
      <value>true</value>
    </define>
    <define append="true">
      <name>CONFIG::timeStamp</name>
      <value>'11/26/2013'</value>
    </define>
    <define append="true">
      <name>CONFIG::air</name>
      <value>true</value>
    </define>
    <define append="true">
      <name>CONFIG::mobile</name>
      <value>true</value>
    </define>
    <define append="true">
      <name>CONFIG::desktop</name>
      <value>false</value>
    </define>
    <optimize>true</optimize>
    <omit-trace-statements>true</omit-trace-statements>
    <verbose-stacktraces>false</verbose-stacktraces>
    <source-path append="true">
      <path-element>C:\Users\m\work\project\src</path-element>
      <path-element>C:\Program Files (x86)\FlashDevelop\Library\AS3\classes</path-element>
    </source-path>
  </compiler>
  <file-specs>
    <path-element>C:\Users\m\work\project\src\com\client\ApplicationName.as</path-element>
  </file-specs>
  <default-background-color>#FFFFFF</default-background-color>
  <default-frame-rate>30</default-frame-rate>
  <default-size>
    <width>1920</width>
    <height>1080</height>
  </default-size>
</flex-config>

这是ApplicationName.as:

package com.client {

    import flash.display.MovieClip;
    import flash.desktop.NativeApplication;
    import flash.events.Event;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.ui.Multitouch;
    import flash.ui.MultitouchInputMode;

    public class ApplicationName extends MovieClip {

        public function ApplicationName () {

            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            stage.addEventListener(Event.DEACTIVATE, deactivate);
            Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
        }

        private function deactivate(e:Event):void 
        {
            // make sure the app behaves well (or exits) when in background
            //NativeApplication.nativeApplication.exit();
        }
    }

}

我可以从Flash,Flash Builder和FlashDevelop构建这个版本 - 但每当我尝试命令行时,我都会收到错误。想一想那是什么?

1 个答案:

答案 0 :(得分:3)

您在配置中错过了playerglobal.swc。最小编译配置应为:

Flex 4:

<flex-config>
<target-player>11.1.0</target-player>
<default-frame-rate>40</default-frame-rate>

<compiler>
    <locale>
        <locale-element>en_US</locale-element>
    </locale>

    <external-library-path>
        <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}.{targetPlayerMinorVersion}/playerglobal.swc</path-element>
    </external-library-path>

    <library-path>
        <path-element>${flexlib}/libs/player</path-element>
    <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}.{targetPlayerMinorVersion}</path-element>    
    </library-path>

    <optimize>true</optimize>
</compiler>
</flex-config>

Flex 3:

<flex-config>
<target-player>10.0.0</target-player>
<default-frame-rate>40</default-frame-rate>

<compiler>
    <locale>
        <locale-element>en_US</locale-element>
    </locale>

    <external-library-path>
        <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}/playerglobal.swc</path-element>
    </external-library-path>

    <library-path>
        <path-element>${flexlib}/libs/player</path-element>
        <path-element>${flexlib}/libs/player/{targetPlayerMajorVersion}</path-element>    
    </library-path>

    <optimize>true</optimize>

    <warn-no-constructor>false</warn-no-constructor>
</compiler>
</flex-config>

您需要从此示例中添加playerglobal.swc的路径。