Posted By

arpo on 02/10/11


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

merritt212


TimeBoolean


 / Published in: ActionScript 3
 

Creates a Boolean that change to its inverted state after a specific time. Usage: var shouldIPop:TimeBoolean = new TimeBoolean(false, 200); if (!shouldIPop.state) return;

  1. package com.utils
  2. {
  3.  
  4. /**
  5. * ...
  6. * @author Mattias Johansson
  7. * Creates a Boolean that change to its inverted state after a specific time.
  8. * Usage
  9. * var shouldIPop:TimeBoolean = new TimeBoolean(false, 200);
  10. * if (!shouldIPop.state) return;
  11. */
  12.  
  13. import flash.utils.Timer;
  14.  
  15. public class TimeBoolean
  16. {
  17. private var _state:Boolean;
  18.  
  19. public function TimeBoolean(defaultState:Boolean, milliSeconds:uint )
  20. {
  21. _state = defaultState;
  22. var myTimer:Timer
  23. myTimer = new Timer(milliSeconds,1);
  24. myTimer.addEventListener("timer", function(){
  25. _state = !defaultState;
  26. });
  27. myTimer.start();
  28. }
  29.  
  30. public function get state() { return _state; }
  31. }
  32. }

Report this snippet  

You need to login to post a comment.