Simple Wheel in AS2 (code)

  1. /**
  2. * by Saulo Brito
  3. * http://www.weka.com.br
  4. * http://creativecommons.org/licenses/by/2.5/br/
  5. */
  6.  
  7. // TextField dynamicField;
  8. // MovieClip upArrow;
  9. // MovieClip downArrow;
  10.  
  11. // dynamicField refers to a dynamic textfield placed on Stage
  12. // upArrow and downArrow are the instance names of the scroll arrows
  13.  
  14. // if selectable property is set to true, the wheel button can scroll without aditional code
  15. //dynamicField.selectable = false;
  16.  
  17. updateArrows();
  18.  
  19. Mouse.addListener(this);
  20. function onMouseWheel(delta:Number,scrollTarget:Object) {
  21. if(scrollTarget == dynamicField) {
  22. if (!dynamicField.selectable) { // "manual" scrolling to non selectable texts
  23. dynamicField.scroll -= delta;
  24. }
  25. updateArrows();
  26. }
  27. }
  28.  
  29. function updateArrows() {
  30. if (dynamicField.scroll == 1) {
  31. upArrow._visible = false;
  32. }
  33. else {
  34. upArrow._visible = true;
  35. }
  36. if (dynamicField.scroll == dynamicField.maxscroll) {
  37. downArrow._visible = false;
  38. }
  39. else {
  40. downArrow._visible = true;
  41. }
  42.  
  43. }
  44.  
  45. upArrow.onRelease = function() {
  46. dynamicField.scroll–;
  47. updateArrows();
  48. }
  49. downArrow.onRelease = function() {
  50. dynamicField.scroll++;
  51. updateArrows();
  52. }