Function always returns null

I’ve got an object inside an object. The child object basically loads a variable from SQL into one of it’s own public variables.

The SQL works 100%, because it traces out correctly.

Now I’ve wrote a function from the child.as


public get_var() : String
	{
		return var_yes_friggin_work;
	}

this function works if the return says

return "blahblah"

Now in the parent.as I’ve got:



//Calling from the Child.as
get_variable = new child(stage);
			
//Get the Variable
var FilePathOriginal:String = get_variable.get_var();
var FilePath:String = "../../" + FilePathOriginal;



Of course the files arn’t called Parent.as and Child.as I’ve just had to rename them because our work is monitored though checking the internet and I can’t delete this form.

The FilePathOriginal doesn’t output anything unless the string is manually set from the child, does anyone know where I’m going wrong here?

(I can’t upload all my code because of the monoriting process)
[hr][/hr]
PS I’ve made all my variables public and tried putting “this.” everywhere with no luck :-/
[hr][/hr]
Ok narrowed it down to the function not returning anything outside it:


var loader:URLLoader = new URLLoader();
			loader.dataFormat = URLLoaderDataFormat.VARIABLES;
			loader.addEventListener(Event.COMPLETE, completeHandler);
			loader.load(request);
			
			//When the loader is complete load the varibles
			function completeHandler(evt:Event)
			{
				//Putting the Array Variables from the POST data into flash variables
				var filepath = evt.target.data.filepath;
				
				var theTextField:TextField = new TextField();
				theTextField.x = 50;
				theTextField.y = 10;
				theTextField.multiline = true;
				theTextField.wordWrap = true;
				theTextField.text = filepath;
				addChild(theTextField)
				
				this.get_string = this.get_string + filepath;
			
			}

Still can’t get the string outside this function no matter what I assign too it.
[hr][/hr]
Anything I do in this function returns null? I’ve done everything :*/


function completeHandler(evt:Event)
		{
			//Putting the Array Variables from the POST data into flash variables
			filepath = evt.target.data.filepath;
		
			var theTextField:TextField = new TextField();
			theTextField.x = 50;
			theTextField.y = 10;
			theTextField.multiline = true;
			theTextField.wordWrap = true;
			theTextField.text = filepath;
			addChild(theTextField);
			
			get_string = "wtf";
		}

When I output filepath it work???
But filepath is null outside this function even what it’s public or has “this.”

Can someone please help me, I’ve stuck on this for 5 hours now and I’m about to go crazy cause I’m behind… :frowning:
[hr][/hr]
Anything that I try to output from this function is always null and I have no idea why… I’ve been looking around and trying stuff for about 5 hours now.


package script
{
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.net.*;
	import flash.text.TextField;
	import flash.display.Stage;
	import flash.sampler.StackFrame;
	
	public class sql_path extends MovieClip 
	{
		private var StageRef:Stage; //reference to the stage.
		private var path_output:String;
		private var get_string:String;
		private var filepath;
		
		public function sql_path(StageRef:Stage) 
		{
			this.StageRef = StageRef;
			
			// Prepare request from PHP file
			var request:URLRequest = new URLRequest("php/as3.php");
			request.method = URLRequestMethod.GET;

			//For loading the varibles from the file
			var loader:URLLoader = new URLLoader();
			loader.dataFormat = URLLoaderDataFormat.VARIABLES;
			loader.addEventListener(Event.COMPLETE, completeHandler);
			loader.load(request);
		}
		
		function completeHandler(evt:Event)
		{
			//Putting the Array Variables from the POST data into flash variables
			filepath = evt.target.data.filepath;
		
			var theTextField:TextField = new TextField();
			theTextField.x = 50;
			theTextField.y = 10;
			theTextField.multiline = true;
			theTextField.wordWrap = true;
			theTextField.text = filepath; //this works... but doesn't outside this function
			addChild(theTextField);
			
			get_string = "wtf";
		}
		
		public function get_filepath() : String
		{
                        //get_string always returns null
			path_output = "../../" + get_string;
			return path_output;
		}
	}
}