Home Tutorials Forums Articles Blogs Movies Library Employment Press
Prev Previous Post   Next Post Next
Old 02-13-2006, 02:11 AM   #1
rabs
Registered User
 
Join Date: May 2004
Posts: 21
Default how can this code be improved

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
rabs is offline   Reply With Quote
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving a cursor - Need help with my code e39m5 ActionScript 1.0 (and below) 2 01-11-2006 08:20 PM
gotoAndPlay("frame") when already on "frame". Why no code execution? jasonyen ActionScript 1.0 (and below) 0 12-13-2004 06:25 AM
Code File Size: Huge! cabbage ActionScript 2.0 1 09-01-2004 04:43 AM
Adding code to a component event handler? BlueTree ActionScript 1.0 (and below) 0 12-02-2002 11:17 PM
code not working jaredly ActionScript 1.0 (and below) 6 06-05-2002 07:56 PM


All times are GMT. The time now is 01:43 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.