Skip to main content
dstx
Inspiring
December 29, 2008
Answered

Flash movie control buttons

  • December 29, 2008
  • 24 replies
  • 3048 views
In Flash 8, I want to add a set of buttons from button library to bottom left of my movie
(begin, stop, pause, play, end) that are visible entire duration of movie.
What is best way to create such action? With event handlers?
Do I put each button on a separate layer and add frames from beginning to end of movie ?
Or can all buttons be on same layer?
And how do I find/write actionscript code that will control entire movie from any frame for each action: go to beginning or end, stop, pause, or play?
This topic has been closed for replies.
Correct answer clbeech
dstx - you're welcome :)

nice kg - that's an efficient toggle setup!

just for fun, how about :D

pauseBtn.onRelease = function() {
(toggle = (toggle) ? false : true) ? stop() : play();
}

24 replies

dstx
dstxAuthor
Inspiring
December 31, 2008
There is only 1 scene.
I had created more to try to manage layers as I have a lot of them, but then realized I should do that with folders withing the 1 scene instead because I wanted sound to play continuously through 1 scene to the next.

I followed kg's instruction and got control buttons to work perfectly,
except file kept repeat playing.

I have Sync menu set to stream as kg says, and menu next to it set to repeat (not loop), with numerical value entered as 0.

I modified button images in Photoshop, imported to library, converted to button symbol, and reaasigned code.
Now control functions won't work again.

Yes, I selected button and Control layer both when entering code, so I went back and selected each button and deleted code from association with it, so code is now only associated with Control layer where buttons are located.

Now, no errors in Output, but controls still don't work.
clbeech
Inspiring
December 31, 2008
right on kg :)

in reviewing the errors I'm wondering about a few other things as well, the line: gotoAndStop(gotoAndStop ... etc - seems to indicate that there is a code line written somewhere that is incorrect, looks like it might have been a 'paste' typo error kinda thing ... LOL ;) happens to us all at times, but you may want to look for that - AND it seems as thought this error line is has been 'attached' to an object (most likely the related button) because another error states 'must be placed within an on handler' - this indicates that the code is attached to the button - which is what ihong7 suggest was firstly, and that i had said was not a 'best' practice - so i guessing here that there is some 'residual' code left there - see if you can locate that. however that odd thing here is that the error path seems to point at the timeline... hmmm.

also i notice that you a have a 'named' scene in your file, are there additional scene as well? this may be part of the problem with the end button which should navigate to the last frame, and you say is not working. if the last frame your looking to go to is within another scene, you may also need to include the scene within the gotoAndStop call.
kglad
Community Expert
Community Expert
December 31, 2008
in the properties panel check/change your sound to streaming. retest your controls.
dstx
dstxAuthor
Inspiring
December 31, 2008
I have a main timeline animation with sound, about 25-30 layers of bitmap and png images that are also converted to symbols for fade in/fade out, overlay and animation.

I just recently attached sound to the "Controls" layer on which I placed all the buttons, in order to try to produce a control panel in the .swf export file for rewind, play, stop, pause and go_to_end of movie.
kglad
Community Expert
Community Expert
December 31, 2008
no, i'm not laughing now. you look like you're moving quickly in the correct direction.

but your basic setup is unclear. you have a main timeline with what on it? an embedded video? timeline animation? sound attached to frames? something else? some combination of the above?
dstx
dstxAuthor
Inspiring
December 31, 2008
Per your instructions, here is the code I entered in the Actions Panel for the Control layer
Each button was given corresponding instance name:

RewindButton.onPress = function() {
gotoAndStop(1);
}
StopButton.onPress = function() {
stop();
}
PlayButton.onPress = function() {
play();
}
EndButton.onPress = function() {
gotoAndStop(_totalFrames);
}
dstx
dstxAuthor
Inspiring
December 31, 2008
I put rewind, stop, play, and end buttons on "Controls" layer with frames extending full length of timeline.
With Control layer highlighted, I opened Actions window, clicked on stop button and added actionscript for "stop" per your instruction, then did same for remaining 3 buttons.

When I play movie online, rewind button works for video, but sound continues to play on continuous.
End button jumps about several hundred frames, not to end of timeline.
Neither stop nor play buttons work.

Output Window (will kg have last laugh?)

**Error** Scene=MoonOfWintertime, layer=Controls, frame=1:Line 1: Wrong number of parameters; gotoAndStop requires between 1 and 2.
gotoAndStop(gotoAndStop(gotoAndStop(gotoAndStop(gotoAndStop();

**Error** Scene=MoonOfWintertime, layer=Controls, frame=1:Line 2: ')' or ',' expected
);

**Error** Scene=MoonOfWintertime, layer=Controls, frame=1:Line 1: Statement must appear within on handler
gotoAndStop(gotoAndStop(gotoAndStop(gotoAndStop(gotoAndStop();

**Error** Scene=MoonOfWintertime, layer=Controls, frame=1:Line 4: Unexpected ')' encountered
);

Total ActionScript Errors: 4 Reported Errors: 4
clbeech
Inspiring
December 30, 2008
OMG LMAO!!!! @ kg :)

dstx - you didn't say anything about your file playing an actual 'video' file, which is what the FLV component is for, and i assumed that you were talking about playing the main timeline itself. it's my guess that the component is really just currently 'sitting' on top of the other assets in the timeline having no effect, one cannot control the timeline with the FLV component. follow the directions i have given to get you started, i didn't state them for no reason, this is how to go about it.
Inspiring
December 30, 2008
lol =D (totally becoming spam)
kglad
Community Expert
Community Expert
December 30, 2008
by "wanna bet" i was opining that cl's attempt to get you started, wouldn't.