如何在flash as3中修复错误1009

时间:2015-06-24 14:37:18

标签: actionscript-3 flash flash-cc

嗨我一直试图通过在网上搜索几个小时并且没有运气来解决这个问题所以所有的帮助都很受欢迎(它发生在我放雪的时候) 在此先感谢

这是我的代码:

Quit.addEventListener(MouseEvent.CLICK, func22);

function func22(event:MouseEvent):void
{
    gotoAndStop(2);
    myTimer3.stop(); myTimer3.removeEventListener(TimerEvent.TIMER, timerListener3);
    myTimer4.stop(); myTimer4.removeEventListener(TimerEvent.TIMER, timerListener4);
}

Help.addEventListener(MouseEvent.CLICK, func33);

function func33(event:MouseEvent):void
{
    gotoAndStop(23);
    myTimer3.stop(); myTimer3.removeEventListener(TimerEvent.TIMER, timerListener3);
    myTimer4.stop(); myTimer4.removeEventListener(TimerEvent.TIMER, timerListener4);
}

var myTimer3:Timer = new Timer(2000,0);
myTimer3.addEventListener(TimerEvent.TIMER, timerListener3);
function timerListener3(e:TimerEvent):void {
Hungry_bar.scaleX-=0.05;
if(Hungry_bar.scaleX<=0.05){
        gotoAndStop(12)
        myTimer3.stop(); myTimer3.removeEventListener(TimerEvent.TIMER, timerListener);
        myTimer4.stop(); myTimer4.removeEventListener(TimerEvent.TIMER, timerListener);
    }
}
myTimer3.start();

var myTimer4:Timer = new Timer(3000,0);
myTimer4.addEventListener(TimerEvent.TIMER, timerListener4);
function timerListener4(e:TimerEvent):void {
Fun_bar.scaleX-=0.05;
if(Fun_bar.scaleX<=0.05){
        gotoAndStop(13)
        myTimer3.stop(); myTimer3.removeEventListener(TimerEvent.TIMER, timerListener3);
        myTimer4.stop(); myTimer4.removeEventListener(TimerEvent.TIMER, timerListener4);
    }
}
myTimer4.start();

Feed.addEventListener(MouseEvent.CLICK,feed2)
function feed2(e:MouseEvent){
Hungry_bar.scaleX+=0.05
if(Hungry_bar.scaleX>=1.5){
    gotoAndStop(14)
    myTimer3.stop(); myTimer3.removeEventListener(TimerEvent.TIMER, timerListener3);
    myTimer4.stop(); myTimer4.removeEventListener(TimerEvent.TIMER, timerListener4);
    }
}

Fun.addEventListener(MouseEvent.CLICK,happy2)
function happy2(e:MouseEvent){
    Fun_bar.scaleX+=0.05
    if(Fun_bar.scaleX>=1.5){
    gotoAndStop(15)
    myTimer3.stop(); myTimer3.removeEventListener(TimerEvent.TIMER, timerListener);
    myTimer4.stop(); myTimer4.removeEventListener(TimerEvent.TIMER, timerListener);
    }
}

//snow

var snowflakes:Array = new Array();
var snowflakeProps:Dictionary= new Dictionary(true);
var max_snowsize:Number = .04;
// pixels
var snowflakesCnt:Number = 150;
var oheight:Number;
var owidth:Number;
init();
function init():void {

    owidth = width;
    oheight = height;
    // quantity
    for (var i:int=0; i<snowflakesCnt; i++) {

    var t:MovieClip = new SnowFlake();//
    t.name = "snowflake"+i;

    t.alpha = .2+Math.random()*.6;
    t.x = -(owidth/2)+Math.random()*(1.5*owidth);
    t.y = -(oheight/2)+Math.random()*(1.5*oheight);
    t.scaleX = t.scaleY=.5+Math.random()*(max_snowsize*10);
    var o:Object = new Object();
    o.k = 1+Math.random()*2;
    o.wind = -1.5+Math.random()*(1.4*3);

    snowflakeProps[t] = o;

    addChild(t);
    snowflakes.push(t);
}
addEventListener(Event.ENTER_FRAME, snowFlakeMover);
}
function shakeUp():void{
for (var i:int=0; i<snowflakes.length; i++) {
    var t:MovieClip = snowflakes[i] as MovieClip;
    t.x = -(owidth/2)+Math.random()*(1.5*owidth);
    t.y = -(oheight/2)+Math.random()*(1.5*oheight);
    }
}
function snowFlakeMover(evt:Event):void {
var dO:MovieClip;
var o :Object;
if(visible && parent.visible){
for (var i:int = 0; i < snowflakes.length; i++) {
    dO = snowflakes[i] as MovieClip;
    o = snowflakeProps[dO];
    dO.y += o.k;
    dO.x += o.wind;
    if (dO.y>oheight+10) {

        dO.y = -20;

    }
    if (dO.x>owidth+20) {

        dO.x = -(owidth/2)+Math.random()*(1.5*owidth);
        dO.y = -20;

    } else if (dO.x<-20) {

        dO.x= -(owidth/2)+Math.random()*(1.5*owidth);
        dO.y = -20;
    }

}
}
}

这是错误:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at petgamewithweather_fla::MainTimeline/frame2()[petgamewithweather_fla.MainTimeline::frame2:9]
at flash.display::MovieClip/gotoAndStop()
at petgamewithweather_fla::MainTimeline/func22()[petgamewithweather_fla.MainTimeline::frame16:5]

0 个答案:

没有答案