I also tried setting the source in the setter function as follows but still
only a broken image
public function set listData( value : BaseListData ) : void
{
_listData = value;
icon3.source="this{data[(DataGridListData(listData).dataField)]}";
}
In another part of the app I successfully display the image in a repeated
custom component as follows.
public function set imagePath(value:String):void {
icon2.source=this[value];
}
Is there a way I can do something similar in the getter function for this
datagrid item renderer?
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: 18 September 2007 07:45
To: [email protected]
Subject: [SPAM] RE: [SPAM] RE: [SPAM] RE: [flexcoders] Changing the image in
a custom component item renderer
Hmm, didn't see that last time. Try this:
<mx:SWFLoader id="icon3" x="60" y="2" width="40" height="40"
source="{data[(DataGridListData(listData).dataField)]}"/>
_____
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Steven
Sent: Monday, September 17, 2007 11:32 PM
To: [email protected]
Subject: RE: [SPAM] RE: [SPAM] RE: [flexcoders] Changing the image in a
custom component item renderer
Thanks for the reply Alex. I do still have those 3 class vars but something
still is not quite working. See my code listing below and you will see the 3
class vars
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: 18 September 2007 07:14
To: [email protected]
Subject: [SPAM] RE: [SPAM] RE: [flexcoders] Changing the image in a custom
component item renderer
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: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Steven
Sent: Monday, September 17, 2007 10:53 PM
To: [email protected]
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" 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: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Alex Harui
Sent: 17 September 2007 19:12
To: [email protected]
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: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Paul Steven
Sent: Monday, September 17, 2007 10:32 AM
To: [email protected]
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" 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>