I am working on a Flash project where a MovieClip that is contained within another clip needs to get a property from the main timeline of the container clip.
trace(this.parent.someProperty)
But this generated an error:
1119: Access of possibly undefined property someProperty through a reference with static type flash.display:DisplayObjectContainer.
I finally found the reason for this in this
excellent article by Josh Tynjala.
The problem is with "casting". The parent clip must be cast as type "MovieClip" or the compiler will throw that error in strict mode.
Either of the following two methods will work:
MovieClip(this.parent.someProperty);
or
(this.parent as MovieClip).someProperty;
For the complete explanation of why this is so, see:
WHY DOESN'T THE "PARENT" PROPERTY WORK THE SAME IN ACTIONSCRIPT 3?
O-m-g!
Finally got it to work!! :D
One million thanks!
Posted by: K on January 4, 2010 11:45 AMThis was a big help. Thanks for posting!
Posted by: Kosta on January 9, 2010 10:21 PMWow!! Thanks You, very very Much!! I was crazy with that error. Really works!!! God Bless You man.
Posted by: manuel guillen on February 14, 2010 4:58 AMThank you so much for the help.
Been scratching my head for two days with stupid compiler errors and strange outputs.
Finally it works as it should thanks to this above.
Posted by: Roever on March 22, 2010 9:24 AMMuito Bom. Obrigado
Posted by: Mário on March 22, 2010 12:48 PMThank you a lot,
Posted by: Stuka on April 17, 2010 9:22 PMI am taiwanese someone to looking for someway to solve error:1119, that is very useful for me.