Bon, un peu plus complique cette fois..
En gros, je donne un fichier xml a une application, qui va recuperer tous les noms de la liste (des strings) et les afficher en tant que personne (label + radioboxes).
Je vous met le code :
sachant que mon fichier Person.mxml est :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50 <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" backgroundGradientColors="[0xFFFFFF, 0xAAAAAA]" verticalGap="50" horizontalGap="15" creationComplete="setPersonsList()" > <!--[Bindable] api.flickr.com/services/feeds/photos_public.gne --> <mx:Script> <![CDATA[ import mx.rpc.events.FaultEvent; import mx.collections.ArrayCollection; import mx.rpc.events.ResultEvent; [Bindable] private var personslist:ArrayCollection = new ArrayCollection(); private function setPersonsList():void { invited.send(); } private function personHandler(event:ResultEvent):void { personslist = event.result.personnes.name as ArrayCollection; } private function onFault(event:FaultEvent):void { trace(event); } ]]> </mx:Script> <mx:HTTPService id="invited" url="listeInvited.xml" fault="onFault(event)" result="personHandler(event)"/> <mx:List id="listInvited" alpha="0.5" verticalScrollPolicy="off" allowDragSelection="true" dataProvider="{personslist}" alternatingItemColors="[0xEEEEEE, 0xDFDFDF]" itemRenderer="Person" rowCount="{personslist.length}" > </mx:List>
Alors voila ensuite dans mon premier fichier, je veux recupere des attributs de Person (le selected des radiobox) a l'aide d'une boucle, mais je n'arrive pas a acceder aux fameuses personnes.. en effet, en utilisant par exemple "j = listInvited.dataProvider[i] as Person" ca marche pas pasque le dataprovider ne contient que les Strings initiaux, et non les radiobox..
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 <?xml version="1.0" encoding="utf-8"?> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="auto" verticalAlign="middle" creationComplete="updatePerson()" > <mx:Label id="nametext" fontWeight="bold" width="30%" text="{data}" paddingLeft="15"> </mx:Label> <mx:RadioButtonGroup id="possibilities"/> <mx:HBox horizontalGap="15" horizontalAlign="right" paddingRight="15" paddingTop="5" paddingLeft="15" paddingBottom ="5" right="0" > <mx:RadioButton groupName="possibilities" id="_default" label="No answer" selected="true" click="updatePerson()"/> <mx:RadioButton groupName="possibilities" id="yes" label="Yes" selected="false" click="updatePerson()"/> <mx:RadioButton groupName="possibilities" id="maybe" label="Maybe" selected="false" click="updatePerson()"/> <mx:RadioButton groupName="possibilities" id="no" label="No" selected="false" click="updatePerson()"/> </mx:HBox> </mx:HBox>
Est ce que qq un aurait une chtite idee ????
Merci
Partager