Reputation: 132872
I'm downporting some ActionScript 3 to ActionScript 2 (some ad agencies sadly still refuse to embrace the future) and I've run into the issue that in ActionScript 2 ExternalInterface
has no objectID
property, as it does in ActionScript 3.
The code I'm working on calls a lot of JavaScript, and some of that code requires the script to know the ID of the Flash object/embed (for example to find the position on the page, and to resize the object/embed).
Is there a simple workaround to get hold of the object/embed ID in ActionScript 2?
I have managed to write some JavaScript code that basically searches all object and embed nodes on the page until it finds one with a special method (set with ExternalInterface.addCallback
) and that way managed to get the ID into the ActionScript environment, but it feels like a hacky and unsafe method to rely on. Surely there is a simpler way?
Edit: I don't have control over the code that embeds the SWF, so passing in the ID doesn't work.
Upvotes: 2
Views: 1720
Reputation: 196
Is this what you looking for? Simple actionscript 2 class that find it owns flash html object id.
http://sourceblogg.se/lang/en/mina-projekt/isitme-get-flash-html-object-id-within-flash/
Upvotes: 2
Reputation:
Try the Flash Javascript Integration kit http://weblogs.macromedia.com/flashjavascript/ . As far as I'm aware, the ExternalInterface class in AS3 was a formalisation of this AS2 solution.
Upvotes: 0
Reputation: 38798
What about passing the ID to the SWF via FlashVars? You should know the ID when you embed it, so it should be easy enough to add it as one of the FlashVars variables passed to Flash. Then store that somewhere your code that calls ExternalInterface can get at it.
Upvotes: 0