O'Reilly logo

Essential ActionScript 3.0 by Colin Moock

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Events Across Security Boundaries

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.

Tip

For information on loading .swf files see Chapter 28.

Module.swf Listener Registers with Main.swf Object

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:

Security.allowDomain("site-b.com");

The preceding line of code allows all .swf files from site-b.com (including Module.swf) to register ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required