n0rd
n0rd

Reputation: 12640

Dragging sprite leaves trails

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: 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.html. 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).

Upvotes: 0

Views: 365

Answers (2)

Malz
Malz

Reputation: 173

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?

Upvotes: 1

Clement Bellot
Clement Bellot

Reputation: 841

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.

Upvotes: 0

Related Questions