Skip to main content
Perfect_Nemus
Known Participant
July 15, 2009
Answered

Getting a DisplayObjectContainer name

  • July 15, 2009
  • 1 reply
  • 371 views

Hi to Eone,

I'd like to know if is possible to trace the name of a container object using the contained object.


Something like:

mc1 = new Movieclip();

cont1.addChild(mc1);

trace ("container object is: " + mc1.function_I_need());

OUTPUT

container object is: cont1

this because i need to know the name of the container object in order to use method such as getChildIndex etc etc

Thx a lot

This topic has been closed for replies.
Correct answer kglad

if you're defining a custom class that extends movieclip and you want to define a custom method function_I_need(), use:

public function function_I_need():DisplayObjectContainer{  //<- to return the parent

return this.parent;

}

// or

public function function_I_need():String{  //<- to return the parent's name

return this.parent.name;

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
July 15, 2009

if you're defining a custom class that extends movieclip and you want to define a custom method function_I_need(), use:

public function function_I_need():DisplayObjectContainer{  //<- to return the parent

return this.parent;

}

// or

public function function_I_need():String{  //<- to return the parent's name

return this.parent.name;

}