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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

making persistant variables?

Status
Not open for further replies.

CGann

Programmer
Jan 23, 2004
31
0
0
US
This is for a clock display- I've got a dropdown populated by an xml file that has a date/time offset for various locations (var = myLoc).
I also have a function that uses the myLoc value passed from the dropdown. This function cycles every 60 seconds to call another function and get some other data. I would like it to keep using the original value of myLoc until the user selects something else from the dropdown but it keeps resetting the myLoc value to null.

Any ideas?

this.onEnterFrame = function():Void {
yourDate = new Date();
yourHours = yourDate.getHours();
yourMins = Number(yourDate.getMinutes());
yourSecs = Number(yourDate.getSeconds()) ;
yourMilliSecs = Number(yourDate.getMilliseconds()) ;

if (yourMins<10){yourMins = "0" + String(yourMins);};
if (yourSecs<10){yourSecs = "0" + String(yourSecs);};
// Cycle every 60 seconds
if (yourSecs==0 && yourMilliSecs<90){
loadWCLocData(myLoc);
}
// LOCAL Time display
localTimeBox.htmltext = yourHours + ":" + yourMins + ":" + yourSecs ;
// DESTINATION Time display
destTimeBox.htmltext = dspSelLocHour+ ":" + dspSelLocMin + ":" +yourSecs ;
};
 
Perhaps the place looking for myLoc and finding 'null' when you want it to find whatever your default value is doesn't have the right scope. Try making myLoc a global variable and see if that changes anything maybe?
_global.myLoc = "default";
After that any scope should be able to read that in and it will only be overidden by (I think) a more local scope eg if you said inside a function somewhere
myLoc = "test";
trace(myLoc);
you'd get test

_________________________________
Leozack
Code:
MakeUniverse($infinity,1,42);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top