Hi everybody,
I got stuck again so I hope somebody can/will help me out.
I am using the following movement mode for krpano (I found this in another thread):
var mx:Number = _cursor.x;
var my:Number = _cursor.y;
var sx:Number = stage.stageWidth * 0.5;
var sy:Number = stage.stageHeight * 0.5;
// calc motion vectors: -1.0 to +1.0
var vx:Number = (mx - sx) / sx;
var vy:Number = (my - sy) / sy;
if(vx > -0.5 && vx < 0.5 && vy > -0.5 && vy < 0.5) {
// middle area - normal control
updateViewMoveForce(0, 0);
}
else {
// outer area - automatic followmouse movement
vx = 2.0 * (vx < 0 ? -1.0 : +1.0) * (Math.max(Math.abs(vx),0.5) - 0.5);
vy = 2.0 * (vy < 0 ? -1.0 : +1.0) * (Math.max(Math.abs(vy),0.5) - 0.5);
// stop very slow moving
if (Math.abs(vx) < 0.01) vx = 0;
if (Math.abs(vy) < 0.01) vy = 0;
// set move forces
updateViewMoveForce(vx, vy);
}
Display More
public function updateViewMoveForce(hLookAtForce:Number, vLookAtForce:Number):void {
_krpano.set("hlookat_moveforce", hLookAtForce);
_krpano.set("vlookat_moveforce", vLookAtForce);
}
Works nice. However there is one problem: Once a hotspot is clicked, I would like to completely stop the movement and make a "lookto". The lookto works fine but I am unable to stop the movement completely which results that after the lookto completes, the pano moves a bit still and gets out of the position. So once again the steps to reproduce this would be:
1. put cursor to a position where you can move the pano -> pano begins to rotate/move
2. if the cursor gets over a hotspot, click it (while pano still moving)
3. that triggers a lookto, which works fine and indeed the pano "looks to" where it should
4. ... but as it was moving before the lookto(), after the lookto it still moves a bit which brings it out of the position.
This is my lookto function:
public function lookTo(ath:Number, atv:Number):void {
updateViewMoveForce(0, 0);
_krpano.call("stoplookto()");
_krpano.set("mylooktocallback", callback);
_krpano.call("lookto("+ath+", "+atv+", 70, smooth(180, -180, 360), true, true, mylooktocallback() )");
function callback() {
dispatchEvent(new Event(MOVE_COMPLETE));
}
}
Is there anything I can do to completely stop the rotation? Setting 0, 0 for the forces obviously does not make the trick as it just "tweens it out". Please note that before I call the lookTo the work forces are not updated on enter frame anymore so the only updateViewMoveForce() called is inside the lookTo() function. Thanks a lot!