PDA

View Full Version : Zoom into Image help



zheriam
June 14th, 2007, 05:00 PM
Hey guys,
I'm looking for a way to zoom into an image, but controlled by the _ymouse. Also the center of the image is 100% zoomed in and it will zoom out at the edges..

This is like the OSx dock menu effect, but controlled by the vertical, and the center of the image being the "zoomed" in..

I'm trying something like:
_root.mymc._xscale += this._ymouse / mymc._height;

same thing for the yscale, this does the opposite, zooms out at the edges and stops at the center.. I understand my ymouse is dividing the height and the center is "0" so no zoom, above that it zooms out, below the opposite..

How can I achieve what I want, I'm trying to have a panoramic image and when you scroll your mouse by the center it zooms in and as you move away from the center, it zooms out..

Any help is appreciated!!

zheriam
June 15th, 2007, 09:03 AM
I've searched the web and kirupa and there are similar problems to mine, but no solution which helps me..

Help !!

zheriam
June 15th, 2007, 10:34 AM
After some serious pondering I came up with a perfect solution.. I'm posting the code to help others in the future..

onClipEvent(load){
myheight = this._height;
mywidth = this._width;
middle = myheight/2;
}


onClipEvent (mouseMove) {
var deltax = Math.round(_root._ymouse - (myheight/2));
var deltay = Math.round(_root._ymouse - (myheight/2));
var diff = Math.round(Math.sqrt((deltax*deltax)+(deltay*delta y)));
diff = Math.min(diff,middle);
}

onClipEvent (enterFrame) {
// _root.xcor.text = _root._xmouse;
// _root.ycor.text = _root._ymouse;
// _root.xthis.text = this._xscale;
// _root.ythis.text = this._yscale;
// _root.diff.text = diff;

if(_root._ymouse < myheight){
endscale = (231.5-diff);
_root.zoom_this._xscale += (endscale-_root.zoom_this._xscale)/20;
_root.zoom_this._yscale += (endscale-_root.zoom_this._xscale)/20;
}

}


Hope it helps, 231.5 was the zoom level that worked the best, since my movie had already been zoomed in to fit, etc..

I'm a 3D animator with a programming background, I've been doing flash on and off through out the years, I've always come to kirupa for help.. Even though I've never posted, I've been a long time lurker..

Hopefully I get to help others as much as this community has helped me through out the years..

Cheers