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

I'm not getting my global variables to work properly...

Status
Not open for further replies.

shwa

Programmer
Mar 12, 2002
1
US
Thanks in advance for any assistance...
I'm making a simple file with 5 check boxes. At the beginning of my movie, I declare 5 global variables like so:

set (houseclip , 1);
set (vacationclip, 1);
set (charityclip, 1);
set (carclip, 1);
set (quitclip, 1);

I'm testing with "quitclip". In my third scene, I have a twice nested movie clip with a button that holds this script.

on (press) {
set (_root.quitclip, 0);
}

Finally, I have a "go" button that holds this script.

on (release) {
if (_root.quitclip = 0) {
tellTarget ("_root") {
gotoAndPlay ("Scene 3", "start3");
}
}
if (_root.quitclip = 1) {
tellTarget ("_root") {
gotoAndPlay ("Scene 4", "start4");
}
}
}

This set of scripts always ends up sending me to scene 4, even after i've pressed the button which should send the user to scene 3. Anybody know why???
 
Shwa...
A lot of Flash 4 syntax in your scripts! Are you using Flash 4?
If not, what's this set (quitclip, 1)?

To set global variables in Flash 5, no need to use "set", just use:

_root.houseclip = 1;
_root.vacationclip = 1;
_root.charityclip = 1;
_root.carclip = 1;
_root.quitclip = 1;

Or...

_root.houseclip = true;
_root.vacationclip = true;
_root.charityclip = true;
_root.carclip = true;
_root.quitclip = true;

(true being equal to 1, and false equal to 0)

Your button's script would then be:

on (press) {
_root.quitclip = 0;
// Or...
_root.quitclip = false;
}

The tellTarget action is also deprecated in Flash 5, you can simply use the dot syntax in the following manner:

on (release) {
if (_root.quitclip == 0) {
_root.gotoAndPlay("start3");
}
if (_root.quitclip == 1) {
_root.gotoAndPlay("start4");
}
}

Note you could further simplify the above with an else statement:

on (release) {
if (_root.quitclip == 0) {
_root.gotoAndPlay("start3");
}
else {
_root.gotoAndPlay("start4");
}
}

Please also note that, in an if statement, you must use double equal signs as ==. Also note that from within a movie clip or a loaded movie on another level, the main timeline is seen as one big scene even if it holds several. It is thus useless to target a scene name, and you should only target a labeled frame. If the first frame of your Scene 3 is labeled start3, then using _root.gotoAndPlay("start3"); will work just fine.

Regards,
And might I be blessed with your vote!
new.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top