Skip to main content
Known Participant
May 6, 2013
Answered

Error #1009: Cannot access a property or method of a null object reference.

  • May 6, 2013
  • 1 reply
  • 709 views

TypeError: Error #1009: Cannot access a property or method of a null object reference.

          at BasicPlayer_fla::MainTimeline/onEnterFrame()[BasicPlayer_fla.MainTimeline::frame1:299]

Line 019:     // Variable List

Line 020:     var my_songs:XMLList; // create variable for reference to XML nodes in playlist

Line 021:     var my_total:Number; // create variable to hold number of songs in playlist

Line 022:     var my_sound:Sound; // create variable to hold sound object

Line 298:      // Get full time

Line 299:      var tallytime = (my_sound.length/1000);

Line 300:      var totalmins:Number = Math.floor(tallytime /60);

Line 301:      var totalsecs = Math.floor (tallytime) % 60;

Line 302:      if (totalsecs < 10)

Line 303:      {

Line 304:           totalsecs = "0" + totalsecs;

Line 305:      }

Line 306:      timerText_txt.text = ( " " + totalmins+ ":" + totalsecs);

I have tried tracing parts of Line 299 and am not sure on what the problem is can anyone care to explain what it is that I am doing wrong as I cannot see it.

This topic has been closed for replies.
Correct answer Ned Murphy

You declare the my_sound variable, but based on the code you show, you do not instantiate it, as in...

my_sound = new Sound()

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
May 6, 2013

You declare the my_sound variable, but based on the code you show, you do not instantiate it, as in...

my_sound = new Sound()

CaseyCCAuthor
Known Participant
May 6, 2013

Cool thanks that fixed the problem!

Ned Murphy
Legend
May 6, 2013

You're welcome