PDA

View Full Version : Gradual Zoom


Butchee
12-14-2001, 08:28 PM
I have a somewhat complex image of a cartoon-like living room created in Flash. I want to zoom in on the room slowly, but tweening it is a bit jerky and slow, even when upping the fps. I've found posts regarding zooming on an image quickly using onClipEvent, for instance from 100% to 150%, but not gradually as in a motion tween. I'm new to Flash 5 and actionscripting, and would appreciate any help.

thanks...butchee

Billy T
12-15-2001, 06:39 AM
if you put this on your movieclip

onClipEvent (enterFrame) {
this._xscale = this._xscale+1;
this._yscale = this._yscale+1;
}

it will scale (or zoom) very gradually.

Need to be more specific as to when you want it to zoom etc....does it have to zoom out again??

cheers

blue
12-15-2001, 11:06 AM
if its runnning slowly its probably cos theres heaps of mcs in there, copy the mc's and paste in place, then break them up all the way and make it a graphic.

so you have:

the graphic plays from 100% to 150% and then the mc comes in and you can control it.

it will run much faster.

Butchee
12-17-2001, 01:42 PM
Thanks blue and Billy T. I used both suggestions and the zoom works great.

butchee :D

Butchee
12-20-2001, 08:19 PM
Hey Billy T,
The script is great, however, now my dilema is how to make it stop at a particular point. My first inclination was to use a stop action, but didn't work or I didn't do it properly. Any ideas on how to make this zoom stop?

-- butchee

Spaceman Spiff
12-20-2001, 08:37 PM
try something like this:

onClipevent (load) {
zoomAmount = 50;
}

onClipEvent (enterFrame) {
if (zoomAmount > 0) {
this._xscale = this._xscale+1;
this._yscale = this._yscale+1;
zoomAmount = zoomAmount - 1;
}
}

Spaceman Spiff
12-20-2001, 08:40 PM
Another cool thing to try is to have the zoom come to a gradual halt. you do this by setting your destination scale and then closing the distance by a fraction of the remaining distance:

onClipEvent (load) {
targetScale = 150;
}

onClipEvent (enterFrame) {
if (this._xscale < 150) {
this._xscale = this._xscale + (150 - this._xscale)/5
this._yscale = this._yscale + (150 - this._yscale)/5
}
}

Spaceman Spiff
12-20-2001, 08:42 PM
BTW that code won't work if you copy and paste it, because it lacks terminating semicolons.

Butchee
12-20-2001, 10:16 PM
It works!

-- thanks for the code. i take it from your user name you may be a calvin & hobbes fan. if so, the new book, c&h sunday pages 1985-1995 is a must.

ttfn
-- butchee

Spaceman Spiff
12-20-2001, 10:20 PM
Sweet! Thanks for the heads up! I spent many a sunny Florida day sitting at the top of a tree reading Calvin and Hobbes as a kid. Waterson's one of my big illustration influences, too.

farafiro
12-24-2001, 01:33 PM
or u can stop the zooming by Billy's way

say you want the MC to aoom in to 150%


onClipEvent (enterFrame) {
this._xscale = this._xscale+1;
this._yscale = this._yscale+1;
if ((this._xscale >= 150) && this._yscale >= 150) {
this._xscale = 150;
this._yscale = 150;
}
}

ilProphet
09-18-2007, 09:59 PM
How do you get this code to run more than once so you get a gradual zoom rather than it just executing once?:confused: