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

  • Home
  • SEARCH
  • 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 7012283
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:14:09+00:00 2026-05-27T22:14:09+00:00

for my current project I am starting to work with AS3 and I have

  • 0

for my current project I am starting to work with AS3 and I have written a ClipManager class where I can define an MC like “mainView” during initialization like this:

clipManager:ClipManager = new ClipManager(mainView);

With my clipManager I can now easily load stuff into the mainView etc. The problem is that I want every button throughout the whole thing to access Class Methods of this instance to alter the mainView. Can I have something like a global Class instance in Flash or is there any smarter way to achieve what I am trying to do?

  • 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-27T22:14:09+00:00Added an answer on May 27, 2026 at 10:14 pm

    You can either add your ClipManager class as a static somewhere – i.e. a god object – (perhaps your main class) and access it through that, or you can use the Singleton pattern.

    A common way to implement it in as3:

    public class Singleton
    {
        private static m_instance:Singleton = null; // the only instance of this class
        private static m_creating:Boolean   = false;// are we creating the singleton?
    
        /**
         * Returns the only Singleton instance
         */
        public static function get instance():Singleton
        {
            if( Singleton.m_instance == null )
            {
                Singleton.m_creating    = true;
                Singleton.m_instance    = new Singleton;
                Singleton.m_creating    = false;
            }
            return Singleton.m_instance;
        }
    
        /**
         * Creates a new Singleton. Don't call this directly - use the 'instance' property
         */
        public function Singleton()
        {
            if( !Singleton.m_creating )
                throw new Error( "The Singleton class can't be created directly - use the static 'instance' property instead" );
        }
    }
    

    Now, to access your class, you call Singleton.instance. There’ll only ever be one instance of this class.

    As for anti-patterns etc, well that’s another post 🙂

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

Sidebar

Related Questions

Just starting out with subversion, have set up repos for 3 current projects and
On my current project, I am using FxCop to work through various code analysis
In my current project I have data about colors. Each color is either a
As part of my current project I've created a custom class loader. Part of
My current task is taking a Java project written and developed in Ubuntu NetBeans
In my current iPhone project, I have a created a dictionary that groups the
I'm just starting now a small project so I can learn more of the
I am starting a project and i would like to be able to test
In our current project, we have one particular page where, when viewed in IE7
My current project is broken down into 3 parts: Website, Desktop Client, and a

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.