Using Flash CS5 Professional I have created a symbol, dragged it onto the stage, and given it an instance name of GreenLight1. If I want to make this visible from the document class, I can simply do the GreenLight1.visible=true; and poof it's good to go when I test the file. As long as I stay in the document class I am good to go, but now I'm trying to move to another class and hitting ALL kinds of trouble just trying to get Flash to allow me to access this simple object. All I am looking to do is have this GreenLight1 go invisible (visible=false) when a certain condition occurs in this new class and Flash just won't let me access GreenLight1 at all.
Things I've tried thus far:
stage is passed to the class and is referenced by _stage and is working just fine when I do _stage.addchild or anything like that. So I have tried "_stage.GreenLight1.visible=false;" and I get "ReferenceError: Error #1069: Property GreenLight1 not found on flash.display.Stage and there is no default value."
My document class extends Sprite, so I figured I'd try the root function. So I tried "Sprite(root).GreenLight1.visible=false;" and I get "1119: Access of possibly undefined property GreenLight1 through a reference with static type flash.display:Sprite."
Finally on the advice of the answer in this thread I tried to create the Resource class as described therein. To which I came across the same problem that I started with in that it doesn't know what GreenLight1 is to begin with so I got "1120: Access of undefined property GreenLight1." Here is my code for Resource.as (am I supposed to pass something to this class from the document class?):
`
package {
import flash.events.Event;
import flash.display.Sprite;
import flash.display.DisplayObject;
public class Resource extends Sprite {
public static var GL1:GreenLight;
public function Resource() {
addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);
}
private function init(e:Event):void{
Resource.GL1 = GreenLight1;
}
}
}
The type "GreenLight" is from the source symbol of GreenLight1. I have "Export for ActionScript" checked off and the base class is called GreenLight. So that is where that comes from. Am I supposed to make a "new GreenLight" somewhere or something like that?? I the class that I'm trying to access it from I am using "Resource.GL1.visible=false;", but it never really gets to worry about that because I get the compile error listed in #3 above.
In any event, I'm at a loss as to what to try next. So... How in the world do I get a class that isn't the document class to recognize GreenLight1?