I have a pure as3 animation which doesn't utilize the stage or the timeline. What is the best way to loop the animation with as3? To my surprise I removed the "stop();" at the end of the animation and it does not loop. I also have the HTML开发者_Python百科 properties set to Loop;
If it doesn't use the stage or the timeline, how does it start? And how do you know when it's done? If it's started by calling a function, you could just restart it by calling that function again. But it really depends on how the animation is coded...
Hmm.. 1) need to adhere to AS3 rules. 2) need to initiate the first part of the code again (this assumes that once you initiate the first part of the code - the rest automatically "plays" through. Meaning, you need a function at the end that refers back to the beginning of the code.
At the end.
stop();
function myLoopFunction(event:Event) { //whatever initiates the code again }
addEventListener(Event.ENTER_FRAME,myLoopFunction);
I would suggest that, if you are using a pure as3 animation, that you look into the usage of TweenLite, which is a great library for animation. you can download the library at this link: http://www.greensock.com/tweenlite/
if you want to animate, you can simple use
TweenLite.to(yourObject, timeItShouldTake, {parameters, e.g.: x: yourXToPosition, y: yourYToPosition, onComplete: yourFunction});
in your case, you would have to fill in the function you are calling this code from with the onComplete. You can find more examples at the site of greensock itself. Hope this helps :)
精彩评论