createjs - How to play a MovieClip x times -
the movieclip class in easeljs module has loop property can set true or false, causing movie clip play infinitely or once. http://www.createjs.com/docs/easeljs/classes/movieclip.html
i need play movie clip (banner ad) 3 times. how can done?
this init function:
<script> var canvas, stage, exportroot; function init() { // --- write js code here --- canvas = document.getelementbyid("canvas"); images = images||{}; var loader = new createjs.loadqueue(false); loader.addeventlistener("fileload", handlefileload); loader.addeventlistener("complete", handlecomplete); loader.loadmanifest(lib.properties.manifest); } function handlefileload(evt) { if (evt.item.type == "image") { images[evt.item.id] = evt.result; } } function handlecomplete(evt) { exportroot = new lib.banner_728x90(); stage = new createjs.stage(canvas); stage.addchild(exportroot); stage.update(); stage.enablemouseover(); createjs.ticker.setfps(lib.properties.fps); createjs.ticker.addeventlistener("tick", stage); } </script>
there no loop count support, nor events movieclip indicating when animation finishes. latter isn't bad idea, feel free log bug in github.
one solution use dispatch custom events timeline script in animate:
this.dispatchevent("walkend");
then can listen event, , handle yourself.
var loopcount = 0; exportroot.myclip.on("walkend", function(event) { loopcount++; if (loopcount > 2) { dosomething(); event.remove(); // no longer event. } });
hope helps.
Comments
Post a Comment