vendredi 21 avril 2017

AS3 Classes Public Atributte

I am getting an error whenever I try running the game. I get errors for every class saying that the public attribute can only be used inside a package and on this line with "private function moveMe" "the private attribute may only be used on class functions". I verified if I have the as file linked properly. I am not sure what the issue is.

package  {
        import flash.display.MovieClip;
        import flash.utils.Timer;
        import flash.events.TimerEvent;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.events.Event;

        public class banana_fall extends MovieClip {

            public function banana_fall (){
            var velX:Number=0;
            var velY:Number=0;
            var falling:Boolean=false;
            var gravity:Number=2;


                public function banana() {
                var timing:Timer = new Timer(20,0);
                timing.addEventListener(TimerEvent.TIMER,moveMe);
                timing.start();

                }

                private function moveMe(event:TimerEvent){
                this.x=this.x+velX;
                this.y=this.y+velY;

                if (falling) {
                    velY=velY+gravity;
                }
            }

                public function setSpot(atX,atY){
                this.x=atX;
                this.y=atY;
            }

            //
            public function setSpeed(dx,dy){
                velX=dx;
                velY=dy;
            }

                }

        }

    }

Aucun commentaire:

Enregistrer un commentaire