|
|
Joined: Dec 1999
Posts: 30,867
Master Elite Member
|
X_AsPercentOfWidth() - How far into the object did a click occurfunction 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);
}
|
|
|
|
Entire Thread
|
X_AsPercentOfWidth() - How far into the object did a click occur
|
Russ
|
01/08/10 08:52 AM
|
|
|
|