Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,169
    Thanks
    19
    Thanked 65 Times in 64 Posts

    Why can one class access root variables but another can't?

    root.somepropertyofmain works in every class in my project (so far) except one. If I trace root from within both say [object main] but one of my classes wont let me access the main variables - it gives a compile error: Access of possibly undefined property name through a reference with static type flash.displayisplayObject.
    The property I'm trying to access is not undefined.It is declared and a value assigned to it in the class definition of Main.as, I cannot attempt to access any root variables from within this class, even ones that work in other classes.

    The class that doesn't work is a class that is totally written in actionscript, when the app is run a movieclip (swatch_group) creates a bunch of these movieclips (paint_sample) within itself . When a paint sample is clicked it needs to know which item to apply itself to, which is a string stored in Main.as

    [Update]

    It will let me do this:

    Code:
    root[root['wall1'].parent.currentwall]
    It allows me to access a property of root that I know is on the stage, access that object's parent (which is root) then access it variables... which is horribly kludgey.
    Last edited by NancyJ; 12-10-2012 at 05:37 PM.


 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •