Reputation: 9897
I'm loading as2 swf into AIR application. It works properly when loaded from file. But when loaded from bytes, it is broken in some way (it reacts to mouse, but some elements are inactive)
var bytes:ByteArray = ... //loaded from resources
var loader:Loader = new Loader();
var context:LoaderContext = new LoaderContext(false);
context.allowCodeImport = true; //this is neccessary
// Method 1 - blocks some scripts in loaded SWF
//context.applicationDomain = new ApplicationDomain();
// (application domain has no effect with as2 swf)
//context.securityDomain = SecurityDomain.currentDomain; //gives error 2114: securityDomain must be null
loader.loadBytes(bytes, context);
// Method 2 - loads properly
//loader.load(new URLRequest(file.url));
So why not just load it from file? My resources are protected with encryption and I can't dump them to disk - they must still be protected.
What tricks may exist to load from bytes properly?
There is similar question, but in my case as2 causes more problems.
Upvotes: 2
Views: 3396
Reputation: 1
It seems that old SWF movies (AS1 and AS2, which require AVM1) loaded into an AIR app with load
get put in their own domains, but those loaded with loadBytes
share a domain. So if you have multiple AVM1 SWFs loaded with loadBytes
their _global
properties will clobber each other. This affects the Flash MX UI components (ca. 2002).
I can't be the only one trying to package ancient Flash files in AIR apps, so I figure this info may be useful to someone.
Upvotes: 0
Reputation: 2635
According the the documentation for LoaderContext
you should only use the applicationDomain
property only when loading ActionScript 3.0 SWFs. Try dropping that parameter (or setting it to null) and see what happens.
Upvotes: 2
Reputation: 808
AS2 and AS3 use different runtimes (bytecode is different) so you won't be able to properly execute any AS2 bytecode in the AS3 runtime. you are basically injecting AS2 code into your AS3 application, so it ain't gonna work :/
Upvotes: 4