One of my teammates recently had a problem with some Flash injection code. She was setting some properties and then calling a function on a JavaScript object that threw an error. We got a message that said "Object doesn't support this property or method".

We isolated it down to a timing issue by dropping an alert() into the code just before we called the method. With the alert() pausing execution for a few seconds, the browser had enough time to fully instantiate our object. Without the alert(), the method was called before it was built. Its a problem that can make your brain hurt.
Here's how you can test for the existence of a JavaScript method before you call it. You might need to do this if you're working with asynchronous calls or dynamic objects that take a while to build.
I created a sample page to demonstrate the issue and how to deal with it. I put three hyperlinks on the page that each call a JavaScript method. Here's the JavaScript code.

At the bottom of the previous code block, you'll see some JavaScript in the mainline section. This code gets executed as soon as the browser sees it. JavaScript is an interpreted language and the browser processes it in a top-down fashion. So, by definition, the browser already knows about my three methods before it runs my code in the mainline. This is where I define an empty object to test and then create an instance of that object. Just two lines, not much so far.
When I click the link that runs the function named TestForFunction(), I perform some due diligence tests by checking for an undefined object as well as a null object. The last test with the arrow pointing to it is the key part. This will tell me if the method exists without actually running the method. I show one of two messages based on the existence of the method.
The top function named CreateFunction() just spot welds a method onto my object. Even though I've already created an instance of my object, I can still see this method in my instance because I've added the method to the prototype. When this function returns, I've got my new method. When I run TestForFUnction() again, it will see the method.
The bottom method just executes the function I added on the fly. When my DoWork() method fires, it shows a message in the alert() pop-up.
If you find that you need to deal with this type of problem in your code, inspect the object for the method before you call it. If the method doesn't exist, refactor your code to call the window.setTimeout() function for a few milliseconds and check again. Once it exists, your code can continue executing.