错误1009 Actionscript Flash CC

时间:2014-10-15 02:42:15

标签: actionscript-3 flash timer movieclip

所以我一直试图弄清楚过去两个小时的这个错误,我已经尝试研究整个互联网的答案,到目前为止我还没弄清楚。

有人能够帮助我吗!这是我的代码:

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



    }
}

这就是错误:

[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.

我已经发现这与x_mc和o_mc影片剪辑有关,但我不知道问题是什么,因为我是动作脚本的新手。

非常感谢你!

1 个答案:

答案 0 :(得分:1)

框架上不存在

x_mco_mc,或者没有设置实例名称。验证两个对象是否都设置了正确的实例名称。完成此操作后,请同时对exoHit_mcexeHit_mc进行验证。