Try to use an bindable ArrayCollection as your dataProvider that uses your array. (see the docs for an example).


On 3/28/06, Gordon Smith < [EMAIL PROTECTED]> wrote:

I'm not sure why an Array of Objects doesn't work, but let's see if Alex Harui does.

 

However, I do want to point out that writing

 

    public var a:Array = [ { name: "nueng" }, { name: "saawng" }, { name: "saam" } ];

 

will produce smaller and faster code than what you're doing in initData().

 

- Gordon

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of Lance Linder
Sent: Monday, March 27, 2006 1:08 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] List Component Bug!!

 

Hello,

 

I was just converting a project from Beta1 to Beta2 and noticed a problem with all my List components that were bound to data providers which are collections of custom objects.

 

The problem is that the List selection highlight is stuck on the last item in the list.  Changing the provider to be an array collection made up of plain instances of the Object class fixes the problem.  The problem seems to effect anything that uses the List component (ComboBox, DataGrid…)

 

Has anyone else seen this and found a fix?  Using plain old Object instances are not an option.

 

Here is some sample code that shows the problem.

 

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns="*" layout="absolute" preinitialize="initData()">

           

            <mx:Script>

                        <![CDATA[

                                   

                                    [Bindable]

                                    public var a:Array;

                                                                       

                                    private function initData():void {

                                               

                                                a = new Array();

                                   

                                                var myObj:MyObject = new MyObject();

                                                myObj.name = "neung";

                                                a.push(myObj);

                                               

                                                var myObj2:MyObject = new MyObject();

                                                myObj2.name = "saawng";

                                                a.push(myObj2);

                                               

                                                var myObj3:MyObject = new MyObject();

                                                myObj3.name = "saam";

                                                a.push(myObj3);

                                    }

                                   

                        ]]>

            </mx:Script>

           

            <mx:List x="10" y="10" dataProvider="{a}" width="200" height="200" labelField="name"></mx:List>

</mx:Application>

 

//------ MyObject.as -----------------

 

package {

 

            public class MyObject extends Object {

                        public var name:String;

            }

}




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS






--
::| Carlos Rovira
::| http://www.carlosrovira.com


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to