2015-11-03 138 views
0

我正在使用基本运动引擎上的ActionScript3.0。当我尝试测试我的代码,我得到这个错误:语法错误:期待结束之前的rightparen

MovementClass.as, Line 44, Column 22 1084: Syntax error: expecting rightparen before colon. 

我得到这个为线44,52,60,和下面的代码68;这些行是heroGoing < 方向>(e:TimerEvent);

package { 
import flash.display.*; 
import flash.display.MovieClip; 
import flash.events.Event; 
import flash.events.KeyboardEvent; 
import flash.ui.Keyboard; 
import flash.utils.Timer; 
import flash.events.TimerEvent; 
import flash.events.TimerEvent; 


public class MovementClass extends MovieClip { 
    var reference:Reference = new Reference(); 
    var hero:Hero = new Hero(); 
    var enemy:Enemy = new Enemy(); 
    var wall:Wall = new Wall(); 

    //Timer 
    var moveTimer:Timer = new Timer(25, 10) 

    //Booleans 
    var movingHeroRight:Boolean = false; 
    var movingHeroLeft:Boolean = false; 
    var movingHeroUp:Boolean = false; 
    var movingHeroDown:Boolean = false; 

    public function MovementClass() { 
     hero.x = stage.stageWidth * .5; 
     hero.y = stage.stageHeight * .5; 
     addChild(hero); 
     startEngine(); 
    } 

    public function startEngine():void { 
     stage.addEventListener(KeyboardEvent.KEY_DOWN, movementHandler); 
     stage.addEventListener(KeyboardEvent.KEY_UP, stopHandler); 
    } 

    public function movementHandler(keyDown:KeyboardEvent):void { 
     if (keyDown.keyCode == 39) { 
      if (movingHeroLeft == true, movingHeroUp == true, movingHeroDown == true) { 
       return; 
      } else { 
       heroGoingRight(e:TimerEvent); 
       movingHeroRight = true; 
       moveTimer.start; 
      } 
     } else if (keyDown.keyCode == 37) { 
      if (movingHeroRight == true, movingHeroUp == true, movingHeroDown == true) { 
       return; 
      } else { 
       heroGoingLeft(e:TimerEvent); 
       movingHeroLeft = true; 
       moveTimer.start; 
      } 
     } else if (keyDown.keyCode == 38) { 
      if (movingHeroLeft == true, movingHeroRight == true, movingHeroDown == true) { 
       return; 
      } else { 
       heroGoingUp(e:TimerEvent); 
       movingHeroUp = true; 
       moveTimer.start; 
      } 
     } else if (keyDown.keyCode == 40) { 
      if (movingHeroLeft == true, movingHeroUp == true, movingHeroRight == true) { 
       return; 
      } else { 
       heroGoingDown(e:TimerEvent); 
       movingHeroDown = true; 
       moveTimer.start; 
      } 
     } 
     //moveTimer.start(); 
    } 

    function heroGoingUp(eUp:TimerEvent):void { 
     if (movingHeroUp == true) { 
      reference.y += 5; 
     } 
    } 

    function heroGoingDown(eDown:TimerEvent):void { 
     if (movingHeroDown == true) { 
      reference.y -= 5; 
     } 
    } 

    function heroGoingLeft(eLeft:TimerEvent):void { 
     if (movingHeroLeft == true) { 
      reference.x += 5; 
     } 
    } 

    function heroGoingRight(eRight:TimerEvent):void { 
     if (movingHeroRight == true) { 
      reference.x -= 5; 
     } 
    } 

    public function stopHandler(keyUp:KeyboardEvent):void { 
     if (movingHeroRight == true) { 
      movingHeroRight = false; 
     } else if (movingHeroLeft == true) { 
      movingHeroLeft = false; 
     } else if (movingHeroUp == true) { 
      movingHeroUp = false; 
     } else if (movingHeroDown == true) { 
      movingHeroDown = false; 
     } 
    } 
} 
} 

我在做什么错?

+0

如果您将行号添加到代码中,将会很好。 – agabrys

+1

更好的是,使用您正在使用的语言标记您的帖子。如果发布版本很重要(例如python2,而不是python),那就要特别注意。 – Prune

+0

改进的代码和消息格式。做了轻微的措辞更新。添加C++标签 – Prune

回答

1

问题是与第一heroMoving电话:

  heroGoingRight(e:TimerEvent); 

编译器认为你想在原地来声明一个变量。声明e:TimerEvent适当,之前你使用它,你应该没问题。

相关问题