Discovering and Referencing Instance Names

Thu, Oct 22, 2009

ActionScript

There is no such a thing as a item on stage without an instance name. If you did not create a name, ActionScript 3.0 will create a name for you. Find out how to trace this name and how to access the item, using it.

CLICK HERE FOR A COMPLETE ACTIONSCRIPT 3.0 CARTOON SMART TUTORIAL

HERE IS THE SOURCE CODE!

//The ActionScript 3.0 Remove Items from Stage by Instance Name
// 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

//This will give us the instance name
trace (mySmile.name);
}

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 {

removeChild(getChildByName ("instance13"));

// this will remove the child with the name instance 13 from stage.
}

Related Articles:

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

One Response to “Discovering and Referencing Instance Names”

  1. TutorialsRoom Says:

    Nice tytorial, it was chosen for the homepage of http://www.tutorialsroom.com


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