In the upcoming Chapter 19, we'll study a variety of scenarios in which security restrictions prevent one .swf file from cross-scripting (programmatically controlling) another. When two .swf files are prevented from cross-scripting each other due to Flash Player security restrictions, they are subject to the following important event-handling limitations:
Event listeners in one .swf file are forbidden from registering for events with objects in the other .swf file.
When an event-dispatch targets an object in a display hierarchy, any objects inaccessible to the target's .swf file are not included in the event flow.
Fortunately, the preceding limitations can be completely circumvented using the flash.system.Security class's static method, allowDomain( ). Let's consider two examples showing how allowDomain( ) can be used to circumvent each of the preceding limitations.
For information on loading .swf files see Chapter 28.
Suppose a .swf file from one site(site-a.com/Main.swf)loads a .swf file from another site (site-b.com/Module.swf). Further suppose that Module.swf defines a listener that wishes to register with an object created by Main.swf. To permit the registration, Main.swf must execute the following line of code before Module.swf registers the listener:
The preceding line of code allows all .swf files from site-b.com (including Module.swf) to register ...