+ Reply to Thread
Results 1 to 1 of 1

Thread: AS3FlexDB: callback function delay

  1. SIT is offline Newborn member little-flashed member SIT is on a distinguished road
    Join Date
    Sep 2009
    Posts
    2

    AS3FlexDB: callback function delay

    Hello,

    I use Ghalex's AS3FlexDB to write my query on Flex client.

    The problem is AS3FlexDB using a callback function to get records returned.

    Code:
     
    myClassQueryExe 
    {  
    public function myClassQueryExe(strQuery:String):void 
    { 
    query.addEventListener(Query.QUERY_END, queryTaskEnd); 
    query.execute(strQuery); 
    }  
    
    public function queryTaskEnd(event:Object):void 
    { 
    Main.myArrCollection = query.getRecords(); 
    }  
    
    }
    So, in my Main program, if i create an instance of myClassQueryExe, pass strQuery into its contructor and expect the result to be returned to the public static myArrCollection like this:

    Code:
     
    public static var arr:Array;
    
    private myFunction():void 
    { 
    var myQuery:myClassQueryExe = new myClassQueryExe(strQuery); //(1) 
    arr = myArrCollection.toArray();   //(2) 
    }
    (2) is executed before myArrCollection get filled because (1) will drill down to a callback function (QueryTaskEnd()) and get a delay. In other word, myArrCollection is still null when (2) is executed, and an error launching.

    I create myClassQueryExe class because i don't want to write the query task again and again in Main program. So, how do i solve this problem? I mean how i could get myArrCollection without delay. Can i dispatch QUERY_END event manually to do this?

    Thank you,
    Last edited by SIT; 4th October 2009 at 10:20.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts