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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:19:25+00:00 2026-06-07T03:19:25+00:00

I’m using actionscript 3.0 and Flash Professional CS5.5 I ran into a problem with

  • 0

I’m using actionscript 3.0 and Flash Professional CS5.5
I ran into a problem with instance objects which are not on the first frame.
My first frame is a menu and my second frame contains a TLF text field.
I have given the text field an instance name, let’s say “username_txt”.
Now if I turn off the “Automatically Declare Stage Instances” and do this in my main class

 public class MainClass extends MovieClip {

        public var username_txt:TLFTextField;

        public function MainClass() {
            username_txt.text = "anything";
        }
 }

I will receive a run time error stating that I try to access the property of a null object. (I have import all the necessary classes so that is not the problem)

This does not happen when I put the text right in the first frame though.

Any help?

Thanks in advance

  • 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-06-07T03:19:27+00:00Added an answer on June 7, 2026 at 3:19 am

    As the text field has not yet been instantiated since the frame has not yet been reached, I’m unsure there is an elegant way to perform this task.

    Perhaps a better model would be to decouple your data model from your views.

    Create a singleton class to store data:

    package
    {
    
        public class ApplicationModel
        {
    
            /** Singleton instance. */
            private static var instance:ApplicationModel = new ApplicationModel();
    
            /** Return singleton instance. */
            public static function getInstance():ApplicationModel
            {
                return instance;
            }
    
            /** Data Model */
            public var username:String;
    
            /** Constructor as singleton enforcer */
            public function ApplicationModel()
            {
                if (instance)
                    throw new Error("ApplicationModel is a singleton and can only be accessed through ApplicationModel.getInstance()");
            }
    
        }
    }
    

    Then from within anywhere such as keyframes or classes, you can get the instance of the object, implemented either as:

    ApplicationModel.getInstance().username = "test";
    

    Or a better practice would be:

    var applicationModel:ApplicationModel = ApplicationModel.getInstance();
    applicationModel.username = "test";
    

    As per your example:

    public class MainClass extends MovieClip {
    
        public var username_txt:TLFTextField;
    
        public function MainClass() {
            ApplicationModel.getInstance().username = "anything";
        }
    }
    

    Then, on the frame you need to update your TLFTextField (frame script of frame 2), you set the text based upon the model:

    username_txt.text = ApplicationModel.getInstance().username
    

    Your view will always update when needed.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I'm making a simple page using Google Maps API 3. My first. One marker
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I am reading a book about Javascript and jQuery and using one of the

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.