RSA Admin

Flex: if-else logic

Discussion created by RSA Admin Employee on Sep 13, 2012

There is no "else" in Flex.

 

 

Obviously some else-type logic is easily approximated by testing both the condition and its opposite:

 

 

<if name="myVar" equal="1">

<!-- do stuff -->

</if>

<if name="myVar" notequal="1">

<!-- do other stuff -->

</if>

 

 

But what about evaluations that don't have an opposite in Flex, like bitwise "and":

 

<if name="myVar" and="1">

 

 

That just takes a couple extra steps:

 

  1. default a temporary numeric variable to 0
  2. perform the evaluation
  3. if the evaluation succeeds (is "true") then set the temp var to 1
  4. after the evaluation, if the temp var is still 0 - that is your "else"

 

 

For example:

 

 

<assign name="check" value="0"/>

<if name="myVar" and="1">

     <assign name="check" value="1"/>

     <!-- do stuff -->

</if>

<if name="check" equal="0">

     <!-- do other stuff -->

</if>

Outcomes