Can a Flash inline object access the DOM of its parent document?

I'm just wondering if it is possible that Flash objects can access the DOM of the document that embedded it.

+5
source share
3 answers

Yes, through the ExternalInterface class.

You can make Javascript calls from the Flash movie and get any public page information your heart desires.

Adding

Looking at this after a year and a half, I decided to add a few examples:

Say you have a JS function on your client page, for example:

function foo(bar,type) {
  // do something with bar and type
}

You call it from Flash (using AS3) as follows:

ExternalInterface.call(foo, bar, type);

, , .

Flash- Javascript, Flash Flex ( , AS3):

application1_applicationCompleteHandler(event:Event) {
  // the app has finished loading, so do whatever we
  // have to do on load, plus add that callback
  ExternalInterface.addCallback(foo, bar);
}

public function bar(arg1, arg2) : void {
  // do something with arg1 and arg2
}

Javascript ( myMovie - SWF):

myMovie.foo(anArg, anotherArg);

addCallback , - , .

+7

, , javascript , , , DOM.

+3

All Articles