Range.as 915 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package {
  2. public class Range
  3. {
  4. public var min:Number;
  5. public var max:Number;
  6. public var step:Number;
  7. public var offset:Boolean;
  8. public function Range( min:Number, max:Number, step:Number, offset:Boolean )
  9. {
  10. this.min = min;
  11. this.max = max;
  12. this.step = step;
  13. this.offset = offset;
  14. }
  15. public function count():Number {
  16. //
  17. // range, 5 - 10 = 10 - 5 = 5
  18. // range -5 - 5 = 5 - -5 = 10
  19. //
  20. //
  21. // x_offset:
  22. //
  23. // False True
  24. //
  25. // | |
  26. // | |
  27. // | |
  28. // +--+--+--+ |-+--+--+--+-+
  29. // 0 1 2 3 0 1 2 3
  30. //
  31. // Don't forget this is also used in radar axis
  32. //
  33. if( this.offset )
  34. return (this.max - this.min) + 1;
  35. else
  36. return this.max - this.min;
  37. }
  38. public function toString():String {
  39. return 'Range : ' + this.min +', ' + this.max;
  40. }
  41. }
  42. }