title: MovieClip, counter almost working AS3
body: <p>How do I get my counter to work? Please include explanation, and feel free to comment. <br></p>
  
  <p><strong>CONFUSION:</strong> I'm confused about the MovieClip container in as3. public class
  NumbersView extends MovieClip, so that seems to
  be a container. <em>That may not be the problem, but
  that's where I got lost.</em></p>
  
  <p>The working version of this code is fantastic. My
  code bellow is an attempt at revising it. The source
  has been adapted from various smart people. It's a work in progress<br></p>
  
  <p><strong>LIBRARY OBJECT</strong> <br>'vertical number column'
  Name: mc-NumberImage<br>
  Class: NumberImage<br></p>
  
  <p><strong>OUTPUT ERRORS</strong> 'When I uncomment the code"<br>
  1023: Incompatible override. NumbersView...<br>
  1021: Duplicate function definition. NumbersView...<br></p>
  
  <pre><code>                         //NUMBER DOCUMENT CLASS
                           //IMPORT
  import flash.display.Sprite; 
  import flash.events.Event; 
  import flash.utils.Timer; 
  import flash.events.TimerEvent; 
  import flash.display.DisplayObject; 
  import flash.display.MovieClip; 
  import flash.utils.Dictionary; 
  import caurina.transitions.Tweener;
  
                           //COUNTER
      var timer:Timer = new Timer(1000);
  
      var count:int = 0;  
      var fcount:int = 0; 
  
  
      timer.addEventListener(TimerEvent.TIMER, incrementCounter);   
      timer.start();  
  
      function incrementCounter(event:TimerEvent) {   
        count++;   
        fcount=int(count*count/1000);
  
      } 
      function formatCount(i:int):String {  
           var fraction:int = i % 100;  
           var whole:int = i / 100;   
        return ("000000000" + i).substr(-9, 9);  
      }  
  
  
  //------------------------------------------------------------------------
                           //PROBLEM AREA
  
         function enterFrameHandler(e:Event):void  
          { 
  //          numbers.setTime(formatCount(fcount)); 
         } 
  
  
     var _listItems:Array = new Array(); 
       var previousNums:Array; 
      const numHeight:int = 120; 
  
  
       var NumbersView:Sprite = new Sprite();
    //var numbers:NumbersView = new NumbersView;
  
                           //NUMBERSVIEW
  //   function NumbersView($n:int):void {
  
         _listItems = new Array(); 
         previousNums = new Array(); 
          var item:NumberImage; 
          var offset:int = _listItems.length;  
       for (var i:Number = 0; i &lt; 9; i++) { 
             item = new NumberImage();
  //  }//&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;
  
  //------------------------------------------------------------------------
                           //PUSH ARRAY
  addChild(item);  
          item.x = i * item.width;  
             _listItems.push(item);  
        }
                           //TWEENER 'Y SCROLLING'
  function setTime($number:String):void { 
              var nums:Array = $number.split(""); 
  
              for (var i:Number = 0; i &lt; nums.length; i++) { 
                  if (nums[i] == previousNums[i]) continue; 
                  Tweener.removeTweens(_listItems[i]); 
  
                  var newY:int = int(nums[i]) * -numHeight; 
                  if (_listItems[i].y &lt; 0) _listItems[i].y = numHeight; 
                  Tweener.addTween(_listItems[i], { y:newY, time:3 } ); 
              } 
              previousNums = nums; 
          }  
  </code></pre>
  
  <p><strong>D E S C R I P T I O N</strong><br></p>
  
  <p><strong>COUNTER:</strong> formatCount needs to get passed to Tweener </p>
  
  <p><strong>STAGE:</strong> for loop, sets up children to be added to the stage
  NumbersView becomes item, item array adds children to stage</p>
  
  <p><strong>TWEENER:</strong> advances the vertical number column every time the
  count fires adds and removes</p>
  
  <p><strong>WHY</strong><br>
  - Learning<br>
  - Benifit in simplifying the classes and putting it in one FLA<br></p>
  
  <p><a href="http://www.ashcraftband.com/myspace/videodnd/bobnums.jpg" rel="nofollow noreferrer">alt text http://www.ashcraftband.com/myspace/videodnd/bobnums.jpg</a></p>
  
  <hr>
  
  <p><strong>MORE ABOUT THE DOCUMENT CLASS</strong><br>
  <a href="http://www.rubenswieringa.com/blog/class-syntax-in-actionscript30" rel="nofollow noreferrer">http://www.rubenswieringa.com/blog/class-syntax-in-actionscript30</a><br>
  <a href="http://www.heaveninteractive.com/weblog/2008/03/04/introduction-to-the-document-class-in-actionscript-30-tutorial" rel="nofollow noreferrer">http://www.heaveninteractive.com/weblog/2008/03/04/introduction-to-the-document-class-in-actionscript-30-tutorial</a></p>
  
  <hr>
  
  <p><strong>AFTER DEBU'S EXAMPLE</strong> </p>
  
  <p><strong>.FLA</strong> 'with symbol in library, Class: NumberImage'</p>
  
  <pre><code>import flash.display.Sprite; 
  import flash.events.Event; 
  import flash.utils.Timer; 
  import flash.events.TimerEvent; 
  
  var timer:Timer; 
  var count:int = 0; 
  var fcount:int = 0; 
  var numbers:NumbersView; 
  
  trace("-----new NumberDocument created");
  timer = new Timer(10); 
  timer.addEventListener(TimerEvent.TIMER, incrementCounter);     
  timer.start();    
  numbers = new NumbersView(); 
  addChild(numbers); 
  
  addEventListener(Event.ENTER_FRAME, enterFrameHandler);
  //addEventListener(Event.ADDED_TO_STAGE, traceMeOut);
  
  
  function incrementCounter(event:TimerEvent) 
  {     
      count++;     
      fcount=int(count*count/1000);//starts out slow... then speeds up 
  } 
  
  function formatCount(i:int):String 
  {    
      return ("000000000" + i).substr(-9, 9); 
  } 
  
  function enterFrameHandler(e:Event):void  
  { 
      numbers.setTime(formatCount(fcount)); 
  } 
  function traceMeOut()
  {
      trace("-----Im here on stage!");
  }
  </code></pre>
  
  <p><strong>NumbersView.as</strong></p>
  
  <pre><code>package   
  { 
      import flash.display.DisplayObject; 
      import flash.display.MovieClip; 
      import flash.utils.Dictionary; 
      import flash.events.Event; 
      import caurina.transitions.Tweener; 
  
      public class NumbersView extends MovieClip 
      { 
          private var _listItems:Array; 
          private var previousNums:Array; 
          private const numHeight:int = 120; 
  
          public function NumbersView()  
          { 
              _listItems = new Array(); 
              previousNums = new Array(); 
  
              var item:NumberImage; 
              for (var i:Number = 0; i &lt; 9; i++) { 
                  item = new NumberImage(); 
                  addChild(item); 
                  item.x = i * item.width; 
                  _listItems.push(item); 
              } 
          } 
  
          public function setTime($number:String):void { 
              var nums:Array = $number.split(""); 
  
              for (var i:Number = 0; i &lt; nums.length; i++) { 
                  if (nums[i] == previousNums[i]) continue; 
                  Tweener.removeTweens(_listItems[i]); 
  
                  var newY:int = int(nums[i]) * -numHeight; 
                  if (_listItems[i].y &lt; 0) _listItems[i].y = numHeight; 
                  Tweener.addTween(_listItems[i], { y:newY, time:3 } ); 
              } 
              previousNums = nums; 
          } 
      } 
  } 
  </code></pre>