开发者

Dragging sprite leaves trails

开发者 https://www.devze.com 2023-03-31 00:44 出处:网络
I have a simple AS class: package Bubbles { import flash.display.Sprite; import flash.events.MouseEvent;

I have a simple AS class:

package Bubbles 
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.display.LineScaleMode;
    import flash.display.CapsStyle;
    import flash.display.JointStyle;

    public class Test extends Sprite
    {
        public function Test()
        {
            var g = graphics;

            g.lineStyle(12, 0xEEEEFF, 1.0, true, LineScaleMode.NONE, CapsStyle.NONE, JointStyle.MITER);
            g.drawRoundRect(0, 0, 60, 60, 10, 10);

            addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
            addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
        }

        private function onMouseDown(e:MouseEvent)
        {
            startDrag();
        }

        private function onMouseUp(e:MouseEvent)
        {
            stopDrag();
        }
    }
}

is added used in class set as stage's class in Event.ADDED_TO_STAGE handler:

            var t = new Test();
            t.x = 20;
            t.y = 20;
            addChild(t);

Now when I start the application both in browser or in flash player and start to drag the object I see trails like on the image:

Dragging sprite leaves trails

Stage only has that green rectangle on it. If I remove it nothing changes. If I change line thickness to 6 trails does not appear, at 7 and higher they appear. You can check SWF here: http://hg.n0rd.com/bubbles.htm开发者_如何学Gol. How do I make it work correctly?

Update: If I change that rectangle shape to something star-like with sharp angles, trails appear even on lower thickness values (trails appear when thickness == 3 or more).


got it to work with

graphics.lineStyle(12, 0xEEEEFF, 1.0, true, LineScaleMode.NORMAL, CapsStyle.NONE, JointStyle.MITER);

I changed LineScaleMode.NONE to LineScaleMode.NORMAL.

Hopefully you don't have to set that?


You are not redrawing the background at each draw. Because of that, the item border stays drawn on the background when it is not overwritten by the next draw.

0

精彩评论

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