开发者

AS3 - swfaddress deep linking when someone pastes a url

开发者 https://www.devze.com 2022-12-10 13:57 出处:网络
I have swfaddress (2.4) working fine on my site - the back button works, I can copy and paste urls and be taken to the correct page, etc.

I have swfaddress (2.4) working fine on my site - the back button works, I can copy and paste urls and be taken to the correct page, etc.

BUT, if I copy a url, say "http://mysite.com/#/bio", and paste it into a new browser window, the site a开发者_运维问答lways just loads to the home page after the preloader. What am I missing? Do I somehow need to check the url when the page loads?


Without seeing any of your code...There's two events you're going to be interested in watching for. When your app starts up you should listen for

SWFAddress.addEventListener(SWFAddressEvent.INIT, __init);

Which would then register the CHANGE listener:

private function __init(event:SWFAddressEvent):void
{
    SWFAddress.addEventListener(SWFAddressEvent.CHANGE, __handle);
}

Your handler function should handle changes in the URL. This will handle the beginning url when it first initializes and when you use SWFAddress.setValue() to change the page:

private function __handle(event:SWFAddressEvent):void
{
    var address:String = SWFAddress.getValue();
    // -- perform actions based on addresss
}
0

精彩评论

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