SWFAddress使用备忘

package 
{
    import com.asual.swfaddress.SWFAddressEvent;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import com.asual.swfaddress.SWFAddress;
    /**
     * ...
     * @author Terry
     */
    public class SwfAddressTest extends Sprite
    {
        private var linkButton:Button;
        public function SwfAddressTest()
        {
            init();
        }
        private function init():void
        {
            linkButton = new Button("this is a test",buttonOnClick);
            this.addChild(linkButton);
            SWFAddress.addEventListener(SWFAddressEvent.INIT, SWFAddressInit);//
            SWFAddress.addEventListener(SWFAddressEvent.CHANGE, SWFAddressChange);//地址发生变化事情(包含内部和外部)
            SWFAddress.addEventListener(SWFAddressEvent.EXTERNAL_CHANGE, SWFAddressExternalChange);//地址在外部发生变化
            SWFAddress.addEventListener(SWFAddressEvent.INTERNAL_CHANGE, SWFAddressInternalChange);//地址在内部发生变化
        }
        private function buttonOnClick(e:MouseEvent):void
        {
            SWFAddress.setValue("new?id=0");//设置当前浏览器地址
            SWFAddress.setTitle("标题要变了哦");//设置当前页面标题
            SWFAddress.setStatus("aaaaa");//设置状态,不太明白
        }
        private function SWFAddressInit(e:SWFAddressEvent):void
        {
            trace("swf init");
        }
        private function SWFAddressChange(e:SWFAddressEvent):void
        {
            trace(e.path);
            for (var i in e.parameters)
            {
                trace(i, e.parameters[i]);//取出传递的参数
            }
        }
        private function SWFAddressExternalChange(e:SWFAddressEvent):void
        {
            trace("SWFAddressExternalChange");
            for (var i in e.parameters)
            {
                trace(i, e.parameters[i]);
            }
        }
        private function SWFAddressInternalChange(e:SWFAddressEvent):void
        {
            trace("SWFAddressInternalChange");
            for (var i in e.parameters)
            {
                trace(i, e.parameters[i]);
            }
        }
    }

}

posted @ 2010-01-27 17:05  TerryXu  阅读(737)  评论(0编辑  收藏  举报