PDA

View Full Version : flag variables


bigjimmo
12-23-2002, 02:12 PM
A few people have said to me that I sould use flag variables. I have looked this term up in my Flash reference guide and it isn't mentioned. What are flag variables and are there any tutiorials on them?

Many thanks,

Jim

Mortimer Jazz
12-23-2002, 04:27 PM
It means to use a variable to track when some event has occurred, such as a user having pressed a button. Usually you'll use a boolean (true/false) but for the sake of clarity I'll use a string value:

If(buttonClicked=="yes"){
//do something
}else{
//do something else
}

...and your button would contain something like

on(release){
buttonClicked="yes";
}

So, quite simply you can tell if the button has been clicked or not by examining the current value of your flag/tracking variable.

note: You would also start your code by initialising the variable buttonClicked to equal something other than "yes" - either buttonClicked=""; or buttonClicked="no" would be the obvious choices.

Glad to see someone using the dictionary :D
Hope this makes all clear. If not post back.
Cheers,
Mort