Hi, I've based this on the moock book but I would like to know how to make it better particularly the deleting of the constructor parameters.
Code:
#initclip
// create the namespace in which to store classes
//
if (global.org == undefined) {
_global.org = new Object();
}
if (global.org.elem == undefined) {
_global.org.elem = new Object();
}
// create the instance var
org.elem.tab = function( ) {
// Create instance properties
this._alpha = this.params.cp_alpha;
this.fadeDuration = this.params.cp_duration;
trace ("this.params.cp_duration" + this.params.cp_duration);
// initialise instance
this.setPosition(this.params.cp_x, this.params.cp_y);
this.setColor(this.params.cp_color);
//this.onLoad =
this.onEnterFrame = this.bigMethod;
//remove constuctor params, to tidy up the memory so remove any property that begin with cp
for (var p in this.params) {
if (p.indexOf("cp_") != -1) {
// trace ("test "+ this[p]);
delete this[p];
}
//trace ("dfdf"+ this.params.cp_color);
}
};
/*
* Set sq's movieclip superclass
*/
org.elem.Tab.prototype = new MovieClip();
/*
Associate the librarys sqSymbol with the Sq class
*/
Object.registerClass("Tab", org.elem.Tab);
/*
* Instance methods
*/
org.elem.Tab.prototype.bigMethod = function() {
if (this.marker == false) {
this.fadeIn(0, 100, this.fadeDuration);
} else {
}
};
org.elem.Tab.prototype.setPosition = function(x, y) {
this._x = x;
this._y = y;
};
org.elem.Tab.prototype.move = function() {
this.depth = this.getDepth();
//test = Math.sin(xangle*Math.PI/180)*20;
this._alpha = (1000/this.depth*10)+(Math.sin(xangle*Math.PI/180)*50);
xangle++;
//xangle = xangle + xangle/numbertest ;
};
org.elem.Tab.prototype.fade_trigger = function() {
this.marker = false;
trace("fadetrigger");
};
org.elem.Tab.prototype.fadeIn = function(beginX, deltaXL, duration) {
// set a marker to run the code only once
// put the spped into an easing equation
// t: current time, b: beginning value, c: change in value, d: duration
var testA = Math.easeOutSine(++this.frameCounter, beginX, deltaXL, duration);
if (this.frameCounter>duration) {
this.frameCounter = 0;
//trace("alpha ="+this._alpha+this.framecounter+" "+duration+" : "+this.marker);
this.marker = true;
}
if (this.frameCounter<duration) {
this._alpha = testA;
//trace("change "+this._alpha+" : "+this.marker);
}
};
org.elem.Tab.prototype.setColor = function(colorVar) {
myColor = new Color(this);
myColor.setRGB(colorVar);
};
/*
*/
#endinitclip