Search code examples
apache-flexflex4flex4.5flexbuilder

combining variables in flex to form a variable or class name


I have an embedded image and the class name to be userd in source tag is a combination of 2 variables, i am confused how to do this, below is an iadea of what i am trying to do:

 [Embed (source="assets/image11_a.jpg")] public static const 11_a:Class;
 var first_part:String="11";
 var second_part:String="a";

and in mxml
<s:Image width="100" height="100" source="{first_part+second_part}"/>

above is just a small simplified example of what i am trying to do, actually the variables are getting populated from list.Basically i want to combine variable names to form the embedded image class name to be used in source of spark image.

Any help ?


Solution

  • Try this:

    <s:Image width="100" height="100" source="{this[first_part+second_part]}"/>
    

    [Note: I'm not sure you're reasoning for this, and trying to piece together variable names at runtime seems like a bad idea to me, personally]