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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:10:14+00:00 2026-06-15T14:10:14+00:00

Inside my Document Class I have assign to an array some objects that are

  • 0

Inside my Document Class I have assign to an array some objects that are placed on stage so I can call them later.

When I declare the array outside the constructor the objects haven’t been created and the assign values are null unlike when I declare them inside constructor.
Why is this happening?

How can I avoid this?Can I use a listener to track when objects are loaded?

First Case

package { 
   public class Document extends MovieClip {
       var obj:Array = [object1,object2];
       public function Document() {
          trace(obj[0]); // <-- null
       }
   }
}

Second Case

package { 
   public class Document extends MovieClip {
       public function Document() {
          var obj:Array = [object1,object2];
          trace(obj[0]); // <-- reference value
       }
   }
}

enter image description here
enter image description here
enter image description here

  • 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-15T14:10:15+00:00Added an answer on June 15, 2026 at 2:10 pm

    Declare the array outside, and stuff values inside the constructor.

    public class Document extends MovieClip {
       var obj:Array;
        public function Document() {
          obj = [object1,object2];
          trace(obj[0]); // <-- reference value
       }
    }
    

    Whatever you write as initialized value is processed first, anything embedded in editor is second, the constructor code is third. So, when you refer assets by name in initialization code, they are yet uninitialized, so you receive nulls.

    Whatever listeners you use will only get applied after the object will be available. init() and ADDED_TO_STAGE listeners are useful if you need stage reference to align your code-controlled asset to given stage dimensions. Before that happens, the stage reference is null.

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

Sidebar

Related Questions

Explanation: i have few objects and im declaring them inside $(document).ready(). WHY? because in
I have products as an embedded document inside the category class as shown below:
I have an entity Course that has a key to another entity (Document) inside.
I have a document Design.rb that has an embedded document Attachment.rb that does some
I'm trying to assign a class that I have within the jQuery UI accordion
I have a class named validate['required'] and I need to put it inside onclick=something();document.getElementById('something').setAttribute('class',here);
So I have this code inside of a class file: Document requestData (String url,
Using mootools I have a 'builder' class that manufactures form objects, dynamically creating divs
I'm using the multicol package inside an a0poster document class. I am trying out
I have store a sample document inside my local server named template.doc. Then I

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.