2 goog.require('FlappLoader');
3 goog.require('FlappDict');
4 goog.require('FlappCanvas');
5 goog.require('FlappMovieClip');
7 goog.scope(function() {
12 Flapp = function(url, canvas_id) {
13 console.debug("Flapp("+url+","+canvas_id+")");
15 this.canvas_id = canvas_id;
16 this.canvas = document.getElementById(canvas_id);
17 goog.global.flapp = this; // debug
19 // this.frameTick = 1000 / 10; // default 0.1[sec]
20 this.frameTick = 1000; // default
25 console.debug("Flapp.prototype.play");
27 var loader = new FlappLoader(flapp); // file loader
28 this.dict = new FlappDict(); // content dictionary
29 this.movieClip = new FlappMovieClip("_root", null, null, null); // root MC
30 loader.fromURL(this.url, this.dict, this.movieClip);
31 this.canvas = new FlappCanvas(this.canvas);
32 this.run(this.dict, this.movieClip, this.canvas);
34 setHeader: function(header) {
35 // this.frameTick = 1000 / header.framerate;
36 this.frameTick = 1000;
37 this.movieClip.totalframes = header.framecount;
38 if (typeof this.timerId === 'number') {
39 clearInterval(this.timerId);
43 run: function(dict, movieClip, canvas) {
44 console.debug("Flapp::run");
52 var movieClip = this.movieClip;
53 var canvas = this.canvas;
54 console.debug("Flapp::ticks "+movieClip.currentFrame);
55 this.timerId = setInterval(function() {
56 if (movieClip.control(dict)) {
58 movieClip.render(canvas);
59 movieClip.increment();
65 goog.exportSymbol('Flapp', Flapp);
66 goog.exportSymbol('Flapp.prototype.play', Flapp.prototype.play);