flex - Problem accessing value of selected item in a list -
I'm having trouble getting the value of an item that the user selects in my mobile flex application when I list I select an item from it, then keep that item in Array. But when I check the value (trace), then the value is [object object] and I can not use the object's actual value . Here's what I'm doing:
Private var selected player: ArrayCollection = New ArrayCollection (); Private var numOfPlayers: int; ... // Check that if the item is not already in the list of selected players (Selected Players Content (Selected Player). Select the selected players. Players.aditem ( Playlistist.Channitime); NumOfPlayers ++; Trace ("Selected Players:" + Selected Players); } Output from trace ():
Selected player: [object object]
Thanks a lot for any advice and insights. / P>
UPDATE: Here is the work code:
... // Check that if the item is not already in the list of selected players (if selected player content (playerlist.sectaid.PNName)) {// Selected list of selected players in the list of selected selected players Player AddItem ({name: player list selectedItem.PName}); NumOfPlayers ++; }
Now I do not stabilize my ArrayCollection.
Try it, the second trace in the click handler will return the property "name" of AC. Update it with your property name.
& lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; S: Application xmlns: fx = "http://ns.adobe.com/mxml/2009" xmlns: s = "library: //ns.adobe.com/flex/spark" xmlns: mx = "library: // Ns.adobe.com/flex/mx "minWidth =" 955 "minHeight =" 600 "Start =" 1_Inlize Application Handler (Event) "& gt; & Lt; Fx: script & gt; & Lt ;! [CDATA [Import mx.collections.ArrayCollection; Selected player of private names: ArrayCollection = New ArrayCollection ({{Name: "iTunes", id: "1"}, {Name: "Media Player", id: "2"}, {Name: "WinAmp", id: "3"}] Protected function button 2_clicker (Event: Mouse Event): Zero {// Tudo Auto-Generated Method Stub Trace ("Selected Players:" + Selected Players) Trace (Selected Players.Gate Item (0 ) .Name); }] & Gt; & Lt; / Fx: script & gt; & Lt; Fx: Announcements & gt; & Lt ;! - Place non-visible elements (for example, services, value objects) - & gt; & Lt; / Fx: Announcements & gt; & Lt; Fx: script & gt; & Lt ;! [CDATA [import mx.events.FlexEvent; Protected function application1_initializeHandler (Event: FlexEvent): Zero {// TODO Auto generated method stub}]] & gt; & Lt; / Fx: script & gt; & Lt; S: Button label = "trace" click = "button 2_click handler (event)" /> & Lt; / S: Applications & gt; If you need all the player names, you need a loop. In this case, I can also help you.
BR Frank
Comments
Post a Comment