Flex Builder MXML Files to Haxe Conversion

289 views Asked by At

I have a very large flex builder project that I need to port to Haxe. All of our actionscript files are converted using as3hx. I have read about HaxeUI, FeathersUI, and NME. Do any of these options make porting MXML files easy and not a complete rewrite of them? It's important to note that a lot of most of my MXML files contain a lot of 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>
1

There are 1 answers

1
Justinfront On BEST ANSWER

I found that there is compiler of mxml for feathers specifically see: https://github.com/BowlerHatLLC/feathers-sdk/tree/master/modules/compiler/src/java/flex2/compiler/mxml Haxe can generate externs for Java libraries.

It's pretty easy to hand port as3 to Haxe, that CDATA just has some getters and setter changes needed, void to Void, changing the protect/private/public, and then using an injection library, https://github.com/jasononeil/dodrugs. You could probably create a macro to parse the xml component creations yourself.... or maybe rewrite project with simpler approach is best?