ActionScript 3.0 :: Way To "pause" A Function
Jan 3, 2010What I want is to pause a function for a few seconds so that a tween can finish... but I don't want to do this with a Timer, I want to do this in the same function.[code]...
View 5 RepliesWhat I want is to pause a function for a few seconds so that a tween can finish... but I don't want to do this with a Timer, I want to do this in the same function.[code]...
View 5 RepliesI am working on making a flash game and I have a pause function in it that doesn't work every time.
_root.PAUSE = false
if (Key.isDown(80)) {
if (_root.PAUSE == false) {// The LETTER "p"[code]....
I'd like to have a filter applied to one movie clip and then after an eight second delay, I'd like to have a filter applied to another movie clip, and then after a 5-second delay, I'd like to have a filter applied to a third movie clip.[code]...
View 9 RepliesIf you have a function that works like this:
mcNew.onEnterFrame = function ()
{ does something or other here, and blank here, and blank there
};
Is there a way to temporarily freeze its operation in its tracks? Like a pause button? And then unpause, so it works again?
I have written a timer code but now i want to be able to pause the timer on the click of a button...i have searched all over but cannot find what i am looking for.
View 8 RepliesI am using a stop(); gotoAndPlay with setInterval on a series of swf files that are loaded into a container movie. There is a bug in doing this, in which when one of the swfs is loaded into the container and you click on a link to load a different swf before the current swf has gotten to the frame in which you reach this function, its stops the function and nothing pauses/plays anymore. [code]...
View 3 RepliesI have a movieclip that when pressed does stuff. I want the mc to finish playing before the function is executed. Below is the code that I've worked with do far.
var spinningLogo:Button;
var aboutUs_mc:MovieClip;
var capabilites_mc:MovieClip;
[code]....
I have a movieClip that is basically a slide show.It is controlled by AS that is on its own timeline. It moves forward on its timeline, then a few frames later, I have it pause for 8 seconds with:
Actionscript Code:
stop();setTimeout (function() {play();}, 8000);
It then resumes playing and,a few more frames later,I have it jump to a different random slide. This all works fine. There are other frames on the MAIN timeline that do not contain this moveiClip. The problem is, if I go to one of those other frames in the main timeline, the above movieClip function is somehow still active, and after the 8 seconds it sends the play command. In this case, it causes the MAIN timeline to start playing.
Here's what I want to do in code.
Animate an MC of a car for a duration of x seconds.
After the car is done, move an MC of a dog for y seconds.
And so on...
With this code, all animations execute simultaneously.
car.slideTo(200,100,1);
dog.slideTo(200,100,5);
blimp.slideTo(200,100,2);
...
Is it possible to write a pause function to put in between those lines? I've tried using getTimeout, but I want to avoid having to define each animation as a separate function.
I'm implementing a pause function in a game, it stops the main game timer and then dispatches an event ("Game_Paused") to stop a second timer. Both timers stop (and start) correctly but the second one throws a null object reference error.
Here's the ActionScript Code:
private function onAddedToStage(e:Event):void{
_timerD = new Timer(100);
_timerD.start();
_timerD.addEventListener(TimerEvent.TIMER, onUpdateTime);
stage.addEventListener("Game_Paused", onPauseGame);
[Code] .....
And this is the output:
Code:
Paused Timer=null
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.rtr.game.UI::timer_display/onPauseGame()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.display::Stage/dispatchEvent()
at com.rtr.game::Game_Timer/onKeyDown()
Paused Timer=[object Timer]
What's really confusing me is that the timer is still getting paused correctly, and the trace is showing up in the output before and after the error with two different objects.
I'm trying to run a function for each item in an array but I don't want it to happen all at once. The end result is to fadein an item in an array then fade it out, then move on to the next item in the array and do the same thing.
i guess in simple form I could demonstrate this with just using text:
Code:
myFunc = function(theGreet){
trace(theGreet);
}
[Code]....
I am just learing ActionScript. I have following code. when I click play button, I want to completeHandler function to wait 5 seconds before executing. Another word, I want movie clip (playstop_mc) to play first. Once it is done playing the movie then I want completeHandler function to run once. How do I do this? or point me to the right direction
playstop_mc.stop();
// Register the function as a listener with the button.
play_button.addEventListener(MouseEvent.CLICK, playAnimation);
[code].....
I have this fla file... 40 frames to be exact, each frame is a movie clip with AS3 code for a fade transition. I implemented to auto play with delay of 10 seconds on each frame, then next frame and so on. I also have implemented the next and prev button (next frame, prev Frame) and the arrow keys on keyboard function.
Now I need help on sorting out the play/pause function on the button (play>pause button) I did a code, it pause on the the frame when i click pause, but the as code on the mc clip on the frame proceeds and when i press the play button, it plays at current frame, but plays fast straight to the last frame.
[Code]...
I am trying to control a external swf file with a pause function. The main idea is loading an external file and when I want, pause it and its childs. The loader object is "introStage"
[Code]...
I'm using this function
function wait(mc, n) {
mc.stop();
var myInterval = setInterval(function () {
mc.play();
clearInterval(myInterval);
}, 3 * 1000);
} _root.wait(this, n)
To delay events along my timeline. That code works fine. My problem is that is that I also want the user to be able to pause the movie at any time. However, if the pause button I'm using is pressed by the user while the timeline is delayed using this function it starts playing again after the interval even if the pause button is still pressed. How can I override this wait function with a pause button?
I just want to have my code wait a couple seconds to let some scripted animation finish then load a movie into a holder but I can't seem to find a pause/wait/delay function is there one and how would I use it or can someone tell me how to do it somehow thats not too processor intense if at all possible.
View 6 RepliesI have a pause function that fires when the first frame of my swf loads.[code]However, if the user navigates away from this "Welcome" section, the actions following the "pause" still fire. I need to find a way to stop the pause function prior to the actions executing. Below is the function used to trigger the navigation events and where I should be executing the action to stop by pauseMC.[code]Just one additional note, all my functions live on frame one of my main timeline.
View 4 RepliesI have been having trouble with the timer, knowing how to plug into the scripts/Functions the correct way. Below is the script (probably not written as efficently as it could be, but I'm trying) Anyway, the script is uses simple tweens for a movieclip. I would like to use the timer/setinterval function to pause the animation between tweens (Using the event listener after the tween stops to start the interval/pause) Is this the right concept or am I barking up the wrong tree.
[Code]...
I have a pause function that fires when the first frame of my swf loads.
PHP Code:
Welcome transition
function pauseMC(sec) {
var i = sec - 1;
var MyPause = setInterval(function () {
if (i == 0) {
clearInterval(MyPause);
[Code] .....
However, if the user navigates away from this "Welcome" section, the actions following the "pause" still fire. I need to find a way to stop the pause function prior to the actions executing. Below is the function used to trigger the navigation events and where I should be executing the action to stop by pauseMC.
PHP Code:
function moveLeft () {
var t = this;
this.opened = true;
//this._x = _root.navWidth * this.index;
[Code] .....
How I can extend this function to fade a sequence of mCs passing a pause sec. value too?
Ex:
function fadeTo (mc, value, speed, pause)
steps:
fade mc1
when fade ends wait pause continue to next mc if exist
MY ACTUAL FUNCTION:
MovieClip.prototype.fadeTo = function(value, speed) {
this.onEnterFrame = function() {
this.aV = Math.floor(value-this._alpha);
[code]....
So your playing a flash game that's fast paced and mouse-based (hey that rhymes somewhat)... And then you accidentally move your mouse outside of the area of the swf... And then it pauses automatically with a "Continue" button, instead of you just dying or whatever. I've thought you could have a huge button the size of the stage and make it do something when the frame isn't 'mouseover' or whatever, but there's gotta be a better way. Also setting limits on the _xmouse and _ymouse wouldn't work cos sometimes the mouse moves too fast for them to accurately get the last mouseposition...
View 8 RepliesI use NetStream to play media file. It includes pause, resume functions. When running in the flash player, there isn't any problem. However, when embedding this swf file in web page, there is following problem. - If clicking [pause] button and then (in short period) clicking [resume] button to continue playing, no problem. But, if clicking [resume] button after longer period (bigger than playing file's time), the swf file will start playing at the next media file in the list, NOT at the time that was paused.
I would like to send the source code link: [URL]
i can't test this article [URL] when I pause netstream. it clear buffer. when I resume it rebuffer
I have a Flash file that has two music tracks. The player I built works well so far except for this, I am trying to make a Pause/Play button the works on either track. Right now it only works on one. With my limited knowledge of AS3 I tried different solutions but none worked.
Here is the SWF file; [URL]
You will see that the Pause/Play button only works on �Kiss My Dogg� which is track 1.
Here is the FLA file; [URL]
Below is some of the Script I wrote. The pause/play is the part I can�t figure out.
//function to load different tracks
function loadMusic(evt:MouseEvent):void{
//stop whatever is playing
SoundMixer.stopAll();
[Code].....
I am trying to create a pause button that will pause everything on the screen including movieclips/audio. Right now I can't figure out how to pause the movieclips.
View 2 RepliesI have some banners I am doing right now and have a pause timer question. I am fairly green at coding. In my first frame I have this:
[Code]...
I want it to pause each time in the last frame for 8 seconds and loop only 3x. Is there a better way to write this? I know all my code should be in the first frame but I still suck.
I am using Macromedia Flash Pro 8. I have a flash intro that has words (phrases) which slide in. I would like to add a 7 second pause between each phrase to give people time to read them (no buttons). Could someone tell me the script(s) to use with all functions, etc. included - as I am so new to all this. I have been looking for weeks & tried many codes but none seem to work - or I don't know exactly where to place them - or both
View 3 RepliesI have a timeline of 30 frames, each it's own mc (page01_mc, etc.). In each mc I show a picture or two and hear narration.I have a first, prev and next nav on the main timeline. I need to add a play/pause btn that will pause both pictures and sound. I assume I do that in each mc, but do not know where to find the code.Here is what is in each mc now:
var mySound:Sound = new Sound();
mySound.load(new URLRequest("english/Intro01.mp3"));
mySound.play()
I'm beginner in Flex 4. I'm trying to pop up a Flex WindowTitle custom component, and after the user choose some values, the parent window must be refreshed.I'm showing the modal window, the user can't interact with other components, but the problem I detect is the execution of the program flows, even I choosing to show the Input window as modal, the next methods to refresh the page is called before the user close the modal page. I don't know if flex or ActionScript works different from Java, where I used to code. see the comments on the code example:
<fx:Script>
<![CDATA[
import mx.controls.Alert;
[code].....
I am using setTimeout() to call a function called "finished" after a 1000ms pause, which works absolutely fine until I try to pass a variable with it.
[Code]....
I've got a Vector of ViewToActionMap objects, which have following constructor:
public function ViewToActionMap(_forModule:eModule,
_forAction:eViewAction,
_toFunction:Function,
[code].....