Subject: Re: [Flashcoders] Calling native code from Flash
My tuppence worth on Zinc is that it is still flaky. Requires workarounds a lot of the time and their support is shocking. On the other hand Northcode (SWFStudio) are probably the most approachable bunch of software developers I've had reason to contact and the product, IMHO, is much more solid. The only reason i'd recommend Zinc over SWFStudio is if you have to deploy something as a mac app (SWFStudio is PC only). .jez Jeremy Becker | lead developer | oakwood design consultants | +44 1179 836 789 Oakwood Design Consultants Ltd. Registered Office 7 Park Street Bristol BS1 5NF Registered in England and Wales. Company Registration No: 3097258 The information in this e-mail and any files transmitted with it is confidential, copyright protected and may be legally privileged. It is intended solely for the addressee and others authorised to receive it. If you are not the intended recipient, any disclosure, copying, distribution or action taken in reliance in its contents is prohibited and may be unlawful. If you have received this e-mail in error, please delete it and notify postmas...@oakwood-dc.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
On 19/07/2011 08:46, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. I can't think of any way to do what you want. All the native code workarounds I know of really aren't efficient for real-time calls and the overhead would outweigh the benefit. Be interesting if anyone suggests a method. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
I should add that one of the reasons it may not be possible, is the possibility of calling malevolent code from flash violating the security sandbox or just code that could crash the flash player/browser itself. I think Adobe will be reluctant to have a feature that risks sandbox security or could compromise the flash player in any way. I don't think Air offers a gateway either, but I may be wrong. On 19/07/2011 09:06, Paul Andrews wrote: On 19/07/2011 08:46, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. I can't think of any way to do what you want. All the native code workarounds I know of really aren't efficient for real-time calls and the overhead would outweigh the benefit. Be interesting if anyone suggests a method. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Hi Gerry, Can you utilize php as a mediator? Flash-PHP-DLL PHP eg: ?php if (is_file(path/To/yourfile.dll)) { // true; we can proceed //code to execute dll, format and send results to flash here } else { return false; } ? HTH, Best, Karl On Jul 19, 2011, at 3:06 AM, Paul Andrews wrote: On 19/07/2011 08:46, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. I can't think of any way to do what you want. All the native code workarounds I know of really aren't efficient for real-time calls and the overhead would outweigh the benefit. Be interesting if anyone suggests a method. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Or a perl script maybe. Best, Karl On Jul 19, 2011, at 2:46 AM, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
On 19/07/2011 09:48, Karl DeSaulniers wrote: Hi Gerry, Can you utilize php as a mediator? Flash-PHP-DLL I think there would be a huge latency, which would defeat the purpose. The fastest alternative I know would be an socket server on the same machine as the flash app. The socket server would then handle the requests and be able to process them natively. Again, there would be a huge latency compared to a native call. PHP eg: ?php if (is_file(path/To/yourfile.dll)) { // true; we can proceed //code to execute dll, format and send results to flash here } else { return false; } ? HTH, Best, Karl On Jul 19, 2011, at 3:06 AM, Paul Andrews wrote: On 19/07/2011 08:46, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. I can't think of any way to do what you want. All the native code workarounds I know of really aren't efficient for real-time calls and the overhead would outweigh the benefit. Be interesting if anyone suggests a method. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. You can even build a php script that polls the dll on its own and que the results for flash to grab from. Best, Karl On Jul 19, 2011, at 3:58 AM, Paul Andrews wrote: On 19/07/2011 09:48, Karl DeSaulniers wrote: Hi Gerry, Can you utilize php as a mediator? Flash-PHP-DLL I think there would be a huge latency, which would defeat the purpose. The fastest alternative I know would be an socket server on the same machine as the flash app. The socket server would then handle the requests and be able to process them natively. Again, there would be a huge latency compared to a native call. PHP eg: ?php if (is_file(path/To/yourfile.dll)) { // true; we can proceed //code to execute dll, format and send results to flash here } else { return false; } ? HTH, Best, Karl On Jul 19, 2011, at 3:06 AM, Paul Andrews wrote: On 19/07/2011 08:46, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. I can't think of any way to do what you want. All the native code workarounds I know of really aren't efficient for real-time calls and the overhead would outweigh the benefit. Be interesting if anyone suggests a method. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy- compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. You can even build a php script that polls the dll on its own and que the results for flash to grab from. Best, Karl On Jul 19, 2011, at 3:58 AM, Paul Andrews wrote: On 19/07/2011 09:48, Karl DeSaulniers wrote: Hi Gerry, Can you utilize php as a mediator? Flash-PHP-DLL I think there would be a huge latency, which would defeat the purpose. The fastest alternative I know would be an socket server on the same machine as the flash app. The socket server would then handle the requests and be able to process them natively. Again, there would be a huge latency compared to a native call. PHP eg: ?php if (is_file(path/To/yourfile.dll)) { // true; we can proceed //code to execute dll, format and send results to flash here } else { return false; } ? HTH, Best, Karl On Jul 19, 2011, at 3:06 AM, Paul Andrews wrote: On 19/07/2011 08:46, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. I can't think of any way to do what you want. All the native code workarounds I know of really aren't efficient for real-time calls and the overhead would outweigh the benefit. Be interesting if anyone suggests a method. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte-code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Duly noted. I guess I am not understanding the quickness this has to be done. Best, Karl On Jul 19, 2011, at 4:36 AM, Paul Andrews wrote: On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. You can even build a php script that polls the dll on its own and que the results for flash to grab from. Best, Karl On Jul 19, 2011, at 3:58 AM, Paul Andrews wrote: On 19/07/2011 09:48, Karl DeSaulniers wrote: Hi Gerry, Can you utilize php as a mediator? Flash-PHP-DLL I think there would be a huge latency, which would defeat the purpose. The fastest alternative I know would be an socket server on the same machine as the flash app. The socket server would then handle the requests and be able to process them natively. Again, there would be a huge latency compared to a native call. PHP eg: ?php if (is_file(path/To/yourfile.dll)) { // true; we can proceed //code to execute dll, format and send results to flash here } else { return false; } ? HTH, Best, Karl On Jul 19, 2011, at 3:06 AM, Paul Andrews wrote: On 19/07/2011 08:46, Gerry Beauregard wrote: Hi Paul, thanks for the quick response. The use case would be to call some CPU-intensive audio signal processing code, most likely written in C++ and packaged as a DLL. The idea is that a SWF (or AIR app) would try to detect the presence of the DLL on the user's machine; if the DLL is present, the SWF (or AIR app) would use the native signal processing functions implemented in it, otherwise it would rely on a simplified lower-quality implementation coded in AS3. I can't think of any way to do what you want. All the native code workarounds I know of really aren't efficient for real- time calls and the overhead would outweigh the benefit. Be interesting if anyone suggests a method. -Gerry On 2011-07-19 , at 15:25 , Paul Andrews wrote: On 19/07/2011 08:15, Gerry Beauregard wrote: Hi folks, Does anyone know whether there's a way to call native code from a Flash SWF or AIR app, for example to call functions in a DLL? Something like Java's JNI but for Flash? I have never heard of anyone doing that and I know of no direct mechanism to do so. What is your use-case? I realize it's possible to read and write local data files from a SWF (using FileReference) or from an AIR app (using the File class), but that's reading and writing data, not running code. I also know it's possible to run C code compiled using Alchemy - but that's not really native code, as Alchemy-compiled code isn't native code, but rather byte- code that runs on the ActionScript VM. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com
Re: [Flashcoders] Calling native code from Flash
Thank you Paul and Karl for your responses! Interesting discussion! On 2011-07-19 , at 17:36 , Paul Andrews wrote: On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. The application involves real-time audio DSP with very low latency. Audio data would need to be passed from the AS3 code to the native code for processing, with results passed back from the native code to AS3. It'd be a lot of data, easily a half dozen streams of 16-bit 44.1kHz audio. Given the amount of data involved and the real-time low-latency requirements, it's almost certainly not practical to go through php, perl, or javascript bridging code. I sort of expected that calling native code in an efficient way wouldn't be possible, due to the security sandbox issues as Paul mentioned. I was just hoping there was some trick to do it... Maybe with signing of native binaries so they're considered trusted by Flash? Maybe having the user give permission to use native code (analogous to how the user needs to give permission to use the microphone input, for example)? But I guess there isn't :-( Looks like I'll have to squeeze whatever performance I can from code written in AS3. Looking on the bright side, at least I can stick to one language :-) Thanks again for all your suggestions and feedback! -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Have you tried Alchemy? http://labs.adobe.com/technologies/alchemy/ * * * @leandroferreira* * 55 61 91151257* On Tue, Jul 19, 2011 at 07:04, Gerry Beauregard gerry.beaureg...@sonoport.com wrote: Thank you Paul and Karl for your responses! Interesting discussion! On 2011-07-19 , at 17:36 , Paul Andrews wrote: On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. The application involves real-time audio DSP with very low latency. Audio data would need to be passed from the AS3 code to the native code for processing, with results passed back from the native code to AS3. It'd be a lot of data, easily a half dozen streams of 16-bit 44.1kHz audio. Given the amount of data involved and the real-time low-latency requirements, it's almost certainly not practical to go through php, perl, or javascript bridging code. I sort of expected that calling native code in an efficient way wouldn't be possible, due to the security sandbox issues as Paul mentioned. I was just hoping there was some trick to do it... Maybe with signing of native binaries so they're considered trusted by Flash? Maybe having the user give permission to use native code (analogous to how the user needs to give permission to use the microphone input, for example)? But I guess there isn't :-( Looks like I'll have to squeeze whatever performance I can from code written in AS3. Looking on the bright side, at least I can stick to one language :-) Thanks again for all your suggestions and feedback! -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Don't know if these will help or get you on the right path.. http://help.adobe.com/en_US/as3/dev/ WSb2ba3b1aad8a27b060d22f991220f00ad8a-8000.html http://www.northcode.com/forums/showthread.php?t=8969 http://www.marijnspeelman.nl/blog/category/actionscript-30/ Best, Karl On Jul 19, 2011, at 5:04 AM, Gerry Beauregard wrote: Thank you Paul and Karl for your responses! Interesting discussion! On 2011-07-19 , at 17:36 , Paul Andrews wrote: On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. The application involves real-time audio DSP with very low latency. Audio data would need to be passed from the AS3 code to the native code for processing, with results passed back from the native code to AS3. It'd be a lot of data, easily a half dozen streams of 16- bit 44.1kHz audio. Given the amount of data involved and the real-time low-latency requirements, it's almost certainly not practical to go through php, perl, or javascript bridging code. I sort of expected that calling native code in an efficient way wouldn't be possible, due to the security sandbox issues as Paul mentioned. I was just hoping there was some trick to do it... Maybe with signing of native binaries so they're considered trusted by Flash? Maybe having the user give permission to use native code (analogous to how the user needs to give permission to use the microphone input, for example)? But I guess there isn't :-( Looks like I'll have to squeeze whatever performance I can from code written in AS3. Looking on the bright side, at least I can stick to one language :-) Thanks again for all your suggestions and feedback! -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Did a google for run dll with AS3 Best, Karl On Jul 19, 2011, at 5:04 AM, Gerry Beauregard wrote: Thank you Paul and Karl for your responses! Interesting discussion! On 2011-07-19 , at 17:36 , Paul Andrews wrote: On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. The application involves real-time audio DSP with very low latency. Audio data would need to be passed from the AS3 code to the native code for processing, with results passed back from the native code to AS3. It'd be a lot of data, easily a half dozen streams of 16- bit 44.1kHz audio. Given the amount of data involved and the real-time low-latency requirements, it's almost certainly not practical to go through php, perl, or javascript bridging code. I sort of expected that calling native code in an efficient way wouldn't be possible, due to the security sandbox issues as Paul mentioned. I was just hoping there was some trick to do it... Maybe with signing of native binaries so they're considered trusted by Flash? Maybe having the user give permission to use native code (analogous to how the user needs to give permission to use the microphone input, for example)? But I guess there isn't :-( Looks like I'll have to squeeze whatever performance I can from code written in AS3. Looking on the bright side, at least I can stick to one language :-) Thanks again for all your suggestions and feedback! -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
mate , just use SWF Studio http://www.northcode.com , it can do even more complex things , read about it and you'll like it . I use it since 2004 and I did many big things with it . *call dll test example in AS3*http://www.northcode.com/forums/showthread.php?t=8969 *Getting Started http://www.northcode.com/forums/forumdisplay.php?f=57 Examples (the API is the same for both AS2 AS3)http://www.northcode.com/v3/examples.php * On Tue, Jul 19, 2011 at 1:34 PM, Karl DeSaulniers k...@designdrumm.comwrote: Did a google for run dll with AS3 Best, Karl On Jul 19, 2011, at 5:04 AM, Gerry Beauregard wrote: Thank you Paul and Karl for your responses! Interesting discussion! On 2011-07-19 , at 17:36 , Paul Andrews wrote: On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. The application involves real-time audio DSP with very low latency. Audio data would need to be passed from the AS3 code to the native code for processing, with results passed back from the native code to AS3. It'd be a lot of data, easily a half dozen streams of 16-bit 44.1kHz audio. Given the amount of data involved and the real-time low-latency requirements, it's almost certainly not practical to go through php, perl, or javascript bridging code. I sort of expected that calling native code in an efficient way wouldn't be possible, due to the security sandbox issues as Paul mentioned. I was just hoping there was some trick to do it... Maybe with signing of native binaries so they're considered trusted by Flash? Maybe having the user give permission to use native code (analogous to how the user needs to give permission to use the microphone input, for example)? But I guess there isn't :-( Looks like I'll have to squeeze whatever performance I can from code written in AS3. Looking on the bright side, at least I can stick to one language :-) Thanks again for all your suggestions and feedback! -Gerry __**_ Flashcoders mailing list Flashcoders@chattyfig.figleaf.**com Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/**mailman/listinfo/flashcodershttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com __**_ Flashcoders mailing list Flashcoders@chattyfig.figleaf.**com Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/**mailman/listinfo/flashcodershttp://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
On 2011-07-19 , at 18:07 , Leandro Ferreira wrote: Have you tried Alchemy? http://labs.adobe.com/technologies/alchemy/ * * * @leandroferreira* * 55 61 91151257* Yes. Alchemy still runs on the ActionScript Virtual Machine, though, so it's not particularly fast. Nowhere near as fast as compiled C++ code. Alchemy has some other issues too. Passing large amounts of data between AS3 and Alchemy code is pretty slow. As far as I can tell, there's no way to pass a VectorNumber, and passing via ByteArrays is really slow - the reading and writing of the ByteArray is slow enough to obviate any gain you get from using Alchemy as opposed to AS3. Alchemy also seems to still be a research project within Adobe Labs, not really a fully-supported official product, so I'm reluctant to use it for commercial code. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Hi, Having tried the Ogg encoding program someone wrote as a demo, I am inclined to agree - to work around this, I used AIR's Native Process API to launch the oggenc encoder to encode wav files. If the northcode DLL stuff is no good, maybe consider running your DLL in an application that provides a simple API over command line and use the Native Process API to pass commands, or use a Socket as other people suggested. We use the socket method to talk to a backend C++ program.. Glen On 19/07/2011 12:35, Gerry Beauregard wrote: On 2011-07-19 , at 18:07 , Leandro Ferreira wrote: Have you tried Alchemy? http://labs.adobe.com/technologies/alchemy/ * * * @leandroferreira* * 55 61 91151257* Yes. Alchemy still runs on the ActionScript Virtual Machine, though, so it's not particularly fast. Nowhere near as fast as compiled C++ code. Alchemy has some other issues too. Passing large amounts of data between AS3 and Alchemy code is pretty slow. As far as I can tell, there's no way to pass a VectorNumber, and passing via ByteArrays is really slow - the reading and writing of the ByteArray is slow enough to obviate any gain you get from using Alchemy as opposed to AS3. Alchemy also seems to still be a research project within Adobe Labs, not really a fully-supported official product, so I'm reluctant to use it for commercial code. -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Embed the flash player in your own native application. Then add stuff to the api using high level magic and there you go, new stuff for actionscript to use. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Gerry, If you can go with an app, check out Zinc. It offers several system interfaces, including invoking DLLs directly: http://www.multidmedia.com/support/livedocs/ --Dave On Jul 19, 2011, at 9:00 AM, flashcoders-requ...@chattyfig.figleaf.com wrote: Message: 12 Date: Tue, 19 Jul 2011 18:04:56 +0800 From: Gerry Beauregard gerry.beaureg...@sonoport.com Subject: Re: [Flashcoders] Calling native code from Flash To: Flash Coders List flashcoders@chattyfig.figleaf.com Message-ID: 33c7166e-228c-476a-872d-ce45a0b8b...@sonoport.com Content-Type: text/plain; charset=us-ascii Thank you Paul and Karl for your responses! Interesting discussion! On 2011-07-19 , at 17:36 , Paul Andrews wrote: On 19/07/2011 10:27, Karl DeSaulniers wrote: Hi Paul, Gerry, Are these runtime calls, or calls to set up runtime? How is the swf published? Local? Server? If Local, you could try javascript. Calling the javascript before you need the results in flash. Then que the results so there is no latency, like a buffer? If server, I would go with Paul's socket suggestion or a perl script. Or call the php before you need the results in flash. A small php script takes milliseconds to execute. Maybe, but there's network latency to be added to that. DSP usually requires fast real-time processing, so latency defeats the object of using native code. My suggestion about the socket server would be to install that on the client, not a remote server. Even so I suspect the latency will be too big. The application involves real-time audio DSP with very low latency. Audio data would need to be passed from the AS3 code to the native code for processing, with results passed back from the native code to AS3. It'd be a lot of data, easily a half dozen streams of 16-bit 44.1kHz audio. Given the amount of data involved and the real-time low-latency requirements, it's almost certainly not practical to go through php, perl, or javascript bridging code. I sort of expected that calling native code in an efficient way wouldn't be possible, due to the security sandbox issues as Paul mentioned. I was just hoping there was some trick to do it... Maybe with signing of native binaries so they're considered trusted by Flash? Maybe having the user give permission to use native code (analogous to how the user needs to give permission to use the microphone input, for example)? But I guess there isn't :-( Looks like I'll have to squeeze whatever performance I can from code written in AS3. Looking on the bright side, at least I can stick to one language :-) Thanks again for all your suggestions and feedback! -Gerry ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
On 19/07/2011 17:18, David Cohn wrote: Gerry, If you can go with an app, check out Zinc. It offers several system interfaces, including invoking DLLs directly: http://www.multidmedia.com/support/livedocs/ --Dave It attracted some poor comments at one time - I don't know if that has changed. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Or Pixel Bender - I've heard you can do some heavy processing with that too. Additionally, HaXe has some ways to avoid some of the overhead of Alchemy when using it from AS3. You'd have to do a lot in haxe instead of AS3, but you can use the alchemy stuff though inlining, which accesses the memory stored in Alchemy directly, instead of copying data back and forth between AS3 and Alchemy memory space, which if I understand it correctly, is where the overhead is with Alchemy. Joa has a tool (http://code.google.com/p/apparat/) which might be useful to help do some AS3 inlining to the Alchemy memory operations. I think the way to use it, is to make sure your bytearrays are stored in the Alchemy memory. Then you can access that from AS3 without the memcopy overhead. Kevin N. On 7/19/11 7:35 AM, Gerry Beauregard wrote: On 2011-07-19 , at 18:07 , Leandro Ferreira wrote: Have you tried Alchemy? http://labs.adobe.com/technologies/alchemy/ * * * @leandroferreira* * 55 61 91151257* ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Hi Kevin, Thanks for this! Definitely interesting. In my limited testing with Alchemy, I found that getting large amounts of data across the AS3-Alchemy boundary using ByteArrays was indeed a major bottleneck, so anything that eliminates that bottleneck is welcome indeed! -Gerry On 2011-07-20 , at 07:09 , Kevin Newman wrote: Or Pixel Bender - I've heard you can do some heavy processing with that too. Additionally, HaXe has some ways to avoid some of the overhead of Alchemy when using it from AS3. You'd have to do a lot in haxe instead of AS3, but you can use the alchemy stuff though inlining, which accesses the memory stored in Alchemy directly, instead of copying data back and forth between AS3 and Alchemy memory space, which if I understand it correctly, is where the overhead is with Alchemy. Joa has a tool (http://code.google.com/p/apparat/) which might be useful to help do some AS3 inlining to the Alchemy memory operations. I think the way to use it, is to make sure your bytearrays are stored in the Alchemy memory. Then you can access that from AS3 without the memcopy overhead. Kevin N. On 7/19/11 7:35 AM, Gerry Beauregard wrote: On 2011-07-19 , at 18:07 , Leandro Ferreira wrote: Have you tried Alchemy? http://labs.adobe.com/technologies/alchemy/ * * * @leandroferreira* * 55 61 91151257* ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Calling native code from Flash
Hi Gerry, Alchemy optimizations. They look like good reads. Hope they are along the lines of what your looking for. http://blog.frankula.com/?p=211 http://philippe.elsass.me/2010/05/as3-fast-memory-access-without- alchemy/ Best, Karl On Jul 19, 2011, at 10:42 PM, Gerry Beauregard wrote: Hi Kevin, Thanks for this! Definitely interesting. In my limited testing with Alchemy, I found that getting large amounts of data across the AS3-Alchemy boundary using ByteArrays was indeed a major bottleneck, so anything that eliminates that bottleneck is welcome indeed! -Gerry On 2011-07-20 , at 07:09 , Kevin Newman wrote: Or Pixel Bender - I've heard you can do some heavy processing with that too. Additionally, HaXe has some ways to avoid some of the overhead of Alchemy when using it from AS3. You'd have to do a lot in haxe instead of AS3, but you can use the alchemy stuff though inlining, which accesses the memory stored in Alchemy directly, instead of copying data back and forth between AS3 and Alchemy memory space, which if I understand it correctly, is where the overhead is with Alchemy. Joa has a tool (http://code.google.com/p/apparat/) which might be useful to help do some AS3 inlining to the Alchemy memory operations. I think the way to use it, is to make sure your bytearrays are stored in the Alchemy memory. Then you can access that from AS3 without the memcopy overhead. Kevin N. On 7/19/11 7:35 AM, Gerry Beauregard wrote: On 2011-07-19 , at 18:07 , Leandro Ferreira wrote: Have you tried Alchemy? http://labs.adobe.com/technologies/alchemy/ * * * @leandroferreira* * 55 61 91151257* ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders