Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4599012
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:28:49+00:00 2026-05-21T23:28:49+00:00

I would like to drag an object in one line. I already know how

  • 0

I would like to drag an object in one line.
I already know how to do this in a horizontal or vertical line

Here’s how I do this

private var handle:Sprite;

private function init():void
{
    handle = new Sprite();
    handle.mouseChildren = false;
    handle.buttonMode = true;
    handle.graphics.beginFill(0xFF0000);
    handle.graphics.drawCircle(0, 0, 5);

    handle.addEventListener(MouseEvent.MOUSE_DOWN, startMove);
    handle.addEventListener(MouseEvent.MOUSE_UP, stopMove); 
}

private function startMove(evt:MouseEvent):void
{               

    var bounds:Rectangle = new Rectangle(0, 0, 100, 1);
    handle.startDrag(false, bounds);

}

private function stopMove(evt:MouseEvent):void
{
    handle.stopDrag();
}

But I want do drag my object in a line that isn’t horizontal or vertical.
For example, I would like to drag the object from the top left corner to the bottom right corner, in one straight line.

I tried to rotate the bounds rectangle, but it seems that you can not rotate a Rectangle.

How do I drag an object in a non-vertical (or non-horizontal) line?

Thank you very much!

Vincent

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T23:28:51+00:00Added an answer on May 21, 2026 at 11:28 pm

    You cannot use startdrag system to do it. You have to use an enterframe event and constraint x/y yourself :

    package
    {
        import flash.display.Sprite;
        import flash.events.Event;
        import flash.events.MouseEvent;
    
        public class Test extends Sprite
        {
            private var handle:Sprite;
    
            public function Test()
            {
                handle = new Sprite();
                addChild(handle);
                handle.mouseChildren = false;
                handle.buttonMode = true;
                handle.graphics.beginFill(0xFF0000);
                handle.graphics.drawCircle(0, 0, 5);
    
                handle.addEventListener(MouseEvent.MOUSE_DOWN, startMove);
                addEventListener(MouseEvent.MOUSE_UP, stopMove); 
            }
    
            private function startMove(evt:MouseEvent):void
            {
                stage.addEventListener(Event.ENTER_FRAME, updateClipPos);
            }
    
            private function stopMove(evt:MouseEvent):void
            {
                stage.removeEventListener(Event.ENTER_FRAME, updateClipPos);
            }
    
            private function updateClipPos(e:Event) : void
            {
                if(mouseX < 100)
                {
                    handle.x = mouseX;
                    handle.y = handle.x;
                }
            }
    
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to drag and drop my data file onto a Python script
I would like to implement some Drag-select functionality into a project of mine but
I would like to allow the user to click within my UserControl and drag
How would I drag and drop something into a static control? It looks like
Would like to know what a programmer should know to become a good at
Would like to know the c# code to actually retrieve the IP type: Static
I would like to know if there is a way to move the node
I would like to drag and drop files from windows explorer onto my application
I'd like to send an action to another object using cocoa. Ideally i would
I know how to drag a view or object: - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.