Jump to content

  • Log In with Google      Sign In   
  • Create Account


Flash actionscript - cooldown movie clip help

  • You cannot reply to this topic
6 replies to this topic

#1 TTHCoder   Members   -  Reputation: 115

Like
0Likes
Like

Posted 30 May 2014 - 04:21 AM

Hello, I want to make a flash game and I code in another actionscript file.

I want to know how to make a "button" which has a cool down effect. 

I am using AS3.

 

The button can be also a movie clip (I will use click event).

Basically I am making this button when you click on it,a gun will appear and when you click on a tile , the gun will be placed and the "button" will be darkened and there will be the 'normal' mode moving from bottom to up. The player will need to wait for a while and cannot click on it.

 

Hope someone can help me.

Thanks in advance. 

 

Edit:I have posted how it looks like.

Attached Thumbnails

  • Example.gif

Edited by TTHCoder, 31 May 2014 - 09:27 AM.


Sponsor:

#2 bwhiting   Members   -  Reputation: 647

Like
0Likes
Like

Posted 30 May 2014 - 08:57 AM

There are a large number of ways you could go about doing this but without a little more information it is going to be difficult to offer you more detailed advice.



#3 TTHCoder   Members   -  Reputation: 115

Like
0Likes
Like

Posted 01 June 2014 - 06:49 PM

Help please.



#4 slicer4ever   Crossbones+   -  Reputation: 3192

Like
1Likes
Like

Posted 01 June 2014 - 09:23 PM

create a bool like canPlace, and set it initally to true.  if canPlace==true then you can click on the button.  once you click on the button set canPlace to false, and create a timer for however long you want, and set it so that once the timer completes, you set canPlace back to true.

 

something like this:

var CanPlace:Boolean = true;
 
Button.addEventListener(Event.CLICK, function(e:Event)){
   if(CanPlace==false) return; //can't do anything while false.
   //do your actions here.
   CanPlace = false;
   var TimerObj:Timer = new Timer(10.0, false); //set a delay of 10 seconds, and not to repeat.
   TimerObj.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:TimerEvent)){
       CanPlace=true;
   }
}

 

this code probably won't compile right away(it's been awhile since i've done flash work).  It's also not the cleanest way to do this, but the concept should work.


Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#5 TTHCoder   Members   -  Reputation: 115

Like
0Likes
Like

Posted 01 June 2014 - 11:02 PM

create a bool like canPlace, and set it initally to true.  if canPlace==true then you can click on the button.  once you click on the button set canPlace to false, and create a timer for however long you want, and set it so that once the timer completes, you set canPlace back to true.

 

something like this:

var CanPlace:Boolean = true;
 
Button.addEventListener(Event.CLICK, function(e:Event)){
   if(CanPlace==false) return; //can't do anything while false.
   //do your actions here.
   CanPlace = false;
   var TimerObj:Timer = new Timer(10.0, false); //set a delay of 10 seconds, and not to repeat.
   TimerObj.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:TimerEvent)){
       CanPlace=true;
   }
}

this code probably won't compile right away(it's been awhile since i've done flash work).  It's also not the cleanest way to do this, but the concept should work.

Thanks, now I need help.

How do I stop a frame from playing using actionscript and play it and also test if the frame of the movie clip is == 1?

(e.g. 

OnClick (gun1btn){

If (canPlace == true){

gun1.x = mousex;

gun1.y = mousey;

addChild (gun1);

gun1btn.play;

}

for (gun1.currentFrame == 1){

canPlace = true;

gun1btn.gotoAndStop (1)

}

}

Sorry for no fomat



#6 slicer4ever   Crossbones+   -  Reputation: 3192

Like
1Likes
Like

Posted 02 June 2014 - 11:03 AM

create a bool like canPlace, and set it initally to true.  if canPlace==true then you can click on the button.  once you click on the button set canPlace to false, and create a timer for however long you want, and set it so that once the timer completes, you set canPlace back to true.
 
something like this:

var CanPlace:Boolean = true;
 
Button.addEventListener(Event.CLICK, function(e:Event)){
   if(CanPlace==false) return; //can't do anything while false.
   //do your actions here.
   CanPlace = false;
   var TimerObj:Timer = new Timer(10.0, false); //set a delay of 10 seconds, and not to repeat.
   TimerObj.addEventListener(TimerEvent.TIMER_COMPLETE, function(e:TimerEvent)){
       CanPlace=true;
   }
}
this code probably won't compile right away(it's been awhile since i've done flash work).  It's also not the cleanest way to do this, but the concept should work.
Thanks, now I need help.
How do I stop a frame from playing using actionscript and play it and also test if the frame of the movie clip is == 1?
(e.g. 
OnClick (gun1btn){
If (canPlace == true){
gun1.x = mousex;
gun1.y = mousey;
addChild (gun1);
gun1btn.play;
}
for (gun1.currentFrame == 1){
canPlace = true;
gun1btn.gotoAndStop (1)
}
}
Sorry for no fomat

You can surround code with [cod*e][/cod*e](remove the stars when you use it.)

As for your quuestion, if i understand what you want to do. You need to place a stop() inside the gun movieclips first frame.

Then the click code would look something like this:

OnClick(gun1btn){
  If(canPlace==true){
    gun1.x = mousex;
    gun1.y = mousey;
    addChild(gun1);
    gun1.gotoAndPlay(2);
    canPlace=false;
  }
  If(gun1.currentFrame!=1) return;
  gun1btn.gotoAndStop(1);
  canPlace=true;
}
Sorry about any mistakes, posting from mobile, I'll clean it up when i get home.
Check out https://www.facebook.com/LiquidGames for some great games made by me on the Playstation Mobile market.

#7 TTHCoder   Members   -  Reputation: 115

Like
0Likes
Like

Posted 03 June 2014 - 01:09 AM

Thanks! You are very helpful.I will try to do it as soon as I can.







PARTNERS