Usability guidelines should be a function of the context in which the application is used, not the technology upon which it is built. If you have usability guidelines for desktop applications, then (since AIR provides resources allowing a Flex application to run on a desktop), the Principle of Least Surprise would dictate that it should follow the same guidelines as apps written in .NET, VB6, C++ Delphi etc. for use as a desktop app.
The more interesting question would be how the guidelines for a Flex app written for the browser would differ from normal Web guidelines, given the greater granularity of user control it provides; but that's not what this question is about.
Got it.
The issue was caused by a different behaviour in the SecurityDomain
system within an AIR application. When a SWF file is loaded within an AIR application, it always depend to a different sandbox. Thus, AIR creates a new SecurityDomain
for this SWF.
Since a SecurityDomain
is a group of one or more ApplicationDomain
s, this behaviour forced the creation of a new ApplicationDomain
(within the new SecurityDomain
), ignoring the specified one (which belong to the 'main' SecurityDomain
).
There is a workaround using URLLoader
. When loaded from bytecode (using Loader.loadBytes
), a SWF is loaded within the same SecurityDomain
. This is why you have to put the allowLoadBytesCodeExecution
to true, since it can be unsafe. So loading the SWF indirectly, first though an URLLoader
, and then with Loader.loadBytes
, solve this issue.
Here's the snippet :
package {
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLLoader;
import flash.net.URLLoaderDataFormat;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.utils.ByteArray;
public class Invoker extends Sprite
{
public function Invoker()
{
var uldr : URLLoader = new URLLoader();
uldr.dataFormat = URLLoaderDataFormat.BINARY;
uldr.addEventListener(Event.COMPLETE, onBytesComplete);
uldr.load(new URLRequest("otherSwf.swf"));
}
private function onBytesComplete(e : Event) : void
{
var bytes : ByteArray = (e.target as URLLoader).data;
var ldr : Loader = new Loader();
ldr.contentLoaderInfo.addEventListener(Event.COMPLETE, onChildComplete);
var ldrC : LoaderContext = new LoaderContext();
// This property was for AIR 1.0.
//ldrC.allowLoadBytesCodeExecution = true;
// Since AIR 2.0, it's allowCodeImport.
ldrC.allowCodeImport = true;
ldr.loadBytes(bytes, ldrC);
}
private function onChildComplete(e : Event) : void
{
var c1ad : ApplicationDomain = (e.target as LoaderInfo).applicationDomain;
var inad : ApplicationDomain = ApplicationDomain.currentDomain;
trace("Child One parentDomain : " + c1ad.parentDomain);
trace("Invoker parentDomain : " + inad.parentDomain);
trace("Child One has Invoker : " + c1ad.hasDefinition("Invoker"));
trace("Invoker has Invoker : " + inad.hasDefinition("Invoker"));
}
}
}
Hope this helps.
Best Answer
Adobe AIR runs on the same technology as Flash (i.e. your AIR apps will run in the Flash player.) The difference is the additional libraries available in AIR to allow you to more easily create Rich Internet Applications, as opposed to Flash itself which is targeted at animation and games creation.
The end product of a compiled AIR application is either a .air file or a natively packaged .exe/.dmg file (if targeted at the desktop in AIR 2+)
The .air file is just a zip file which contains a .swf file and relevant directories from your project (such as unembedded assets).
The .exe file is the same except for it also contains code to download and install the Adobe AIR Runtime if the user does not have it installed on their system. This can be very useful if you want your application to run only on the desktop as it means users won't get an 'open this file with..' message when they run the app without the runtime installed.
The Adobe AIR runtime is what allows your operating system to interpret .air files and install/run them on the system. It contains the relevant AIR libraries not included in Flash.
Adobe AIR when combined with Flex (mxml application) does allow states and transitions. States and transitions are a feature of Flex, so you would need to be using the Flex SDK in your project to use them.