I tried using this idea:
<object name="FlashName" ... />
<embed name="FlashName" ... />
but while this works in IE it's not working in firefox at all.
I also tried detecting the browser and focusing the embed instead of the object in firefox, but turns out that the embed can't take focus easily.
Eventually i've encountered this post: http://www.asserttrue.com/articles/2006/11/17/firefox-and-flash-swf-selection-and-focus-problems which solved this issue.
In order to focus flash in both firefox and IE, there're 2 things need to be done:
1. add wmode="opaque" to the object and to the embed
2. address the flash by name and not by ID or separating the code for IE and FireFox since each of the browsers is using different HTML tags (Object, Embed) and use the focus() method.