Thursday, December 24, 2009

How do you make a score counter in flash with actionscript 3?

I would like to know how to make a score counter that would display the number of time's you had clicked a button or movieclip





Thanks in advance for the answers.How do you make a score counter in flash with actionscript 3?
Add an event listener to whatever object you want to detect clicks on and have the code increment a count. Have the count render whatever score visual you want.How do you make a score counter in flash with actionscript 3?
Try this code





*******************





var num_count:Number=0;








var mc_btn: MovieClip = new MovieClip();


mc_btn. graphics. beginFill(0x00FF00,1);


mc_btn. graphics. drawRect(0,0,100,50);


mc_btn. graphics. endFill();








addChild( mc_btn);


mc_btn. buttonMode = true;


mc_btn. addEventListener (MouseEvent. CLICK, clickHandler);


mc_btn. x= 350;


mc_btn. y= 150;








var txt_score: TextField = new TextField();


addChild (txt_score);


txt_score. text = ';0';;


txt_score. height = 20;


txt_score. border = true;


txt_score. y=150;


txt_score. x=150;








function clickHandler(e: MouseEvent):void{





txt_score. text = String (++num_count);


}





*******************





Anil





anilkumarnd@gmail.com

No comments:

Post a Comment

Post a Comment