FORUMS: list search recent posts

Play/Pause button toggle

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
mark2741
Play/Pause button toggle
on Jan 16, 2006 at 3:19:27 pm

I have a main movie that loads in child movies. I have a navigation bar in my main movie that contains a play/pause toggle button (not a component). Currently, the button is the pause symbol (webdings font(;)).

When the user clicks on it, the child movie pauses. When they click it again, the child movie resumes. So that works (not an easy feat considering the child Movies are Captivate swf's, which are not controllable using standard actionscript methods). What I want to do now is this:

when the user clicks on the pause button, I'd like the pause button image to change to a play button. Right now it stays as a pause button in appearance.

Background:

I'm creating a flash app that loads in and plays Captivate-generated swf's. I know that the CaptivatePlayer already exists, but it does not meet my needs due to it's inability to control the individual movies (it requires the navigation bar in Captivate) and the Captivate navigation bars, besides visually unappealling, do not allow one to fast-forward or rewing to specific points set by me in the movie, only to specific slides/durations (ie, not frames). It's almost done, and I'm putting the finishing touches on it (if anyone wants it, feel free to email me for the source).



Return to posts index

lajoiet
Re: Play/Pause button toggle
on Jan 16, 2006 at 10:18:12 pm

There are several ways of doing this. The way I like to do it is rather simple in that I make 2 buttons, one with a Play symbol and one with a Pause symbol, and put them one on top of the other on the timeline. The Actionscript code has onRelease code for both buttons, but when I start up I put the code "playBtn._visible = false" which hides and disables the Play button. Then you just need to change the _visible property in each buttons onRelease code:

playBtn.onRelease = function() {
ns.pause(false);
playBtn._visible = false;
pauseBtn._visible = true;
};

pauseBtn.onRelease = function() {
ns.pause(true);
playBtn._visible = true;
pauseBtn._visible = false;
};

(I like this because I can use things other than text symbols for the buttons since each is created separately...)

and that way it appears that your button's text is toggling.

The other way is to make the symbol on a single play/pause button as dynamic text and initially set it to the pause symbol, then each time it's clicked change the value of the text field to the code for the correct symbol based on testing what's happening:

playBtn.onRelease = function() {
ns.pause();
if (playBtn.symbol.text == "4") { // Play Symbol
playBtn.symbol.text = ";"; // Pause Symbol
}
if (playBtn.symbol.text == ";") { // Pause Symbol
playBtn.symbol.text = "4"; // Play Symbol
}
}

I haven't tested the code, so forgive me on any blunders, but that's the basic principle behind the way I've done it.


Return to posts index

doogal
Re: Play/Pause button toggle
on Oct 6, 2007 at 3:02:05 pm

Hi,

I've attempted to follow this approach (having also given up on the movie clip approach), but can get no functionality of any kind whatsoever beyond the button graphic rollovers.

Can you give me some really low level pointers please:

1. where does the initial action script making the play button invisible go? I've tried every where, but the process of elimination has not worked ( I have an action script layer in the timeline, which is where I would assume it goes)

2. are the two button graphics on different layers, or are thay one above the other on the same layer?

3. Where does the main code go for the buttons? In the action script layer? or is each piece of code in the action script for each instance?

-- I've duplicated the naming conventions "playBtn" etc, but can get nothing to work.

I'd originally started with a movie clip button, but this seems a much more straightforward approach. If only I could get it to work...

I'd really appreciate your help, as I'm getting very frustrated with Flash at the moment, even though i can see it is a good package in the long run.

doogal


Return to posts index


doogal
Re: Play/Pause button toggle
on Oct 6, 2007 at 4:02:08 pm

Hi

I've been through the code and worked through it, and whilst mine is most likely not good/elegant coding, it appears to toggle OK.

However, I can't get the play button to be invisible at the first instance - once the "on release" code has been activated, it does as it should, but it always appears as visible when when the playhead gets to it in the timeline, so point one of my post still remains as a question.

doogal


Return to posts index

doogal
Re: Play/Pause button toggle
on Oct 7, 2007 at 10:17:07 am

well, i got there in the end:

visibility script goes in the action script layer.
each button symbol on two separate layers
the code for each button goes in the stage instance of each button.

I'd like to say thanks for the above hints however, as this is for me the most suitable solution

regards

doogal


Return to posts index

lajoiet
Re: Play/Pause button toggle
on Jan 16, 2006 at 11:02:39 pm

DOH!!!

I forgot to mention the fact that you can also use the second method and a holder movie clip and load in a PNG to the holder based on which symbol you want to have on the button rather than the dynamic text block.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]