Making a flash page that can cycle through these three images on mouseclick. For some reason the local changes to count are not reflected on the global one. I tried _global but the syntax was odd and gave me errors. How should I implement this?
import flash.events.Event;
var images:Array = ["images/image.jpg", "images/image2.jpg", "images/image3.jpg"];
var count:int = 0;
forward.addEventListener(MouseEvent.CLICK, loadPhoto);
function loadPhoto(evt:Event){
if(count>2){
count = 0;
}
trace(count);
imageFrame.source = images[count];
count++;
}
A simplified version of the problem would be getting trace to output the number of times you’ve clicked.
import flash.events.Event;
var count:int = 0;
forward.addEventListener(MouseEvent.CLICK, clickHandler);
function clickHandler(evt:Event)
{
trace(count);
count++;
}
Any chance that the code is in a frame that is executing multiple times? (because you missed a stop() somewhere, for example)
If so, you might have a problem you hadn’t noticed which is causing this strange behaviour. A simple way to check if this is happening is adding a
trace("test")after declaringcount(or before, but put it in that frame script).