# Problem with return function from custom class

**URL:** <https://forum.kirupa.com/t/problem-with-return-function-from-custom-class/273301>\
**Category:** flash\
**Created:** [October 14, 2008, 5:04am UTC](https://forum.kirupa.com/t/problem-with-return-function-from-custom-class/273301 "2008-10-14T05:04:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![bbarney261](https://avatars.discourse-cdn.com/v4/letter/b/e79b87/32.png) [@bbarney261](https://forum.kirupa.com/u/bbarney261)\
**Post date:** [October 14, 2008, 5:04am UTC](https://forum.kirupa.com/t/problem-with-return-function-from-custom-class/273301/1 "2008-10-14T05:04:26Z")

</div>

Hi,

I’m new to AS3 and was wondering if someone here would be able to help me with a this problem. I created a custom class and in the class I try to set the value of an instance variable and the return that value. When I trace the return value, I get “undefined”. Here is the class code:

package {  
import flash.events._;  
import [flash.net](http://flash.net)._;

```
public class GetTypes {

	private var typeTitle:Array;
	private var typesLoader:URLLoader;
	private var typesURL:URLRequest;

	public function GetTypes(url:String):void {
		this.typeTitle = new Array();
		this.typesLoader = new URLLoader();
		this.typesURL = new URLRequest(url);
		this.typesLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
		this.typesLoader.addEventListener(Event.COMPLETE, typesComplete);
		this.typesLoader.load(typesURL);
	}
	public function returnTitles():Array {
		return this.typeTitle;
	}
	
	function typesComplete(e:Event):void {
		this.typeTitle = typesLoader.data.ttl.split(",");
		trace(this.typeTitle);// This trace returns the correct list.
	}
}

```

}

and here is the code from the actions layer in the .fla file:

var typeTitle:GetTypes = new GetTypes(baseURL + page);  
var test:Array = new Array();  
test = typeTitle.returnTitles();  
trace(test[0]); //This trace returns “undefined”

Any help would be greatly appreciated.

Thanks in advance!
