# Returning an array from within class

**URL:** https://forum.kirupa.com/t/returning-an-array-from-within-class/319578
**Category:** flash
**Created:** [February 24, 2011, 11:18pm UTC](https://forum.kirupa.com/t/returning-an-array-from-within-class/319578 "2011-02-24T23:18:16Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![simon\_davies](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@simon\_davies](https://forum.kirupa.com/u/simon_davies)
#### Post date: [February 24, 2011, 11:18pm UTC](https://forum.kirupa.com/t/returning-an-array-from-within-class/319578/1 "2011-02-24T23:18:16Z")

</div>

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:

```auto

... 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:

```auto

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
