Page 1 of 1

asynch call back to flash

Posted: Thu May 18, 2006 3:21 pm
by steanson
I have a 3rd party dll that I need to use, however it takes callback functions as arguments
what would be the best approach to utilizing this.
any help much appreciated thanks Steve
:D

Posted: Thu May 18, 2006 3:45 pm
by Softanics
Thank you for your question.

Could you tell me what exactly you want to do?

Posted: Thu May 18, 2006 9:09 pm
by steanson
Essentially this is a voting system connected to a hardware hub that can receive votes, the dll acts as the glue to the hardware hub which receives info from a room full of voting devices.

I want to be able to call a dll method from the flash passing in a function that will be called by the dll.
I wondered whether it'd be possible to create an xml based proxy dll server that could listen for flash requests using flashes socket server mechanism or directly communicate with the dll
e.g.prototype in the dll:
ACTIVOTE_API AV_RESULT_T __stdcall AVOpen ( PACTIVOTE_REGISTRATION_CALLBACK pfnRegistrationCallback,
PACTIVOTE_VOTING_CALLBACK pfnVotingCallback
)

Posted: Fri May 19, 2006 9:41 am
by Softanics
steanson wrote:I want to be able to call a dll method from the flash passing in a function that will be called by the dll.


In ActionScript you can use fscommand, in the C++ you can handle fscommand event and call the dll method.

Posted: Fri May 19, 2006 10:49 am
by steanson
I need the flow to be like this:

1. AS calls c++ passing an AS function to call at some later stage
2. c++ calls dll passing in a function pointer for callback
3. c++ function gets called from dll via pointer
4. c++ then calls AS function

its akin to a handler.
I think the main issue is being able to store a function to call back to AS.
Coz this is a voting application it must be asynchronous.

cheers Steve

Posted: Fri May 19, 2006 11:36 am
by Softanics
steanson wrote:1. AS calls c++ passing an AS function to call at some later stage


AS calls fscommand(name_of_as_function), in C++ this name is saved. The 3rd party dll will call this AS function as a callback? Am I right?

steanson wrote:3. c++ function gets called from dll via pointer
4. c++ then calls AS function


The name of the AS function is saved, we can call this function using Flash External API: http://www.f-in-box.com/dll/features.ht ... ternal_api

Posted: Fri May 19, 2006 11:42 am
by steanson
the dll needs to inform the AS via a callback of somesort
however the dll is not written with ExternalInterface API in mind.
so praps I need write a proxy to interface between the 2, just not sure how to do it using f-in-box

cheers Steve

Posted: Fri May 19, 2006 12:29 pm
by Softanics
I still can't understand the problem...

steanson wrote:the dll needs to inform the AS via a callback of somesort


Could you describe me again about the task?

We have the flash movie and the dll. When a function of the dll is called, a pointer of callback function is passed as an argument. We need to pass something that allows to call an actionscript code as a callback? The solution: the callback calls AS using External API.

Another scenario. The movie is informed about a pointer to callback function. And later in ActionScript code we should call this callback? The solution: set a value of flash variable by the value of callback pointer / or call AS function using External API and pass the callback pointer as an argument. Later, when AS code should call the callback, it calls fscommand and pass saved callback pointer as an argument of fscommand. The C++ code handles fscommand event, extract the pointer and call the callback.

Posted: Fri May 19, 2006 12:42 pm
by steanson
I reckon the external api will do the trick
I'll investigate that thanks for all your help - much appreciated!
Could you recommend a resource/book to help me improve my c++ which is only at a basic stage! I've never written an MFC app for instance
thanks Steve

Posted: Fri May 19, 2006 2:36 pm
by Softanics
steanson wrote:Could you recommend a resource/book to help me improve my c++ which is only at a basic stage! I've never written an MFC app for instance


I think the best resources are CodeGuru.com, CodeProject.com...
A book is good, but exploring the code is better :)