Flex Builder MXML 文件到 Haxe 的转换

Flex Builder MXML Files to Haxe Conversion

我有一个非常大的 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>

发现有mxml for feathers的编译器,具体见: https://github.com/BowlerHatLLC/feathers-sdk/tree/master/modules/compiler/src/java/flex2/compiler/mxml Haxe 可以为 Java 个库生成外部文件。

将端口 as3 交给 Haxe 非常容易,CDATA 只是有一些吸气剂和 setter 需要更改,void 到 Void,更改 protect/private/public,然后使用注入库,https://github.com/jasononeil/dodrugs。您可能可以创建一个宏来自己解析 xml 组件创建......或者最好用更简单的方法重写项目?