Skip to main content
Known Participant
May 27, 2008
Question

Help me understand instance variable scope of classes linked to MovieClips onstage.

  • May 27, 2008
  • 1 reply
  • 251 views
If I create a Symbol called MyMovieClip and add a TextField to it called my_txt,and link it using by checking "Export for Actionscript" to my class called MyMovieClip.

When I try to access the my_txt object from inside the class with say trace(this.my_txt) in the constructor, I keep getting the error "There is no property with the name my_txt". But in the constructor I can reference the same element using _level0.myMovieClipInstance.my_txt.

How useful is this linking if you can't access stuff inside the MovieClip? Hope you can help me understand what I'm missing.


This topic has been closed for replies.

1 reply

Inspiring
May 27, 2008
It's because the compiler is looking for a class property when you say
this.my_txt. The workaround is to use array notation:

trace(this["my_text"]);

--
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/