ActionScript 3.0 :: Implementing Pause Function In Game?

Jun 8, 2011

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.

View 2 Replies


Similar Posts:


ActionScript 2.0 :: A Mouse-focus Based Pause Function For A Game?

Mar 4, 2008

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 Replies

ActionScript 2.0 :: [F8] Implementing Game Menu?

Nov 19, 2007

why I didn't put it into games category. I've got a game, it's mostly OOP. I've only one frame with "include" statement and the rest is in classes. Now I'd like to do a menu.Can I somehow separate the code of buttons inside menu? I add new frame with a menu MC inside and the "stop()" code. The "start game" button has got this code inside:

Code:
on(release)
{
_root.gotoAndPlay("2");
}

In frame 2 there's a playable part of my game. It works but... Can I move this code somewhere else so I can manage all buttons in one place? I tried:

Code:
_root.menu.start_button.on(release)

But it's not working (as if it should...).

View 7 Replies

ActionScript 3.0 :: Implementing Dynamic Starfield Into Game

Jun 1, 2011

I'm trying to implement a dynamic starfield into the game blaster mines (chapter 11) from the book "The Essential Guide To Flash Games" (from Jeff and Steve Fulton) but had no success yet. I built a separate starManager.as class and a BasicBlitArrayStar.as class for it. Also I'm using a pool for inactive and active stars (basically I think it's the same method when building the projectiles or rather particles except that the stars move only when the mouse moves (using the same direction).

If u don't know what I mean check out the parallax starfield from [URL]:
freeactionscript.com/2010/06/endless-starfield-parallax-scrolling

Currently it's not working. The inactive pool is full of stars but when I try to draw them on the background I can see absolutely no star. Even when there is an active star available it doesn't draw it on the background. The goal is a starfield that uses similar techniques from the framework like particles and projectiles do. I have some things in mind like getting the child index for creating different star layers but currently I'm not able to realize it properly.

Here are some code excerpts:
starManager.as:
package {
import flash.display.BitmapData;
import com.framework_mod.src.BlitArrayAsset;
import com.framework_mod.src.BasicBlitArrayStar;
[Code] .....

View 1 Replies

Flash :: Implementing Dynamic In-game Advertising Inside Games

Jul 17, 2010

I'm a django(python) web developer. I can also make 2D flash games. I'm planning to make :

online flash games distribute them to various websites then use dynamic in-game ads inside these games( ad changes during game play).

[Code]...

View 1 Replies

Flash :: Pause The Game ?

Aug 1, 2011

I have written the game. It starts at once, when running the program. EVERYTHING works in one Document Class. Now, I want to do some basic intro, for example, animated countdown before the game starts. How can I kinda pause the game? there is only one frame on the main timeline which contains the background.

View 2 Replies

ActionScript 3.0 :: How To Pause/resume A Game

Mar 29, 2009

I'm making a game, and I'm at the point where I want to add pause and resume functionality. The main onEnterFrame is no problem, but I have a bunch of objects that have their own onEnterFrame functions. These objects also have different functions, for example one for moving, the other for exploding. So each object is in a different state. I can't use hasEventListener, because it only checks for the type of event and not which function is part of the event. Is there a way I can check which functions the ENTER_FRAME event has? If a particular object doesn't have a particular function in its ENTER_FRAME event, I don't want to put it back when I resume the game. I suppose I could have a global variable that tells each function whether or not it's paused, but that feels messy since I would need an if in every single function I have.

View 2 Replies

Pause Flash Game Using Javascript

Feb 17, 2010

I'm working on a flash gaming site, BeardedGames.com. I just recently implemented a "Panic" button that makes the entire site display: none and display: block's a iframe with a allowed in school website of the user's choice.It works well so far, but the user's flash game still runs in the background while hidden. Is there a way to pause (not reset) the game, that will work on most, if not all, flash games? It needs to be accessible from javascript (possibly just javascript, or a flash wrapper?), and it has to work in IE 6 and greater (I know... I know. Can't help it.).Failed to make it clear that the user must be able to "un-pause" their game after the unpanic button is pressed.I haven't made these games, these are already made games like linerider.

View 3 Replies

ActionScript 2.0 :: Pause A Game When Switching Windows?

Oct 20, 2010

I've noticed since the last few version of flash player that when your main view isn't focused on the flash game, it tends to mess the game up.How do I make it so the game automatically pauses when I switch to a new window or lose focus.

View 6 Replies

ActionScript 2.0 :: Virtual Shooter - Pause The Game?

Mar 14, 2008

I am playing around with the Vertical Shooter by Ernesto Quezada aka _Bruno

link on kirupa: http:[url]....

how can I pause the game.I added a button, but I need the right coding in AS2

View 1 Replies

ActionScript 3.0 :: Pause Game Using Stage.framerate?

Dec 28, 2010

So mys question is this, I want to have a hidden button on a flash game where I press the 'P' key and it pauses and unpauses my flash game. To do this I want to use the stage.framerate command.... where I would pause the game by hitting the P key and setting the stage.frameRate = 0.01; and then unpause the game hitting the P key again and setting the stage.frameRate = 24;I used to tinker around in Flash stuff using as2 about 5 years ago and not touched flash since.

View 6 Replies

Actionscript 3 :: Pause Absolutely All Processes In Flash Game?

Aug 19, 2011

Like when pressing (not clicking!!!) the windows |X| button on the game window. Is that possible? Or will I have to write custom pause function? :S I have a very complicated program, and now I want to add PAUSE button.

View 3 Replies

ActionScript 3.0 :: Pause And Resume A Game When It Has More Than One Enterframe Event?

May 22, 2011

how can i pause and resume a game when it has more than one Enterframe Event?

View 2 Replies

ActionScript 3.0 :: Simulate A Pause Command For Multiple Parts Of A Game?

Oct 8, 2009

I need to simulate a pause command for multiple parts of a game I'm programming. How do I start the timer, then stop it after 10 seconds in as few lines of code as possible without using multiple functions?

View 3 Replies

ActionScript 2.0 :: Flash8 - Pause Game As Start Point To Terminate Code

Oct 17, 2009

I'm designing a platformer game, in which the code is all held within the character MC. I want to pause the game using something like 'delete this.onEnterFrame' as a start point to terminate code. The code layout within the character is like so:

onClipEvent (enterFrame) {
...
this.onEnterFrame = function(){ //within clip event
...
if(btnon == 1){ // when button pressed(on stage)) global value of 1 is true
delete this.onEnterFrame;
}...}}

Due to the fact its within a clip event structure, it doesn't pause it, instead it slows everything down. Would I have to construct all my code in a frame layer or can I still use an MC to terminate this?

View 2 Replies

ActionScript 2.0 :: Pause Function

Dec 5, 2009

I 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]....

View 9 Replies

ActionScript 3.0 :: Way To Pause A Function

Oct 25, 2011

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 Replies

ActionScript 2.0 :: How To PAUSE A Function

Sep 21, 2006

If 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?

View 2 Replies

Implement A "pause" Button For Music In Flash Game?

Sep 7, 2010

I'm making a flash game, and I want to make a button. When I click on it, pause the music. When I click again, resume the music.

View 1 Replies

ActionScript 2.0 :: Pause A Timer Function?

Mar 28, 2010

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 Replies

ActionScript 2.0 :: Pause And Play Function?

Oct 6, 2005

I 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 Replies

ActionScript 2.0 :: Pause Before Function Is Performed?

Sep 26, 2006

I 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]....

View 2 Replies

ActionScript 2.0 :: Timeout Function - Pause For 8 Seconds?

Mar 25, 2010

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.

View 4 Replies

ActionScript :: GetTimeout - Possible To Use Pause Function Between Lines?

Jun 10, 2009

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.

View 5 Replies

ActionScript 2.0 :: Function For Each Array Item With A Pause?

Apr 27, 2007

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]....

View 8 Replies

ActionScript 3.0 :: Flash Pause/sleep A Function?

Sep 24, 2011

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].....

View 2 Replies

ActionScript 3.0 :: Sorting Out The Play/pause Function On The Button?

Nov 9, 2011

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]...

View 7 Replies

ActionScript 3.0 :: Control External Swf File With A Pause Function?

Mar 8, 2012

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]...

View 9 Replies

ActionScript 2.0 :: How To Override Wait Function With Pause Button

Aug 24, 2004

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?

View 5 Replies

ActionScript 2.0 :: Can't Seem To Find A Pause/wait/delay Function?

Jul 6, 2005

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 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved