0

I am trying to build an app that tracks touchpoints and draws circles at those points using Flash Builder. The following works perfectly, but after a while, it begins to lag and the touch will be well ahead of the drawn circles. Is there a way of drawing the circles that does not produce lag as more and more of them are added?

In declarations, I have:

    <fx:Component className="Circle">
        <s:Ellipse>
            <s:stroke>
                <s:SolidColorStroke alpha="0"/>
            </s:stroke>
        </s:Ellipse>
    </fx:Component>

And this is the drawing function:

            var c:Circle = new Circle();
            c.x = somex;
            c.y = somey;
            c.fill = new SolidColor(somecolorint);
            c.height = somesize;
            c.width = somesize;
            c.alpha = 1;
            addElement(c);
            c = null;
eqb
  • 1,650
  • 3
  • 20
  • 25
  • Do you want a trail of circles created, or do you just want a circle constantly under each touchpoint? – joshperry Sep 24 '11 at 01:32
  • I should add that I'm doing the paint on ontouchmove and ontouchbegin events, if that helps. – eqb Sep 24 '11 at 01:38

1 Answers1

0

Try taking a look at doing a fullscreen Bitmap created with a BitmapData class. As the touch points are moved, update the bitmap data at the coordinates where the touch occured. Modifying and blitting a screen-sized bitmap is extremely fast and will probably work great for what you're trying to do.

Another performance trade off often done is to make a series of lines instead of continuous circles. You create a new line segment only when a certain distance has been traveled, this lets you limit the number of nodes in the segment thereby keeping performance high.

joshperry
  • 41,167
  • 16
  • 88
  • 103
  • thank you! I'll read a bit more on bitmaps and get back to you with questions :) – eqb Sep 24 '11 at 04:29