Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing LoadVars variables

Status
Not open for further replies.

CGann

Programmer
Jan 23, 2004
31
US
I'm trying to access the variables outside a function but can't seem to figure out what I'm doing wrong. I've combed through google & tutorials but still can't seem to find the answer.

I've got a perl script that returns the variable "serverDate" I want to be able to manipulate this string from there (it's a lot of lenghty code that works. I'm just trying to modularize & parameterize for portability) when I access the variable inside the funtion, it works great. but outside the function it's empty, even using "return"

any thoughts?

myLoadVar = new LoadVars ();
myLoadVar.load("time.pl");
myLoadVar.onLoad = function (success) {
if (success == true) {
trace("myLoadVar success");
serverDtTm = myLoadVar.serverDate;
//trace("serverDtTm: " +serverDtTm); return serverDate;

} // if (success == true)
return serverDate;
} // END myLoadVar.onLoad = function...


trace("myLoadVar.serverDtTm : " + myLoadVar.serverDtTm );
 
Code:
var serverDtTm:String;

var myLoadVar:LoadVars = new LoadVars();
myLoadVar.load("time.pl");
myLoadVar.onLoad = function(success):Void  {
	if (success == true) {
		trace("myLoadVar success");
		serverDtTm = myLoadVar.serverDate;
		processData();
	}
};

function processData():Void {
	trace("serverDtTm : "+serverDtTm);
	trace("myLoadVar.serverDate : "+myLoadVar.serverDate);
}

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top