Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : movieclips and visibilty



jessicuh
5/28/2004 10:35:38 PM
Hello!

I am researching some options for a project we are working on.

What we are trying to accomplish is changing a movie clip's visibility based
on dynamically loaded variables from an ASP page, as well as some set in the
flash movie.

So far, we set the variables:
q1 = q1;
q2 = q2;
... to q32

Then we set the visibility of the movieclip on EnterFrame:
onClipEvent (enterFrame) {
_root.q1red._visible = false;
}

Then, when the user presses a button, it determines whether it's a correct or
incorrect answer, thus changing the movieclip to visible or leaving it
invisible:
if (right_answer == button_pressed) {
gotoAndPlay("Q1 right");
_root.q1red._visible = true;
q1 = true;
trace("right");
} else {
gotoAndPlay("Q1 wrong");
_root.q1red._visible = false;
q1 = false;
trace("wrong");
}

This seems to work all fine and good except that it isn't retaining the values
throughout the flash movie. What I mean by this is, at the end of the movie we
have a progress screen which is supposed to read the value of q1 - q32 and
respectively display the visibilty. This does not work. I have tried both
these codes:

The code that does not work is:
onClipEvent (enterFrame) {
if (q1 = 1) {
_root.q1red._visible = true;
} else {
_root.q1red._visible = false;
}
}

and so on through to q32. I also tried:

onClipEvent (enterFrame) {
if (q1 = 1) {
_root.q1red._visible = true;
} else if (q1=0) {
_root.q1red._visible = false;
}
}

Any suggestions?

I feel like I'm having a hard time communicating all the things going on in
this movie, so if anyone has an interest in helping me out, please post a reply
with your email and I will send you a copy of the movie to look at.

Thanks,
jessicuh

Jack.
5/28/2004 11:06:59 PM

onClipEvent (enterFrame) {
// if (q1 = 1) { you need == for comparisons
//
if(q1==1){
_root.q1red._visible = true;
} else {
_root.q1red._visible = false;
}
}

Jack.
5/28/2004 11:14:35 PM
also -
//onClipEvent (enterFrame) { // this is a continuous event
// so q1red can never be visible, perhaps you need -
onClipEvent(load){ // this is a one-off event
// so q1red is only initially set invisible
_root.q1red._visible = false;
}

hth
AddThis Social Bookmark Button