-
Targeting Movie Clips?
I'm a bit new to flash and could use some help.
I'd like to use an if/else statement to target different frames in a movie clip. I created an instance of the desired movie clip in frame one on Stage1. I would think the code below would work in frame one, but it doesn't:
if (strTest=="products") {
gotoAndPlay("MovieClip1", 20);
}
else if (strTest=="design") {
gotoAndPlay("MovieClip2", 20);
} else {
gotoAndPlay(2);
stop();
}
I'd rather not create separate scenes if possible, but that's the only way I know how to do this.
Thanks for any help!
- Josh
-
World Kit Vote Holder
You certainly don't need to use separate scenes for that. But let me ask you this: did you place a separate keyframe with a "stop-sign" in the timeline? Without the stop signs your movie will be send to any frame you decide, but after that they would just slide along...
-
Abelius, thanks for your reply. Nah, it's not a frame issue per se. I guess my question is how do you target a specific frame from a movieclip? I think the line below only works for targeting a new scene.
gotoAndPlay("MovieClip1", 20);
-
"MovieClip1" and "MovieClip2" have to be the particular instance names of the clips, not just ther Library names. Then simply use dot syntax to control them:
_root.MovieClip1.gotoAndPlay(20);
-
getting closer?
Thanks for your help. I must be missing something basic here. I have one scene with two movie clips (both are instances in frame one of scene one). Is something wrong with my syntax below, because when I change the value of "x" it's not going to the correct frame in the movie clip. Thanks!
x=3
if (x=1) {
_root.clipone.gotoAndPlay(15);
} else if (x=2) {
_root.cliptwo.gotoAndPlay(5);
} else if (x=3) {
_root.cliptwo.gotoAndPlay(20);
} else {
stop();
}
-
iguanagirl32
your setting X equal to 3 but then saying if X equals 1, etc...this can never return true...that's probably why it's not working...
-
Thanks for the reply. No, I just hardcoded "3" for testing. With my code, if I put a 1, 2 or a 3 where I said "x=3", it all goes to the same place. When I change the value of x, I should be taken to a different point in my movieclip, but I'm not. It doesn't redirect, so there must be something wrong with my syntax. Help! :-)
-
Thanks for the reply. No, I just hardcoded "3" for testing. With my code, if I put a 1, 2 or a 3 where I said "x=3", it all goes to the same place. When I change the value of x, I should be taken to a different point in my movieclip, but I'm not. It doesn't redirect, so there must be something wrong with my syntax. Help! :-)
-
so what is it doing, just stopping or is it opening something completly different? also, where does this code reside, in a button, on the main timeline on a frame?
i had a problem where it was on the main timeline and it was open ing the movie, but then looping back to frame 1 so you couldn't see the mc. add acouple of frames if it is on the main timeline and see if it shows. sometimes its where you put the code!
Jeff
-
You are just using the wrong operator,
"=" assigns a value while "==" compares a values
if (x=3) is not comparing the value of x to 3 it is assigning 3 to x,
if (x == 3) compares x to 3, so if x is 3, statement is true, all the code between the brackets executes, if x is 1 (or anything else but 3) the code in the else brackets executes.
hope that helps.
---
Thinking outside of the box will get you fired if the "box" is strict budget.
-
Thanks!
4Sheezy, jeffiec and everyone else . . . Problem solved! thank you, I really appeciate the help.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|