[RESOLVED] Need help with swaping depths.
I have button that when clicked on creates a movie clip with the following script.
Code:
spots[spots.length] = this.attachMovie("spot","spot",this.getNextHighestDepth());
where spots is a previously declared array.
I have the following code in a found in a function elsewhere.
Code:
for(i=0;i<spots.length;i++)
{
if(xmouseGrid == spots[i]._x && ymouseGrid == spots[i]._y)
{
spots[i].swapDepths(spots[i-1]);
break;
}
}
The if statement and the condition under which it executes are not relevant.
What matters is that the swapDepths function simply does nothing here.
I did the following test to try and find out what was wrong.
Code:
for(i=0;i<spots.length;i++)
{
if(xmouseGrid == spots[i]._x && ymouseGrid == spots[i]._y)
{
trace(spots[i].getDepth() + " : " + spots[i-1].getDepth());
spots[i].swapDepths(spots[i-1]);
trace(spots[i].getDepth() + " : " + spots[i-1].getDepth());
break;
}
}
And the trace displayed the same exact message both times, nothing had happened between the two traces.
I did a lot of testing and it seems that swapDepths does not work properly when the mc's involved are a part of an array.
There is another place where I swap a different mc's depth with that of spots[i] but it swaps depth with the wrong instance of the spots array.
Can anyone tell my why this is or if there is anyway of fixing it?
Any help is greatly appreciated.