2010-10-16 68 views
-1

我是新的ActionScripting Thing。 :(所以,我真的很感激,如果有人可以给我尽可能简单地解释:。dTypeError:Error#1009(Help Please?)

我不断收到下面当我点击到另一个网页错误请帮我,如果我做错了什么。^^

类型错误:错误#1009:在FlashDoc_fla无法访问空对象引用的属性或方法 :: MainTimeline/followBall_a() 类型错误:错误#1009:无法访问的属性或方法空对象参考 at FlashDoc_fla :: MainTimeline/rotate_a()

代码如下...

stage.addEventListener(Event.ENTER_FRAME,rotate_a);函数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); (theX < 0)角度+ = 180; } if(the X> = 0 & & theY < 0)角度+ = 360°; } eye_text.text = angle; eye_ball_icon.rotation =(angle * -1)+ 90; }

stage.addEventListener(Event.ENTER_FRAME,followBall_a); 函数followBall_a(事件:事件):void var dx:int = eye_ball_icon.x - mouseX; eye_ball_icon.x - = dx/20; eye_ball_icon.y = 530;

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

停止(); 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); }

回答

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在第一帧上。