Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-23-2002, 03:28 AM   #1
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Question How to Pause / UnPause the Game???

Hi...

I made a little game and I want to put Pause/UnPause button...

I tried Jesse's code, but it didn't work well for me...

on (release) {
if (_root.pause == false) {
_root.stop()
} else {
_root.play()
}
}

When I tried the code, stop() looked like it just stopped the main timeline as it says _root.stop()... All other movieclips were still playing with that code... Does this mean that I have to go over all those little movieclips and tell them to stop??? Do I need to get the currentFrame for all those movieclips so that I can resume at that frame when the user pressed the UnPause button???
One more thing... the _root.play() somehow started my movie from the beginning... I have the main scene which is basically the introduction of the game, how to play and so on, and the second scene is the three frame long movie that does actual game play... The play() returned the timeline to the first frame of the main scene... I don't know why... Can someone help me how to put Pause/UnPause button for my game???

Thank you and have a nice weekend!!!

Jason
CyanBlue is offline   Reply With Quote
Old 02-23-2002, 03:44 AM   #2
maccer
Large Member
 
maccer's Avatar
 
Join Date: Jun 2001
Posts: 186
Send a message via AIM to maccer Send a message via Yahoo to maccer
Default

that we be one way to do it..yet if there are lots of mc's then obviously that would be madness!!

i think you would need to create a movieclip.prototype function, that would set all obects of a movie clip instance to stop!!

will get back to ya on this one later...there are some examples of this in the functions library..you might find something there...

good luck for now
maccer is offline   Reply With Quote
Old 02-23-2002, 06:43 AM   #3
maccer
Large Member
 
maccer's Avatar
 
Join Date: Jun 2001
Posts: 186
Send a message via AIM to maccer Send a message via Yahoo to maccer
Default

on you first frame of your movie create the prototype function

MovieClip.prototype.stopAll= function () { if (goPlay && (play)) {gotoAndStop (_currentframe);}};

now on all the mc's that u want to pause place this:

onClipEvent (enterFrame) {
this.stopAll();
}

now for your pause btn use:

on (release) {
mc1.goPlay = false;
mc2.goPlay = false;
mc3.goPlay = false;
}

now for your play btn use:

on (release) {
mc1.goPlay = true;
mc2.goPlay = true;
mc3.goPlay = true;
}


there could be an easier way..but thats my best effort
keep me posted!!
maccer is offline   Reply With Quote
Old 02-23-2002, 06:17 PM   #4
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Thank you, maccer...

I am fairly new to Flash, so bear with me...
I tried your suggestion with no succes due to lack of my knowledge on prototype... I am reading as much as I can right now about this prototype...

However, I have some problem understanding the use of this prototype in my program...
As for my understanding, prototype in Flash is creating a base object and the child objects of that object can inherit all the properties and functions of the parent object... Am I right??? It seems to me that this prototype is almost same as instanciating objects in Java if I may say...
The problem is that I do not have instanciated the prototype object in my movie at all, so how am I use the stolAll() function???

Basically I tried this... I changed the base name(?) of the prototype to Crane and put it to the first frame of the first scene...

Code:
Crane.prototype.stopAll= function () { 
  if (goPlay && (play)) {
    trace("currentFrame = " + _currentFrame);
    gotoAndStop (_currentframe);}};
and a couple of the moving movieclip throughtout the entire movie are Crane and Timer movieclips, in scene 2, so I've put the following on each movieclips...

Code:
onClipEvent (enterFrame) { 
  this.stopAll(); 
}
and on one of the empty movieclip that I have put all my scripts, I've put the following codes...

Code:
  ...
  ...
  else if(Key.isDown(80))
  {  // P
    trace("P has been pressed for Pause");
    _root.Paused = true;
    Crane.goPlay = false;
    _root.Crane.goPlay = false;
    Timer.goPlay = false;
    _root.Timer.goPlay = false;
  }
  else if(Key.isDown(85))
  {  // U
    if (_root.Paused)
    {
      trace("U has been pressed for UnPause");
      Crane.goPlay = true;
      _root.Crane.goPlay = true; 
      Timer.goPlay = true; 
      _root.Timer.goPlay = true; 
      _root.Paused = false;
    }
  }
On playtime...
I pressed 'P' key and 'U' key then I see following statements are working on the output window...
trace("P has been pressed for Pause");
trace("U has been pressed for UnPause");
I do not see either Crane or Timer stopping after the key press... as a matter of fact, I do not think stopAll() on each movieclips are working because my trace statement in the prototype is not showing anything at all...

I am still trying to figure it out myself...
A couple of tips from the masters would help me a lot...

Thank you and have a nice weekend...

Jason
CyanBlue is offline   Reply With Quote
Old 02-23-2002, 09:18 PM   #5
maccer
Large Member
 
maccer's Avatar
 
Join Date: Jun 2001
Posts: 186
Send a message via AIM to maccer Send a message via Yahoo to maccer
Default

Quote:
Basically I tried this... I changed the base name(?) of the prototype to Crane and put it to the first frame of the first scene...
thats the error!!

all mc's in a flash movie are infact an instance of the movieclip object...

so you would need to keep the code as

PHP Code:
MovieClip.prototype.stopAll= function () { if (goPlay && (play)) {gotoAndStop (_currentframe);}}; 
then call the function on the desired mc's in your timeline with;


this.stopAll();
}


::::::::::im still not convinced this is the best way to do what u require but this will work:::::::::::

a better appraoch would be to create sopme kind of wrapper that would effect all mc's on the root level????

i will try to work something out...
maccer is offline   Reply With Quote
Old 02-23-2002, 10:06 PM   #6
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Thank you, maccer...

Aha...
All the movieclips are the instances of the movieclip object... Gotcha!!!

Put play() at the end of your code and it is working as it is supposed to be...

Code:
MovieClip.prototype.stopAll= function () { 
  if (goPlay && (play)) {
    gotoAndStop(_currentframe);}
  else
    play();};
What is the 'play' at the if statement though??? Is that some sort of reserved word??? It has to be because I see it in blue color in Flash, so it has to be.. I don't know...

Thank you and have a nice weekend...

Jason
CyanBlue is offline   Reply With Quote
Old 01-13-2006, 11:01 AM   #7
ASMan
Registered User
 
Join Date: Jan 2006
Posts: 1
Default New movieclip redefine ...

You can redefedine existing prototipes in the master constructor. Yo don't need paste on(enterFrame) in each Movieclip of your proyect:

MovieClip.prototype.onEnterFrame = function () {
this.stopAll();
};

This work all right, so you only paste scripts at main movie (_root) first frame. 8)
ASMan is offline   Reply With Quote
Old 01-13-2006, 11:48 AM   #8
Cota
Super Moderator
 
Cota's Avatar
 
Join Date: Jul 2001
Location: NYC
Posts: 10,175
Default

ASman...you do realize this thread is from 2002 dont you?
__________________
Color Wars™ | (kul′ər wôrs) n. - Open conflict between factions. www.theColorWars.com

cota - www.chadworkman.com | http://shavedplatypus.com
occupation: designer | flash developer | server-side developer (php, asp, mssql, mysql)
Cota is offline   Reply With Quote
Old 01-14-2006, 08:00 PM   #9
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

Ah... That's one of the first posts that I have made when I got into this AS.org...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 01-14-2006, 08:03 PM   #10
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

Quote:
Originally Posted by CyanBlue
Ah... That's one of the first posts that I have made when I got into this AS.org...
In that case:

Howday and Welcome!

Kind of funny to hear CyanBlue say he is new to Flash.
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");

Last edited by Flash Gordon; 01-14-2006 at 08:24 PM.
Flash Gordon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A pause loop? Legacy ActionScript 1.0 (and below) 5 03-04-2008 03:57 AM
[AS2] Card Match Game, Colour Me In Pictures and Board Game Total Frigging Gaming and Game Development 4 02-21-2005 12:04 AM
word search game with AS2 black General Chat 5 08-12-2004 09:44 AM
[AS2] Tile game or not tile game? krolben Gaming and Game Development 4 07-28-2004 12:41 PM
Game - freelancer required fatherb Projects and Positions 6 07-18-2003 11:47 AM


All times are GMT. The time now is 04:51 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.