View Full Version : interactive image pan
juice22
December 28th, 2006, 12:25 PM
i followed the interactive image pan tutorial off of the flash tutorials and it worked
now i'm trying to make this image pan go vertically as opposed to horizontally as it does in this code:
//////////////////////////////
this.onMouseMove = function() { constrainedMove(bg_mc, 4, 1); }; function constrainedMove(target:MovieClip, speed:Number, dir:Number) { var mousePercent:Number = _xmouse/Stage.width; var mSpeed:Number; if (dir == 1) { mSpeed = 1-mousePercent; } else { mSpeed = mousePercent; } target.destX = Math.round(-((target._width-Stage.width)*mSpeed)); target.onEnterFrame = function() { if (target._x == target.destX) { delete target.onEnterFrame; } else { target._x += Math.ceil((target.destX-target._x)*(speed/100)); } }; }
//////////////////////would anyone know what i would need to change in this code for the pan to be vertical?
id really appreciate it
xtinarox26
December 28th, 2006, 12:31 PM
wouldn't you just change THE _x values to Y ? :|:book:
Krilnon
December 28th, 2006, 12:36 PM
Yeah, and 'width' to 'height':
this.onMouseMove = function() {
constrainedMove(bg_mc, 4, 1);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
var mousePercent:Number = _ymouse/Stage.height;
var mSpeed:Number;
if (dir == 1) {
mSpeed = 1-mousePercent;
} else {
mSpeed = mousePercent;
}
target.destY = Math.round(-((target._height-Stage.height)*mSpeed));
target.onEnterFrame = function() {
if (target._y == target.destY) {
delete target.onEnterFrame;
} else {
target._y += Math.ceil((target.destY-target._y)*(speed/100));
}
};
}
juice22
December 28th, 2006, 12:50 PM
ok thx
Dane the Viking
January 23rd, 2007, 11:53 AM
Yeah, and 'width' to 'height':
ActionScript Code:
this.onMouseMove = function() {
constrainedMove(bg_mc, 4, 1);
};
function constrainedMove(target:MovieClip, speed:Number, dir:Number) {
var mousePercent:Number = _ymouse/Stage.height;
var mSpeed:Number;
if (dir == 1) {
mSpeed = 1-mousePercent;
} else {
mSpeed = mousePercent;
}
target.destY = Math.round(-((target._height-Stage.height)*mSpeed));
target.onEnterFrame = function() {
if (target._y == target.destY) {
delete target.onEnterFrame;
} else {
target._y += Math.ceil((target.destY-target._y)*(speed/100));
}
};
}
And how do you combine the vert movement with the horinzontal movement?
I've been reading old threads like crazy to find a way to navigate a movieclip that's larger then the stage. Like a map you know.
I found various examples but i can't get them to work for various reasons. All i am looking for is a simple code like the image pan code, that can go both up and down, left and right :/
cyan
May 24th, 2007, 07:49 PM
I used this variation of the code, and it worked great for me, but I have one question:
how would I alter the code so that if the mouse was outside of the movie clip that I'm panning, the movieclip does not move?
The movieclip has buttons in it, so I cannot simply use a "onRollOver" instead of "onMouseMove".
Thanks in advance.
Galia
June 6th, 2007, 08:21 PM
Hi.
I've taken the code from krilnon tuturial for the interactive image panning and and added a vertical option upon the image.
The problem is I have buttons on the image, (in the layers above) and they make the image movement to get stuck every time the mouse touches a button.
I am aiming for the movement to not be influated by the buttons.
I'm attaching my file
I've tried many codes but krilnon's seems to be the bst answer
www.spice-e.net/tryforcode.zip (http://www.spice-e.net/tryforcode.zip)
Please take a look and answer me.
Thanks
Galia
cyan
June 11th, 2007, 09:24 PM
This looks cool, but I was trying to do an image pan where the mouse is outside of the target/movieclip, it would stop moving.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.