1 Reply Latest reply on Dec 12, 2008 9:19 AM by rtalton

    BrowserManager Set HTML Title?

    glen08 Level 1
      I use the code from Flex3 Cookbook (p489):

      private function changePageTitle(newTitle:String):void {
      var bm:IBrowserManager=BrowserManager.getInstance();
      bm.init();
      bm.setTitle(newTitle);
      }
      I used it with creationComplete event, but the page title did not get set. It still just displays the URL.
        • 1. Re: BrowserManager Set HTML Title?
          rtalton Level 4
          I went through a lot of work to use deep linking in Flex. Setting the page title when a site visitor first opened the page was pretty frustrating for me. (I assume you've already enabled "Enable integration with browser navigation" under Flex Compiler in your project properties)

          You'll need to thoroughly read the help docs for Deep Linking to understand what's happening. Focus on Browser Manager events, like BROWSER_URL_CHANGE

          In the meantime, this may point you in the right direction:
          1) Create a public var named "parsing" type: Boolean value=false.
          2) On the app's creation complete event, initiate the Browser Manager, and add an event listener for BROWSER_URL_CHANGE. Also, set the page title.
          3) Also in this same creation compete function, add a callLater() line to the listener.
          4) In the listener function, set parsing=true.
          Then I look at the fragment: URLUtil.stringToObject(browserManager.fragment)
          I set the app's state according to the fragment. (IMPORTANT NOTE: may have been opened from a bookmark...)
          I set parsing=false.
          I set the URL fragment.
          Finally, I set the page title.

          I know it seems like the title is being set twice. Keep in mind this is because the site visitor may be arriving from a bookmark, or not. It makes a difference.
          This is the only way I could get it to work. If anyone has a better method, I'm receptive. Deep Linking was a real PITA to get working properly (for me) but once I got it, it's a beautiful thing to have in my application!