[EMAIL PROTECTED] Wed Apr 07 02:32:27 2004 Return-Path: <[EMAIL PROTECTED]> X-Sender: [EMAIL PROTECTED] X-Apparently-To: [email protected] Received: (qmail 80547 invoked from network); 7 Apr 2004 09:32:26 -0000 Received: from unknown (66.218.66.172) by m5.grp.scd.yahoo.com with QMQP; 7 Apr 2004 09:32:26 -0000 Received: from unknown (HELO p15112434.pureserver.info) (217.160.168.91) by mta4.grp.scd.yahoo.com with SMTP; 7 Apr 2004 09:32:25 -0000 Received: from [10.44.4.2] ([213.128.227.106]) (authenticated (0 bits)) by p15112434.pureserver.info (8.11.6/8.11.6) with ESMTP id i379WLf30931 for <[email protected]>; Wed, 7 Apr 2004 10:32:21 +0100 To: [email protected] In-Reply-To: <[EMAIL PROTECTED]> References: <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> <[EMAIL PROTECTED]> Content-Type: multipart/alternative; boundary="=-zATILQv6wbUH65BazPPH" Organization: iteration::two Message-Id: <[EMAIL PROTECTED]> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.4.6 Date: Wed, 07 Apr 2004 10:32:15 +0100 X-eGroups-Remote-IP: 217.160.168.91 From: Alistair McLeod <[EMAIL PROTECTED]> Subject: Re: [flexcoders] combobox with graphics and text X-Yahoo-Group-Post: member; u=151017110 X-Yahoo-Profile: alimcleod
--=-zATILQv6wbUH65BazPPH Content-Type: text/plain Content-Transfer-Encoding: 7bit Hi Jonathan, This one got me intrigued, so I've spent an hour this morning seeing what I could come up with. You can use the fact that a ComboBox contains a List, and that the the List control has an iconField property that specifies an icon that can appear beside each item in the combo dropdown. So, here's what i have: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" > <mx:Script> [Embed(source="1.jpg")] var iconSymbol1:String; [Embed(source="2.jpg")] var iconSymbol2:String; [Embed(source="3.jpg")] var iconSymbol3:String; </mx:Script> <mx:ComboBox id="theCombo" creationComplete="theCombo.getDropdown().iconField='icon'" > <mx:dataProvider> <mx:Array> <mx:Object label="One" icon="{ iconSymbol1 }" /> <mx:Object label="Two" icon="{ iconSymbol2 }" /> <mx:Object label="Three" icon="{ iconSymbol3 }" /> </mx:Array> </mx:dataProvider> </mx:ComboBox> <mx:Button label="Rotate Icons" click="rotate();" /> <mx:Script> <![CDATA[ function rotate() { var firstIcon = theCombo.dataProvider[0].icon; for ( var i = 1; i < theCombo.dataProvider.length; i++ ) { theCombo.dataProvider[i-1].icon = theCombo.dataProvider[i].icon; } theCombo.dataProvider[ theCombo.dataProvider.length - 1 ].icon = firstIcon; theCombo.bLabelFieldChanged = true; theCombo.invalidate(); theCombo.dispatchEvent({type:"labelFieldChanged"}); } ]]> </mx:Script> </mx:Application> In this example, the graphics to appear in the combo are embedded at compile time, but can be changed at runtime, as shown in the rotate() method. Data binding should work the same way. Hopefully theres enough in there to get you going - its a rough implementation - I'd extract a custom component from the above and I've not investigated the best way to inform the ComboBox that its embedded List control has changed (thats what the bits and the end of the rotate() function do). I've not got time to explain this in full details just now (I've got real work to do too :) ), but I'll blog about the implementation over on http://www.richinternetapps.com later today. Cheers, Ali On Tue, 2004-04-06 at 15:15, Jonathan Bezuidenhout wrote: > Hi all, > > I am trying to create a combobox where each entry consists of a changeable > graphic (that can be data bound) followed by some text. Say a tick mark > in front of some text, if a certain condition changes in the system > somewhere, I want the tick to automatically show up or not. > > Can something like this be done using MXML or AS, or can this only be done > using Flash? Chapter 16 does not tell me very much - are there any > examples of doing this for real? I looked in the flex for flash and it > does not seem like what I need to do either. > > Thanks > > Jonathan > > > > Yahoo! Groups Links > > > > -- --=-zATILQv6wbUH65BazPPH Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 7bit <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN"> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8"> <META NAME="GENERATOR" CONTENT="GtkHTML/3.0.10"> </HEAD> <BODY> Hi Jonathan,<BR> <BR> This one got me intrigued, so I've spent an hour this morning seeing what I could come up with.<BR> <BR> You can use the fact that a ComboBox contains a List, and that the the List control has an iconField property that specifies an icon that can appear beside each item in the combo dropdown.<BR> <BR> So, here's what i have:<BR> <BR> <?xml version="1.0" encoding="utf-8"?><BR> <mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" ><BR> <BR> <mx:Script><BR> [Embed(source="1.jpg")]<BR> var iconSymbol1:String;<BR> [Embed(source="2.jpg")]<BR> var iconSymbol2:String;<BR> [Embed(source="3.jpg")]<BR> var iconSymbol3:String;<BR> </mx:Script><BR> <BR> <mx:ComboBox id="theCombo" creationComplete="theCombo.getDropdown().iconField='icon'" ><BR> <mx:dataProvider><BR> <mx:Array><BR> <mx:Object label="One" icon="{ iconSymbol1 }" /><BR> <mx:Object label="Two" icon="{ iconSymbol2 }" /><BR> <mx:Object label="Three" icon="{ iconSymbol3 }" /><BR> </mx:Array><BR> </mx:dataProvider><BR> </mx:ComboBox><BR> <BR> <mx:Button label="Rotate Icons" click="rotate();" /><BR> <BR> <mx:Script><BR> <BR> <![CDATA[<BR> <BR> function rotate()<BR> {<BR> var firstIcon = theCombo.dataProvider[0].icon;<BR> for ( var i = 1; i < theCombo.dataProvider.length; i++ )<BR> {<BR> theCombo.dataProvider[i-1].icon = theCombo.dataProvider[i].icon;<BR> }<BR> <BR> theCombo.dataProvider[ theCombo.dataProvider.length - 1 ].icon = firstIcon;<BR> <BR> theCombo.bLabelFieldChanged = true;<BR> theCombo.invalidate();<BR> <BR> theCombo.dispatchEvent({type:"labelFieldChanged"});<BR> }<BR> ]]><BR> <BR> </mx:Script><BR> <BR> </mx:Application><BR> <BR> In this example, the graphics to appear in the combo are embedded at compile time, but can be changed at runtime, as shown in the rotate() method. Data binding should work the same way. <BR> <BR> Hopefully theres enough in there to get you going - its a rough implementation - I'd extract a custom component from the above and I've not investigated the best way to inform the ComboBox that its embedded List control has changed (thats what the bits and the end of the rotate() function do).<BR> <BR> I've not got time to explain this in full details just now (I've got real work to do too :) ), but I'll blog about the implementation over on http://www.richinternetapps.com later today.<BR> <BR> Cheers,<BR> <BR> Ali<BR> <BR> <BR> On Tue, 2004-04-06 at 15:15, Jonathan Bezuidenhout wrote: <BLOCKQUOTE TYPE=CITE> <PRE><FONT COLOR="#737373"><I>Hi all, I am trying to create a combobox where each entry consists of a changeable graphic (that can be data bound) followed by some text. Say a tick mark in front of some text, if a certain condition changes in the system somewhere, I want the tick to automatically show up or not. Can something like this be done using MXML or AS, or can this only be done using Flash? Chapter 16 does not tell me very much - are there any examples of doing this for real? I looked in the flex for flash and it does not seem like what I need to do either. Thanks Jonathan Yahoo! Groups Links <*> To visit your group on the web, go to: </FONT><A HREF="http://groups.yahoo.com/group/flexcoders/"><U>http://groups.yahoo.com/group/flexcoders/</U></A> <FONT COLOR="#737373"> <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: </FONT><A HREF="http://docs.yahoo.com/info/terms/"><U>http://docs.yahoo.com/info/terms/</U></A> <FONT COLOR="#737373"> </I></FONT></PRE> </BLOCKQUOTE> <PRE><TABLE CELLSPACING="0" CELLPADDING="0" WIDTH="100%"> <TR> <TD> <PRE>-- </PRE> </TD> </TR> </TABLE> </PRE> </BODY> </HTML> --=-zATILQv6wbUH65BazPPH--

