Hmm, I might be misunderstanding what you're looking for. I think you're
asking how to get the source of the image at run time. Source being the image
content itself. As an example if you were to use the ResourceManager, you can
get the source of the image at runtime by doing the following.
_icon1 = this.resourceManager.getClass("imageBundle","iconForState0");
_icon2 = this.resourceManager.getClass("imageBundle","iconForState1");
This can be more dynamic than using the Embed metatag, as you can use a
variable to supply the "resourceName" parameter of getClass and pull in any of
the images in the resource bundle dynamically at runtime.
Chris
> Date: Sat, 21 Mar 2015 10:11:49 -0500
> Subject: Re: Custom Item renderer to show various icons
> From: [email protected]
> To: [email protected]
>
> Still, both solutions expect images to be embed at a compile time meaning
> hard coding their names. I am trying to avoid that.
>
> Thanks
>
> On Sat, Mar 21, 2015 at 9:55 AM, Chris Martin <[email protected]> wrote:
>
> > You can embed your image assets through the Embed metatag [1]. Or you can
> > get a little fancy and use the ResourceManager to manage all of your
> > embedded image assets [2].
> >
> > Chris
> >
> > [1]
> > http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf60546-7ff2.html
> > [2]
> > http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7f3a.html
> >
> > > Date: Sat, 21 Mar 2015 07:40:16 -0500
> > > Subject: Re: Custom Item renderer to show various icons
> > > From: [email protected]
> > > To: [email protected]
> > >
> > > How would this work if I compile all my resources into a swf file? How
> > can
> > > I then get an image source at the run-time?
> > >
> > > Thanks
> > >
> > > On Wed, Mar 18, 2015 at 3:42 PM, Alex Harui <[email protected]> wrote:
> > >
> > > > Did you try:
> > > >
> > > > if (data)
> > > > {
> > > > var c:Class = data.status == 0 ? _icon1 : _icon2;
> > > > image.source = new c();
> > > > }
> > > >
> > > >
> > > >
> > > >
> > > > On 3/18/15, 8:18 AM, "mark goldin" <[email protected]> wrote:
> > > >
> > > > >I need to have a custom renderer in ADG to show different icons in a
> > cell.
> > > > >Here is my simplified code for the renderer:
> > > > >
> > > > >private var _IconsSourceArrayCol:ArrayCollection = new
> > ArrayCollection();
> > > > >
> > > > >[Embed(source=".icon1.png")]
> > > > >private var _icon1:Class;
> > > > >[Embed(source="icon2.png")]
> > > > >private var _icon2:Class;
> > > > >
> > > > >....
> > > > >override public function set data(value:Object):void
> > > > >{
> > > > >super.data = value;
> > > > >if (data)
> > > > >{
> > > > >_IconsSourceArrayCol.addItem({source:_icon1});
> > > > > _IconsSourceArrayCol.addItem({source:_icon2});
> > > > >image.source = _IconsSourceArrayCol[data.status].source;
> > > > >}
> > > > >}
> > > > >
> > > > >Is there a better way of doing it?
> > > > >
> > > > >Thanks
> > > >
> > > >
> >
> >