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 var matrix = FlappSWFMatrix.multiplyScalar(FlappSWFMatrix.identity(), (1/20));
30 this.movieClip = new FlappMovieClip("_root", matrix, null); // root MC
31 loader.fromURL(this.url, this.dict, this.movieClip);
32 this.canvas = new FlappCanvas(this.canvas);
33 this.run(this.dict, this.movieClip, this.canvas);
35 setHeader: function(header) {
36 // this.frameTick = 1000 / header.framerate;
37 this.frameTick = 1000;
38 this.movieClip.totalframes = header.framecount;
39 if (typeof this.timerId === 'number') {
40 clearInterval(this.timerId);
44 run: function(dict, movieClip, canvas) {
45 console.debug("Flapp::run");
53 var movieClip = this.movieClip;
54 var canvas = this.canvas;
55 console.debug("Flapp::ticks "+movieClip.currentFrame);
56 this.timerId = setInterval(function() {
57 if (movieClip.control(dict)) {
59 movieClip.render(canvas);
60 movieClip.increment();
66 goog.exportSymbol('Flapp', Flapp);
67 goog.exportSymbol('Flapp.prototype.play', Flapp.prototype.play);