"wrapper": All (non AIR) Flex apps run in the Flash Player, which is in
turn hosted in an Html file, which is rendered by the browser.  That
html file is often referred to as the "html wrapper".  Flex Builder
generates the wrapper by default, naming it the same as your
application.

That function I posted goes in a javascript block in that html wrapper
file.  I put my script in with the version declarations in the commented
area near the top.

You invoke the javascript "showHelp()" function from Flex using
ExternalInterface. Below is the code I use for my help.

Tracy

import flash.external.ExternalInterface;

  public function
showHelp(sModuleId:String,sViewId:String="",sAnchor:String=""):void
  {
    var sFileName:String = sModuleId.toLowerCase();
    if (sViewId.length > 0) {
      sFileName += "_" + sViewId.toLowerCase();
    }
    sFileName += ".html";
    if (sAnchor.length > 0) {
      sFileName += "#" + sAnchor.toLowerCase();
    }    
    var sLoadUrl:String = _sSiteAssetsUrl + "help/" + sFileName;
    //trace(sLoadUrl)
    ExternalInterface.call("showHelp", sLoadUrl);   
  }//



From: [email protected] [mailto:[email protected]] On
Behalf Of simonjpalmer
Sent: Tuesday, December 30, 2008 3:06 PM
To: [email protected]
Subject: [flexcoders] Re: Controlling browser window state during
navigateToURL

There are a couple of things I'm not quite getting:
1) how do you invoke this from Flex?
2) what do you mean by your "wrapper"?

I understand the code below but I am still not really clear how it
gets invoked. Sorry for being so dim :-(

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Tracy Spratt" <tspr...@...> wrote:
>
> I handle this by having a js function in my wrapper create the new
> window, with the parameters I need, then using externalInterface to
> invoke the js function.
> 
> This has an additional benefit of allowing me to make the same window
> show different content from flex(I haven't figured out how to do this
> with navigateToURL directly). Here is the javascript I am using:
> 
> Tracy
> 
> var windowHelp;
> function showHelp(sURL)
> {
> if (windowHelp && windowHelp.open && !windowHelp.closed) { //Be
> SURE the window is available
> if (sURL != sLastURL && sURL.length > 0) { //If
> user wants a new url
> windowHelp.location.href = sURL;
> //navigate
> sLastURL = sURL;
> }
> windowHelp.focus();
> //always focus
> }
> else {
> if (sURL.length > 0) {
> //make sure we have an url
> var iBorderWidth = 50;
> var iLeft = window.screenLeft;
> var iTop = window.screenTop;
> var iWidth = document.body.offsetWidth;
> var iHeight = document.body.offsetHeight; 
> 
> var sWindowProperties =
> "location=no,toolbar=no,scrollbars=yes,menubar=no,resizable=yes"
> sWindowProperties += ",top=" + (iTop + iBorderWidth);
> sWindowProperties += ",left=" + (iLeft + iBorderWidth);
> sWindowProperties += ",height=500";
> sWindowProperties += ",width=400";
> windowHelp = window.open(sURL,'Help',sWindowProperties);
> sLastURL = sURL;
> }
> }
> }//showHelp
> 
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of simonjpalmer
> Sent: Tuesday, December 30, 2008 10:11 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] Controlling browser window state during
> navigateToURL
> 
> Hi,
> 
> I want to place a link on my app which starts a static HTML help page
> in a new broswer window and I want to control the appearance of the
> browser window that gets created. If I were doing this in HTML I
> would use JavaScript window.open and set the config parameter, e.g.
> 
> <SCRIPT LANGUAGE="javascript">
> <!--
> window.open ('titlepage.html', 'newwindow', config='height=100,
> width=400, toolbar=no, menubar=no, scrollbars=no, resizable=no,
> location=no, directories=no, status=no')
> -->
> </SCRIPT>
> 
> Is there a way of doing this in Flex (specifically Flex 2)?
> 
> TIA
> Simon
>
 

Reply via email to