X_AsPercentOfWidth() - How far into the object did a click occur

Code
function X_AsPercentOfWidth(MyX:Number, MyMovieClip:MovieClip):uint {
	/*
	Purpose
		Used to convert the location of a point to a percentage of the width of the specified MovieClip.
		This is useful for determining what percentage of the way across an object the mouse was clicked.
	Paramters
		MyX (Number) = The location we're working with.
		MyMovieClip (MovieClip) = The reference object. We use the width from this object.
	Return (uint)
		Returns the percentage represented by a point referenced to the width of an object.
		For example, if MyX is the middle (horizontally) of the object, we return 50.
		The return value is always betwen 0 and 100.
	Version History
		1.0 2010.01.08	Tested by Russ Tanner on AS3.
						If you update this code, please put a copy here:
						http://orbisvitae.com/ubbthreads/ubbthreads.php?ubb=showflat&Number=55143#Post55143
	*/
	
	// Trap: The specified point is <= 0. Just return 0 to prevent anomalies in the following division.
	if (MyX <= 0) return 0;

	// Convert the point to a percentage of the MovieClip width and return the result.
	// We don't let this exceed 100.
	return Math.min(MyX / MyMovieClip.width * 100, 100);
}


The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)