1 Reply Latest reply on Aug 23, 2007 9:40 PM by LinkOracleHero

    Unexplained Error #1009 when calling a function in a component.

    LinkOracleHero Level 1
      I created a component that allows you to display a song listing.
      I need to create various instances using it's constructor, then add them to a main scrollbar control.
      Before putting it in a loop, I wanted to make sure I could add a single instance, with this code:

      var NewListing:mediaUnit = new mediaUnit();
      NewListing.setArtist("In Flames");
      NewListing.setAlbum("Come Clarity");
      NewListing.addSong(1,"Take This Life");
      mediaLib.addObject(NewListing);

      Compiled, ran, got this:

      TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at mediaUnit/addSong()
      at MC3_PORT_fla::MainTimeline/MC3_PORT_fla::frame36()

      Okay, maybe it's the code of addSong, right? So I commented it out so it's basically:

      public function addSong(id:int,song:*):int {
      return 0;
      }

      Still gives the error.
      Why do setArtist and setAlbum, being in the SAME exact scope, not give this error? It just doesn't make sense to me.