0
votes

I am trying to create a simple gallery. I have created a gallery movieclip that contains 4 frames with pictures. The above code works fine for one trigger. The gallery mc moves to frame 2 and the second image is shown. The next trigger though (after 2 more seconds) doesn't work properly. It gets stuck (eg other buttons of the stage aren't clickable any more). If I trace the NextPhoto function, it outputs two times and nothing more. What am I missing and the second trigger is not working?

import flash.utils.Timer;
stop();
gallery1.stop();

var myTimer:Timer = new Timer(2000);
myTimer.addEventListener(TimerEvent.TIMER, NextPhoto);
myTimer.start();

function NextPhoto(TimerEvent):void
{
    if (gallery1.currentFrame < gallery1.totalFrames){
        gallery1.gotoAndStop(gallery1.currentFrame+1);
    }
    else if (gallery1.currentFrame == gallery1.totalFrames){
        gallery1.gotoAndStop(1);
    }
}
2
Does the code exist on all frames? Also, it should be function nextPhoto(e:TimerEvent):void. You added the datatype as the argument. - Josh

2 Answers

0
votes

I am not quite able to get your code as I'm a Flex kind of guy. But what I am able to guess from your code is that your Timer is not being restarted after it has executed for the first time. You should restart the timer for every frame, until the last frame to have the NextPhoto(e:TimerEvent) executed.

0
votes

Thanks for the answes guys, eventually it was simply a memory issue. When I Alt+Entered the project it didn't work. When I published at Projector, it worked. Seems CS6 lately consumes too much memory, or I should upgrade my tower...