Saturday, May 29, 2010

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:
The following doesn't work, and there is no error message:
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.


Vitalijus said...

While not very clean, this should probably work:


Shannon -jj Behrens said...

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

Shannon -jj Behrens said...

That makes perfect sense. Thanks a lot for explaining it to me :)