I'm trying to code an application using PhotoshopTouchSDK and have a "generic" problem due to the inherent asynchronous operating way of flex.
Regarding that answers are available in an eventhandler I have no direct way to return a value to the calling function.
If I need to get a layer name I ask first if there is a document open to avoid errors, so I create a function to get the "documentopen" value and if answer is yes I can continue. The problem is that the answer is not available in the function itself but in the eventhandler of the message dispatcher.
Of course I could continue from inside the event handler but this would not allow for reusing the "documentopen" function in the code and I would need to create a different eventhandler each time I need to be sure a document is actually open for whatever other process I may start.
Setting a public variable value doesn't helps because there is no immediate change of it, and asking the value doesn't ensure getting the new one.
A synchronous message dispatch would solve this problems but I believe this is against the nature of flex.
I have read some articles about callbacks but I'm not sure this is the correct approach, if yes I would greatly appreciate a sample (if possible with the message dispatcher of the SDK).
Probably I'm not using flex in the correct way ( I'm used to synchronous functions with return values for too many years ) but can't find a different way to get this solved.