I need a help. I've created a 5 min flash movie and need to add a pause, play, rewind buttons for the viewer's control. I read many posts here and the Flash help, but they all talk about embeded video clips like mov or alike. I tried to save my flash video as swf and then import it to library, but I get a mess with over 100 pieces. I must be missing something basic, please help. Any thought, suggestion or an example will be greatly appreciated. Jeff
I will not be loading this movie into any other movie. So I would need to add these buttons to my flash movie - or maybe there is other way of doing it that I'm not aware of. In any case......I appreciate your assistance.
attach the code below the dotted line to frame 1 of you main timeline. this will add a new method to movieclips that lets you control their timelines with much more flexibility than the play() and stop() methods. you'll need to decide how fast you want your movie to play when you click fast forward (if you decide to have a ff button) and rewind. otherwise, you don't need to do anything else with the script below: pauseBtn.onPress=function(){ _root.stop(); } playBtn.onPress=function(){ _root.play(); } rewindBtn.onPress=function(){ _root.playF(_root._currentframe,1,fpsRewind); // define fpsRewind } fastforwardBtn.onPress=function(){ _root.playF(_root._currentframe,_root._totalframes,fpsFF); // define fpsFF } ---------------------------------------------------------------------------- MovieClip.prototype.playF = function(m, n, fps) { function playF2(mc) { if (mc.m<mc.n) { mc.nextFrame(); } else { mc.prevFrame(); } if (mc._currentframe == mc.n) { clearInterval(mc.int); } updateAfterEvent(); } this.m = m; this.n = n; this.fps = fps; this.gotoAndStop(this.m); clearInterval(this.int); this.int = setInterval(playF2, 1000/this.fps, this); };
Thanks for your quick response. I'm very new to ActionScript so please don't mind the extra questions. I have open my movie (.fla) and added the new layer to be a main time line, and placed in the first frame (key frame) your script below the dotted line. I did that by pasting it to the "Actions - Frame" control panel, after clicking on the first frame in main time line. To test it, I created in the library a pause button and placed it in the 1 frame of a new layer that I just added for this button. Gave a name to the instance, and pasted your pause button code (above dotted line) into the "Actions - Frame" panel. When I play the movie the button is there, it reacts to my mouse pointer (a hand shows up) but the movie doesn't stop. I think I'm missing a behavior for my button or something. Could you tell me what my problem might be?
did you name your pause button: pauseBtn? if not, did you change the code to match your name: yourPauseBtnName.onPress=function(){ _root.stop();
Thanks for pointing this, I had a wrong name. Now I have corrected it, but am getting the following error: -------------------------- **Error** Scene=Scene 1, layer=Layer 336, frame=1:Line 1: Statement must appear within on handler pauseBtn.onPress=function(){ -------------------------- My action script for the button is: pauseBtn.onPress=function(){ _root.stop(); }
Don't see what you're looking for? Try a search.
|