Web developers wiki ASP.NET Sitecore Sharepoint Kentico by Evident Interactive

jQuery and ExternallInterface

Modified: 2010/05/04 11:26 by jeroenoliemans - Categorized as: Flash, Front-end, JQuery
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);
}

The javascript way worked 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)
}

 © Evident Interactive BV