[ascoders] Re: AW: Re: Drawing API

  • From: Timo Stamm <t.stamm@xxxxxxxxxx>
  • To: ascoders@xxxxxxxxxxxxx
  • Date: Sat, 09 Oct 2004 15:35:25 +0200

Alex Uhlmann wrote:
> Du brauchst also ein Wrapper Objekt, dass auf EnterFrame events immer
> eine Linien mehr zeichnet.

>>wie meinst du das?

Äh... so in etwa meine ich das:


function PolygonClass (stageMC, pointsArray) { points = pointsArray; stage = stageMC; }

p = PolygonClass.prototype;

p.draw = function (lineStyle, fill) { // draw as usual
  stage.lineStyle(lineStyle);
  stage.beginFill(fill);
  for (var i=0; i<points.length; i++) {
    stage.moveTo( points[i].x, points[i].y );
  }
  stage.moveTo( points[0].x, points[0].y );
  stage.endFill();
}

p.drawAnimated () { // draw one line per frame
  framePos = 0;
  stage.onEnterFrame = function () {
    listener.onE();
  };
  stage.listener = this;
}

p.onE = function () {
  stage.clear();

  if (framePos++ == points.length) {
    this.draw();
    stage.listener = undefined;
  } else {
    stage.lineStyle(lineStyle);
    for (var i=0; i<framePos; i++) {
      stage.moveTo( points[i].x, points[i].y );
    }
  }
};

delete p;


HTH, Timo ------------------------------------------------------ Archiv : //www.freelists.org/archives/ascoders/ Optionen : //www.freelists.org/list/ascoders ------------------------------------------------------

Other related posts: