views:

522

answers:

3

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

+1  A: 

The 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.

fenomas
In this case I have to rule out option 1 - though I know that this does solve the problem.Reading the article hasn't cleared everything up, though I have stumbled on a partial answer. If I publish the AS2 modules using Flash 7 option, then I can call their functions and get about 90% working.
Adrian Raper
That's thorny territory. When flash player ver. X plays content published as Y<X, it runs in a sort of compatibility mode, attempting to show content as it would have appeared in player Y. But security changes are often not emulated, so the fine details are elusive. Is everything local-trusted?
fenomas
Also, can you verify whether your problem is a security issue (i.e., access is blocked), or a compatibility issue (access occurs but not as expected)? If it's the latter, spender's answer may be the right track, or something else in the same vein (especially if classes are used).
fenomas
+1  A: 

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
spender