Skip to main content
Participant
December 20, 2010
Answered

Error 1009 in Action Script 3. Help!

  • December 20, 2010
  • 1 reply
  • 798 views

When I try playing my movie, I get

“TypeError: Error #1009: Cannot access a property or method of a null object reference.at RhettMovie_fla::MainTimeline/showsmokescene()

The error pops up when I click each of the four buttons, which are supposed to each start playing a different symbol. Help!!

Here’s my ActionScript:

import flash.events.MouseEvent;

// make the characters invisible

birthdayscene.visible  = false;

dancescene.visible = false;

trippyscene.visible  = false;

smokescene.visible = false;

// tell both scenes to stop animating

birthdayscene.stop();

dancescene.stop();

trippyscene.stop();

smokescene.stop();

// set up our buttons

btn1.addEventListener(MouseEvent.CLICK, showsmokescene);

btn2.addEventListener(MouseEvent.CLICK, showdancescene);

btn3.addEventListener(MouseEvent.CLICK, showtrippyscene);

btn4.addEventListener(MouseEvent.CLICK, showbirthdayscene);

// commands for making things visible and invisible

function showsmokescene(event:MouseEvent)

            {

            smokescene.visible = true;           

            smokescene.play();

           

            dancescene.visible = false;

            dancescene.stop();           

           

            trippyscene.visible = false;

            trippyscene.stop();           

           

            birthdayscene.visible = false;

            birthdayscene.stop();           

            }

           

function showdancescene(event:MouseEvent)

            {

            dancescene.visible = true;

            dancescene.gotoAndPlay(1);

                       

            smokescene.visible = false;

            smokescene.stop();

           

            trippyscene.visible = false;

            trippyscene.stop();           

           

            birthdayscene.visible = false;

            birthdayscene.stop();           

            }

function showtrippyscene(event:MouseEvent)

            {

            trippyscene.visible = true;

            trippyscene.gotoAndPlay(1);

                       

            smokescene.visible = false;

            smokescene.stop();

           

            dancescene.visible = false;

            dancescene.stop();           

           

            birthdayscene.visible = false;

            birthdayscene.stop();           

            }

           

function showbirthdayscene(event:MouseEvent)

            {

            birthdayscene.visible = true;

            birthdayscene.gotoAndPlay(1);

                       

            smokescene.visible = false;

            smokescene.stop();

           

            dancescene.visible = false;

            dancescene.stop();           

           

            trippyscene.visible = false;

            trippyscene.stop();           

            }

This topic has been closed for replies.
Correct answer kglad

click file/publish settings and tick "permit debugging".  retest.  click one of your buttons.  the problematic line number will be in the error message.  that line contains a reference to an object that doesn't exist when your code executes.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
December 20, 2010

click file/publish settings and tick "permit debugging".  retest.  click one of your buttons.  the problematic line number will be in the error message.  that line contains a reference to an object that doesn't exist when your code executes.

Participant
December 20, 2010

Now all of my sounds are playing at once! Each symbol has its own MP3 file in it (MP3 file names are the same as the symbol names for ease, so

smokescene.mp3 goes with smokescene and etc.)

How can I fix this in action script? 

import flash.events.MouseEvent;

// make the characters invisible

birthdayscene.visible  = false;

dancescene.visible = false;

smokescene.visible = false;

// tell both scenes to stop animating

birthdayscene.stop();

dancescene.stop();

smokescene.stop();

// set up our buttons

btn1.addEventListener(MouseEvent.CLICK, showsmokescene);

btn2.addEventListener(MouseEvent.CLICK, showdancescene);

btn4.addEventListener(MouseEvent.CLICK, showbirthdayscene);

// commands for making things visible and invisible

function showsmokescene(event:MouseEvent)

{

smokescene.visible = true;

smokescene.play();

dancescene.visible = false;

dancescene.stop();

birthdayscene.visible = false;

birthdayscene.stop();

}

function showdancescene(event:MouseEvent)

{

dancescene.visible = true;

dancescene.gotoAndPlay(1);

smokescene.visible = false;

smokescene.stop();

birthdayscene.visible = false;

birthdayscene.stop();

}

function showbirthdayscene(event:MouseEvent)

{

birthdayscene.visible = true;

birthdayscene.gotoAndPlay(1);

smokescene.visible = false;

smokescene.stop();

dancescene.visible = false;

dancescene.stop();

}

kglad
Community Expert
Community Expert
December 20, 2010

if you have sounds attached to a timeline, you should set their sync to stream, not event.