Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 01-21-2007, 10:26 AM   #1
Can I
Registered User
Can I's Avatar
Join Date: Oct 2006
Location: Coventry, UK
Posts: 46
Default icon in combobox


I know how to display icons in a dropdown list of a combobox, but when I select an item, there is no icon apearing next to label. I recon I should build my own ItemRenderer for selected item, but do you know how to apply it?

here's code sample

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

	    var iconSymbol:String;

 <mx:Panel width="250" height="200" layout="horizontal" horizontalCenter="0" verticalCenter="-37.5">
  <mx:ComboBox id="itemsCbx">
  	       <mx:Object label="item" icon="{ iconSymbol }"/>
  	       <mx:Object label="item" icon="{ iconSymbol }"/>
  	       <mx:Object label="item" icon="{ iconSymbol }"/>

Can I is offline   Reply With Quote
Old 01-22-2007, 08:34 PM   #2
Join Date: May 2006
Posts: 46
Send a message via ICQ to nirth Send a message via AIM to nirth Send a message via MSN to nirth Send a message via Yahoo to nirth Send a message via Skype™ to nirth


I did not finished this component, so you have to modify createChildren and updateDisplayList methods, to allign image.

package eu.orangeflash.controls
	import mx.controls.ComboBox;
	import mx.controls.Image;

	public class IconComboBox extends ComboBox
		protected var _iconWidth:Number = 16;
		protected var _iconHeight:Number = 16;
		protected var _iconField:String;
		protected var _icon:Image;
		public function set iconWidth(value:Number):void
			_iconWidth = value;
		public function get iconWidth():Number
			return _iconWidth;
		public function set iconHeight(value:Number):void
			_iconHeight = value;
		public function get iconHeight():Number
			return _iconHeight;
		public function set iconField(value:String):void
			_iconField = value;
		public function get iconField():String
			return _iconField;
		override protected function createChildren():void
			textInput.move(_iconWidth, 0);
				_icon = new Image();
				_icon.move(0, 0);
			_icon.width  = _iconWidth;
			_icon.height = _iconHeight;	
		override protected function commitProperties():void
			_icon.source = selectedItem[iconField];
		override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
			super.updateDisplayList(unscaledWidth, unscaledHeight);
			_icon.source = selectedItem[iconField];
OrangeBlog finally in english, but really bad one
nirth is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS2] Icon in a combobox pajeczyca Components 7 09-06-2012 05:01 AM
Dynamic Icon List danNL Components 6 08-05-2008 04:47 PM
Understanding icon in a combobox example pajeczyca Components 0 08-15-2006 03:24 AM
Icon position with DataGrid Cell djsodom Components 2 01-03-2005 01:08 AM
[mx] combobox, focus & keypad arrows chartrandi Components 0 03-31-2004 11:12 AM

All times are GMT. The time now is 01:25 PM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.