Friday, December 10, 2004

ActionScript - function flipIndex()

This is a helpful function to flip an array index, as opposed to using Array.reverse. I've updated this to as I completely overlooked the simple solution before, also changed the documentation to NaturalDocs format. Plus I'd rather not look like a complete idiot ;).
/*
* Description:
* Flip an array index.
*
* Parameters:
* index - index to flip
* length - length of array
* 
* Return:
* flipped index (Number)
*
* Version:
* 13 March 2005
*/

function flipIndex (indexToFlip:Number, rangeLength:Number) : Number
{
    return (length - index);
}