mercredi 30 décembre 2015

Error 1119 : Access of possibly undefined property x through a reference with static type model:PlayerModel

I'm usually developping in Java but I need to do something in AIR (AS3), but I'm struggling with something that seems really stupid :

package model {
    import view.PlayerView;

    public class PlayerModel extends BasicModel implements UpdatableModel{

        private var view:PlayerView;

        public function PlayerModel(game:Game, initX:Number, initY:Number) {
            super(game, initX, initY);
            this.view = new PlayerView();
            this.game.addChild(this.view);
            this.view.x = initX;
            this.view.y = initY;
        }

        public function update() {
            if(view != null) {
                this.view.updatePosition(this.body.position.x, this.body.position.y);
            }
        }

    }

}

It doesn't want to compile with the error :

Line 13 1119: Access of possibly undefined property x through a reference with static type model:PlayerModel. Line 14 1119: Access of possibly undefined property y through a reference with static type model:PlayerModel.

I'm using Flash Pro CS5.5 and I auto-generated the Class PlayerView.as through the MovieClip (Export for ActionScript).

package view {

    import flash.display.MovieClip;


    public class PlayerView extends MovieClip {


        public function PlayerView() {
            super();
        }

        public function updatePosition(newX:Number, newY:Number) {
            this.x = newX;
            this.y = newY;
        }

        public function idle(){
            this.gotoAndStop("Idle");
        }

        public function walk(){
            this.gotoAndStop("Walking");
        }

    }

}

It also seems that I could have an error for the updatePosition method too ...

Thanks

Aucun commentaire:

Enregistrer un commentaire