I would like to do simple (looping) animation (moving, changing alpha etc) in haXe (flash9). I don't have anything that resembles frames in my library, just single frame assets.
Since I am a beginner. I am not necessarily looking for a sophisticated framework. I would be happy with something quick & dirty. Maybe if
s checking the frame
(class variable) and linearly interpolating the values.
class MyClass extends Sprite {
static var frame:Int = 0;
static inline var framerate:Int = 25;
static function main() {
var app:MyClass = new MyClass();
flash.Lib.current.addChild(app);
}
private function new() {
super();
// init assets here
var myTimer:Timer = new Timer(1000/framerate);
myTimer.addEventListener(TimerEvent.TIMER, animate);
myTimer.start();
}
function animateForeground(event:TimerEvent) {
frame = (frame + 1) % 1000;
// set new values depending on frame
}
}
I know the basic idea of keyframe animation. What I am looking for is more about how to structure this part of the program.
Can you please give me some pointers on how should I proceed?