SamDeveloper
SamDeveloper

Reputation: 536

How to stop drag x in as3?

How to lock / stop drag .x? please help me. i want to make look like a scroll.

  sc_btn.addEventListener(MouseEvent.MOUSE_MOVE, fl_ClickToDrag_2);


    function fl_ClickToDrag_2(event:MouseEvent):void
    {
        sc_btn.startDrag();
    }
    stage.addEventListener(MouseEvent.MOUSE_UP, fl_ReleaseToDrop_2);

    function fl_ReleaseToDrop_2(event:MouseEvent):void
    {
        sc_btn.stopDrag();
    }

Thanks

Upvotes: 0

Views: 183

Answers (1)

Marty
Marty

Reputation: 39456

startDrag() accepts a Rectangle as its second argument, which you can set to be 1 pixel wide.

Parameters

lockCenter:Boolean (default = false) — Specifies whether the draggable sprite is locked to the center of the pointer position (true), or locked to the point where the user first clicked the sprite (false).

bounds:Rectangle (default = null) — Value relative to the coordinates of the Sprite's parent that specify a constraint rectangle for the Sprite.


Response to comment:

You can change your code to this:

sc_btn.startDrag(false, new Rectange(0, -1000, 1, 2000));

Upvotes: 3

Related Questions