CodingForums.com

CodingForums.com (http://www.codingforums.com/index.php)
-   Flash & ActionScript (http://www.codingforums.com/forumdisplay.php?f=52)
-   -   Why can one class access root variables but another can't? (http://www.codingforums.com/showthread.php?t=283913)

NancyJ 12-10-2012 05:25 PM

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.display:DisplayObject.
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.


All times are GMT +1. The time now is 03:45 PM.

Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.