user1190524
user1190524

Reputation: 65

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 ?

Upvotes: 0

Views: 157

Answers (1)

JeffryHouser
JeffryHouser

Reputation: 39408

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]

Upvotes: 3

Related Questions