Using loops in Actionscript 3
Hey, I want to make a loop in Actionscript 3 so when I activate a boolean for example, my numberOfCookies would start to add 1 score every second.
My current script if it will help.
var numberOfCookies: Number = 1
circle.addEventListener(MouseEvent.CLICK, plus)
function plus(e: MouseEvent) {
score.text = new String(numberOfCookies)
numberOfCookies += 1
}
function init(): void {
box.addEventListener(MouseEvent.CLICK, shop)
}
function shop(event: MouseEvent): void {
if (numberOfCookies >= 6) {
numberOfCookies -= 5
}
}
init();
At the moment I have gone as far as doing the loop although it loops it instantly and I cannot make it so it loops it an infinite amount of times. This is the code:
| for(numberOfCookies; numberOfCookies<100; numberOfCookies++){ | ||||
| ||||
| } |
