jwx
jwx

Reputation: 137

Flex image source concatenated

Within Flex, I am trying to concatenated the name of an image within a pathname. Preferably, I would like to do this by embeding, but if it will only work without embeding then I will go that route. My code looks like this for embeded:

<s:Image id="loader1" source="@Embed(source="'/images/'+{data.photo}+'.png'")"/>

Where my code for unembeded looks like this:

<s:Image id="loader1" source="'/images/'+{data.photo}+'.png'"/>

When I code the direct pathname I am able to get the picture. That code looks like this:

<s:Image id="loader1" source="@Embed(source='/images/2008-2011.png')"/> 

Upvotes: 0

Views: 378

Answers (1)

skovalyov
skovalyov

Reputation: 2099

It is impossible, because embedding is compile time and by metadata you specify the explicit path to the image. While your data.photo variable gets its value during runtime. I would recommend you to embed all the images you need upfront and declare a hash table, where all possible values for data.photo are keys and embedded images are values. This would help you to implement a binding in a very similar way to what you are looking for.

Upvotes: 1

Related Questions