Flex conditional compilation of MXML?

In Flex, you can now use the -define compiler option to do all kinds of cool things. In my program, I use this opportunity so that some of my codes are excluded by such blocks:

CONFIG::FACEBOOK{
   //Some code
}

And it works well.

How do I get similar behavior with MXML?

I want to do the same, but skipping / including MXML tags in this way, not AS code blocks.

+5
source share
3 answers

My solution is to add tags that can help comment on unnecessary blocks of mxml code in a specific assembly. For example, I want to add different buttons in Android and iOS:

<!-- iOS --><!--
<s:Button id="backBtn" 
    icon="{SHOW_LIST}" 
    click="navigator.popView()"/>
--><!-- /iOS -->

<!--Android-->
<s:Button id="exitBtn" 
    label="Exit" 
    click="NativeApplication.nativeApplication.exit()"/>
<!--/Android-->

script, , Android, iOS

PrepareForIos.cmd

@echo off
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "<!--Android-->" "<!-- Android --><!--"
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "<!--/Android-->" "--><!-- /Android -->"
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "<!-- iOS --><!--" "<!--iOS-->"
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "--><!-- /iOS -->" "<!--/iOS-->"
pause

FART -

iOS:

<!--iOS-->
<s:Button id="backBtn" 
    icon="{SHOW_LIST}" 
    click="navigator.popView()"/>
<!--/iOS-->

<!-- Android --><!--
<s:Button id="exitBtn" 
    label="Exit" 
    click="NativeApplication.nativeApplication.exit()"/>
--><!-- /Android -->

:

PrepareForAndroid.cmd

@echo off
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "<!--Android-->" "<!-- Android --><!--"
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "<!--/Android-->" "--><!-- /Android -->"
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "<!-- iOS --><!--" "<!--iOS-->"
"C:\Program Files (x86)\bin\fart.exe" -r -w -- H:\Flash\MyProject\src\* "--><!-- /iOS -->" "<!--/iOS-->"
pause
+2

, :

package 
{
    public class MyAppConstants
    {
        CONFIG::Debug
            public static const DEBUG:Boolean = true;           
        CONFIG::Release
            public static const DEBUG:Boolean = false;
    }
}

MXML:

<namespace:component visible="{MyAppConstants.DEBUG}" includeInLayout="{MyAppConstants.DEBUG}"/>

, , , . , "" .

+1

, :

, . , ( ..), . - ​​, . ? - 20 14:40

, flex , - MXML, , .

( mx):
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7aee.html

Flex 3

Flex 3, createComponentsFromDescriptors() childDescriptors, , MXML .

, MXML . , , .

UIComponentDescriptor: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/core/UIComponentDescriptor.html

Flex 4

Flex 4 - MXML ( childDescriptors, mxmlContentFactory, ).

MXML :

, , , , :)


:

, MXML. MXML .

, MXML?

/ , MXML? .. actionscript.

:)

0

All Articles