Log in

View Full Version : track the number of clicks/finite clicks/change event



evan
07-01-2008, 07:16 PM
I can assign an event to a button or mc, what about making the event happen a finite amount of times?

or

making a different event happen the second time an event is clicked.

I can fudge that by using the timeline to keep advancing frames -but I would like to do it programatically.
UPDATE:



//first time clicked display hello 3rd time clicked display movie clip, pretty simple
//see essential actionscript 3.0 1.7 pg 14
var blah:Number= 1;
happy_btn.addEventListener(MouseEvent.CLICK,hello);
function hello(e:MouseEvent):void{
status.text= "hello";
blah++;
if (blah == 3){ var clip:MovieClip = new Clip ();
addChild (clip);
clip.x=200;
clip.y=200;}
}

Medyman
07-02-2008, 08:25 PM
You have the right idea...

Just use a variable to calculate how many times you've clicked on a button (i.e. how many times a particular function is called). And then evaluate that variable against it's constraints in a conditional to do whatever it is that you need to happen on the 2nd click or whatever...

evan
07-03-2008, 04:08 PM
yeah me getting smart ;)