4 Replies Latest reply on Nov 2, 2008 4:29 PM by Sunil Guttula

    How to use events to control the calling sequence with data loading component

    JZBAO Level 1
      I created a data loading component TimestampManager.mxml, which retrieve a server timestamp from http://www.XYZ.com/timestamp.php

      $timezone = "TZ=US/Central";
      $Return = "<timestamp>".date("m/d/Y H:i:s", time())." US CST"."</timestamp>";

      <?xml version="1.0" encoding="utf-8"?>
      <mx:UIComponent xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="timestampService.send()">
      <mx:Script> <![CDATA[
      import mx.rpc.events.ResultEvent;
      public function getTimestamp():String {
      return timestampService.lastResult.timestamp;
      private function serviceResult(event:ResultEvent):void {
      ]]> </mx:Script>

      <mx:HTTPService id="timestampService" url=" http://www.XYZ.com/timestamp.php"
      result="serviceResult(event)" useProxy="false" method="POST" />

      I have an application called Footer.mxml, which uses the TimestampManager.mxml to get server timestamp:

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns:mgr="com.XYZ.managers.*" layout="absolute" height="30" width="797">
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" width="797" height="30" backgroundColor="#05075C" y="0" >
      <mx:Label id="timestamp" text="{tsMgr.getTimestamp()}" color="#FEFEFE" height="20" y="10" textAlign="left" width="224" x="60"/>
      <mgr:TimestampManager id="tsMgr"/>

      The problem I have is that the application Footer.mxml calls the component TimestampManager.mxml to get the timestamp before TimestampManager.mxml retrieves the data from timestamp.php on the server. I'm not sure how to control the calling sequence:

      1st: The component TimestampManager.mxml calls timestamp.php on the server first to get the timestamp;
      2nd: The application Footer.mxml calls the component TimestampManager.mxml to display the timestamp.