简体   繁体   中英

Actionscript-3 looping issue--Adobe Animate CC

My employer decided they wanted me to start doing animation with Adobe's new "Animate CC" application. My issue is that I don't know how to loop my animation outside of the Adobe Animate environment. I am new to Adobe Animate CC and ActionScript, unfortunately, so I will probably need a relatively basic answer to understand why my solution isn't working. From what I can tell, my ActionScript code is being ignored by the IDE completely.

In the IDE and in the browser test command, the animation plays beyond frame 100, to the end, and then flashes a frame of white before repeating. I need it to loop without this white frame interrupting the screen, whether that be through a loop or some other means that I'm just not aware of.

For context: my project has about 100 layers of content and I'm unfamiliar with how this program works. I've thoroughly searched the web for tutorials on how to do what I need to do, but I've come up empty handed.

I have an actions layer among my motion tweens and other layers https://gyazo.com/6e0b8502d98b6c9903bb96ac3a939bae

I've been trying to use gotoAndPlay(0) at frame 100 to start the animation over from the beginning. https://gyazo.com/704ee7158bae6dfd149b6283cfa33451

Basically, how do I use Action-Script in Adobe Animate CC in order to infinitely loop my animation until closed?

Thanks everyone.

Your flicker may be a result of having an extra blank keyframe on one of your layers.

Assuming that you don't have any additional scripts to stop your animation (eg stop()), the Timeline should loop automatically whether your animation is inside a MovieClip or on the main Timeline. You shouldn't have to put any script on your timeline or in a separate AS file to make an animation loop. I would suggest this method.

Additionally, although you have the code specifying that you want it to go the first frame, it will ignore your call because the timeline is still playing and therefore the priority. One way you can combat this is by adding a stop(); function and a delay timer that contains your gotoAndPlay(0) function. This will take focus away from playing the Timeline and will allow you to execute your script. I wouldn't suggest this method because it seems a bit redundant.

However, if you're curious one way that you could approach this is shown below, simply add this script to the frame you want the animation to restart at.

//Stop the Timeline
stop();

//Create a delay timer for 5 miliseconds that is executed once
var timer:Timer = new Timer(5,1);

//Add an event listener that calls once the timer is complete
timer.addEventListener(TimerEvent.TIMER_COMPLETE, timerHandler);

//Start the timer
timer.start();

//Timer handler that is called once the delay timer is complete 
function timerHandler(event:TimerEvent){

     //Go to and play the first frame
     gotoAndPlay(0);
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM