PDA

View Full Version : simple VAR questions for Flash5



ericinho
April 23rd, 2003, 05:24 PM
Ok, this is what I want to achieve:

on one page there are 6 invisible buttons. All have a AS like bwlow attached to them. The AS trigger one of 6 MC.
The MC itself has three states:

frame 1: invisible
frame 2: rollOver state
frame 3: selected state when onRelease (on release also a var is being set as you can see)

it works, except that when one of the 6 MC's are in Selected state, all others should remain in FRAME 1, so invisible and not clickable (in the selected mc there will be the opportunity to make the others active again and it will set the var back to empty).

I want to accomplish this by checking whenever I rollOver if the VAR is being set to one of the 6. If yes, onRollOver goes to play frame 1 of the MC - Invisible state.
If not, the MC plays frame 2 - the rollOver state.

But how do I check for all six VAR variables (so the 1,2,3,4,5,6)???

(and obviously i have to change the rollOut part as well :whistle:


on (rollOver) {

if (_root.textMC.pdvar == "1,2,3,4,5,6") {
_root.textMC.pd_p2_1.gotoAndPlay(1);
} else {
_root.textMC.pd_p2_1.gotoAndStop(2);
}
}
on (rollOut) {
if (_root.textMC.pdvar ne "1") {
_root.textMC.pd_p2_1.gotoAndStop(1);
} else {
_root.textMC.pd_p2_1.gotoAndStop(3);
}
}
on (release) {
_root.textMC.pdvar = "1";
_root.textMC.pd_p2_1.gotoAndStop(3);
}

ericinho
April 24th, 2003, 01:17 AM
hmmm, perhaps not so simple ;)

7of9
April 24th, 2003, 11:15 AM
I'm a newpie to ActionScript, but I think you can't do following:
if (_root.textMC.pdvar == "1,2,3,4,5,6") ...

What you can do is 2 things: Use a Switch statement or
do this(easier):

if (_root.textMC.pdvar >=1 || _root.textMC.pdvar <=6)...
"Assuming pdvar is a number value".

If not do this:
if (parseInt(_root.textMC.pdvar) >=1 || parseInt(_root.textMC.pdvar) <=6)...

Flashmatazz
April 24th, 2003, 05:06 PM
but don't use '||' (OR-statement) but '&&' (AND-statement)

and maybe just set the var as a number instead of a string:



_root.textMC.pdvar = 1;


so without the quotes.

7of9
April 24th, 2003, 06:30 PM
Yes use the && operand instead of the ||. Great catch....

ericinho
April 25th, 2003, 04:11 AM
thanks all :)

Flashmatazz
April 26th, 2003, 06:45 AM
No problem.