【问题标题】:How to specify swc when building a swf?构建swf时如何指定swc?
【发布时间】:2010-07-07 15:18:53
【问题描述】:

我在 Flex 中实现了一些实用程序类,我想在多个 AIR 项目中使用它们。我创建了一个包含这些类的 swc。我在 Linux 机器上工作并且没有 FlashBuilder。所以我使用的是 compc 和 mxmlc 命令行 SDK 工具。我的问题是在构建独立项目时我无法找到指定 swc 的方法。一个教程建议使用以下命令: mxmlc -load-config /opt/flex/4.1.0/frameworks/air-config.xml -library-path=/path/to/utility.swc hello.mxml。但是,使用它会给我错误hello.mxml: Error: Unable to locate specified base class 'mx.core.WindowedApplication' for component class 'hello'。如果我将所有代码从 swc 移动到单个整体项目,一切正常。有谁可以帮我离开这里吗?独立项目的代码是:

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" windowComplete="completeHandler();">
<mx:Script>
<![CDATA[
import com.example.Ext;
private function completeHandler():void
{
    var e: Ext = new Ext();
    e.hi();
}
]]>
</mx:Script>
<mx:Label text="Hello World" />
</mx:WindowedApplication>

Ext 类型包含在 utility.swc 中。

更新: 我修复了之前的错误。命令行应该是mxmlc -load-config /opt/flex/4.1.0/frameworks/air-config.xml -library-path+=/path/to/utility.swc hello.mxml。这会将我的 swc 附加到现有的库路径而不是替换它。但是,我有一个新问题。现在错误是hello.mxml(10): Error: Type was not found or was not a compile-time constant: Ext. 我也在粘贴utility.swc 的代码:

package com.example {
    public class Ext {
        public function Ext {
            // do something
        }   
        public function foo( ): void {
            return;
        }   
    }   
}

【问题讨论】:

    标签: apache-flex air mxml


    【解决方案1】:

    使用-library-path+=/path/to/my.swc。如果您使用= 而不是+=,编译器将丢弃路径中已经存在的所有平台库。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-09-14
      • 2013-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多