Is there a JS event that allows me to tell when the SWF has been loaded?
something like an onload event?
Basically I am using a custom HTML toolbar that I want to update with total pages, currentzoom, etc... after the swf loads. Currently I am just doing a "setTimeout" and waiting 2 seconds, but if the swf takes longer than 2 seconds the code doesnt work.
Any suggestions are appreciated.
Thanks.
js onload
Re: js onload
There is an onload event for BODY tag but it appears that major browsers may call it even before a SWF file is fully loaded. To get a reliable onLoad event call we recommend using the following technique:
1. Declare the following JavaScript function:
2. After SWF load code (such as OBJECt tag) insert the following code:
Here MyDoc is the name of your OBJECT tag and GetDoc refers to the function described at http://print2flash.com/help/UsingDocume ... ations.php
3. Then declare your onLoaded event handler with whatever initialization code you need:
1. Declare the following JavaScript function:
Code: Select all
function checkLoaded(doc) {
try {
doc.getCurrentPage()
clearInterval(doc.checkLoadedInt)
onLoaded(doc)
}
catch(e) {
}
}
Code: Select all
GetDoc('MyDoc').checkLoadedInt=setInterval("checkLoaded(GetDoc('MyDoc'))",100)
3. Then declare your onLoaded event handler with whatever initialization code you need:
Code: Select all
function onLoaded(doc) {
doc.setCurrentPage(2)
// Other actions
}