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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:40:46+00:00 2026-05-25T10:40:46+00:00

I am making a website in Flash, coded in flashbuilder. Whenever I try to

  • 0

I am making a website in Flash, coded in flashbuilder. Whenever I try to export my code I get the same error again and again (TypeError = see below).

I think the problem has something to do with the stage of my project. Whenever I change the var stageMiddenX = (stage.stageWidth / 2); into var stageMiddenX = 512;, the code works. but I wan’t the var to be dynamic.

TypeError
Error #1009: cannot access a property or method of a null object reference at main()

package {
import flash.display.MovieClip;

  public class main extends MovieClip{
    var stageMiddenX = (stage.stageWidth / 2);
    var stageMiddenY = (stage.stageHeight / 2);
    private var object1:Object1 = new Object1();
    private var object2:Object2 = new Object2();
    private var object3:Object3 = new Object3();
  }
}
  • 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-25T10:40:46+00:00Added an answer on May 25, 2026 at 10:40 am

    The issue here is that stage is not yet available at the time you are requesting it.

    You’ll want to wait until the Event.ADDED_TO_STAGE event is fired before attempting to acccess stage.

    package {
        import flash.display.MovieClip;
    
        public class main extends MovieClip{
            private var object1:Object1 = new Object1();
            private var object2:Object2 = new Object2();
            private var object3:Object3 = new Object3();
            private var stageMiddenX:Number;
            private var stageMiddenY:Number;
    
            public function main(){
                if(stage) init(null);
                else addEventListener(Event.ADDED_TO_STAGE, init)
            }
    
            private function init(e:Event):void {
                removeEventListener(Event.ADDED_TO_STAGE, init);
                stageMiddenX = (stage.stageWidth / 2);
                stageMiddenY = (stage.stageHeight / 2);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I see all this heavy Flash/3D websites and it's making me wonder how do
I am actually making a unlike button for my website. The code I've used
I'm making a flash website, I know the basics of html and AS3, but
I was making a website for a music band, and i was wondering the
I'm making a website that tend to handle all the request in one page
I am making the website of a movie theater, and I want Google Movies
I'm making a website that mail users when a movie or a pc game
I'm making a website using JSP and servlets and I have to now break
I am thinking about making a website with some fairly intense JavaScript/canvas usage and
I am in the process of making a website that involves a shopping cart.

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.