In the original post, you had 3 class vars You still need those. @Embed is compile time, so you have to embed the 3 images like you had it at first, then the code I showed will choose one of the three variables.
________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Monday, September 17, 2007 10:53 PM To: flexcoders@yahoogroups.com Subject: RE: [SPAM] RE: [flexcoders] Changing the image in a custom component item renderer Thanks Alex I have tried what you suggested but the image is not displaying. I have added a text field into the custom component - this is displaying the correct value. But it is not displaying any image - just a broken image icon. Here is the code for my custom component: <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " width="100" height="30"> <mx:Script> <![CDATA[ import mx.controls.dataGridClasses.DataGridListData; import mx.controls.listClasses.BaseListData; import flash.events.Event; // Make the listData property bindable. [Bindable("dataChange")] private var _listData : BaseListData; public function get listData() : BaseListData { return _listData; } public function set listData( value : BaseListData ) : void { _listData = value; } [Bindable] [Embed('assets/icons.swf', symbol='incomplete')] public var incomplete:Class; [Bindable] [Embed('assets/icons.swf', symbol='awaitingSubmission')] public var awaitingSubmission:Class; [Bindable] [Embed('assets/icons.swf', symbol='submitted')] public var submitted:Class; ]]> </mx:Script> <mx:SWFLoader id="icon3" x="60" y="2" width="40" height="40" source="@Embed('assets/icons.swf' , symbol={data[(DataGridListData(listData).dataField)]}"/> <mx:Label text="{data.status}"/> </mx:Canvas> From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Alex Harui Sent: 17 September 2007 19:12 To: flexcoders@yahoogroups.com Subject: [SPAM] RE: [flexcoders] Changing the image in a custom component item renderer Something like: imagePath="{data[DataGridListData(listData).dataField]}" You'll need to add a listData getter/setter and implement IDropInListItemRenderer. Copy the listData get/set from Label or TextInput ________________________________ From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Paul Steven Sent: Monday, September 17, 2007 10:32 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Changing the image in a custom component item renderer I am creating a datagrid that uses a custom component in an item renderer to display one of 3 images (symbols of an embedded swf) The data grid columns are created dynamically. I can't figure out how to set the value of imagePath inside this custom component. The symbol names are the same as the value for xmlColumn.localName(); Any help really appreciated!! e.g dgc = new DataGridColumn(); dgc.headerText = xmlColumn.localName(); dgc.itemRenderer=new ClassFactory(statusComponent); dgc.dataField = xmlColumn.localName(); My custom component is as follows: <?xml version="1.0" encoding="utf-8"?> <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" <http://www.adobe.com/2006/mxml> width="100" height="30"> <mx:Script> <![CDATA[ [Bindable] [Embed('assets/icons.swf', symbol='incomplete')] public var incomplete:Class; [Bindable] [Embed('assets/icons.swf', symbol='awaitingSubmission')] public var awaitingSubmission:Class; [Bindable] [Embed('assets/icons.swf', symbol='submitted')] public var submitted:Class; public function set imagePath(value:String):void { statusIcon3.source=this[value]; } ]]> </mx:Script> <mx:SWFLoader id="statusIcon3" x="5" y="6"/> </mx:Canvas>