Hi,
I need some help with deeplinking on a Flex 3 website. I've got a weird problem. I set-up deeplinking and everything was working fine. I could use the back button and I could paste the url in the browser and it would open to the appropriate "page". I set-up the deeplinking using the ViewStack's selected index as the fragment to set. So www.mysite.com/#a=2, for example with 2 being the viewstack's selected index. This worked fine.
//ORIGINAL WORKING
private function initBrowserManager():void {
browserManager = BrowserManager.getInstance();
browserManager.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE, parseUrl)
browserManager.init(, My Website Title);
parseUrl();
}
private function updateUrl():void {
browserManager.setFragment(a=+ mainViewStack.selectedIndex);
}
But, I didn't want to use the selected indexes as they change when I add content and more importantly, I wanted SEO friendly URLs that contained words. So, the URL would be, for example, www.mysite.com/#view=my_cool_stuff. So, I took the viewstack.selectedChild id's, replaced the underscores with dashes and I also capitalized the page titles. This is what I've got:
//NEW Version with Problems
private function initBrowserManager():void {
browserManager = BrowserManager.getInstance();
browserManager.addEventListener(BrowserChangeEvent.BROWSER_URL_CHANGE, parseUrl)
browserManager.init("", "My Website Title");
parseUrl();
}
private function updateUrl():void {
var selectedStack:String = mainViewStack.selectedChild.id;
var dashedURLFragment:String = selectedStack.replace(/_/g,"-");
var withoutUnderscore:String = selectedStack.replace(/_/g," ");
var capitalizeTitle:String = withoutUnderscore.replace(/\b./g, function(...m):String{return m[0].toUpperCase()});
//page title
capitalizeTitle = capitalizeTitle.replace(/Sat/g,"SAT ");
var newTitle:String = capitalizeTitle.replace(/Ma/g,"MA")
browserManager.setTitle("My Website | " + newTitle);
browserManager.setFragment("view="+dashedURLFragment);
}
The problem is probably in the parseUrl function.
In the last line of parseUrl, I tried changing: mainViewStack.selectedIndex = o.a; to mainViewStack.selectedIndex = o.view; but that's not working either.
private function parseUrl(e:BrowserChangeEvent = null):void {
var o:Object = URLUtil.stringToObject(browserManager.fragment);
mainViewStack.selectedIndex = o.a;
}
Thank you.
Best regards, Laxmidi
The back button works fine in the new version. The page titles appear fine. The url fragments are added. BUT, if I copy a url and paste it into the browser it goes to my main "page" instead of the one it was supposed to go to. I tested it by copying and pasting into the browser on a map page in the new and old version. I navigated to the correct page in the old version, but not the new version. What's happening? I really need some help. I also posted my problem on Adobe's Flex site.
Any suggestions? Thank you. -Laxmidi