首页 > 解决方案 > 使用 OpenFL 将 Haxe Flash 应用程序编译到 Adob​​e AIR

问题描述

我正在为一家公司提供支持,该公司的商业应用程序haxe编译为Flash swf. 该应用程序是一个布局生成器,它加载一个项目列表,然后可以将其拖到布局上。项目列表是使用从PHP服务器加载的AMFPHP

我们正在考虑将这个应用程序移植到,Adobe AIR以便我们可以在 2020 年之后继续使用这个应用程序。在做了一些研究之后,我发现了这个扩展,并认为最好的方法是尝试让代码编译到使用. 我没有任何使用或开发的经验,所以这对我来说都是全新的,我不知道这个端口在多大程度上是可行的。所以我的第一个问题非常广泛,但我想知道是否有人有过这样的转换经验,谁能评论这种方法的可行性?Lime/OpenFL VSCodehaxeAIRLimehaxeFlashOpenFL

为了提供有关该应用程序的更多详细信息,以下是build.hxml用于编译当前Flash应用程序的内容:

-cp Source
-D LOCAL_TEST
-D haxe-boot
-D flash-use-stage
-swf-lib index.swf
-swf-version 9
-swf pdfbuilder.swf
-debug
PDFBuilder

使用index.swf单独编译mxmlc,并且只是使用Flex. 所以我关于这个端口的下一个问题是我是否能够index.swf在编译时包含它AIR

我已经Haxe 4.0安装了;我已经创建了一个OpenFL项目VSCode并尝试编译它。我收到了许多错误消息,主要的两个是导入haxe.remoting.AMFConnection失败并出现未找到类型错误,并且应用程序没有Main类型,因为Flash应用程序的启动明显不同。

我不完全确定如何更改启动;当前应用启动如下:

class PDFBuilder {
    // CONFIG
    inline public static var _hostAddress = #if LOCAL_TEST 'http://212.45.52.43' #else '' #end;
    inline public static var _hostLocalPath = 'C:/Inetpub/wwwroot';
    public static var _userPath:String;

    /** Reference to Main Flex Application object **/
    public static var flex:Dynamic;

    public static var app:PDFBuilder;
    public static var event:PDFBuilderEvents;

    public static var service = AMFConnection.urlConnect(#if LOCAL_TEST _hostAddress +
        '/commonfiles/php/amfphp-1.2/gateway.php' #else 'amfphp-1.2/gateway.php' #end);

    // Layout items container
    public static var itemData:ItemData = new ItemData(updateItemTreeData);

    public var grid:layout.Grid;
    public var events:PDFBuilderEvents;
    public var uploader:UploadManager;

    public function main(_flex:Dynamic) {
        app = this;

        ....

Lime我相信期待一个Main类而不是反映应用程序名称的类名(PDFBuilder),但我确信除了类名之外还有更多需要更改的东西。

标签: flashhaxeopenflhaxelib

解决方案


Use --library argument in your hxml file: https://haxe.org/manual/compiler-usage.html

For haxe4 I think you need to use air4 lib https://lib.haxe.org/p/air4haxe/


推荐阅读