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!
// 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 assign a name to our stage item....
mySmile.name = "mySmile"+i;
//i variable is the loop counter
//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 ("mySmile0"));
// this will remove the child with the name we created from stage.
}
// thanks for watching !!






9 Responses to “Assigning Instance Names with ActionScript 3.0”
Trackbacks/Pingbacks
How To Help a Friend Going Through Divorce…
[...] We don’t show it to others but deep down inside going through a divorce is a heartbreaking time. Moving on after divorce is not easy. We’re told to keep our emotions in when the truth is we need to let it out. Begin to rebuild who you are menta…
Master Internet Marketing…
Making money online can be much easier than what most tend to think. You just need the right startup! Get it here!…
Keep it up…
I enjoy reading post like these Keep it up man…
Look here:…
[...]you made running a blog glance[...]…
…Take a look for more Information on that topic…
[...]Wow, awesome blog format! How long have you been blogging for?[...]…
great info…
discover more here…
…Awesome website…
[...]The whole look of your web site is fantastic, let well as the content material![...]…
Title…
Wow that was weird. I just wrote an extremely detailed response but after I clicked submit my comment didn’t show up. Hmmm… well I’m not typing all that again. Anyways, just wanted to say cool blog!…
Title…
Wow, I’m sincerely happy that I clicked on this site, good info here! Better than http://google.com!…