Zoom easing on mouse click

How would i go about modifying the “Easing on Mouse Click” tutorial to incorporate an easing zoom effect along with the position easing?

For example, the MC starts at x=0, y=0, and scale =100%.
Click anywhere on screen and the MC goes to that position and scales to 200%.

Thanks in advance.

Create an mc. Put these actions on it:

[COLOR=blue]onClipEvent (load) {
_x = 0;
_y = 0;
amount = 5;
}
onClipEvent (mouseDown) {
new_x = _root._xmouse;
new_y = _root._ymouse;
_xscale = 200;
_yscale = 200;
}
onClipEvent (enterFrame) {
_x += (new_x-_x)/amount;
_y += (new_y-_y)/amount;
}
[/COLOR]

It only scales to 200% once, else it will keep getting bigger.

Thanks Flex for your help, but that’s not quite what I’m looking for. I think my explanation was too vague, so let me give it another go around.

Is there a way to have the MC scale with inertia similar to how the position changes (enterFrame equation)?

onClipEvent (load) {
_x = 0;
_y = 0;
amount = 5;
scaler = 100;
}
onClipEvent (mouseDown) {
new_x = _root._xmouse;
new_y = _root._ymouse;
scaler = 200;
}
onClipEvent (enterFrame) {
_x += (new_x-_x)/amount;
_y += (new_y-_y)/amount;
_xscale (scale from 100 to 200); //some sort of equation here?
_yscale (scale from 100 to 200);
}

Try

[COLOR=blue]onClipEvent (load) {
_x = 0;
_y = 0;
amount = 5;
count = 0;
}
onClipEvent (mouseDown) {
new_x = _root._xmouse;
new_y = _root._ymouse;
new_xscale = 5;
new_yscale = 5;
}
onClipEvent (enterFrame) {
_x += (new_x-_x)/amount;
_y += (new_y-_y)/amount;
if (count<=“20”) {
_xscale += new_xscale;
_yscale += new_yscale;
count++;
}
}[/COLOR]

thanks, i think that’ll work

That won’t give the inertia effect, I’m afraid. In fact you use the exact same formula for the scale and the distance… It’s the basis of easing, all you have to do is apply it here. I let you look for the answer, if you can’t find it, post back.

pom :slight_smile:

The mouse mc follows, with inertia, and the x and y scale gradually - that’s what he said he wanted - I’m not sure what inertia you’re talking about pom. Maybe I misunderstood something.

Exactly, the size increases gradually:

_xscale += new_xscale;

No inertia in there.

Just to refresh mbrumm’s memory, the basics of inertia:

presentProperty=presentProperty+(finalProperty-presentProperty)/factor

Works the same for everything…

pom :slight_smile:

I was just thinking “gradual” effect. But, technically, that’s not inertia.

I suppose if he applied the same principle to the x and y scale, as the movement - that would be correct.

Exactly :slight_smile:

Well - in this case I was too quick to code and should have read his question more carefully. So I take it I don’t win the car?..

:stuck_out_tongue: