PDA

View Full Version : Global Variables


wattie187
02-15-2006, 08:58 AM
I haved created an Action layer to hold all my main action script code, on this page I have declared a variable

_global.correct = false;

a boolean that is set to false.
I have also created a global function that checks the status of this variable.

_global.checkCorrect=function():Void{
if (_global.correct == false){
//Load congrats movie
this.createEmptyMovieClip("con",_root.getNextHighestDepth())
this.con.attachMovie("congrats","newMc",1,{_x:370,_y:-185});
_root.newMC.congrats;
}
}

Everything grand so far lol.

Now on one of my other layers I have an on (release) event handler, within this I have set this variable to true.

if(_global.totalPoint == 6) {

_global.correct=True
trace(_global.correct)
_global.checkCorrect()
//this.createEmptyMovieClip("con",_root.getNextHighestDepth());
//this.con.attachMovie("congrats.swf");
//this.stop
}

Two questions I have,
1/The trace statement returns Undefined, why?
2/How do I call the function that checks the variables True or False status?

Any help welcomed.

Tink
02-15-2006, 11:29 AM
_global.correct=True should be _global.correct=true

and change your method to_global.checkCorrect=function():Boolean
{
if (_global.correct == false)
{
//Load congrats movie
this.createEmptyMovieClip("con",_root.getNextHighe stDepth())
this.con.attachMovie("congrats","newMc",1,{_x:370, _y:-185});
_root.newMC.congrats;
}
return _global.correct;
}

wattie187
02-15-2006, 12:28 PM
Thanks very much thats great \m/