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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:12:45+00:00 2026-05-16T04:12:45+00:00

I am building a AS3 only project and got runtime error that said Cannot

  • 0

I am building a AS3 only project and got runtime error that said “Cannot access a property or method of a null object reference.”

Here is my code:

main.as

       public class videoMain extends Sprite{

         private var videoPlayer:Player;

       public function videoMain (){
         loadPlayer()
         loadProgress();
       }

       private function loadProgress():void{

        //the code below gave me null object error.....     
        var byteLoaded:Number=videoPlayer.videoBytesLoaded; //the problem code
        var byteTotal:Number=videoPlayer.videoBytesTotal;  //the problem code

        var percent:Number=Math.floor(byteLoaded/byteTotal)*100;
        }

        private function loadPlayer():void{

        videoPlayer= new Player();
        videoPlayer.createPlayer();
    }

}

Player.as

public function createPlayer():void{

    _loader = new Loader();
    _loader.contentLoaderInfo.addEventListener(Event.INIT, onLoaderInit);
    _loader.load(new URLRequest(playerType));

    }

public function get videoBytesLoaded():Number{
    return _Player.getVideoBytesLoaded();  //youtube api method
    }

public function get videoBytesTotal():Number{
    return _Player.getVideoBytesTotal;    //youtube api method
    }

 private function onLoaderInit(event:Event):void {
    _Player=_loader.content;
        //only show part of codes....
    }

I appreciate any help....Thanks!!!!!
  • 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-16T04:12:46+00:00Added an answer on May 16, 2026 at 4:12 am

    _Player is only defined after the Event.INIT has fired so any call before the _Player value is defined will throw an error.

    You should, at the minimum , have this:

    public function videoMain (){
         loadPlayer()
       }
    
    private function onLoaderInit(event:Event):void {
        _Player=_loader.content;
        //only show part of codes....
        loadProgress();
    
    }
    

    but progress events are not static so really you should have an enterFrame event listener in order to listen to the changing values…

    private function onLoaderInit(event:Event):void {
        _Player=_loader.content;
        //only show part of codes....
    
        addEventListener(Event.ENTER_FRAME , enterFrameListener);
    }
    
    private function enterFrameListener(event:Event):void
    {
        loadProgress();
        // and here you add some way to remove this event listener when 
        // the video is fully loaded
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building an as3 only web application and want to be able to include
I'm building a social media app in Flash (AS3) that is tightly integrated with
I'm building a game in as3 that has balls moving and bouncing off the
I'm building a Flash-based (AS3) website that incorporates Facebook Connect through a combination of
I'm building a flash site (as3) with large videos that act as transitions from
I'm building a Flash app (as3) that allows users to embed photos of themselves
I have a simple game that I am building in as3/air using flash develop,
I'm building, basically, an ad server. This is a personal project that I'm trying
I'm building a large flash site (AS3) that uses huge FLVs as transition videos
So, I'm building stuff in AS3, I have a main movie clip, and 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.