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

flash actionscript : gotoandplay function for different layers.


RonH.
7/20/2004 8:08:17 PM
I am making a mp3 player. There also will be speakers that come out when the
mp3 player comes out. I want it to where when someone clicks "play" on the mp3
player, the speakers (which will be on a different layer than the mp3 player)
will start their animation. When someone presses stop or pause, the animation
would stop. One idea that I have is to of course have the music player on one
layer, and have the speakers on another layer. To clarify, there will be two
frames of animation for the speakers (example: animation frame1=speaker in
normal position, animation frame2=speaker moved up.). There will be 3 frames to
the speaker layer. on the first frame, there would be the speaker in its normal
postion with the script, "stop ();" inserted so that it would not go to the
next frame. Then in the second frame of the speaker layer, there would be the
speaker again in its normal position, but with no script. Then on the third
layer, there will be the speaker in a different position (like animation
mentioned before), but in the 3rd frame, there would be a script telling it to
go back to the second frame so then it would move back to the third frame
again, making a continuous loop in the speakers untill someone pressed stop or
pause (which would have the same script as the stop button). If you have any
script help for any part of this tutorial, or know where I can find a good
tutorial on how to make a mp3 player that you can modify without wondering if
something bad will happen (example: The tutorial uses a function that you dont
want, so you dont use it, but the whole time you are wondering that since you
left that one function out will it still play normally, without the function.).
I have really tryed to make this as non-confusing as possible. Please leave
something that you think will help.

-Ron

kglad
7/21/2004 1:57:47 AM
layers only exist in the authoring environment for ease of move creation. so,
you can't control layers and you shouldn't get side-tracked about anything
going on in a particular layer.

make a new movieclip containing as many frames as you wish with your spearkers
in normal position on frame 1 and with a stop() in frame 1. drag that
movieclip to the timeline where you want your speakers to appear. give this
movieclip an instance name, say speakersMC.

if this movieclip is on the _root timeline you can control it buy referencing
_root.spearkersMC from anywhere in your movie. for example, when your sound
starts you will add:

_root.speakersMC.gotoAndPlay(2);

and when your sound stops you will execute:

_root.speakersMC.gotoAndStop(1);
AddThis Social Bookmark Button