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 7886223
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:15:54+00:00 2026-06-03T05:15:54+00:00

I’m working on a very simple first step of a project I’m doing: a

  • 0

I’m working on a very simple first step of a project I’m doing: a memory timeline. Basically, a timeline with years listed on them. It’s a line and you’re supposed to be able to move it horizontally to go to the year of your choosing, then add events and information.

Right now, I’m trying to implement that line, which I suppose is going to have to be infinitely wide, and the drag&drop functionality.

I’ve got something working but it’s bugged and I don’t see what’s going wrong. I’m not that experienced with Flash so I’m asking here.

This is the code. The stage is empty and there is no code on the timeline. Just this one Document class, created from the Properties:

package {

    import flash.geom.Rectangle;
    import flash.events.MouseEvent;
    import flash.display.Sprite;


    public class Document extends Sprite {

        // rootMc, global container
        public static var rootMc:Sprite = new Sprite();
        public var test:Sprite = new Sprite();

        public function Document() {
            test.graphics.beginFill(0x000000);
            test.graphics.drawRect(0, stage.stageHeight/2, 2000, 6);
            test.graphics.endFill();

            test.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
            test.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

            addChild(rootMc);
            rootMc.addChild(test);
        }

        function mouseDownHandler(evt:MouseEvent):void {
            trace("mouseDownHandler");
            var sprite:Sprite = Sprite(evt.target);
            sprite.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
                    //Limit the drag to a horizontal rectangle
            sprite.startDrag(false, new Rectangle(0, sprite.y, 2000, 0));
        }

        function mouseUpHandler(evt:MouseEvent):void {
            trace("mouseUpHandler");
            var sprite:Sprite = Sprite(evt.target);
            sprite.removeEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
            sprite.stopDrag();
        }

        private function mouseMoveHandler(evt:MouseEvent):void {
            trace("mouseMoveHandler");
            evt.updateAfterEvent();
        }
    }

}

The problems are:

  1. The drag&drop only works when I click exactly on the line. I’d like there to be some room above and below that I can also click. But the line must never move vertically, not a single pixel. I have no idea how to implement this right now.
  2. Related to the first problem: The mouseUpHandler will only be called if my cursor is on the line. If it’s off by even a pixel and I let go of the mouse button, the dragging will continue. I then have to move back on to the line, click down again and let go. I want to make it so that the dragging stops no matter where I let go of my mouse button. Or when the mouse leaves the stage.

This is probably just a lack of experience. I don’t know what functions exist to deal with this functionality. So I’m asking about that here. And at the same time it’s a chance to get some feedback on the code.

  • 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-06-03T05:15:55+00:00Added an answer on June 3, 2026 at 5:15 am

    Here is my advice to pin point your problems concerning the drag & drop.

    Problem 1:
    Just create an invisible container behind the black line, so that the ‘test’ MovieClip is made bigger. But only the black line will be visible. You can accomplish this by adding following code before the black line is drawn:

    test.graphics.beginFill(0xffffff,0); 
    // white container with 0 alpha
    test.graphics.drawRect(0, stage.stageHeight/2 - 10, 2000, 26); 
    // start 10px before and end 10 px after
    test.graphics.endFill();
    

    Problem 2:
    It would be better if you add the MouseEvent.MOUSE_UP eventlistener to the stage, and not to the ‘test’ MovieClip. Just use this:

    this.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am doing a simple coin flipping experiment for class that involves flipping a
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm working with an upstream system that sometimes sends me text destined for HTML/XML

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.