Results 1 to 15 of 43
-
May 2nd, 2009, 10:50 PM #165Registered User
postsMovie image in opposite direction
Does anyone know the algorithm used in this image panner
http://flashden.net/item/image-viewer/8883
How to move the image in the opposite direction of mouse.
-
May 3rd, 2009, 12:43 AM #2238Registered User
postssomething like that would probably do the trickCode:var img:Sprite; //zoomed image stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove); function onMove(m:MouseEvent) : void { var mx:Number = stage.mouseX; var my:Number = stage.mouseY; var dx:Number = mx - tempx; var dy:Number = my - tempy; tempx = mx; tempy = my; if( (mx > 0) && (mx < img.width) ) img.x -= dx; if( (my > 0) && (my < img.height) ) img.y -= dy; }
-
May 3rd, 2009, 12:46 AM #3238Registered User
posts^^forgot to declare tempx and tempy, oops
-
May 3rd, 2009, 12:49 AM #465Registered User
postsWould tempx and tempy just be a number?
I tried that math out and it just makes it disappears. Its probably off the stages viewing area.Last edited by waverider303; May 3rd, 2009 at 12:54 AM.
-
May 3rd, 2009, 12:58 AM #5238Registered User
poststry this?
var img:Sprite; //zoomed image
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
function onMove(m:MouseEvent) : void {
var mx:Number = stage.mouseX;
var my:Number = stage.mouseY;
var dx:Number = ( (mx – tempx) > 1) ? 1: -1;
var dy:Number = ( (my – tempy) > 1) ? 1: -1;
tempx = mx;
tempy = my;
if( (mx > 0) && (mx < img.width) ) img.x -= dx;
if( (my > 0) && (my < img.height) ) img.y -= dy;
}
-
May 3rd, 2009, 01:06 AM #665Registered User
postsvar dx:Number = ( (mx – tempx) > 1) ? 1: -1;IS this AS3? why does the if statement not have { }. What is the ? for in the statement?if( (mx > 0) && (mx < img.width) ) img.x -= dx;
-
May 3rd, 2009, 01:12 AM #7238Registered User
postsyeah it's as3.
in an if statement, you don't need the braces if there is only one line. if i needed to do something else besides just "img.x -= dx" i would have to use braces.
the ? is a conditional operator. it's basically an if/then statement all in one line. it's a little faster, but really just more elegant.
is equivalent to:Code:var dx:Number = ( (mx - tempx) > 1) ? 1: -1;
so really it's just a space saverCode:var dx:Number; if( (mx-tempx) > 1){ dx = 1; }else{ dx = -1; }
-
May 3rd, 2009, 01:16 AM #865Registered User
postsOk a gave it a try it is moving in the right place. One problem is it only moves to the right it wont come back to the left. Would it be an anchor point problem? I currently have it in the middle.
-
May 3rd, 2009, 01:21 AM #9238Registered User
postsedit: yes it should be anchored at top left
-
May 3rd, 2009, 01:22 AM #1065Registered User
postshave you given this math a try?
It only moves towards the bottom right. So the upper lefthand corner is the only part of the stage that will make it move. in the bottom right corners it doesnt move.Last edited by waverider303; May 3rd, 2009 at 01:25 AM.
-
May 3rd, 2009, 01:24 AM #11238Registered User
postsno my laptop died today
i don't have flash on this computer. is it not working?
-
May 3rd, 2009, 01:48 AM #1265Registered User
postsno Dice. It moves pretty smoothly it just moves down and to the right. It doesnt move up or to the left.
Last edited by waverider303; May 3rd, 2009 at 01:52 AM.
-
May 3rd, 2009, 01:56 AM #13238Registered User
postsoh, sorry.
var dx:Number = ( (mx – tempx) > 1) ? 1: -1;
var dy:Number = ( (my – tempy) > 1) ? 1: -1;
should be
var dx:Number = ( (mx – tempx) > 0) ? 1: -1;
var dy:Number = ( (my – tempy) > 0) ? 1: -1;
-
May 3rd, 2009, 02:03 AM #1465Registered User
postsUnfortunately its the same. Here is a link to see in real time the demo. Thanks for helping me through this. I bet we will get it working soon!
Link: http://www.csteelmedia.com/flash/test.html
-
May 3rd, 2009, 02:04 AM #15238Registered User
postscan you post the code you're using for this? for me, its always moving even if the mouse isn't moving

Reply With Quote

Bookmarks