Range

Kind of class:class
Inherits from:CoreObject
Version:09/10/07
Author:Aaron Clinger
Classpath:org.casalib.math.Range
File last modified:Monday, 01 December 2008, 13:34:40
Creates a standardized way of describing and storing an amount or extent of variation/a value range.
Example:
  • var valueRange:Range = new Range(-100, 100);
    trace(valueRange.getValueOfPercent(new Percent(.25)));

Summary


Constructor
  • Range (startValue:Number, endValue:Number)
    • Creates and defines a Range object.
Instance methods
  • setRange (startValue:Number, endValue:Number) : Void
    • Defines or redefines range.
  • getStartValue : Number
  • getEndValue : Number
  • getMinValue : Number
  • getMaxValue : Number
  • isWithinRange (value:Number) : Boolean
    • Determines if value is included in the range including the range's start and end values.
  • getValueOfPercent (percent:Percent) : Number
    • Calculates the percent of the range.
  • getPercentOfValue (value:Number) : Percent
    • Returns the percentage the value represents out of the range.
  • equals (range:Range) : Boolean
    • Determines whether the range specified by the range parameter is equal to this range object.
  • overlaps (range:Range) : Boolean
    • Determines whether this range and the range specified by the range parameter overlap.
  • contains (range:Range) : Boolean
    • Determines whether this range contains the range specified by the range parameter.
  • clone : Range
  • destroy : Void
Instance methods inherited from CoreObject

Constructor

Range

function Range (
startValue:Number, endValue:Number)

Creates and defines a Range object.
Parameters:
startValue:
[optional] Beginning value of the range.
endValue :
[optional] Ending value of the range.
Usage note:
  • You are not required to define the range in the contructor you can do it at any point by calling setRange.

Instance methods

clone

function clone (
) : Range

Returns:
  • A new range object with the same values as this range.

contains

function contains (
range:Range) : Boolean

Determines whether this range contains the range specified by the range parameter.
Parameters:
A:
defined Range object.
Returns:
  • Returns true if this range contains all values of the range specified; otherwise false.

destroy

function destroy (
) : Void

equals

function equals (
range:Range) : Boolean

Determines whether the range specified by the range parameter is equal to this range object.
Parameters:
percent:
A defined Range object.
Returns:
  • Returns true if ranges are identical; otherwise false.

getEndValue

function getEndValue (
) : Number

Returns:
  • Returns the value of "endValue" as defined by Range or setRange.

getMaxValue

function getMaxValue (
) : Number

Returns:
  • Returns the maximum value of the range.

getMinValue

function getMinValue (
) : Number

Returns:
  • Returns the minimum value of the range.

getPercentOfValue

function getPercentOfValue (
value:Number) : Percent

Returns the percentage the value represents out of the range.
Parameters:
value:
An integer.
Returns:
  • A Percent object.

getStartValue

function getStartValue (
) : Number

Returns:
  • Returns the value of "startValue" as defined by Range or setRange.

getValueOfPercent

function getValueOfPercent (
percent:Percent) : Number

Calculates the percent of the range.
Parameters:
percent:
A defined Percent object.
Returns:
  • The value the percent represent of the range.

isWithinRange

function isWithinRange (
value:Number) : Boolean

Determines if value is included in the range including the range's start and end values.
Returns:
  • Returns true if value was included in range; otherwise false.

overlaps

function overlaps (
range:Range) : Boolean

Determines whether this range and the range specified by the range parameter overlap.
Parameters:
A:
defined Range object.
Returns:
  • Returns true if this range contains any value of the range specified; otherwise false.

setRange

function setRange (
startValue:Number, endValue:Number) : Void

Defines or redefines range.
Parameters:
startValue:
Beginning value of the range.
endValue :
Ending value of the range.