You can only call upon DOM elements when the DOM is loaded. Just use
the SWFObject 2.0 API [
http://code.google.com/p/swfobject/wiki/SWFObject_2_0_api_javascript_dev
] to execute the functionality after the DOM is loaded and after your
Flash content has been inserted, e.g. add the following code after
your embedSwf method:
function setFocusOnFlash() {
var fl = document.getElementById(flashObjectId);
if (fl) { fl.focus(); }
}
if (swfobject.hasFlashPlayerVersion("9.0.0")) { // insert the version
you test for
swfobject.addDomLoadEvent(setFocusOnFlash);
}
Just let me know if this works for you.
On Dec 8, 4:13 pm, teshca <Nickolay.Artamo...@gmail.com> wrote:
> Hi. I am trying to migrate my application from SWFObject v1.5 to
> SWFObject v2.0. I read documentation but I still don't get how can I
> set focus to my flash object. I use swfobject.embedSWF, and then
> document.getElementById(flashObjectId).focus(), but this rise
> exception because element with that Id not yet exists. How can I be
> sure that swfobject.embedSWF already finish its work and I can get dom
> element? The simple setTimeout works but It is a kind of hack. Is
> there a better solution for my problem?