You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by mark goldin <ma...@gmail.com> on 2015/03/23 17:00:49 UTC

Combobox with icons

I am working on a combobox that has both icons and text in its dropdown
section.
Here is how I do it:

[Embed(source="icon1.png")]
public var _icon1:Class;
[Embed(source="icon2.png")]
public var _icon2:Class;

.....................

<mx:ComboBox id="combo" labelField="label" width="100%"
 creationComplete="{combo.dropdown.iconField='icon'}">
<mx:Object icon="_icon1"
label="Label1" value="value1"/>
<mx:Object icon="_icon2"
       label="label2" value="value2/>
</mx:ComboBox>

Now I want to use an ArrayCollection as a combo dataProvider. Icons will be
loaded into it. How exactly do I configure the ArrayCollection to serve the
same purpose as my current object?


Thanks

Re: Combobox with icons

Posted by mark goldin <ma...@gmail.com>.
Well, I am doing something like this ...
Here is some code, simplified:

My item renderer is based on HBox.

private var image:Bitmap = new Bitmap();
private function init():void
{
var uic:UIComponent = new UIComponent();
uic.addChild(image);
addChild(uic);
}

override public function set data(value:Object):void
{
     image = new Bitmap(FlexGlobals.topLevelApplication.Icons[0].Icon;
}
.....
private function PreloadImage_CompleteHandler(event:Event):void
{

FlexGlobals.topLevelApplication.Icons.addItem(event.currentTarget.content.bitmapData);
}


It works fine, but I also want to use my renderer with an image placed at a
design time and not added at the run time. Is it possible?

Thanks


On Wed, Mar 25, 2015 at 5:15 AM, Kessler CTR Mark J <
mark.kessler.ctr@usmc.mil> wrote:

> Ahh, guess it's going to be just gathering a list of urls from a source
> (such as a server) and creating a class to pre-download using something
> like URLLoader .  Then when you reference them later they are already in
> the client cache.  You could also alternatively store the binary data an
> object as well.
>
> -Mark
>
> -----Original Message-----
> From: mark goldin [mailto:markzolotoy@gmail.com]
> Sent: Monday, March 23, 2015 2:04 PM
> To: users
> Subject: Re: Combobox with icons
>
> My code is a bit simplified. bitmapData is a result of loading an image in
> advance.
>
> On Mon, Mar 23, 2015 at 1:00 PM, Kessler CTR Mark J <
> mark.kessler.ctr@usmc.mil> wrote:
>
> > I do know a s:BitmapImage can load files on the fly with its source
> > property [1].  It supports "The name of a external image file" and " The
> > image location can be specified via a URL, URLRequest, or file
> reference".
> > It  is limited to PNG, GIF, or JPG.
> >
> >
> > [1]
> >
> http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/primitives/BitmapImage.html#source
> >
> > -Mark
> >
>

RE: Combobox with icons

Posted by Kessler CTR Mark J <ma...@usmc.mil>.
Ahh, guess it's going to be just gathering a list of urls from a source (such as a server) and creating a class to pre-download using something like URLLoader .  Then when you reference them later they are already in the client cache.  You could also alternatively store the binary data an object as well.

-Mark

-----Original Message-----
From: mark goldin [mailto:markzolotoy@gmail.com]
Sent: Monday, March 23, 2015 2:04 PM
To: users
Subject: Re: Combobox with icons

My code is a bit simplified. bitmapData is a result of loading an image in
advance.

On Mon, Mar 23, 2015 at 1:00 PM, Kessler CTR Mark J <
mark.kessler.ctr@usmc.mil> wrote:

> I do know a s:BitmapImage can load files on the fly with its source
> property [1].  It supports "The name of a external image file" and " The
> image location can be specified via a URL, URLRequest, or file reference".
> It  is limited to PNG, GIF, or JPG.
>
>
> [1]
> http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/primitives/BitmapImage.html#source
>
> -Mark
>

Re: Combobox with icons

Posted by mark goldin <ma...@gmail.com>.
My code is a bit simplified. bitmapData is a result of loading an image in
advance.

On Mon, Mar 23, 2015 at 1:00 PM, Kessler CTR Mark J <
mark.kessler.ctr@usmc.mil> wrote:

> I do know a s:BitmapImage can load files on the fly with its source
> property [1].  It supports "The name of a external image file" and " The
> image location can be specified via a URL, URLRequest, or file reference".
> It  is limited to PNG, GIF, or JPG.
>
>
> [1]
> http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/primitives/BitmapImage.html#source
>
> -Mark
>

RE: Combobox with icons

Posted by Kessler CTR Mark J <ma...@usmc.mil>.
I do know a s:BitmapImage can load files on the fly with its source property [1].  It supports "The name of a external image file" and " The image location can be specified via a URL, URLRequest, or file reference".  It  is limited to PNG, GIF, or JPG.


[1] http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/primitives/BitmapImage.html#source

-Mark

Re: Combobox with icons

Posted by mark goldin <ma...@gmail.com>.
Will something like this work?
ArrayCollectionIconSourceDataProvider.addItem({icon:imageArray[0]});

where imageArray defined like this:
imageArray.addItem(new Bitmap(bitmapData));

Thanks

On Mon, Mar 23, 2015 at 11:57 AM, Alex Harui <ah...@adobe.com> wrote:

> Those two mx:Objects were probably placed in an ArrayCollection.  Take a
> look in the debugger.
>
> -Alex
>
> On 3/23/15, 9:00 AM, "mark goldin" <ma...@gmail.com> wrote:
>
> >I am working on a combobox that has both icons and text in its dropdown
> >section.
> >Here is how I do it:
> >
> >[Embed(source="icon1.png")]
> >public var _icon1:Class;
> >[Embed(source="icon2.png")]
> >public var _icon2:Class;
> >
> >.....................
> >
> ><mx:ComboBox id="combo" labelField="label" width="100%"
> > creationComplete="{combo.dropdown.iconField='icon'}">
> ><mx:Object icon="_icon1"
> >label="Label1" value="value1"/>
> ><mx:Object icon="_icon2"
> >       label="label2" value="value2/>
> ></mx:ComboBox>
> >
> >Now I want to use an ArrayCollection as a combo dataProvider. Icons will
> >be
> >loaded into it. How exactly do I configure the ArrayCollection to serve
> >the
> >same purpose as my current object?
> >
> >
> >Thanks
>
>

Re: Combobox with icons

Posted by Alex Harui <ah...@adobe.com>.
Those two mx:Objects were probably placed in an ArrayCollection.  Take a
look in the debugger.

-Alex

On 3/23/15, 9:00 AM, "mark goldin" <ma...@gmail.com> wrote:

>I am working on a combobox that has both icons and text in its dropdown
>section.
>Here is how I do it:
>
>[Embed(source="icon1.png")]
>public var _icon1:Class;
>[Embed(source="icon2.png")]
>public var _icon2:Class;
>
>.....................
>
><mx:ComboBox id="combo" labelField="label" width="100%"
> creationComplete="{combo.dropdown.iconField='icon'}">
><mx:Object icon="_icon1"
>label="Label1" value="value1"/>
><mx:Object icon="_icon2"
>       label="label2" value="value2/>
></mx:ComboBox>
>
>Now I want to use an ArrayCollection as a combo dataProvider. Icons will
>be
>loaded into it. How exactly do I configure the ArrayCollection to serve
>the
>same purpose as my current object?
>
>
>Thanks