Using dynamic text to toggle a play/pause button
July 01, 2007
Flash | Free Downloads | Video and Multimedia

I've been building a simple flash video player based on the one here and had the idea to use dynamic text to easily toggle the play button between the play and pause states. The Webdings font character for the play state is "4" and for the pause state is ";"

To avoid problems with fonts not displaying on some machines, click the "Embed" button on the text properties panel when creating the dynamic text, and embed the numerals.


Ads by Google

Posted by ellen at July 01, 2007 12:20 PM


The line of script that does the toggling is:


play_btn.play_symbol_txt.text = (isPaused ? "4" : ";");

which means "if isPaused is true, set the text property of the dynamicText "play_symbol_txt" within the "play_btn" movieclip to 4 ("play"). Else, set it to ";" ("pause").


Click here to see the demo of the play/pause button

The complete function that assigns the correct action to the button is:


play_btn.onRelease = pause_btn.onRelease = function(){
ns.pause();
isPaused = !isPaused;
play_btn.play_symbol_txt.text = (isPaused ? "4" : ";");
}

Download file

The basic syntax to reach the text property of a piece of dynamic text is:
_root.myClip_mc.dynamicText_text.text


Ads by Google


Ads by Google

 RSS   |   Contact Me


Ads by Google