Recently, I made a mail activation function. I did not expect that the more knowledge points I need to know, the more logical judgments I have, and the more I can think. We are now sharing the problem of parsing the address bar parameters.
Since the default page encapsulated by Flex is an HTML page, what is different from JSP is that the parameter is passed after "#", while JSP is in "?" Later, so we have to figure this out.
To parse parameters, you first need to obtain the Link parameter chain (namely the parameter pair after "#") in the address bar. There are many methods, such as calling the externalinterface of JavaScript. the call () method is obtained by using the flex static class browsermanager. The Code is as follows:
/*** Get the parameter chain in the address bar **/Public Function getallparams (): String {var BM: ibrowsermanager = browsermanager. getinstance (); BM. init (); Return BM. fragment}
This method returns the address bar parameter pair.
The following code splits the parameter pairs and stores them in an object:
/*** Receive and parse URL Information in the browser's address bar **/Public functiongetparams (): object {var Params: Object ={}; var query: String = getallparams (); if (query) {var pairs: array = query. split ("&"); For (var I: uint = 0; I <pairs. length; I ++) {var pos: Int = pairs [I]. indexof ("="); If (Pos! =-1) {var argname: String = pairs [I]. substring (0, POS); VaR value: String = pairs [I]. substring (Pos + 1); Params [argname] = value ;}} return Params ;}
This method returns an object. If the parameter chain is not empty, the value is as follows:
Var obj:Object= getParams(); Var email:String=obj.email;
Then you can add your own business logic.
For example, if the test page does not contain parameters:
Business judgment when parameters are available:
There are a lot more. I will not list them one by one, but I just want to make an axe in front of Daniel.
Original article, reproduced please indicate the source: http://www.dianfusoft.com/