mbrumm
September 18, 2002, 2:09pm
1
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.
system
September 18, 2002, 2:31pm
2
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.
system
September 18, 2002, 3:02pm
3
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);
}
system
September 18, 2002, 3:10pm
4
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]
system
September 18, 2002, 3:57pm
5
thanks, i think that’ll work
system
September 18, 2002, 9:34pm
6
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
system
September 18, 2002, 9:39pm
7
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.
system
September 18, 2002, 9:51pm
8
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
system
September 18, 2002, 9:56pm
9
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.
system
September 18, 2002, 10:32pm
11
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?..