2. Images and animations - Osilos/openfl-game-template GitHub Wiki

To create new image or animation, we use SWF library, first add your generated SWF in project.xml file :

<library path="assets/swf/your-swf.swf" type="swflite" if="html5" preload="true"/>

<library path="assets/swf/your-swf.swf" type="swf" unless="html5" preload="true"/>

Then, you just have to create new GameObject with library name and Movieclip name :

var player:GameObject = new GameObject('your-swf-name', 'your movieclip name');
player.getAnim() // Use getAnim() to get the movieclip and access method like anim.gotoAndPlay();

Your movieclip must always be converted to flipbook inside flash before using it, if you use interpolation or other things like this, it will not works as intended on some platforms.

If you have movieclips with different state, (like player_fall, player_fire, player_move…) use StateObject instead GameObject :

var player:StateObject = new StateObject(‘your-swf-name', 'your movieclip name');
player.setState(‘move’); // change movieclip state
player.setState(‘fall’);
player.getAnim() // To get the movieclip