Child Index Video Tutorial: Removing Items from Stage with removeChildat method

Wed, Oct 21, 2009

ActionScript


Every Item on stage has a index number that relates to it. IT is called the Child Index or the CHILD AT. The stage is considered the father. Here we teach how does the childat method works.

HERE IS THE SOURCE CODE!

//The ActionScript 3.0 RemoveChildat
// Avraham Saltoun solutions at say-web dot com
// FREE to USE, COPY and DISTRIBUTE

var mySmile : Smile;

// the variable mySmile will contain
// a smile movie clip

//This will add 3 smiles
//next one another

for (var i: int =0; i <3; i++) {
mySmile = new Smile();
//this class was automatically created
// on previous tutorial
addChild (mySmile);
//this adds a smile to stage

mySmile.x = i*mySmile.width;
//this will position the smile next to previous

}

addChild(mySmile);
//this will place a smile
//on our empty stage

remove_btn.addEventListener(MouseEvent.CLICK, removeSmile);
// removeSmile is a function we will create
// that removes the movie clip from stage

function removeSmile (event:MouseEvent):void {

removeChildAt(3);
removeChildAt(2);
removeChildAt(1);
// this will remove the child index number 1 from stage
}

//thanks for watching

Related Articles:

, , , , , , , , , , , , ,

One Response to “Child Index Video Tutorial: Removing Items from Stage with removeChildat method”

  1. Dan Says:

    Cool tutorial. Is there any way to find out what index # a movie clip has? Such as a

    button.addEventListener(MouseEvent.CLICK, whatsMyIndex)

    function whatsMyIndex(evt.MouseEvent:void):void {
    trace(myIndex(self));
    }

    something like that??


Leave a Reply

Security Code:

AVA Trading Forex
WIX create a FREE website.
Try ACT! 2010 Today
Accept Credit Cards
UseNeXT Fast Downloads
For Free Stuff Click Here

Get Paid for Filling Surveys


Go Daddy $7.49.com sale 125x125 Huddle Collaboration
oDesk Certified Action Script Programmer oDesk Certified Adobe Flash CS3 Designer oDesk Certified Adobe Photoshop 6.0 Designer

Compare Web Hosting Services and Prices

web hosting - Web Hosting guide to popular hosts.

Twitter Followers