var flapp = this;
var loader = new FlappLoader(flapp); // file loader
this.dict = new FlappDict(); // content dictionary
- this.movieClip = new FlappMovieClip("_root", null, null, null); // root MC
+ var m = FlappSWFMatrix;
+ var matrix = m.multiply(m.identity(), 20);
+ this.movieClip = new FlappMovieClip("_root", matrix, null); // root MC
loader.fromURL(this.url, this.dict, this.movieClip);
this.canvas = new FlappCanvas(this.canvas);
this.run(this.dict, this.movieClip, this.canvas);
goog.provide('FlappMovieClip');
+goog.require('FlappObject');
goog.require('FlappDisplay');
goog.require('FlappShape');
goog.require('FlappAction');
/**
* @constructor
*/
-FlappMovieClip = function(parentMovieClip, name, matrix, colorTransform) {
- this.OBJECT_TYPE = 2; // 1:Shape, 2: MovieClip
+FlappMovieClip = function(parentMovieClip, matrix, colorTransform) {
this.parentMovieClip = parentMovieClip?parentMovieClip:null;
this.rootMovieClip = parentMovieClip?parentMovieClip.rootMovieClip:this;
- this.name = name?name:'anonymous';
+ this.name = null;
this.matrix = matrix;
this.colorTransform = colorTransform;
this.childMovieClips = {}; // name => movieClip
- this.childMovieClips_seqnum = 1; // for name movieClip
+ this.instanceSeqno = 1; // for name object (movieClip, etc...)
this.clearControlTags();
//
this.prevShowFramePos = 0;
this.canvasDirty = false; // dirtyFlag
//
this.displayList = new FlappDisplay();
+ this.displayObjectLifeSpan = {}; // for gotoFrame
//
this.totalframes = 0;
this.currentFrame = 0;
case 26: // PlaceObject2
// set display List;
var obj = null;
- if (tag.move) {
- this.displayList.set(tag.depth, obj, tag);
+ if (tag.move && (tag.id === null)) {
+ this.displayList.move(tag.depth, tag);
} else {
+ if (tag.move) {
+ obj = this.displayList.get(tag.depth);
+ if (obj === null) {
+ console.error("Can't get DisplayObject by depth:"+tag.depth);
+ }
+ if (obj.code === 39) { // DefineSprite
+ this.deleteChildMovieClip(obj.name);
+ }
+ this.displayList.del(tag.depth);
+ }
defineTag = dict.get(tag.id);
- console.log(tag);
- if (defineTag.code === 39) { // DefineSprite
- var name = tag.name;
- if (name === null) {
- name = "instance"+this.childMovieClips_seqnum;
- defineTag.name = name;
- this.childMovieClips_seqnum++;
- }
- obj = new FlappMovieClip(this, name, tag.matrix, tag.colorTransform);
- obj.setControlTags(defineTag.controlTags);
- this.addChildMovieClip(name, obj);
- } else if (defineTag.code === 2) { // DefineShape
- obj = new FlappShape(name, tag.matrix, tag.colorTransform);
- console.log(obj);
- obj.loadShapeTag(defineTag);
+ if (defineTag === null) {
+ console.error("defineTag === undefined");
+ return ;
+ }
+ var name = tag.name;
+ if ((name === null) && (defineTag.code === 39)) {
+ name = "instance"+this.instanceSeqno;
+ tag.name = name;
+ this.instanceSeqno++;
+ }
+ obj = FlappObject.factory(this, name, defineTag, tag);
+// console.debug(obj);
+ if (defineTag.code === 39) { // DefineSprite
+ this.addChildMovieClip(name, obj);
}
this.displayList.set(tag.depth, obj, tag);
break;
var depthList = this.displayList.descSortedDepth();
for (var i = 0, l = depthList.length ; i < l ; i++) {
var depth = depthList[i];
- var obj = this.displayList.getObj(depth);
- if (obj.OBJECT_TYPE === 2) { // MovieClip
- obj.render(this.canvas);
- } else if ((obj.OBJECT_TYPE === 2) && (this.playing == true)) {
- obj.render(this.canvas);
- }
+ var obj = this.displayList.get(depth);
+ obj.render(this.canvas);
}
},
setVariable: function(key, value) {