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