Search code examples
apache-flexmxml

MXML syntax for "inline" functions


Somewhere in the internets I stumbled across some kind of inline function for setting the color of a label.

Something like this:

color="{data >0 ? 0x006600 : 0xFF0000}

Basically, this is exactly what I need in my ItemRenderer, but in an if-else if-else way.

The script above says data > 0 then set color to green, else set it to red. What I need is an additional case, that is no change set color to gray.

Is that accomplishable with this sort of "inline" function?


Solution

  • You can do something like this:

    data==null ? 0xCCCCCC : (data>0 ? 0x006600 : 0xFF0000)
    

    But what's the underlying goal? You might be better off with a style function.