1 Reply Latest reply on Nov 28, 2009 6:20 AM by Gregory Lafrance

    how to get the timer in flex

    dasari161

      Hi,

      i am doing a game in  flex. The game is, there is object which escaping  from the balls coming toward it.If the ball hit means the object falls down.

      My question is i want to get the balls in increasing manner.suppose in first 5 seconds in ball comes means , in next 5 secounds 3 balls must come like that.

      Can any one suggest how to solve this problem?

        • 1. Re: how to get the timer in flex
          Gregory Lafrance Level 6

          If this post answers your question or helps, please mark it as such.

           

          This should get you started:

           

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            creationComplete="timer.addEventListener(TimerEvent.TIMER, timerFunc);" 
            viewSourceURL="srcview/index.html">
            <mx:Script>
              <![CDATA[
                private var timer:Timer = new Timer(1000, 0);
                [Bindable] private var numBalls:uint = 1;
                
                private function timerFunc(event:TimerEvent):void{
                  numBalls+=2;
                }
              ]]>
            </mx:Script>
            <mx:Label id="lbl" text="{numBalls} ball(s) falling now" fontSize="100" textAlign="center"/>
            <mx:Button label="Start Game" click="timer.start();"/>
            <mx:Button label="Stop Game" click="timer.stop();numBalls=1;"/>
          </mx:Application>
          
          


          Greg Lafrance
          www.ChikaraDev.com

          Flex Development and Support Services