1.  
  2. function MyFader(comp, interval) {
  3. if (_biInPrototype) {
  4. return;
  5. }
  6. BiEventTarget.call(this);
  7. this.intervalId;
  8. this.component = comp;
  9. this.interval = interval;
  10. }
  11. _p = _biExtend(MyFader, BiEventTarget, "MyFader");
  12. _p.fadeIn = function() {
  13. var opacity = 0;
  14. if (this.component && this.interval) {
  15. var self = this;
  16. self.dispatchEvent("fadestart");
  17. var doFadeIn = function() {
  18. if (opacity <= 1) {
  19. opacity += .01;
  20. self.component.setOpacity(opacity);
  21. } else {
  22. clearInterval(self.intervalId);
  23. self.dispatchEvent("fadeend");
  24. }
  25. }
  26. doFadeIn();
  27. this.intervalId = setInterval(doFadeIn, this.interval);
  28. }
  29. }
  30. _p.fadeOut = function () {
  31. var opacity = 1;
  32.  
  33. if (this.component && this.interval) {
  34. var self = this;
  35. self.dispatchEvent("fadestart");
  36. var doFadeOut = function() {
  37. if (opacity > 0) {
  38. opacity -= .01;
  39. self.component.setOpacity(opacity);
  40. } else {
  41. clearInterval(self.intervalId);
  42. self.dispatchEvent("fadeend");
  43. }
  44. }
  45. doFadeOut();
  46. this.intervalId = setInterval(doFadeOut, this.interval);
  47. }
  48. }
  49. _p.setComponent = function(comp) {
  50. this.component = comp;
  51. }
  52. _p.setInterval = function(interval) {
  53. this.interval = interval;
  54. }
  55.  
  56.