I'm just curious if it's possible that Flash objects can access the DOM of the document that has embedded it.
Yes, through the ExternalInterface class.
You can make calls to Javascript from within the Flash movie and get back any public information about the page that your heart desires.
Addendum
Looking at this a year and a half later, i decided to add some examples:
Say you have a JS function on your client page like this:
function foo(bar,type) {
// do something with bar and type
}
You call it from Flash (using AS3) like so:
ExternalInterface.call(foo, bar, type);
Note that the function name is the first object and the arguments are listed sequentially thereafter.
To expose a method of the Flash movie to outside Javascript, you would do this in your Flash or Flex (again, 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
}
In the Javascript on the page you invoke it like this (where myMovie is the ID of the SWF):
myMovie.foo(anArg, anotherArg);
In the addCallback
method, the first argument is the external name of the function, and the second argument is the closure that will get called.
Yes.
An example: http://livedocs.adobe.com/flex/3/html/help.html?content=ProgrammingHTMLAndJavaScript_07.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With