5 Replies Latest reply on Aug 7, 2010 8:29 PM by Deepanjan Das

    Null Object Runtime Error! Help!

    jerry98225 Level 1

      Hi guys..

         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:




                 public class videoMain extends Sprite{


                   private var videoPlayer:Player;


                 public function videoMain (){





                 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();








      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 {


                  //only show part of codes....



          I appreciate any help....Thanks!!!!!