我在代码中遗漏了什么

时间:2014-04-14 18:40:33

标签: flash-cs6

嗨mi sorta这是一个全新的代码,所以代码非常简单我也不是很熟练的编码,所以如果有人有答案,请用最愚蠢的语言说话,你可以为我的利益感谢sooooo很多< / p>

问题是它一直告诉我在分号之前期待分号并且在分号之前预期标识符任何想法?

package  
{

    import flash.display.*;
    import flash.events.*;
    import flash.ui.*;



    public class Assignment2 extends MovieClip 
    {


        public function Assignment2() 
        public var character:Miner; 
        public var LEFT:Boolean;
        public var RIGHT:Boolean;
        public var APRESSED:Boolean;
        public var powerup:Boolean;

        {
            character = new Miner();
            addChild(character);    

            character.x = 150;      
            character.y = 150;      

            character.stop();

            addEventListener(Event.ENTER_FRAME,onEnter);
            stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyPress);
            stage.addEventListener(KeyboardEvent.KEY_UP,onKeyRelease);
        }

        public function onEnter(e:Event)
        {
            //handle the animation of the game
            if(LEFT)
            {
                //do something for the left press
                character.x += -3
                character.gotoAndStop("walk");

                if(character.scaleX > 0)
                {
                    character.scaleX = -character.scaleX;   
                } 

            }

            if(RIGHT)
            {
                //do something for the right press
                character.x += 3
                character.gotoAndStop("walk");

                if(character.scaleX < 0)
                {
                    character.scaleX = -character.scaleX;   
                } 
            }

            if(APRESSED)
            {
                attacking = true;
            }

            if(powerup)
            {
                character.gotoAndStop("powerup");

                if(character.powerup.currentFrame == character.attack_mc.totalFrames)
                {
                    powerup = false;
                }
            }

            if(!LEFT && !RIGHT && !powerup)
            {
                character.gotoAndStop("idle");
            }
        }

        public function onKeyPress(e:KeyboardEvent)
        {
            switch(e.keyCode)
            {
                case Keyboard.LEFT:
                    LEFT = true;
                    break;
                case Keyboard.RIGHT:
                    RIGHT = true;
                    break;
                case Keyboard.A:
                    APRESSED = true;
                    break;

            }
        }

        public function onKeyRelease(e:KeyboardEvent)
        {
            switch(e.keyCode)
            {
                case Keyboard.LEFT:
                    LEFT = false;
                    break;
                case Keyboard.RIGHT:
                    RIGHT = false;
                    break;
                case Keyboard.A:
                    APRESSED = false;
                    break;
            }
        }
    }
}

0 个答案:

没有答案