[flexcoders] Re: TitleWindow lost focus on startup

2006-03-23 Thread Doug Lowder
I did quite a bit of investigation on this, including Jester's take 
on the problem over on his site.  The root of the problem is that 
the browser does not automatically give the Flash player focus when 
the page loads.  For Internet Explorer, there is a way to accomplish 
this through Javascript.  As far as I know, Mozilla browsers do not 
allow setting the focus to a plugin via Javascript.

Here is html that you can use as a wrapper to set the focus to a 
Flash app on startup.  Just set the mxmlname and url variables 
approiately for your case and browse to the html page instead of 
your mxml app.

html
head
titleAboveNet Customer Portal/title
/head

script language=JavaScript
!--
var mxmlname = app.mxml;
var url = http://server:port/path/; + mxmlname;
var flashname = mxmlname + .swf;
var appframename = appframe;

function setInitialFocus(sFrame, sFlash) {
document.frames[sFrame].document[sFlash].focus();
}

document.writeln(frameset onload=\setInitialFocus(' + 
appframename + ', ' + flashname + ')\);
document.writeln(frame name=' + appframename + ' 
scrolling='no' width='100%' height='100%'  + 
frameborder=0 topmargin=0 bottommargin=0 leftmargin=0 
rightmargin=0 marginwidth=0 marginheight=0  + 
src=' + url + ');
document.writeln(/frame);
document.writeln(/frameset);
//--
/script

/html


--- In flexcoders@yahoogroups.com, xithor [EMAIL PROTECTED] wrote:

 I have a TitleWindow set to popup at the startup of my 
application. I use this window at 
 other points in the program with absolutely no problems. But when 
it's called on startup 
 using the 'initialize' event on my main canvas, it opens the 
popup, and it functions fairly 
 normally, but A: does not obtain focus automatically, B: does not 
capture tab key presses.
 
 The loginWin TitleWindow is set to setFocus() on one of the text 
input boxes... It highlights 
 it in blue, but when you type, the text doesn't go into it, unless 
you manually click in teh 
 box.
 
 Then if I hit tab, it tabs through the items in my main canvas, vs 
tabbing through items in 
 the popup.
 
 I'm guessing this is somehow related to the window loading before 
the main components 
 are finished initializing, but I'm not sure how to get around 
this. I've tried all sorts of tips 
 and tricks, but still can't get it to work.
 
 Any suggestions would be appreciated. Code snippits below:
 
 
 
 Main Canvas:
 
 mx:Canvas id=mainCanvas width=100% height=100% 
initialize=startUp();
 
 
 loginWin definition:
 
 var loginWin:Object;
 
 
 startUp() function:
 
 function startUp() {
 loginWin=TitleWindow(PopUpManager.createPopUp
(mainCanvas, loginBox , 
 true));
 loginWin.mainApp = this;
 loginWin.centerPopUp();
 }








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
 





[flexcoders] Re: TitleWindow lost focus on startup

2006-03-23 Thread Doug Lowder
A more appropriate page title would probably be in order, too.  ;)


--- In flexcoders@yahoogroups.com, Doug Lowder [EMAIL PROTECTED] 
wrote:

 I did quite a bit of investigation on this, including Jester's 
take 
 on the problem over on his site.  The root of the problem is that 
 the browser does not automatically give the Flash player focus 
when 
 the page loads.  For Internet Explorer, there is a way to 
accomplish 
 this through Javascript.  As far as I know, Mozilla browsers do 
not 
 allow setting the focus to a plugin via Javascript.
 
 Here is html that you can use as a wrapper to set the focus to a 
 Flash app on startup.  Just set the mxmlname and url variables 
 approiately for your case and browse to the html page instead of 
 your mxml app.
 
 html
 head
 titleAboveNet Customer Portal/title
 /head
 
 script language=JavaScript
 !--
 var mxmlname = app.mxml;
 var url = http://server:port/path/; + mxmlname;
 var flashname = mxmlname + .swf;
 var appframename = appframe;
 
 function setInitialFocus(sFrame, sFlash) {
 document.frames[sFrame].document[sFlash].focus();
 }
 
 document.writeln(frameset onload=\setInitialFocus(' + 
 appframename + ', ' + flashname + ')\);
 document.writeln(frame name=' + appframename + ' 
 scrolling='no' width='100%' height='100%'  + 
 frameborder=0 topmargin=0 bottommargin=0 leftmargin=0 
 rightmargin=0 marginwidth=0 marginheight=0  + 
   src=' + url + ');
 document.writeln(/frame);
 document.writeln(/frameset);
 //--
 /script
 
 /html
 
 
 --- In flexcoders@yahoogroups.com, xithor frog@ wrote:
 
  I have a TitleWindow set to popup at the startup of my 
 application. I use this window at 
  other points in the program with absolutely no problems. But 
when 
 it's called on startup 
  using the 'initialize' event on my main canvas, it opens the 
 popup, and it functions fairly 
  normally, but A: does not obtain focus automatically, B: does 
not 
 capture tab key presses.
  
  The loginWin TitleWindow is set to setFocus() on one of the text 
 input boxes... It highlights 
  it in blue, but when you type, the text doesn't go into it, 
unless 
 you manually click in teh 
  box.
  
  Then if I hit tab, it tabs through the items in my main canvas, 
vs 
 tabbing through items in 
  the popup.
  
  I'm guessing this is somehow related to the window loading 
before 
 the main components 
  are finished initializing, but I'm not sure how to get around 
 this. I've tried all sorts of tips 
  and tricks, but still can't get it to work.
  
  Any suggestions would be appreciated. Code snippits below:
  
  
  
  Main Canvas:
  
  mx:Canvas id=mainCanvas width=100% height=100% 
 initialize=startUp();
  
  
  loginWin definition:
  
  var loginWin:Object;
  
  
  startUp() function:
  
  function startUp() {
  loginWin=TitleWindow(PopUpManager.createPopUp
 (mainCanvas, loginBox , 
  true));
  loginWin.mainApp = this;
  loginWin.centerPopUp();
  }
 








--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

* To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/

* To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]

* Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/