Skip to main content
Known Participant
August 10, 2010
Answered

problem with root and constructors

  • August 10, 2010
  • 1 reply
  • 1082 views

hello guys,

i have serious problem, its 2 days i am trying to do something about it,

i have some object inside object inside another object,

if in their constructors i write:

MovieClip(root).someVar

(or function)

its not working!

it works only i regular functions,

i cant even call a egular function from the constructor,

please help my guys, i really need this!

thanks alot!

This topic has been closed for replies.
Correct answer kglad

nothing in a displayobject constructor can reference the stage or any other object in the displaylist because the displayobject hasn't been added to the displaylist yet.

to remedy, use an addedtostage event listener to trigger a function that can reference then reference the stage or root.

1 reply

kglad
Community Expert
Community Expert
August 10, 2010

i don't understand what you're trying to say.

Known Participant
August 10, 2010

if i have some var on the stage.

and i have some object on the stage.

if i want to get to the var on the stage i can write:

MovieClip(root).var

but it is not working if i write it in the object constructor

only in regular functions

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
August 10, 2010

nothing in a displayobject constructor can reference the stage or any other object in the displaylist because the displayobject hasn't been added to the displaylist yet.

to remedy, use an addedtostage event listener to trigger a function that can reference then reference the stage or root.