PROBS passing onEnterFrame parameters

Hi guys and girls,

Having a few problems. I give a number of mc’s an onEnterFrame event on the fly (in a for loop) which calls an easing function. This function is passed a variable whos value is worked out incrementally, ie on each loop the value is incremented (+=).
I do this because I want each mc to be horizontally offset, in other words each clip eases so they come one after the other. Hope this makes sense, ANYWAY the problem the value of the variable (I mentioned above) which each clip uses to determine the postion it has to ease to seems to constantly reset itself. In other words the clips ease right on top of each other since the variable is reset to the last value it obtained from the last increment!!!. Anyone help!??


trace("yes");
	panelAmt = 5;
	speed = 4;
	tabWidth = 20.5;
		
	for(i=1;i<=panelAmt;i++)
	{
		
		this["panel" + i].onEnterFrame = function(leftAlign)
		{
			
			//var leftAlign = tabWidth*i;//offsets left alignment
			this._x += (temp-this._x)/speed;
			trace(speed);
			trace(this + " " + leftAlign);
		}
		leftAlign+=tabWidth;
		
	}

onEnterFrame events recieve no arguments. Where is leftAlign supposed to come from?

Hmm I think I just figured it out Sen, rather daft of me to think that I could pass onEnterFrame arguments:sigh: . I just gave each instance a variable and initialised it at the same time…
… Im just trying to create sliding tabs, Im now onto the part where I have to figure out how to slide tabs relative to which one is clicked…ie shuffle the inactive ones.


stop();

speed = 4;
tabWidth = 20.5;
tabAmt = 5;

for(i=1;i<=tabAmt;i++)
{
	this["panel" + i].leftPos = tabWidth*i;
	this["panel" + i].onEnterFrame = function()
	{
		this._x += (this.leftPos-this._x)/speed;	
	}
	
}

there ya go :beam:

i find problem solving quite exciting up till the 1hr mark, then it gets frustrating, ive been working on this for 20mins so Im still at the “excitement” stage, lol

oO one quick question Sen how can I check for a particular instance of an MC ?


key = panel3;

for(i=1;i<tabAmt;i++)
{

if(this["panel" + i]._name == key)
{
 trace("FOUND");

}
}



going to work?

key = “panel3”;

or

if(this[“panel” + i] == key)

HOORAY FOR ME ! :slight_smile:

Hey Senoc, I finished my first version of my sliding tabs thingy! Thought you might want to take a look :p:

Any ideas for optimization??

post reply for attachment