html5 - Waiting for the end of an animation in Haxe/OpenFL -




i'm making turn-based game using haxe + openfl + swf + actuate (i'm targeting js). 1 of important gameplay aspects using abilities. each ability has animation and, of course, takes time animation play.

i want know how can handle end of swf animation? in advance

there various ways. if have movie called 'myswf' movieclip setup on main timeline linkage 'holder' can attach , control enterframe loop per haxe nme example ( openfl pretty similar ). not tried html5 code nme prefer on openfl, unfortunately nme not support html. can find alternate approach in nyancat sample in nme haxelib, there similar 1 using 'swf' library in openfl sample folder, matter or switching imports over.

package; import nme.display.sprite; import nme.display.stagealign; import nme.display.stagescalemode; import nme.assets; import format.swf; import format.swf.instance.movieclip; import flash.events.event; class main extends sprite{   public function new(){      super ();      loadmovie( 'myswf');   }   var mc: format.swf.instance.movieclip;   public function loadmovie( movie: string ){      var swf = new swf ( assets.getbytes ("assets/"+movie + ".swf") );      mc  = swf.createmovieclip("holder");      mc.gotoandstop(0);      mc.play();      mc.addeventlistener( event.enter_frame, loop ,false,0,true );      addchild( mc );   }   function loop( e ){      if( mc.totalframes == mc.currentframe ){         mc.stop();         mc.removeeventlistener( event.enter_frame, loop );      }   }  } 

make sure name movieclip want attach different name linkage identifier example code needs 'holder', setup linkage 'export actionscript' , 'export in first frame' , place on first frame of timeline. example above work fine cs3 flash swf ( as3 ) or newer, think nyancat example needs newer flash version such animate.

if want @ simpler more efficient approaches webgl , canvas fallback need export timeline set of png's flash, , can load images application , show different 1 each frame. instance if used kha instead of openfl in render loop like...

function render2d( g2: kha.graphics2.graphics ){         g2.begin(false);         g2.transformation = fastmatrix3.translation( dx, dy ); // or rotation etc..         if( count < images.length ){             g2.drawimage( images[count++], posx, posy );         }         g2.transformation = fastmatrix3.identity();         g2.end();     } 

obviously can explore flump supported in kha, luxe, openfl, nme, flambe ( exports nested structures fla's png , json/xml ). or can @ spritesheet/tilesheet solutions. swf nice , supported not used much, , might optimal file size imagine html it's quite overhead , may not supported on openfl javascript target @ least not support on c++. swf support nme/openfl not perfect gradients, , actions not supported. sprite sheet png work. other alternatives might try export frames svg.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -