TypeError:错误#1009(请帮忙?)

时间:2010-10-16 11:25:05

标签: flash

我是整个ActionScripting Thing的新手。 :(如果有人能尽可能简单地向我解释,我真的很感激。:D

当我点击进入另一个页面时,我一直收到以下错误。如果我做错了,请帮帮我。 ^^

  

TypeError:错误#1009:无法访问null的属性或方法   对象参考。在FlashDoc_fla :: MainTimeline / followBall_a()   TypeError:错误#1009:无法访问null的属性或方法   对象参考。在FlashDoc_fla :: MainTimeline / rotate_a()

代码如下......

stage.addEventListener(Event.ENTER_FRAME,rotate_a);
function rotate_a (e:Event){
 var theX:int = mouseX - eye_ball_icon.x;
 var theY:int = (mouseY - eye_ball_icon.y) * -1;
 var angle = Math.atan(theY/theX)/(Math.PI/180);
 if (theX<0) {
  angle += 180;
 }
 if (theX>=0 && theY<0) {
  angle += 360;
 }
 eye_text.text = angle;
 eye_ball_icon.rotation = (angle*-1) + 90;
}


stage.addEventListener(Event.ENTER_FRAME,followBall_a);
function followBall_a(event:Event):void {
 var dx:int = eye_ball_icon.x - mouseX;
 eye_ball_icon.x -= dx / 20;
 eye_ball_icon.y=530;

 if (eye_ball_icon.x < 150){eye_ball_icon.x = 150};
 if (eye_ball_icon.x > 850){eye_ball_icon.x = 850};
}


stop();
about_icon.addEventListener(MouseEvent.CLICK,iconpage);
function iconpage(event:MouseEvent) { gotoAndPlay(3); }

works_icon.addEventListener(MouseEvent.CLICK,workspage);
function workspage(event:MouseEvent) { gotoAndPlay(4); }

contact_icon.addEventListener(MouseEvent.CLICK,contactpage);
function contactpage(event:MouseEvent) { gotoAndPlay(5); }

1 个答案:

答案 0 :(得分:0)

试试这个rotate_a方法:

function rotate_a (e:Event){
if(currentFrame==1){
    var theX:int = mouseX - eye_ball_icon.x;
    var theY:int = (mouseY - eye_ball_icon.y) * -1;
    var angle = Math.atan(theY/theX)/(Math.PI/180);
    if (theX<0) {
        angle += 180;
    }

    if (theX>=0 && theY<0) {
        angle += 360;
    }
    eye_text.text = angle;
    eye_ball_icon.rotation = (angle*-1) + 90;
}}

在尝试对第1帧上的对象执行任何操作之前,它会检查您是否在第1帧。我假设您在第一帧中有此代码,并且eye_text和eye_ball_icon位于第一帧。