代码之家  ›  专栏  ›  技术社区  ›  Student

如何将此AS2调整为AS3?

  •  0
  • Student  · 技术社区  · 16 年前

    AS2代码为:

    MovieClip.prototype.setModel = function(m)
    {
        this.model = m;
        this.drawModel(m);
    }
    
    MovieClip.prototype.drawModel = drawModel;
    

    package
    {
        import flash.display.MovieClip;
    
        public class Prototype extends MovieClip
        {
            public function Prototype()
            {
                super();
            }
    
            public function setModel(m)
            {
                this.model = m;
                this.drawModel(m);
            }
    
            public function setDrawModel(m)
            {
                this.drawModel = m;
            }
    
        }
    }
    

    但是,没有this.modelMovieClip中的“尼特”drawModel(m)。

    你知道吗?

    2 回复  |  直到 16 年前
        1
  •  0
  •   Billy    16 年前

    您有define model和drawModel。我只看到setModel和setDrawModel,没有变量。

    因此,如果在类中添加以下内容:

    然后你的this.model 会有用的。

        2
  •  0
  •   PatrickS    16 年前
     public class Whatever extends MovieClip
     {
        private var _model:DisplayObject;
    
        public function set model(m:Object):void
        {
           this._model = m;
           this.drawModel();
        }
    
        private function drawModel():void
        { 
            _model.graphics.beginFill(0); //etc...
        }
     }
    

     var whatever:Whatever = new Whatever();
     whatever.model = new DisplayObject();