You need to sign in to do that
Don't have an account?
bryano
Flex Toolkit, having a callback function return a value
I'm using the Apex Flex Toolkit. I call a function and within that function I make a query. I have the query's callback function return a string. Is there a way for the original function to return that string?
For example, I'm trying to do something like this:
Code:
For example, I'm trying to do something like this:
Code:
var soql:String = "Select Id from document where Name = 'imageName'"; var pathToImage:String = getPath(soql); private function getPath(soql:String):String { apex.query(soql, new AsyncResponder(function (qr:QueryResult):String { // Work with QueryResult and return a string return <some string>; })); return <same string from callback> }
basicaly the outer function has already returned before the inner ( async) ever gets called.
I understand that Async processing is a new mind-set, however, I feel it is well worth learning.
Basicaly (in flex apps) the async process happens , then your callback calls the next function that needs this data, eventualy updating the UI by binding the results to a UI element.
you can build a busy wait loop, but i don't think your app will perform the way you want if you do this.
This (sync) alternative is (write your callback to ) fire an event, which has the result, then in the outer function you make the query, and enter a busy wait loop (forever loop) until you recieve the event sent by the callback. I don't have any code for this, and i would not recomend building an app that does this. This method defeats the async processing.
Since the app will be on different orgs, I need to do the following when the app is loading:
1. Query document object to get the id
2. Set the source path of the images with the correct URL
3. Finish loading the app
Maybe I'm going about this wrong. Perhaps there is a better way to get images to display when I attach the .swf file to the s-control.