开发者

Faster Paint on Flex Mobile

开发者 https://www.devze.com 2023-04-06 22:11 出处:网络
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

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;


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.

0

精彩评论

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

关注公众号