views:

617

answers:

4

I was going to make an AIR application but I need to execute an external application and because of the security restrictions in Adobe AIR... I was thinking why not try and bypass it by writing some C code that does something like System("file to execute"); and then use Alchemy to change it into a swc and us that in my application... Anyone tried this sort, or think it could work?

+7  A: 

What you need to understand about Alchemy is that it compiles C into the same bytecode as actionscript, and it runs under the same virtual machine (AVM2) as flash/flex as3 applications.

The reason Alchemy is able to be faster for some operations is that the compiled C (compiled to bytecode) is given access to raw "memory" (ApplicationDomain.domainMemory) via some optimised AVM2 instructions that were added in flash 10.

What I'm trying to get at is that because Alchemy simply runs on top of the AVM2, it is restricted in the same way as any other application. Alchemy in an AIR application can do more than Alchemy in the browser sandbox, but it is still restricted by that sandbox.

If you really need to execute an external application, you'll need to look into something like Shu or Zinc.

Sorry I couldn't be any more help.

Richard Szalay
You helped a lot! I was not aware of how Alchemy works, you answered my question, I really wish they'd just open up AIR a bit more, great platform, I just need a little bit more functionally.
Glad I could help :)
Richard Szalay
+1  A: 

This will not work - Alchemy is not really / really not suited for programs that interact with the outside world. I don't think it will support doing a system call, and even if Alchemy would support it the flash/air runtime will most certainly still block it.

If you don't need cross platform behavior you can look into creating an oldfashioned 'projector'. It is possible to launch programs from a projector exe using fscommand- just be aware the executable you want to launch has to be located in a folder named fscommand next to the binary. If that is not sufficient you could try a third party commercial tool like http://www.northcode.com/.

Simon Groenewolt
A: 

No, Richard Szalay's correct: Alchemy compiles C code into ActionScript bytecode, so the resulting SWF is still subject to the same sandbox restrictions as any other; the AIR restrictions may be looser, but using Alchemy provides no benefit in that respect.

However, you can still "call out" of the sandbox using a socket connection, provided you have an app listening for the connection; check out Merapi -- it might be able to help as a simple solution, if you were open to using Java, although you could certainly roll your own with something else, like C#.

Christian Nunciato
Hm, this Merapi thing seems like it mighty be useful... Thanks for the link, big help!
Sure thing. Good luck!
Christian Nunciato
A: 

我试过了,是不行的。被和谐了!