2 var FlappMovieClip = function(parentMovieClip) {
3 this.parentMovieClip = parentMovieClip?parentMovieCli:this;
4 this.rootMovieClip = parentMovieClip?parentMovieClip.rootMovieClip:this;
5 this.childMovieClips = {}; // name => movieClip
6 this.clearControlTags();
8 this.prevShowFramePos = 0;
10 canvas = document.createElement('canvas');
11 canvas.width = 240; // XXX
12 canvas.height = 240; // XXX
14 this.canvasDirty = false; // dirtyFlag
16 this.displayList = {}; // depth => [tag, matrix, colorTransform]
19 this.currentFrame = 0;
21 FlappMovieClip.prototype = {
22 clearControlTags: function(controlTag) {
23 this.controlTagsList = [[]]; //
24 this.labelMap = {}; // label => frameNum
25 this.framesLoaded = 0;
27 appendControlTag: function(controlTag) {
28 // console.debug("FlappMovieClip::appendControlTag");
29 this.controlTagsList[this.framesLoaded].push(controlTag);
30 if (controlTag.code === 1) { // ShowFrame
31 this.controlTagsList.push([]);
33 } else if (controlTag.code === 43) { // FrameLabel
34 this.labelMap[controlTag.name] = this.framesLoaded;
37 setControlTags: function(controlTags) {
38 this.clearControlTags();
39 for (var i = 0, l = controlTags.length ; i < l ; i++) {
40 this.appendControlTag(controlTags[i]);
43 control: function(dict) {
44 console.debug("FlappMovieClip::control");
46 if (this.framesLoaderd < this.totalframes) { // imcomplete
47 if (this.currentFrame < this.framesLoaderd) {
51 var controlTags = this.controlTagsList[this.currentFrame];
52 this.actionTagList = [];
53 for (i = 0, l = controlTags.length ; i < l ; i++) {
54 tag = this.controlTags[i];
59 this.actionTagList.push(tag);
61 case 26: // PlaceObject2
66 this.currentFrame = 0;
70 console.debug("FlappMovieClip::action");
72 for (i = 0, l = this.actionTagList.length ; i < l ; i++) {
73 tag = this.actionTagList[i];
77 render: function(canvas, matrix, colorTransform) {
78 console.debug("FlappMovieClip::render");
82 global.FlappMovieClip = FlappMovieClip;