-1

So I have been trying to figure out this error for the past two hours, I've tried researching the entire internet for an answer and so far I haven't been able to figure it out.

Would someone be able to help me! This is my code :

stop();
countdown_mc.visible = false;
stage.focus = stage;
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.sensors.Accelerometer;
import flash.events.AccelerometerEvent;



var myAccel: Accelerometer = new Accelerometer();
var score: Number = 0;
var countDown: Timer = new Timer(1000);

stage.addEventListener(Event.ENTER_FRAME, checkHit);
myAccel.setRequestedUpdateInterval(100); //Every half second.




countDown.addEventListener(TimerEvent.TIMER, count);


countDown.start();

if (Accelerometer.isSupported == true) {
    myAccel.addEventListener(AccelerometerEvent.UPDATE, update);

    function update(e: AccelerometerEvent) {

        x_mc.x -= (e.accelerationX * 30);
        o_mc.x -= (e.accelerationX * 30);


        if (x_mc.x < 150) {
            x_mc.x = 150;
        }
        if (x_mc.x >= stage.stageWidth - 150) {
            x_mc.x = stage.stageWidth - 150;
        }

        if (o_mc.x < 150) {
            o_mc.x = 150;
        }
        if (o_mc.x >= stage.stageWidth - 150) {
            o_mc.x = stage.stageWidth - 150;
        }



    }
}




function count(eeee: TimerEvent) {

    var drop: Number = Math.floor(Math.random() * 5) + 1;




    if (drop == 1) {
        x_mc.gotoAndPlay(2);
        countDown.stop();
        gotoAndPlay(180);
        o_mc.stop();
        stage.removeEventListener(Event.ENTER_FRAME, checkHit);
        stage.removeEventListener(AccelerometerEvent.UPDATE, update);
        stage.removeEventListener(TimerEvent.TIMER, count);

    } else if (drop == 2) {
        o_mc.gotoAndPlay(2);
        countDown.stop();
        gotoAndPlay(180);
        x_mc.stop();
        stage.removeEventListener(Event.ENTER_FRAME, checkHit);
        stage.removeEventListener(AccelerometerEvent.UPDATE, update);
        stage.removeEventListener(TimerEvent.TIMER, count);

    } else if (drop) {

        x_mc.stop();
        o_mc.stop();

    } else if (x_mc.hitTestObject(exoHit_mc)) {
        score++;

    }







}


function checkHit(eeee: Event) {
    if (x_mc.hitTestObject(exeHit_mc)) {
        gotoAndStop(257);
        stage.removeEventListener(Event.ENTER_FRAME, checkHit);
        stage.removeEventListener(AccelerometerEvent.UPDATE, update);
        stage.removeEventListener(TimerEvent.TIMER, count);



    }
}

And this is the error :

[SWF] flash%20gmae.swf - 2013164 bytes after decompression
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at flashgmae_fla::MainTimeline/count()[flashgmae_fla.MainTimeline::frame179:91]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at flashgmae_fla::MainTimeline/count()[flashgmae_fla.MainTimeline::frame179:91]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at flashgmae_fla::MainTimeline/count()[flashgmae_fla.MainTimeline::frame179:79]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at flashgmae_fla::MainTimeline/count()[flashgmae_fla.MainTimeline::frame179:91]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at flashgmae_fla::MainTimeline/count()[flashgmae_fla.MainTimeline::frame179:79]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at flashgmae_fla::MainTimeline/count()[flashgmae_fla.MainTimeline::frame179:67]
    at flash.utils::Timer/_timerDispatch()
    at flash.utils::Timer/tick()
[UnloadSWF] flash%20gmae.swf
Test Movie terminated.

I have figured out that is has something to do with the x_mc and o_mc movie clips but I have no idea what the issue is as I am new to action script.

Thank you so much!

Samson
  • 21
  • 6
  • Just a guess: one of the objects your script refers to is not present (doesn't exist) at frame 179. Check your timeline(s). – Craig Oct 15 '14 at 04:14

1 Answers1

1

x_mc and o_mc are not present on the frames, or don't have an instance name set. Verify that both objects have the correct instance name set. After doing that, verify this for exoHit_mc and exeHit_mc as well.

Pimgd
  • 5,983
  • 1
  • 30
  • 45