PDA

View Full Version : problem with External Interface



ParanoidAndroid
March 1st, 2010, 03:15 PM
i want to call a javascript function from within an embeded swf file in a html page and i'm using the ExternalInterface class. i know this function must be defined in a <script> tag in the html page. however, i want to have all my javascript code in an external file, but it doesn't work. my trial file just can't find the function, although i have my external js file linked in the header. how can i do this? i'd really appreciate your help, thanks.

biznuge
March 1st, 2010, 03:29 PM
are you maybe trying to hit the function before the JS has loaded. maybe you have a race condition in your code?

maybe try alerting out in the top of your JavaScript include to make sure you're not trying to call something thats not there yet...

also, have you allowed script access in your object/embed tags or whatever method of flahs injection you have...

just a coupla ideas.

ParanoidAndroid
March 1st, 2010, 05:51 PM
you may be right, there's something strange going on here. i'm using the ready handler from jquery and that seems to be the problem, beacuse when i don't use it works! :S really don't understand this.

biznuge
March 1st, 2010, 06:10 PM
where are you writing in the flash. If it's in its own object tag right there in the page, then there's every chance the flash container (the object tag that will be the hook for the plash player plugin to run in) is getting written in to the page well before the JQuery ready method ever fires.

If you try swfobject, or the flash satay method (if that still exists) to get your flash into the page AFTER the document.ready method fires, then you may be more successful.

This is all just speculation though, so please feel free to prove my postulations wrong.

good luck anyway, and post back if you need anything else or get it fixed!