views:

47

answers:

2

the AS2 code is:

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

MovieClip.prototype.drawModel = drawModel;

I tried:

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;
        }

    }
}

but there is no "this.model" nither "drawModel(m)" in MovieClip.

Any idea?

A: 

You have define model and drawModel. I only see setModel and setDrawModel and no variables.

So if you add following inside the class:

private var model:type;

Then your this.model will work.

Billy
But somehing is wrong, becouse this way the model have no use. No other part of the code uses it. But in the AS2 code it exists inside MovieClip and I need set it to work.
Tom Brito
ok, found: in this snipet the model actually don't need to exist..
Tom Brito
A: 
 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...
    }
 }

Then in another class , you can do this

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