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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:32:06+00:00 2026-06-07T16:32:06+00:00

I have some problems with basic drag and drop scrolling algorithm. Here is my

  • 0

I have some problems with basic drag and drop scrolling algorithm. Here is my algorithm:

  1. When mouse pressed down i set boolean dragging = true and store the current mouse x and y position in stored_position variable.

  2. When mouse up i set boolean dragging = false.

  3. On each frame i check dragging == true and if it is i calculate the dx = current_mouse.x – stored_position.x and dy = current_mouse.x – stored_position.y. Then i store current mouse position as the new stored_position and scroll my view (it is 2d camera object) by this dx dy, as the Camera.x -= dx, Camera.y -= dy (i need the inversion one because of camera specific).

The problem with this algorithm is that when i drag the camera it starting to blink and move around/shake. I think it is because when i move my mouse from left to right it traces dx like this:

71
-67
69
-68
69
-68
8
-5

So i think it is the mouse twitching(i mean the mouse is jumps back sometimes when we try to draw a line). Any idea of changing algorithm, maybe i miss something?
Here is example of this problem: https://dl.dropbox.com/u/78904724/as_host/buld_build_other.rar (you need to run the index.html chose the level and try to drag the screen).

Updated
Here is the example full source link (this is the random picture, i swear): https://dl.dropbox.com/u/78904724/as_host/scroll_test.rar
And this is the code i used (in example i use native flash events instead of using axgl checks to not confuse someone, i have both examples and it cause the same problems):

        //variables with comments
        private var dragging:Boolean = false; //dragging flag
        private var current_mouse:Array; //stored mouse position array [0] - x, [1] - y
        private var d:Array; //dx dy array [0] - x, [1] - y

        [Embed(source = "test.jpg")] public static const _sprite:Class; //sprite graphics
        private var view_sprite:AxSprite; //some image on the stage to drag it

        //this is the class constructor code
            view_sprite = new AxSprite(0, 0, _sprite);
            add(view_sprite);

            current_mouse = new Array();
            d = new Array();

            Ax.stage2D.addEventListener(MouseEvent.MOUSE_DOWN, function(e:MouseEvent):void {                
                current_mouse[0] = Ax.mouse.x;
                current_mouse[1] = Ax.mouse.y;
                dragging = true;
            });
            Ax.stage2D.addEventListener(MouseEvent.MOUSE_UP, function(e:MouseEvent):void {
                dragging = false;
            });
            Ax.stage2D.addEventListener(MouseEvent.MOUSE_MOVE, function(e:MouseEvent):void {
                if (dragging) {                                 
                    d[0] = Ax.mouse.x - current_mouse[0]; 
                    d[1] = Ax.mouse.y - current_mouse[1];                       

                    Ax.camera.x -= d[0];
                    Ax.camera.y -= d[1];
                    current_mouse[0] = Ax.mouse.x;
                    current_mouse[1] = Ax.mouse.y;
                }
            });
  • 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-07T16:32:08+00:00Added an answer on June 7, 2026 at 4:32 pm

    I am totally confused but the problem was this two strings(thanks the axgl author for helping me):
    current_mouse[0] = Ax.mouse.x;
    current_mouse[1] = Ax.mouse.y;
    And when i remove them the dragging will work perfectly. But… I swear i tried this before and nothing gonna happed, camera just started to move faster without this and now… it works!
    Thank you all for trying to help my. If someone would have the similar problems here is the full worked source: https://dl.dropbox.com/u/78904724/as_host/scroll_test_worked.rar
    And this is the thread on axgl.org: http://axgl.org/forums/viewtopic.php?f=12&p=394

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

Sidebar

Related Questions

I'm new to WPF and still having some basic problems. I have a control
i have some problems with a Query seem IN dosen't work with Group_concat, that
I have some problems with Javascript. In fact, I'm just newbie in that script
I have some problems with header() function. It works and doesn't work at the
I have some problems with my first Open Graph custom action: I've created a
I have some problems sending mails through SMTP using Spring's MailSender interface and the
I have some problems with OpenCV s cvCanny(...) and the Image data types it
i have some problems with rowspan: var doc1 = new Document(); doc1.SetPageSize(PageSize.A4.Rotate()); string path
I have some problems sending an id though jquery. I have a form select
I have some problems with mod_rewrited at .httacess. We have created a website, the

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.