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

variable question

Status
Not open for further replies.

manfishj

Programmer
May 30, 2002
44
US
Hi,

On my main timeline, I have a bunch of movie clips that are consecutive. I have a button on the main timeline that, when clicked, I want to go to "_currentframe + 20" of whichever movie clip is playing.

What I did was...in a frame action of the first clip I declared a variable -- myClip = slide1. Then, at the first frame of the second clip-- myClip = slide2, and so on.

For the script attached to the button, I put:

on (release) {
cframe = _root.myClip._currentframe + 20;
_root.myClip.gotoAndPlay(cframe);
}

It's not working though. What am I doing wrong? Basically, I want the name of the current movie clip to be put into the variable myClip, so it knows where to go when the button is pressed. Can anyone help?

Thanks in advance.

manfishj
 
What you need to do is give each clip an 'instance' name rather than name a variable in the first frame. Select the clip on the stage and fill in the instance name on the 'properties' panel (in MX).

Once your clip has an instance name you can refer to it with actionScript in the way you outlined above.
 
I did give it an instance name. The reason I tried using a variable is so that the button on the main timeline can have only one script--and it won't matter which movie clip is playing. That's the reason I used myClip. myClip should somehow get the name of each movie clip as it's playing.

Does that make sense?
 
Okay, I see what you're getting at...

How are you placing the clips on the stage?

Are they all there at the start of the movie or are you attaching them as the movie runs?
 
I've been placing the all of the movie, consecutively, each on its own layer. The button, which is a fast-forward button, I placed on the main timeline, and extended it the length of all of the movie clips.
 
Hey wait...I think I got it working. It seems to be that for slide 2, I didn't have the sound set to "stream". Thanks for the help though. I appreciate it.

manfishj
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top