[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 253
  • Last Modified:

event.currentTarget

any reason why i would be getting this as an output...

function clicked(event:MouseEvent):void{
        transLoad(event.target.name + ".swf");
            trace(event.target.name);
            }
Output:
instance13

is what is says when clicked...my addEventListeners look right..this was working once before and then my computer locked up and i lost what i had done..so i had to start over and i cant get it to work

merchandise.addEventListener(MouseEvent.CLICK, clicked);
merchandise is the name of the swf i am bring to the stage. its in the same folder as the main swf...

i am at a lose
0
chefkeifer
Asked:
chefkeifer
1 Solution
 
moagriusCommented:
"merchandise" is a reference to the object - it's name is instance13 - the "13" means it's the 13th instance instantiated.

you can have any number of references to an object, for example:

var sprite:Sprite = new Sprite();
addChild(sprite);
var firstChild:Sprite = getChildAt(0);
var lastChild:Sprite = getChildAt(numChildren-1);

in this case, "sprite", "firstChild", and "lastChild" are all references to the same object, and none are its name (which would be instance1).

you can assign it's name programmatically

mechandise.name = "merchandise"

0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now