PDA

View Full Version : cool AS scaler - check it out - help me tweak it


zorph
03-28-2003, 01:58 AM
here it is:

I really want someone to make my code better. I kind of lost it in the end.

here is the script on my MC:
------------------------

onClipEvent (mouseMove) {
minsize = 70
maxsize = 100
halfwidth = 32
//take the width of the image and divide it by 2 to get the halfwidth.
//This will scale until the edge of image instead of the center point.
startpoint = 100
//How many points away from the edge you want the scale to start.
xdiff = _x - _parent._xmouse;
ydiff = _y - _parent._ymouse;
percent = ((Math.sqrt(xdiff*xdiff+ydiff*ydiff)) +100) /2 ;

if (percent > maxsize) {_xscale = _yscale = minsize}
else {_xscale = _yscale = -percent +(minsize+maxsize);}

if (percent < minsize) {_xscale = _yscale = maxsize}


updateAfterEvent();
}

---------------------------

The above will take any MC, scale it back by 70%, then scale it up to 100% via the mouse position.

Notice I didn't use the "startpoint" variable.
One of the things I want to be able to set the distance at which the scale starts, in pixels, from the the edge of the MC.

I'm new to actionscript, so I would really love for someone to come along and clean this up.... maybe make it cooler.

Mortimer Jazz
03-28-2003, 02:21 AM
Yes I like these kind of things. A bit like an executive stress toy :]
You could add some elasticity to it - that would be nice

zorph
03-28-2003, 02:15 PM
I actually had some elasticity to it, but it was too much. I just want something that is subtle, clean, and controlled
... sometimes less is more.
Personally I think elastic buttons are becoming overdone...
but these guys did it right:
sick... just plain sick.
http://www.mjau-mjau.com/main.html