Professional Web Applications Themes

if/else tag syntax - Macromedia Flex General Discussion

Hello, I know, how to do if/else in Actionscript, but how can I do something like if/else in MXML syntax? I want to decide on startup/compile time, if or if not to display a custom component, I made. Can anyone help? Regards, Matthew...

  1. #1

    Default if/else tag syntax

    Hello,

    I know, how to do if/else in Actionscript, but how can I do something like
    if/else in MXML syntax? I want to decide on startup/compile time, if or if not
    to display a custom component, I made.
    Can anyone help?

    Regards,
    Matthew

    negttid Guest

  2. #2

    Default Re: if/else tag syntax

    To be correct, I can solve my problem with Actionscript, but I guess, there is
    a solution with MXML Tag syntax only, which I do not know. And if there's none,
    then there should be one:

    in AS:
    <mx:SomeParent id="someParent" />
    if (CONDITION) { someParent.createChild(SomeChild, undefined, {arg1: value;
    arg2: value}); }

    in MXML (is there something like that?)
    <mx:SomeParent id="someParent">
    <mx:if test="{CONDITION}">
    <mx:SomeChild arg1="value" arg2="value" />
    </mx:if>
    </mx:SomeParent>


    negttid Guest

  3. #3

    Default Re: if/else tag syntax

    There is no such mxml syntax in Flex 1.5.
    Tracy
    ntsiii Guest

  4. #4

    Default Re: if/else tag syntax

    Tracy, that's true! I know, that there's no <mx:if> Tag, but there should be
    one!

    Imagine you retrieve data with an XML based dataprovider.
    you want to show the <title value="something" /> within a <mx:Label> Tag.
    You build your Application, and this Label should appear, when the data is
    retrieved over an HTTPService...
    Before it is retrieved, there should be no Label and no space used, like if
    there is a Label.
    Understand?
    How do you do that?

    Has someone an idea, how to implement an "if"-Class to have a <local:if> Tag?
    ;-)

    negttid Guest

  5. #5

    Default Re: if/else tag syntax

    negttid wrote:
    > Tracy, that's true! I know, that there's no <mx:if> Tag, but there should be
    > one!
    >
    > Imagine you retrieve data with an XML based dataprovider.
    > you want to show the <title value="something" /> within a <mx:Label> Tag.
    > You build your Application, and this Label should appear, when the data is
    > retrieved over an HTTPService...
    > Before it is retrieved, there should be no Label and no space used, like if
    > there is a Label.
    > Understand?
    > How do you do that?
    >
    > Has someone an idea, how to implement an "if"-Class to have a <local:if> Tag?
    > ;-)
    >
    The point you are missing is that "if" isnt a class. It is an operator.

    Also realize that MXML is designed for layout, not conditional logic.
    Let's say you did make a conditional tag... What order would it fire in?


    --
    Dave Wolf
    Cynergy Systems, Inc.
    Macromedia Flex Alliance Partner
    [url]http://www.cynergysystems.com[/url]

    Email: [email]dave.wolfcynergysystems.com[/email]
    Office: 866-CYNERGY

    Dave Wolf Guest

  6. #6

    Default Re: if/else tag syntax

    Hi Dave,
    > The point you are missing is that "if" isnt a class. It is an operator.
    that's right. it's conditional logic.
    > Also realize that MXML is designed for layout, not conditional logic.
    designed for layout - this must not be an obstacle!
    conditional in the way: to lay_out, or to not lay_out ;-)
    > Let's say you did make a conditional tag... What order would it fire in?
    What do you mean with "order" and "fire"?

    Perhaps I can't make myself understandable.
    Compared my question for an <mx:if> Tag with a <mx:Repeater> Tag and a XML
    dataprovider.
    In the later case it is possible to do conditional logic with the help of
    XPath conditions, e.g. node/[arg='value'].

    But I don't want to waste Repeaters, when all I want to show is a single
    element or not.

    I want to layout something in the way of a "INVISIBLE" placeholder. After
    retrieving the data, I want to fill the 'something' and make it "VISIBLE".
    Repeaters are shown only, when the DataPointer is defined (which is the case
    after the data was retrieved). Before the data was retrieved, there is shown
    nothing.
    Labels are shown always - whether there is the text="" attribute set or not.
    The Label take always the space of a lineheight.

    I just want the label to occupy no space until it is filled.

    Regards,
    Matthew

    sorry for my bad english


    negttid Guest

  7. #7

    Default Re: if/else tag syntax

    Your intended use of if/else can be handled using states. Check out the help:
    Use states and transitions. Control the interface by switching states. The key
    to the problem is having an event to respond to to decide what state you should
    be in.

    Paul

    pauland Guest

  8. #8

    Default Re: if/else tag syntax

    Hey check this out, to insert if else condition in MXML OR Spark component.
    I hope that will help you :)
    http://www.fatehkhan.com/2011/03/13/use-if-else-condition-in-mxml-with-bindable-variable/
    fatehkhan is offline Junior Member
    Join Date
    Mar 2011
    Location
    Sydney
    Posts
    2

  9. #9

    Default Re: if/else tag syntax

    You can use if else condition in MXML/Spark components by using "inline if" statement:

    <mx:VBox horizontalAlign="{checkBox.selected?'left':'center '}"
    verticalAlign="{checkBox.selected?'top':'middle'}"
    width="300" height="100" backgroundColor="#9715E8" >

    I hope that will help you :)

    Have a look here:

    http://www.fatehkhan.com/2011/03/13/use-if-else-condition-in-mxml-with-bindable-variable/
    fatehkhan is offline Junior Member
    Join Date
    Mar 2011
    Location
    Sydney
    Posts
    2

Similar Threads

  1. Help with SYntax, Please!
    By Artspan in forum Macromedia ColdFusion
    Replies: 3
    Last Post: April 15th, 06:23 PM
  2. Syntax again - Help!
    By Geoff in forum Macromedia Flash Sitedesign
    Replies: 4
    Last Post: November 18th, 11:23 PM
  3. Need Help With Syntax!
    By Aaron Bertrand - MVP in forum ASP Database
    Replies: 10
    Last Post: August 7th, 03:44 PM
  4. Syntax
    By yma in forum ASP.NET General
    Replies: 1
    Last Post: July 3rd, 02:00 PM
  5. Help with DB2 Syntax.
    By sharads in forum IBM DB2
    Replies: 1
    Last Post: July 3rd, 09:04 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139