Jump to content


MC Scale to mouse distance.


  • You cannot reply to this topic
3 replies to this topic

#1 PixelWarrior

    Young Padawan

  • Members
  • Pip
  • 8 posts

Posted 02 August 2006 - 03:16 AM

I'm trying to get a mc to get bigger as u move the mouse closer to it. Kinda like http://www.insidercl....uk/index2.html but without the button sticking to the mouse.

Edited by PixelWarrior, 02 August 2006 - 08:38 AM.


#2 icio

    Young Padawan

  • Members
  • Pip
  • 10 posts
  • Location:Perth, Scotland

Posted 03 August 2006 - 12:28 PM

var circle:MovieClip;
circle.onEnterFrame = function() {
	
	var minimum_distance = 300; // the distance at which the movieclip is smallest
	var minimum_scale = 10;	 // the scale the movieclip is when it is smallest
	
	var x:Number = _root._xmouse-this._x;
	var y:Number = _root._ymouse-this._y;
	var distance:Number = Math.sqrt(x*x+y*y);
	
	this._xscale = this._yscale = Math.max(0, minimum_distance-distance)*(100-minimum_scale)/minimum_distance+minimum_scale;
}
This code will create the effect that you are after. It scales the movieclip from 100 to `minimum_scale` over a distance of `minimum_distance`.

My setup is simply a movieclip on the stage with instance-name circle.

Hope this helps.

#3 PixelWarrior

    Young Padawan

  • Members
  • Pip
  • 8 posts

Posted 04 August 2006 - 11:13 PM

Exactly what I was trying to make. Thanks heaps...
I got close to that... but yeah, not quite lol

You Rock!

#4 icio

    Young Padawan

  • Members
  • Pip
  • 10 posts
  • Location:Perth, Scotland

Posted 05 August 2006 - 09:07 AM

Glad to help ;)





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users