ActionScript: jQuery and ActionScript Callbacks

Let's suppose you have a SWF, and you're calling callbacks on that SWF from JavaScript. The following works:
document.getElementById('id-of-your-embed').someActionScriptCallback('someJavaScriptCallback')
The following doesn't work, and there is no error message:
$('#id-of-your-embed').someActionScriptCallback('someJavaScriptCallback')
I often think of $() as a way to use document.getElementById, but since it returns a jQuery shim, some things don't work as expected. This one took me quite a while to figure out.

Comments

Vitalijus said…
While not very clean, this should probably work:

$('#id-of-your-embed')[0].someActionScriptCallback('someJavaScriptCallback')
I'm sure you're right. I was just caught off guard ;)
HerrSerker said…
$ in jQuery return always an jQuery object. This is a wrapper for a HTML object. To get the HTML object in this use the array operator [] or the get() method like
$('#id')[0] or $('#id').get(0)
than it should work
That makes perfect sense. Thanks a lot for explaining it to me :)