malkomalko (owner)

Revisions

gist: 226038 Download_button fork
public
Public Clone URL: git://gist.github.com/226038.git
Embed All Files: show embed
ActionScript #
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
[Bindable]private var arrayCollection:ArrayCollection;
 
Rx.http(function(result:XML):void {
  arrayCollection = convertXml(result);
  list.dataProvider = arrayCollection;
}).invoke("offers.fxml");
 
public static function toArray(obj:Object):Array {
  if (!obj)
    return [];
  else if (obj is Array)
    return obj as Array;
  else
    return [ obj ];
}
    
private function convertXml(file:String):ArrayCollection {
  var xml:XMLDocument = new XMLDocument(file);
 
  var decoder:SimpleXMLDecoder = new SimpleXMLDecoder();
  var data:Object = decoder.decodeXML(xml);
  var array:Array = data == null ? new Array() : toArray(data.offers.offer);
  
  return new ArrayCollection(array);
}