2 var Flapp = function(url, canvas_id) {
3 console.debug("Flapp("+url+","+canvas_id+")");
5 this.canvas_id = canvas_id;
6 this.canvas = document.getElementById(canvas_id);
7 global.flapp = this; // debug
9 // this.frameTick = 1000 / 10; // default 0.1[sec]
10 this.frameTick = 1000; // default
14 console.debug("Flapp.prototype.play");
16 var loader = new FlappLoader(flapp); // file loader
17 this.dict = new FlappDict(); // content dictionary
18 this.movieClip = new FlappMovieClip(); // root MC
19 loader.fromURL(this.url, this.dict, this.movieClip);
20 this.canvas = new FlappCanvas(this.canvas);
21 this.run(this.dict, this.movieClip, this.canvas);
23 setHeader: function(header) {
24 // this.frameTick = 1000 / header.framerate;
25 this.frameTick = 1000;
26 this.movieClip.totalframes = header.framecount;
28 run: function(dict, movieClip, canvas) {
29 console.debug("Flapp::run");
32 this.tick(flapp, this.dict, this.movieClip);
34 tick: function(flapp, dict, movieClip) {
35 console.debug("Flapp::tick "+movieClip.currentFrame);
36 setTimeout(flapp.tick, flapp.frameTick, flapp, dict, movieClip);
37 if (movieClip.control(dict)) {
39 movieClip.render(flapp.canvas);
40 movieClip.increment();