好的,我想通了。
我的问题是我试图在加速度计运动功能之外的自身功能中添加风运动功能。
解决方案:是将我的风代码移动到加速度计功能中:
ball.addEventListener(Event.ENTER_FRAME, moveBall);
function moveBall(evt:Event){
ball.x -= accelX*10;
ball.y += accelY*10;
if(ball.x > (480-ball.width/2)){
ball.x = 480-ball.width/2;
}
if(ball.x < (0+ball.width/2)){
ball.x = 0+ball.width/2;
}
if(ball.y > (800-ball.width/2)){
ball.y = 800-ball.width/2;
}
if(ball.y < (0+ball.width/2)){
ball.y = 0+ball.width/2;
}
// Wind Functions
//Wind Strength
if (this.Stage_Txt_Box.text == "1")
{WindStrength = int(2);}
if (this.Stage_Txt_Box.text == "2")
{WindStrength = int(3);}
if (this.Stage_Txt_Box.text == "3")
{WindStrength = int(4);}
if (this.Stage_Txt_Box.text == "4")
{WindStrength = int(5);}
if (this.Stage_Txt_Box.text == "5")
{WindStrength = int(6);}
if (this.Stage_Txt_Box.text == "6")
{WindStrength = int(7);}
if (this.Stage_Txt_Box.text == "7")
{WindStrength = int(8);}
if (this.Stage_Txt_Box.text == "8")
{WindStrength = int(9);}
//Wind Directions
trace(WindStrength);
if (windD == "left")
{ball.x -= WindStrength; trace("Wind is blowing left");}
if (windD == "right")
{ball.x += WindStrength; trace("Wind is blowing right");}
if (windD == "up")
{ball.y -= WindStrength; trace("Wind is blowing up");}
if (windD == "down")
{ball.y += WindStrength; trace("Wind is blowing down");}
}