Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 05-18-2012, 01:07 PM   #1
Gdizzie
Registered User
 
Join Date: May 2012
Posts: 2
Default vCam unequal scrolling/panning

Hi everyone, my first post on the forums and I really appreciate anybody's help with this problem.

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; }

The vCam is called viewBox. 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.

It seems the Pos values on both axis' are not strong enough or the Neg values are too strong, therefore creating an imbalance. I've tried different multiply values but i can't seem to get it perfect, and it should work with the same values anyway.

My explanations might not be perfectly clear so I've uploaded an example .fla file and I'd be happy to PM anybody with the link (seeing as I'm a new user)

I appreciate all that can help with this problem, it seems so simple yet gives me headaches
Gdizzie is offline   Reply With Quote
Old 05-22-2012, 03:01 PM   #2
Gdizzie
Registered User
 
Join Date: May 2012
Posts: 2
Default

So, I've found a workaround, changing some code already posted on another forum. Here it is just for reference.

ActionScript Code:
var vx:Number = 0; var vy:Number = 0; var ax:Number = 0; var ay:Number = 0; onEnterFrame = function(){             ax = 0.4*(_root._xmouse-_root.viewBox._x)+165     ay = 0.4*(_root._ymouse-_root.viewBox._y)+120     _root.viewBox._x = vx += ax;     _root.viewBox._y = vy += ay;     vx *= 0.4;     vy *= 0.4; }
Gdizzie is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 07:14 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.