jQuery and ExternallInterface

It seems to be that ExternalInterface will not work if the flash file is referenced with jQuery. Which is odd because the jQuery wil translate to the javascript function getElementById. However the following code gave javascript errors that the function send2Flash could not be found.


if( $("#debaak").length > 0 )
{
$("#debaak").send2Flash(str);
}

After discussing this subject we found the following solutions. JQuery returns an object, with the get function it is possible to get any element in the jQuery object returned by the jQuery selector

$("#debaak").get(0).send2Flash(str);
or
$("#debaak")[0].send2Flash(str);

The javascript way also works perfectly whithout any errors.


if (document.getElementById)
{
flashMovie = document.getElementById("debaak");
}

if (flashMovie)
{
flashMovie.send2Flash(str);
}

Below you can find the necessary code for flash.


public function Main()
{
ExternalInterface.addCallback("send2Flash", callJS);
}
private function callJS(msg)
{
//called from js
trace('call from js:' + msg)
}