A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: vCam unequal scrolling

Threaded View

  1. #1
    Registered User
    Join Date
    May 2012
    Posts
    1

    Unhappy vCam unequal scrolling

    Hi there everyone, this is my first post on the forum and I hope I am able to learn a lot while I'm here. Starting by fixing this bug I have been having.

    Actionscript Code:
    _root.currentMouseX = 275;
    _root.currentMouseY = 200;
    _root.lastMouseX = 275;
    _root.lastMouseY = 200;

    onEnterFrame = function(){
        _root.currentMouseX = _root._xmouse;
        _root.currentMouseY = _root._ymouse;
           
        xMouseDiffPos = (_root.currentMouseX - _root.lastMouseX)*0.4;
        xMouseDiffNeg = (_root.lastMouseX - _root.currentMouseX)*0.4;
       
        yMouseDiffPos = (_root.currentMouseY - _root.lastMouseY)*0.4;
        yMouseDiffNeg = (_root.lastMouseY - _root.currentMouseY)*0.4;
       
        if(_root.currentMouseX < _root.lastMouseX){
            _root.viewBox._x -= xMouseDiffNeg;
        }
       
        if(_root.currentMouseX > _root.lastMouseX){
            _root.viewBox._x += xMouseDiffPos;
        }
       
        if(_root.currentMouseY < _root.lastMouseY){
            _root.viewBox._y -= yMouseDiffNeg;
        }
       
        if(_root.currentMouseY > _root.lastMouseY){
            _root.viewBox._y += yMouseDiffPos;
        }
       
       
        _root.lastMouseX = _root._xmouse;
        _root.lastMouseY = _root._ymouse;
    }

    So in terms of mathematics, and the logic in my head, this code should work perfectly. The scene has a center point. When I place my mouse over the center point, I also want the vCam to be centered. However this is not the case. After moving the mouse around for 30 seconds or so, there is a noticable shift in placements.

    Unless I am missing something, each time I move the mouse away from the center, the amount moved by the vCam should be equaled when I move the mouse back.

    My explanations might not be perfectly clear so I will attach an example .fla.

    I appreciate all that can help with this problem, it has been bugging me for a while now.
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center