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

  • Home
  • SEARCH
  • 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 369531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:55:44+00:00 2026-05-12T13:55:44+00:00

I am creating grid based map renderer in AS3 which loads required chunks of

  • 0

I am creating grid based map renderer in AS3 which loads required chunks of PNG images and render them in a container. I’ve applied scrolling/dragging logic in this app using MOUSE_MOVE event handler. What I do is,

I register bDragging flag in MOUSE_DOWN and position of mouse,
In every MOUSE_MOVE, I check displacement of mouse and move main map accordingly
Unregister bDragging flag in MOUSE_UP and set position to NaN.

My problem is dragging is quite jerky/shaky.

Any suggestion would be appreciated. following is sample code I’m using.

function onMouseDown(e:MouseEvent):void
{
     m_bDragging = true;
     m_ptPrevPoint = new Point(e.stageX, e.stageY);
}

function onMouseUp(e:MouseEvent):void
{
     m_bDragging = false;
     m_ptPrevPoint = null;
}
function onMouseMove(e:MouseEvent):void
{
    if(!m_bDragging || null == m_ptPrevPoint)
    return;

var nDiffX:Number = int(e.stageX - m_ptPrevPoint.x);
var nDiffY:Number = int(e.stageY - m_ptPrevPoint.y);

//Make movement smoother 
//nDiffX = nDiffX * 4) / 4;
//nDiffY = nDiffY * 4) / 4;

if(nDiffX != 0 || nDiffY != 0)
{
    trace("X : " + nDiffX + ", Y : " + nDiffY + ", points-Old " + m_ptPrevPoint + ", New " + new Point(e.stageX, e.stageY) );
    m_oCircle.x += nDiffX;
    m_oCircle.y += nDiffY;

    m_ptPrevPoint = new Point(e.stageX, e.stageY);

    e.updateAfterEvent();
}
else
    trace("not moved - X : " + nDiffX + ", Y : " + nDiffY+ ", points-Old " + m_ptPrevPoint + ", New " + new Point(e.stageX, e.stageY)) }

Please check FLA file here…made in Flash CS3. Please note if mouse is on circle it will jerk like hell but if you drag it from outside of circle, It will go smoother!

Sample FLA

  • 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-12T13:55:44+00:00Added an answer on May 12, 2026 at 1:55 pm

    Thanks guys, I figured out the problem!

    actually this might be some bug of adobe, I was strangely getting some odd coordinates and that was the reason movement was not smooth. I converted stageX and stageY using localToGlobal and everything became smoother!!!

    now, I dont know why should I be needed to convert stageX/stageY to global. 🙂 my brief changes are as below.

    var curPt:Point = DisplayObject(e.currentTarget).localToGlobal(new Point(e.stageX, e.stageY));

    var nDiffX:Number = int(curPt.x – m_ptPrevPoint.x);

    var nDiffY:Number = int(curPt.y – m_ptPrevPoint.y);

    Thanks guys, every help appreciated.

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

Sidebar

Ask A Question

Stats

  • Questions 466k
  • Answers 466k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm guessing you want the feedback functionality. May 16, 2026 at 1:45 am
  • Editorial Team
    Editorial Team added an answer TL;DR #!/bin/bash cd "$(dirname "$0")" The long winded explanation How… May 16, 2026 at 1:45 am
  • Editorial Team
    Editorial Team added an answer You are getting the Forbidden error because you are setting… May 16, 2026 at 1:45 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.