Friday, January 8, 2010

How to make a function in actionscript to add a number 1 to a value each time a button is pressed?

How do I make a function in actionscript 2 that would add/subtract the value 1 to/from a value each time a button is pressed?


E.g. 1+1=2; 2+1=3; 3+1 =4 ect...


Thank you!!!How to make a function in actionscript to add a number 1 to a value each time a button is pressed?
Say your variable need to be changed based on button click is x


onClipEvent(load){x=0;} //initialize variable x





Actionscript to put on button 1


onClipEvent(mouseUp){add1();}





Actionscript to put on button 2


onClipEvent(mouseUp){sub1();}


function add1(){_root.x++;}


function sub1(){_root.x--;}

No comments:

Post a Comment