2010-10-16 71 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在第一幀上。