Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6185507
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T01:43:30+00:00 2026-05-24T01:43:30+00:00

Using Flash CS5 Professional I have created a symbol, dragged it onto the stage,

  • 0

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:

  1. 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.”

  2. 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.”

  3. 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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T01:43:31+00:00Added an answer on May 24, 2026 at 1:43 am

    1 doesn’t work because the stage property of an object(assuming it’s on the display) is a Stage object. By default, your document class will be the first child of the stage, unless you have inserted something in there using setChildIndex(0) or addChildAt(someObject,0). So you should be able to access via the document class with

    this.stage.getChildAt(0).GreenLight1;
    

    2 doesn’t work because you are casting your root as a Sprite. It’s not a Sprite, it’s your document class that is a descendant of Sprite, so this should work:

    this.root.GreenLight1
    

    I’m going to skip over number three and try to offer up a more direct solution. You have this symbol in your library, you’ve set it to ‘Export for actionscript’ and have given it a class name of GreenLight. Good start. So now anywhere in your code you can do something like this:

    var myGreenLight:GreenLight = new GreenLight();
    

    which has created a reference (myGreenLight) to a new instance of your GreenLight symbol. You can now attach this to the display tree of your calling class with

    addChild(myGreenLight);
    

    Assuming that the class you’re coding in is itself on the stage, then your instance of GreenLight should be visible. You could also, from any object that’s on the stage, call this.stage.addChild(myGreenLight); to attach your GreenLight instance directly to the stage if that was what you wanted.

    So now, finally to the real question. You have an instance of GreenLight on the stage called GreenLight1. (Please note, by convention only class names start with a capital, variable names and instance names should start with a lower case character). You have another class which is also on the display tree and you need to get a reference to GreenLight1 that’s on the stage. Here’s a function to do that:

    function getMovieClip($instanceName:String,$scope:DisplayObjectContainer):DisplayObject
    {
        var child:DisplayObject;
        var loopLength:int = $scope.numChildren;
        for(var i:int = 0; i < loopLength; i++) {
            child = $scope.getChildAt(i);
            if(child.name == $instanceName) return child;
        }
        //didn't find it
        return null;
    }
    

    and you use it from any object that can access stage like this:

    var greenLightRef:GreenLight = getMovieClip('GreenLight1',this.stage) as GreenLight;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some class that I created visually in Flash Professional CS5 by transferring
I have Adobe Media Server 4, and I am using Flash Professional CS5.5 to
I have created an iPad app using Flash cs5.5, how do I test on
I am very new to Action Script. I am using Flash Professional CS5 with
I create an augmented reality application on android using the Adobe Flash Professional CS5
I'm using Flash Professional cs5/AS3 I'll try and describe this the best I can.
I have completed a simple contact form using Flash CS5 and AS2. Instead of
I have a Flash Professional CS5 movie which I'm trying to pass a parameter
I am loading an swf created in flash professional cs5 via the loader class
How can I use Stage Video in my project in Flash Professional CS5? Do

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.