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 3224632
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:14:45+00:00 2026-05-17T16:14:45+00:00

The problem I’m facing is that I’m trying to manipulate (in this particular case

  • 0

The problem I’m facing is that I’m trying to manipulate (in this particular case add eventListeners) objects (in this case some MovieClips) on the stage from a class that isn’t the document class.

1120: Access of undefined property trans.

Now I know that it’s probably a scope thing and I probably can’t access stage objects directly from a non document class (as I’m doing in the code below) but I can’t figure out how to access them properly. I’ve been stuck with this problem for a couple of hours already and I’ve read a lot of solutions to similar problems and explanations on scope related problems but I still haven’t figured out a solution. I’m hoping now that someone here can help me out.

Anyway, here’s the deal:

I’ve got 3 dynamic text fields (called “NL”, “FR” and “EN”) on my stage in a movieclip called “trans”. I’m trying to add eventlisteners in a second class to make them do something when clicked on.

Here’s my document class:

package {

  import flash.display.MovieClip;

  // Import custom classes.
  import classes.Translate;

  public class Main extends MovieClip {

    // Init Translation class on load.
    public var translate:Translate = new Translate();

    public function Main() {

    }

  }
}

And here’s my custom class Translate (which is in a subfolder “classes”).

package classes {

  import flash.display.MovieClip;
  import flash.events.MouseEvent;

  public class Translate extends MovieClip {

    public function Translate() {

      // Init translation eventListeners.
      trans.NL.addEventListener(MouseEvent.CLICK,
        function(event:MouseEvent):void {
          loadNl();
        }
      );

      trans.FR.addEventListener(MouseEvent.CLICK,
        function(event:MouseEvent):void {
          loadFr();
        }
      );

      trans.EN.addEventListener(MouseEvent.CLICK,
        function(event:MouseEvent):void {
          loadEn();
        }
      );
    }

    public function loadNl() {
      trace("NL");
    }

    public function loadFr() {
      trace("FR");
    }

    public function loadEn() {
      trace("EN");
    }

  }
}

Thanks in advance for taking time to help me out.

Dries

  • 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-17T16:14:46+00:00Added an answer on May 17, 2026 at 4:14 pm

    Sorry I haven’t responded yet to my own question.

    The solution i was looking for is rather simple and leans mostly to Ben’s answer.

    Basically I wanted to use my Main class in other classes. I just have to send a reference to it to the new object’s class constructor.

    package {
    
      import flash.display.MovieClip;
    
      // Import custom classes.
      import classes.Translate;
    
      public class Main extends MovieClip {
    
        private var _instance:MovieClip;
    
        public function Main() {
          _instance = this;
    
          var trans:Translate = new Translate(_instance);
        }
      }
    }
    

    And now I can refer to my Main class and stage objects through this reference.

    package classes {
    
      import flash.display.MovieClip;
    
      public class Translate {
    
        private var _main:MovieClip;
    
        public function Translate(main:MovieClip) {
          _main = main;
    
          // Trace the amount of stage objects.
          trace(_main.stage.numChildren); 
        }
      }
    }
    

    Thanks Ben and Scott for helping out.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem Description: Multi-player Game that works over the some kind of network, in game
Problem : Trying to read from some electronic scales using the comport via Java
Problem: I have two spreadsheets that each serve different purposes but contain one particular
Problem: Trying to create a Mix that is applied to the AVPlayerItem, but it
Problem: I have a table that prints out vertical but I would like it
Problem: I am trying to build a recursive tree using a function and data
Problem occured when i tried to display xml data that has been taken by
Problem: I'm working on a website where there is a dial that displays a
PROBLEM: Here's the code: import matplotlib.pyplot as plt plt.bar([1,2],[5,4]) plt.title('this is a very long
Problem: I have 2 classes, DB class and a User class, that will work

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.