I have an old program written in Actionscript 1, compiled in Flash 6. It loads 10 other modules, of which 3 are written in Actionscript 2, compiled in Flash 8. The original program is embedded into an html and works perfectly when the html file is run on a webserver. But if I just drag the html file to my browser, the 3 AS2 modules will not load. Or, more accurately, they do load but I can't access their functions. All the modules are compiled with "local playback security=access local files only". I am using Flash CS3 to compile all the modules. Without rewriting the main loading module to AS2, is there anything I can do to solve this? Thanks
views:
522answers:
3The rules of Flash's security model get kind of arcane, but it seems you're up against a cross-scripting restriction. One option might be to work around it, for example by installing Apache (or whatever) and accessing the content via http://localhost...
rather than file://...
. However, the security issue can probably be addressed too.
First you might want to check out this article, and particularly the chart partway down that page, which lays out the ground rules for when one SWF is allowed to access the functions of another. As indicated in the chart, the easiest way to make all accesses work is to get all the contents functioning in the "local trusted" sandbox. How to do that is covered part-way down page 4 of the same article.
I'm not sure if this is related to your problem, but mixing AVM1 SWF files can be problematic.
If a flash SWF is compiled for version 6 without the "optimize for version 6r65" option selected in the output settings, then the bytecode produced is largely incompatible with AVM1 swf files compiled for v6r65 or later (esp. when using AS2 language as opposed to AS1).
This is because any reference to the _global property refers to a different location when compiling for these earlier versions, so properties defined in the _global namespace are not visible to movies targetted for later versions and vice versa.
Given that class definitions reside as variables in the _global namespace, this can prove very problematic when mixing swf files that are targetted for versions that lie either side 6r65.
I remember hacking around this by copying the _global reference in one of the SWF files to a location that was visible to the other SWF file.
(in pre 6r65)
class SomeClass
{
//
}
...
_global.someProp=123;
_level0.globalCopy=_global
(in post 6r65)
trace(SomeClass) //undefined
trace(_global.someProp) //undefined
trace(_level0.globalCopy.SomeClass) //[object object] i.e. defined
trace(_level0.globalCopy.someProp) //123
I have a similar question http://stackoverflow.com/questions/1242667/trying-to-load-remote-images-into-a-flash-sideshow