All data access operation in Flex are asynchronous.

 

You can not access the result in the same function that invokes the send/operation call.

 

You must use an event handler function run by the result event, or use binding.

 

Tracy

 


From: flexcoders@yahoogroups.com [mailto:flexcoders@yahoogroups.com] On Behalf Of David Brown
Sent: Friday, August 25, 2006 9:58 AM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] If statment runs before remote call returns data

 

I am writting a login function that calls a remote cfc and returns data.  Based on the length of lastresult either show different view stack child or turn visiable on for label that displays no user found

 

The remote call works, but I have to press login button twice to display the no user found message or to switch to another child of the view stack.

 

It looks like the if statment exacutes before the remoteobject is returned...

 

Thank you in adance.

 

David

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="logincall();">
     <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 mx.events.MenuEvent;
            import mx.controls.Alert;
            import mx.collections.*;
            import flash.net.*;
           
   public function checkRecordCount():void{
    if (classifiedCFC.qryLogin.lastResult.length==0){
     lblFailedLogin.visible=true;
    }
   }
   
    
            public function logincall():void{
         classifiedCFC.qryLogin(fldemployeeID.text,fldssn.text);
   if (classifiedCFC.qryLogin.lastResult.length==0){
     lblFailedLogin.visible=true;
    }
   else{
    vsappId.selectedChild=Main;    
    }
   
   }
   
            [Bindable]
            public var menuBarCollection:XMLListCollection;
      public var selectedItem:Object;
      public function clickEvt(event:ItemClickEvent):void {
                // Access target TabBar control.
                var targetComp:TabBar = TabBar(event.currentTarget);
//                GetQCCQues.qryQccQuesWidget(event.label);
    }   
         ]]>
    </mx:Script>
 <mx:RemoteObject id="classifiedCFC" destination="ColdFusion" source="applications.Classifieds.CFCs.classifiedapp" showBusyCursor="true" />
 <mx:ViewStack x="32" y="25" id="vsappId" width="622" height="494">

__._,_.___

--
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




__,_._,___

Reply via email to