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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:03:34+00:00 2026-05-13T07:03:34+00:00

I want to imitate the iPhone scroll behavior in a Flash app I am

  • 0

I want to imitate the iPhone scroll behavior in a Flash app I am developing. The idea is to enable drag-drop with a certain amount of inertia/deceleration (you know, when you drop something while your cursor is still moving and the thing would continue moving for a moment and then stop).

I am using the TweenMax library for my animations.

Any ideas will be appreciated.

Thanks

  • 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-13T07:03:35+00:00Added an answer on May 13, 2026 at 7:03 am

    When I recently created something like this, I simply listened for MOUSE_DOWN and MOUSE_UP, and whenever I reckoned that the mouse button was pressed (i.e. in-between those two events, also respecting Event.MOUSE_LEAVE) I would flag it as such, e.g. using a _mouseIsDown class-scope variable.

    Then I would have an ENTER_FRAME event handler, or a timer, that would behave differently depending on whether the button was pressed or not.

    When the mouse button is down, the ENTER_FRAME handler simply moves the target object to the new mouse position. It will also subtract the current mouse position from the previous one, to get a speed vector. Finally, it would log the current mouse position to allow the above to happen again the next frame.

    If the mouse button is released however, it will not just move the target object using a 1:1 mapping to the mouse position, but rather, move it according to the speed vector. It would also decrease the length of the speed vector each tick, until it’s close enough to zero for the entire system to be put into idle state to save up resources.

    A simplified solution would look like this, ignoring the setting and resetting of the mouseIsDown flag.

    private function _handleEnterFrame(ev : Event) : void
    {
      if (_mouseIsDown) {
        // Set speed here, but don't use it while mouse is pressed
        _speed.x = stage.mouseX - _prev_mouse_pos.x;
        _speed.y = stage.mouseY - _prev_mouse_pos.y;
    
        // Instead, just move target object accordingly
        _targetObject.x = stage.mouseX;
        _targetObject.y = stage.mouseY;
      }
      else {
        // Mouse is released, meaning that it has been tossed, so move
        // object according to speed vector, and decrease speed.
        _targetObject.x += _speed.x;
        _targetObject.y += _speed.y;
    
        _speed.x *= 0.8;
        _speed.y *= 0.8;
    
    
        // Negligible speed, so stop the processing to save resources
        if (_speed.length < 0.05) {
          this.removeEventListener(Event.ENTER_FRAME, _handleEnterFrame);
        }
      }
    
      _prev_mouse_pos.x = stage.mouseX;
      _prev_mouse_pos.y = stage.mouseY;
    }
    

    Obviously, you will need to start listening for the ENTER_FRAME event whenever the mouse is pressed. Also, you need to have the appropriate class-scope variables _prev_mouse_pos and _speed, both instances of flash.geom.Point, as well as the _targetObject which is whatever display object you wish to affect by dragging.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to imitate the behavior of the shuffle button in the iPod app
I want to imitate the Button in QML, but why does it only work
I want to imitate an anchor click when a user clicks on the containing
I want to imitate the following SOAP request using Zend Framework but I don't
How I can imitate transactions on objects. For example, I want to delete the
I want to create wrapper class, which will enable keys duplicates while default hash
When i learn MFC ,, I want to imitate some mechanism, here, i just
I'm currently designing an app for the iPhone and I'm deciding on some features
I want to set one specified live wallpaper for my device, so I imitate
I'm trying to imitate how gMail sticks the header to the top on scroll,

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.