Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple ActionScript Help 2

Status
Not open for further replies.

DGTLguy

Technical User
Joined
Jul 23, 2003
Messages
125
Location
US
I have a sprite (circle) that I want to scale gradually up to 300% onRollOver.

onRollOut I want it to scale back to its original size.

any actionscript help to get me started would be greatly appreciated.
 
Try this on the main timeline, affecting a movieclip with instance name 'clip':

Code:
scanClip = function () {
	// do scaling
	if (over) {
		scale += (scale<300) ? 5 : 0;
	}
	else {
		scale -= (scale>100) ? 5 : 0;
	}
	clip._xscale = clip._yscale=scale;
};
//button actions
clip.onRollOver = function() {
	over = true;
};
clip.onRollOut = function() {
	over = false;
};
//run check
scale = 100;
this.onEnterFrame = scanClip;
//
stop();
 
it works great... thanks alot... one more question...
i want to scale up as the mouse gets closer to the sprite,
and scale down as i pull away. (without actually rolling over the sprite)

i figure the xy placement of the mouse and the center of the sprite would be reference points to calculate the scaling ...

not sure how easy this would...
 
Try this:

Code:
scanClip = function () {
	// distance from mouse to centre of clip (assuming clip has a central registration point)
	diffX = _xmouse-clip._x;
	diffY = _ymouse-clip._y;
	// do scaling - fiddle these values until you get what you want
	scale = 300-Math.sqrt(diffX*diffX+diffY*diffY);
	scale = (scale<100) ? 100 : scale;
	clip._xscale = clip._yscale=scale;
};
this.onEnterFrame = scanClip;
//
stop();
 
you have my vote for tipmaster of the week... you've been awesome...

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top