Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  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. Similar Questions and Discussions

    1. Help with SYntax, Please!
      I want the name of a product to show IF the Name field is NOT NULL AND if there's an image for that Record. Can anyone help? Here's the code...
    2. If than syntax help please
      I'm trying to say: If price2 equals the selected price than apply the style bold price. If price 2 is nothing or zero than show nothing. If price...
    3. Syntax again - Help!
      I have a movie clip instance named 22mc. Can anyone tell me why this is not good syntax: on (release) { with (_root.22mc) { play(); } } ...
    4. Syntax
      Hi, In a subclass, is sub new() end sub the same as sub new()
    5. Help with DB2 Syntax.
      Hi Everyone, Recently our comany upgraded their applications from MS ACCESS 2000 to DB2 version 7.2 UDB. I'm not as skilled in DB2 with the...
  3. #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

  4. #3

    Default Re: if/else tag syntax

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

  5. #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

  6. #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.wolf@cynergysystems.com[/email]
    Office: 866-CYNERGY

    Dave Wolf Guest

  7. #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

  8. #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

  9. #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

  10. #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

Posting Permissions

  • You may not post new threads
  • You may 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