| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
|
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 |
|
|
|
|
|
#2 |
|
Large Member
|
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 |
|
|
|
|
|
|
|
|
#3 |
|
Large Member
|
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!! |
|
|
|
|
|
#4 |
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
|
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);}};
Code:
onClipEvent (enterFrame) {
this.stopAll();
}
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;
}
}
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 |
|
|
|
|
|
#5 | |
|
Large Member
|
Quote:
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:
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... |
|
|
|
|
|
|
#6 |
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
|
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();};
Thank you and have a nice weekend... Jason |
|
|
|
|
|
#7 |
|
Registered User
Join Date: Jan 2006
Posts: 1
|
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) |
|
|
|
|
|
#8 |
|
Super Moderator
Join Date: Jul 2001
Location: NYC
Posts: 10,026
|
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) |
|
|
|
|
|
#9 |
|
Super Moderator
Join Date: Jan 2002
Location: Centreville, VA
Posts: 24,878
|
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...
|
|
|
|
|
|
#10 | |
|
rather be programming
Join Date: Feb 2005
Location: City of Angels
Posts: 10,000
|
Quote:
Howday and Welcome! ![]() Kind of funny to hear CyanBlue say he is new to Flash.
__________________
I'm old enough to know better and young enough to do it anyway. -- maskedman Last edited by Flash Gordon; 01-14-2006 at 09:24 PM.. |
|
|
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| A pause loop? | Legacy | ActionScript 1.0 (and below) | 5 | 03-04-2008 04:57 AM |
| Card Match Game, Colour Me In Pictures and Board Game | Total Frigging | ActionScript 2.0 | 4 | 02-21-2005 01:04 AM |
| word search game with AS2 | black | General Chat | 5 | 08-12-2004 10:44 AM |
| [AS2] Tile game or not tile game? | krolben | Gaming and Game Development | 4 | 07-28-2004 01:41 PM |
| Game - freelancer required | fatherb | Projects and Positions | 6 | 07-18-2003 12:47 PM |