views:

670

answers:

3

Using ExternalInterface in AS3 is it possible to call OS (C#?) functions within XP?

Example: Set the desktop background to a image supplied by a flash app?

If it is possible would it be different calls when applied to different OS. And what about cross over the Mac?

Any information would be great

Thanks

+1  A: 

If you're launching the swf from within a C# app, external interface will do just fine. Nothing will change on the flash side, but you'll need to go through a couple hoops to get it to work in C#. It's not as simple as AMF or External Interface to JS.

All the communications to C# get converted to XML describing the data, and you've gotta write XML to send back to flash. Other than that though, its relativly simple.

Here's some info on how to do it. The AS portion is Flash 8/AS2, but the C# portion should say the same.

Alex Jillard
I was just viewing that exact page :). thanks Alex.In terms of communicating with Windows OS functions (set background for instance) will i need to create c# scripts to act as a bridge between a desktop base swf and the OS? or is it possible to interact direct with the OS? Bare in mind i know nothing about the c# programing language - this is research into ideas.
Yup, you'd have to use C# (or some other programming language) as a go-between. Flash doesn't have access to most of your computer for security reasons. I'm sure there are ways to use EI with other languages too. I did it once in Delphi years ago...C# more recently, and I'm sure you could do it in Java and whatnot as well.
Alex Jillard
A: 

When working with Flash from a webpage or as a desktop app, you are limited to a small security sandbox and you will not be able to make any relevant OS call. I thought that switching to AIR would give the developper more flexibility but it doesn't seem correct either. From "The Pros and Cons of Adobe Air":

AIR apps have file access, clipboard access, support multiple windows, support drag and drop, and can trigger notifications (toast in Windows). If you app needs to interact with the desktop in other ways, the chances are that AIR is not suitable. For example, there is no access to COM automation, and no way to execute external applications. The reason is to maintain cross-platform compatibility. That's a worthy goal, but it would be good to have a way out of the sandbox. Unlike Java or .NET, you cannot extend AIR with custom native code libraries. Nor can you call operating system APIs.

As Alex Jillard commented, if your swf is called inside a C# desktop application, you should be able to access more OS funcionalities although I'm not sure how.

jdecuyper
A: 

You could use as already mentioned AIR. Another idea would be to use HippoHX (I haven't written this, the similarity with my username is just coincidence). It runs on top of the NekoVM and gives you unrestricted (so no limitations like in AIR ) access to the system.

Hippo