0

我有一个非常大的 flex builder 项目,需要移植到 Haxe。我们所有的 actionscript 文件都是使用 as3hx 转换的。我读过有关 HaxeUI、FeathersUI 和 NME 的信息。这些选项中的任何一个是否使移植 MXML 文件变得容易,而不是完全重写它们?重要的是要注意,我的大部分 MXML 文件都包含大量 CDATA。

<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
         bottom="0"
         top="0"
         left="0" 
         right="0"
         implements="com.dstawd.modeler.IDiagramInfoComponent"
         creationComplete="onCreationComplete()">

    <mx:Metadata>
        [ResourceBundle("Modeler")]
        [ResourceBundle("ServiceModeler")]
    </mx:Metadata>

    <mx:Script>
        <![CDATA[

            import com.dstawd.modeler.Diagram;
            import com.dstawd.modeler.assets.Icons;
            import com.dstawd.modeler.component.shape.ShapeUIComponent;
            import com.dstawd.modeler.controller.Controller;
            import com.dstawd.modeler.controller.ValidationErrorMap;
            import com.dstawd.modeler.events.ValidateEvent;
            import com.dstawd.modeler.managers.WorkspaceManager;
//            import com.dstawd.modeler.service.component.shape.Loop;
//            import com.dstawd.modeler.service.LoopDiagram;

            import mx.collections.ArrayCollection;
            import mx.core.Application;

            [Bindable] private var _diagram:Diagram;
            [Bindable] private var _errors:ArrayCollection = new ArrayCollection();

            private function onCreationComplete():void
            {
                validateButton.setStyle("skin", null);
            }

            private function refreshValidations():void
            {
                var application:IModeler = Application.application as IModeler;
                var controller:Controller = application.controller;
                controller.validate();
            }

            public function get diagram():Diagram
            {
                return _diagram;
            }

            public function set diagram(value:Diagram):void
            {
                _diagram = value;
            }

            public function get errors():ArrayCollection
            {
                return _errors;
            }

            public function set errors( errs:ArrayCollection ):void
            {
                _errors = errs || new ArrayCollection();
            }

            private function doClickAsItem( item:ValidationErrorMap ):void
            {
                if ( summary.selectedIndex < summary.maxVerticalScrollPosition )
                {
                    summary.verticalScrollPosition = summary.selectedIndex;
                }

                if (item.component is ShapeUIComponent)
                {
                    diagram.select(item.component as ShapeUIComponent);
                }
            }

            protected function onDoubleClick(event:MouseEvent):void
            {
                var item:ValidationErrorMap = summary.selectedItem as ValidationErrorMap; 
                if (item && item.component)
                {
//                    selectParent( item );
                    doClickAsItem( item );
                }
            }
]]>
    </mx:Script>
    <mx:HBox height="20" 
             width="100%" 
             verticalAlign="middle" 
             paddingRight="5">
        <mx:Label text="{resourceManager.getString('Modeler', 'validPropPage_lbl_validResults')}" 
                  fontWeight="bold"/>
        <mx:Spacer width="100%"/>
        <mx:Image source="{Icons.Refresh}" 
                  buttonMode="true" 
                  toolTip="{resourceManager.getString('ServiceModeler', 'toolTip_refreshValidations')}" 
                  id="validateButton" 
                  height="17" 
                  width="17" 
                  click="refreshValidations()" 
                  mouseDownEffect="Glow"/>
    </mx:HBox>
    <mx:DataGrid id="summary" 
                 width="100%" 
                 height="100%"
                 verticalScrollPolicy="on" 
                 wordWrap="false"
                 paddingBottom="0" 
                 dataProvider="{_errors}"
                 doubleClickEnabled="true" 
                 doubleClick="onDoubleClick(event);">
        <mx:columns>
            <mx:DataGridColumn headerText="{resourceManager.getString('Modeler', 'validPropPage_hdr_element')}" 
                               dataField="name" />
            <mx:DataGridColumn headerText="{resourceManager.getString('Modeler', 'validPropPage_hdr_message')}" 
                               dataField="message" 
                               dataTipField="message" 
                               showDataTips="true"/>
        </mx:columns>
    </mx:DataGrid>
</mx:VBox>
4

1 回答 1

1

我发现有针对羽毛的 mxml 编译器,具体参见: https ://github.com/BowlerHatLLC/feathers-sdk/tree/master/modules/compiler/src/java/flex2/compiler/mxml Haxe 可以为 Java 生成 externs图书馆。

将 as3 移植到 Haxe 非常容易,CDATA 只需要一些 getter 和 setter 更改,将 void 更改为 Void,更改保护/私有/公共,然后使用注入库,https://github.com/jasononeil/做药。您可能可以创建一个宏来自己解析 xml 组件的创建......或者用更简单的方法重写项目是最好的?

于 2020-01-29T19:30:34.493 回答