>From the docs:

package {
    import flash.utils.Timer;
    import flash.events.TimerEvent;
    import flash.display.Sprite;

    public class TimerExample extends Sprite {

        public function TimerExample() {
            var myTimer:Timer = new Timer(1000, 2);
            myTimer.addEventListener("timer", timerHandler);
            myTimer.start();
        }

        public function timerHandler(event:TimerEvent):void {
            trace("timerHandler: " + event);
        }
    }
}


so your 'code' would look something like:
       // Using the suggestion from an earlier post, use the interval
as the default
     // Also, make it public var so you can adjust it if you want,
have a slider to offer more frequent updates or less frequent updates
or turn off.  This would be myTimer.delay = slider.value or something
similar...
      var interval:Number = 60 * 30 * 1000;
      // Leave off second param here to make it go indefinitely
      var myTimer:Timer = new Timer(interval);


      public function initTimer: void {
      myTimer.addEventlistener("timer", timerHandler);
      myTimer.start();
}
      public function timerHandler(event:TimerEvent):void {
            trace("timerHandler: " + event);
         // Lookup weather, update datasets, update display
         // Don't know yet if you need to turn off timer, then turn on
at end in case update takes too long.
        }
--- In [email protected], "David Brown" <[EMAIL PROTECTED]> wrote:
>
> Thank you for you're help.  The timer event is the part I am having
trouble with.  I don't know how to write or where to start.  Any
suggestions would be great.
> 
> David
> 
>   ----- Original Message ----- 
>   From: sinatosk 
>   To: [email protected] 
>   Sent: Saturday, August 05, 2006 5:41 PM
>   Subject: Re: [flexcoders] Timer to run function every 30 min
> 
> 
>   60 * 30 * 1000
> 
>   60 seconds
>   times
>   30 minutes
>   times
>   1000 miliseconds
>   equals
>   1800000
> 
>   I recommend using "60 * 30 * 1000" instead of the "1800000" so
it's easier for you to change/debug 
> 
>   and then just add an event listener on "timer" event name along
with the function you want it to call upon 30 minutes and then your
done :p
> 
> 
> 
>   On 05/08/06, David Brown <[EMAIL PROTECTED]> wrote:
> 
>     Hello all,
> 
>     I could use some help.  I have been
livedocs.macromedia.com/flex/2docs looking for a way to create a timer
function that would execute a function every 30 min.  I found an
example of mytimer and looked at a example for simple analog clock. 
But I am having a hard time understanding how it relates to my code. 
Below is a code snipet.
> 
>     I would like to run the InitApp() function every 30 min.  That
should refresh my two datagrids that inturn will update my screen.
> 
>     Any help would be great.
> 
>     Thank 
>     David
> 
>     mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
layout="absolute" width="500" height="56"
backgroundGradientColors="[#ffffff, #ffffff]"
creationComplete="initVars()" horizontalAlign="center"
verticalAlign="middle" borderColor="#ff0000" backgroundColor="#ffffff"
borderStyle="solid" borderThickness="1">
>          <mx:Script>
>             <![CDATA[
>        import mx.logging.LogEvent;
>        /* import flash.events.MouseEvent;
>        import mx.events.FlexEvent; */
>        import mx.styles.CSSStyleDeclaration;
>              import mx.effects.*;
>        import mx.events.*;
>              import mx.rpc.events.*;
>              import mx.controls.Alert;
>        import mx.managers.PopUpManager;
>        import flash.events.Event;
>           import flash.events.TimerEvent;
>           import flash.utils.Timer;   
>                 import mx.controls.Alert;
>                 import mx.collections.*;
>                 import flash.net.*;
>                 import flash.display.Sprite;
>           [Bindable]         
>              public var mylocID:String;
> 
>           // Assign values to new properties.
>              private function initVars():void {
>         InitApp();
>              }
>                 public function InitApp():void
>        { 
>         // assign values passed from the html object flashvars
>         mylocID = Application.application.parameters.mylocID;
>         // if no value passed from the html object tag then assign value
>         if (mylocID == null) {
>          mylocID = "29223";
>         }
>         // get weather
>         weatherSvc.qryCurrentWeather(mylocID);
>         weatherSvc.qryExtendedWeather(mylocID);
>         // set focus on the first row of the grids
>         dgCurrentWeather.selectedIndex = 0;
>         dgExtendedWeather.selectedIndex = 0;         
>        }
>        
>              ]]>
>         </mx:Script>
>         
>      <mx:RemoteObject id="weatherSvc" destination="ColdFusion"
source="Widgets.cfc.widgets" showBusyCursor="true" />
>







--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to