You can try this below, but it is going to be hard to debug:
<mx:Label text="{this[XML(data)[EMAIL PROTECTED]" id="testme"
textAlign="center"/>
You will probably get a binding warning re the brackets. So that
probably won't work when renderer is recycled.
I would store the icon name in set data(), and in commitProperties
assign the image source, using bracket notation to resolve the
appropriate variable.
You only have one image embedded, you will have more, correct? The
variable name has to match the value in @icon.
Tracy
________________________________
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Jerry DuVal
Sent: Monday, January 21, 2008 12:28 PM
To: [email protected]
Subject: [flexcoders] Loading image based on attribute value in XML
content
I have created a ItemRenderer that displays some text based on values in
the XML data. Everything works as expected, but I want to display a
image based on the value in the XML data. The image source attribute =
"{XML(data)[EMAIL PROTECTED]" which returns a value = "addNew", but does not
load
the image defined in the class. The full code is below.
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
horizontalAlign="center" width="86" height="80">
<mx:Spacer height="1"/>
<mx:VBox width="100%" height="100%" borderStyle="solid"
borderThickness="3" backgroundColor="#a4b7ac" borderColor="#99aea3"
xmlns:head="layout.*" xmlns:components="components.*"
verticalAlign="top" cornerRadius="11">
<!--mx:Label text="[EMAIL PROTECTED]"
id="testme" textAlign="center"/-->
<mx:Label text="{XML(data)[EMAIL PROTECTED]"
id="testmets" textAlign="center" fontWeight="bold"/>
<mx:Label text="{XML(data)[EMAIL PROTECTED]"
id="testme" textAlign="center"/>
<mx:Image id="myLogo"
source="{XML(data)[EMAIL PROTECTED]"/>
</mx:VBox>
<mx:Script>
<![CDATA[
[Bindable]
[Embed(source="../assets/add.png")]
public var addNew:Class;
]]>
</mx:Script>
</mx:VBox>
Jerry DuVal
Pace Systems Group, Inc.
800.624.5999
www.Pace2020.com