开发者

Actionscript - Heart-rate monitor with the drawing API?

Good evening all. I've got a movieclip which monitors and graphs the level of activity coming in, like a heart-rate monitor at the hospital. The graph scrolls the data off the screen, but the movieclip is never cleared, and the off-screen data builds up indefinitely. The longer the user stays on the page, the more memory the un-seen part of the graph takes.

What's the best way to clean up the unseen part of the movieclip?

The code is as follows:

this.stage.addEventListener(flash.events.Event.ENTER_FRAME,
  function(event){
    var dif = md.getDifferences();
    meter.graphics.lineTo(xpos,dif);
    meter.graphics.moveTo(xpos,dif);
    if(xpos>WIDTH){
    // once the graph exceeds the width of the clip, the graph scrolls off开发者_运维问答 the screen
      meter.x -= 1;
    }
    xpos ++;
  }
);


This is how I'd do it:

  1. Store the coordinates that are visible on the screen in an array,
  2. DisplayObject.graphics.clear();
  3. Redraw the graph with the visible area only.

Hope it helps. Rob

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜