Should be careful with initialize and [Bindable] .

Joe

  ----- Original Message ----- 
  From: Paul DeCoursey 
  To: [email protected] 
  Sent: Friday, March 23, 2007 12:33 AM
  Subject: [flexcoders] Re: display current time


  I just did something like that..

  <?xml version="1.0" encoding="utf-8"?>
  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
  layout="absolute" initialize="this.init();">
  <mx:Script>
  <![CDATA[
  import flash.utils.setInterval;
  import flash.utils.clearInterval;

  private function init():void {
  flash.utils.setInterval(this.resetNow, 1000);
  }


  private function resetNow():void {
  this.now = new Date();
  }

  private function set now(d:Date):void {
  this.nowText = d.toTimeString();
  }

  [Bindable]
  private var nowText:String = "";


  ]]>
  </mx:Script>
  <mx:Panel x="55" y="43" width="487" height="371" layout="absolute"
  title="Time" creationComplete="this.resetNow();">
  <mx:Form width="100%" height="100%">
  <mx:FormHeading label="Time"/>
  <mx:HRule width="100%"/>
  <mx:FormItem label="Now">
  <mx:Text text="{this.nowText}"/>
  </mx:FormItem>
  </mx:Form>
  </mx:Panel>
  </mx:Application>

  You'll have to play around with DateFormatters to get the kind of
  display you want. But as you can see it's very simple. Note however
  that this could slow down the responsiveness of your app.

  Paul

  --- In [email protected], "Chad Gray" <[EMAIL PROTECTED]> wrote:
  >
  > I need the current time in my flex app.
  > 
  > Also is it possible to display the current time in the flex app
  having it always current? So the user would watch the seconds and
  minutes change?
  > 
  > How is best handled? Is this an actionscript thing?
  > 
  > Thanks,
  > Chad
  >



   

Attachment: ma_grp_160.gif
Description: GIF image

Attachment: nc3=3
Description: Binary data

Reply via email to