PDA

View Full Version : Better zoom/drag technique



kinda86
April 11th, 2009, 05:07 PM
Hey all,

I am new to Kirupa and kind of still beginning with flash too..
I've been working on this website http://www.artengine.ca/cgervais/ for a while now but been having trouble enhancing it... If you click on the Press section at the bottom, it's taking a long time loading, and once you click on any of the images and go to the page with the content and click (keep clicking don't release) it zooms in and the user is also able to drag the image around. You can see how that can get annoying, first because the gallery and press buttons on both sides don't disappear, and second because if the user needs to readjusts the mouse and lets go the image goes back to it's place...

What i Want is for the user to click once and be able to drag freely without holding the mouse button down. and if the image is clicked again it goes back to its normal size and location....

here's the action script for the movieClip images that [i am using CS3 as2]:
Actionscript:



function dragZoom(movieClip) {

_global.homeX = 0;
_global.homeY = 0;

_global.zoomIncrement = 10;

_global.zoomAmount = 200;

function zoomIn(movieClip) {

if(movieClip._yscale && movieClip._xscale < zoomAmount) {

movieClip._xscale = movieClip._xscale + zoomIncrement;
movieClip._yscale = movieClip._yscale + zoomIncrement;

}
}

function zoomOut(movieClip) {

if(movieClip._yscale && movieClip._xscale > 100) {

movieClip._xscale = movieClip._xscale - zoomIncrement;
movieClip._yscale = movieClip._yscale - zoomIncrement;

}
}

movieClip.onPress = function() {

this.startDrag();

movieClip.onEnterFrame = function() {
zoomIn(this);

}
}

movieClip.onRelease = function() {

this.stopDrag();

movieClip.onEnterFrame = function() {

zoomOut(this);


InstanceName._x = InstanceName._x - (InstanceName._x - homeX) / 5;
InstanceName._y = InstanceName._y - (InstanceName._y - homeY) / 5;

}

}

}
dragZoom(InstanceName);



anyideas???

countersweet
April 11th, 2009, 07:20 PM
inspire here
http://www.kirupa.com/forum/showthread.php?t=324333

basically, use onReleaseOnly. and what's going to happen (whether zoom in or out) will be controlled by some global boolean variable that will change it's value with each click

kinda86
June 15th, 2009, 11:15 PM
Any other ideas? I tried that a while back.... but it ended up zooming and not zooming out once clicked... how should i adjust my AS to get this to work???

glosrfc
June 16th, 2009, 03:44 PM
Experiment with Boolean values:
http://www.kirupa.com/forum/showthread.php?t=328981

kinda86
June 16th, 2009, 04:04 PM
Thanks a lot Glosrfc,
I've never used Boolean values before and i am just beginning with flash. how do i incorporate it to the script i already have? i can't attach the source file since it exceeds 74kb even after compression... I am having a really difficult time with this page in terms of speed and practicality.

(it's the press page on the link i first posted)