<p>I have a swf file that is not controlled by me. The swf expects a javascript call to set some variables after initialization. </p>

<p>The swf is embedded using the swfobject and I'm trying to call the as function right after the embed. This appears to be too soon because I get an error. Everything else should be fine since calling the as function manually via firebug does not produce the error.</p>

<p>So the question is how do I call the function when the embed is complete?</p>

Are you doing this while the page is still loading? Or from am onload handler?
If it's inline javascript I would suggest doing it in the onload handler from javascript which you can do like this -
```
```
window.onload = function() {
  // your code here 
}
```
```
it will run your code once the page is fully loaded.
This doesn't guarentee that the flash is initialised though. You could do that by having the flash make a callback to javascript once it is ready, but you said that the swf is not in your control. All I can really think of us using the onload method to make sure the page is finished loading, and then insert a short delay before trying to use it. Look at the setTimeout javascript function for that. Not a great solution though.