TheDesignspace
1119: Access of possibly undefined property error in ActionScript 3


October 31, 2008
Most Popular | Flash

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?
Posted by ellen at October 31, 2008 02:55 PM | TrackBack

 Comments

O-m-g!

Finally got it to work!! :D

One million thanks!

Posted by: K on January 4, 2010 11:45 AM

This was a big help. Thanks for posting!

Posted by: Kosta on January 9, 2010 10:21 PM

Wow!! 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 AM

Thank 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 AM

Muito Bom. Obrigado

Posted by: Mário on March 22, 2010 12:48 PM

Thank you a lot,
I am taiwanese someone to looking for someway to solve error:1119, that is very useful for me.

Posted by: Stuka on April 17, 2010 9:22 PM
 Post a comment
Name:


Email Address:


URL:


Comments:


Remember info?