I have this class that basically reads a json file and then places it into an array, which I then want to pass back to the var set etc, how do i go about this:
I have the following at present:
Heres part of my list class:
... the normal import etc of stuff above then the following....
public function loadVideoList(_videoURL:String=""):void
{
try{
_request.url = _videoURL;
_loader.load(_request);
_loader.addEventListener(Event.COMPLETE, init);
} catch(err:Error){
trace("There was an error loading the list of videos: " +err);
}
}
public function init(e:Event):Array
{
var _VideoArray =new Array();
var _videoList:URLLoader = URLLoader(e.target);
var _videos:Array = JSON.decode(_videoList.data);
var _vlen:Number = _videos.length;
//-- populate the videos to an array to pass to the menu listing
for(var vl=0; vl<_vlen; vl++){
_VideoArray[vl] = {
videoURL: _videos[vl].videoURL,
videoTitle: _videos[vl].videoTitle,
videoThumb: _videos[vl].videoThumb,
videoDefault: _videos[vl].default
};
}
return _VideoArray;
}
this all works weel and my details trace all ok etc.
Heres my call code:
var _videoList:loadVideoList = new loadVideoList("json feed url");
trace(_videoList.length);
but this gives me an error on the trace, any ideas where I am going wrong or suggestions on the best way to go with this.
Thanks