开发者

Flex 3 : Easy Deep Linking Question

I'm having a problem with deeplinking on my Flex 3 site. I want people to be able to link to different parts of the site. I also want to be able to type a url into the browser bar and be taken to a particular part of my site. Also, I need the default to open to #view=2.

I'm having problems setting the default #view=2. So, it's supposed to check the browser fragment to see whether its a valid section of the site. If it is then it should call parseUrl() and open that section of the site. So far, so good. The problem is how do I set the default to view=#2, if the loop doesn't find a valid view number?

Here's my code:

private function initBrowserManager(): void {

    browserManager = BrowserManager.getInstance();
    browserManager.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE, parseUrl);
        browserManager.init("","My Website");

    if(browserManager.fragment != null){

         for (var j:uint = 0; j < ComboBoxDP.length; j++){
            if(browserManager.fragment == "view="+ComboBoxDP[j].series){
                            parseUrl();
                            break;
            }


         }

    }


 }

I've tried to add this line: else{browserManager.setFragment("view="+ 2); parseUrl();} everywhere I could think of, but 开发者_高级运维no luck so far. I know that the answer will be really simple. Any suggestions?

Thank you.

-Laxmidi


I'm assuming some of the intent of the code, but I'd use a boolean:

var initialFragmentValid:Boolean = false;
if(browserManager.fragment != null){
     for (var j:uint = 0; j < ComboBoxDP.length; j++){
        if(browserManager.fragment == "view="+ComboBoxDP[j].series){
            initialFragmentValid = true;
            break;
        }
     }
}

if (!initialFragmentValid) {
    // set the default
    browserManager.setFragment("view=2");
}

// always parse initially because we'll have a fragment regardless
parseUrl();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜