Share

MX v.2 Components Patch

Tracker: Patches

5 mx.core.View.destroyChildAt() bugfix - ID: 1371527
Last Update: Tracker Item Submitted ( carlos_rovira )

http://www.razorberry.com/blog/archivespage.php?cat=all&paged=2


Ok, this is an obscure post, but someone somewhere
might be having problems with this method while
extending mx.core.View and happen to google search for
it. :D

I came across this while creating and destroying
objects with createChild() and destroyChildAt(). The
depths seem to get messed up and you end up placing one
object on top of another in certain circumstances,
causing it to vanish.


And so I present a tweaked version. I’ve only tested it
with my application but if for some weird reason you’re
having problems with your views you can try it.

function destroyChildAt(childIndex:Number):Void
{
if (!(childIndex >= 0 && childIndex < numChildren))
return;

var childName:String = childNameBase + childIndex;
var nChildren:Number = numChildren;

destroyObject(childName);

// Shuffle all higher numbered children down
for (var i = childIndex; i < (nChildren - 1); i++)
{
var c = this[childNameBase + i] =
this[childNameBase + (i + 1)];
c.swapDepths(i+depth-nChildren);
}

// Delete the leftover slot
delete this[childNameBase + (nChildren - 1)];
depth-=1;
}


Carlos Rovira ( carlos_rovira ) - 2005-12-02 08:33

5

Open

None

Nobody/Anonymous

None

None

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.