PDA

View Full Version : Communicate with C/C++


buhayjason
12-01-2008, 01:59 PM
Is AS3 capable of calling functions that were created in C/C++, like the jni of java?

Rossman
12-01-2008, 03:16 PM
Not really, no. If you embed the SWF into a C/C++ wrapper you could communicate with it via ExternalInterface....? But you can't call shit compiled into a DLL or something, not normally at least.

meddlingwithfir
12-01-2008, 03:51 PM
Alchemy might be able to help you.

http://labs.adobe.com/technologies/alchemy/

Rossman
12-01-2008, 05:21 PM
Unfortunately not, as Alchemy is just compiling C/C++ code into flash bytecode. (ie. so you can write in C/C++ but still get a working SWF at the end instead of an EXE)

meddlingwithfir
12-01-2008, 07:37 PM
Depends on what he's trying to do. If he's got this C function that he just needs to be able to access (say a super-efficient modulo or square root function), then Alchemy should be able to help out there. It doesn't matter whether the end code is run as C or AS3 bytecode -- as long as it gets run and returns a result.

If he's looking to have a C++ app running in the background, and have a SWF connect to that, then he will need to look elsewhere (ExternalInterface as noted).

Rossman
12-01-2008, 09:56 PM
Agreed, in that case it might be handy, but in my opinion you would probably be better off just porting the C code to AS3, you probably won't be able to get better performance than that. I guess it depends how good the Alchemy cross compiler is.