[AS3]ASÓïÑÔ»ñÈ¡url²ÎÊýµÄ˵Ã÷,Url×Ö·û´®¿ÉÒÔÔÚjsÖÐͨ¹ýwindow.location»ñÈ¡¡£Param_info¼´Îª²ÎÊý×Ö·û´®£¬¶ÁÈ¡µ¥¸ö²ÎÊýÖµ»¹ÐèÒª½øÐнâÎö
AS»ñÈ¡url²ÎÊý
Ò»¡¢Ò³Ãæurl²ÎÊý
ÕâÀïÊǵ÷ÓÃjsµÄeval·½·¨£¨jsÖж¨Ò壩·µ»Øurl×Ö·û´®
var urlPath:String = ExternalInterface.call("eval", "window.location.href");//»ñÈ¡Ò³ÃæµÄurl
var param_info:String = urlPath.split("?")[1];//½ØÈ¡urlÖеIJÎÊý
Url×Ö·û´®¿ÉÒÔÔÚjsÖÐͨ¹ýwindow.location»ñÈ¡¡£
Param_info¼´Îª²ÎÊý×Ö·û´®£¬¶ÁÈ¡µ¥¸ö²ÎÊýÖµ»¹ÐèÒª½øÐнâÎö¡£
¿ÉÒÔͨ¹ýwindow.location·½·¨»ñÈ¡URL ¡¡¡¡
ͳһ×ÊÔ´¶¨Î»·û (Uniform Resource Locator, URL)
ʾÀý£º ¡¡¡¡
http://www.home.com:8080/windows/location/page.html?ver=1.0&id=timlq#love ¡¡¡¡
1, window.location.href ¡¡¡¡Õû¸öURl×Ö·û´®(ÔÚä¯ÀÀÆ÷ÖоÍÊÇÍêÕûµÄµØÖ·À¸) ¡¡¡¡
·µ»ØÖµ£º
http://www.home.com:8080/windows/location/page.html?ver=1.0&id=timlq#love ¡¡¡¡
2,window.location.protocol ¡¡¡¡
URL µÄÐÒ鲿·Ö ¡¡¡¡
·µ»ØÖµ£ºhttp: ¡¡¡¡
3,window.location.host ¡¡¡¡
URL µÄÖ÷»ú²¿·Ö£¬ ¡¡¡¡
·µ»ØÖµ£ºwww.home.com ¡¡
4,window.location.port ¡¡¡¡
URL µÄ¶Ë¿Ú²¿·Ö¡£Èç¹û²ÉÓÃĬÈϵÄ80¶Ë¿Ú(update:¼´Ê¹Ìí¼ÓÁË:80)£¬ÄÇô·µ»ØÖµ²¢²»ÊÇĬÈϵÄ80¶øÊÇ¿Õ×Ö·û¡£ ¡¡¡¡
±¾Àý·µ»ØÖµ:8080 ¡¡¡¡
5,window.location.pathname ¡¡¡¡
URL µÄ·¾¶²¿·Ö(¾ÍÊÇÎļþµØÖ·) ¡¡¡¡
·µ»ØÖµ£º/windows/location/page.html ¡¡¡¡
6,window.location.search ¡¡¡¡
²éѯ(²ÎÊý)²¿·Ö¡£³ýÁ˸ø¶¯Ì¬ÓïÑÔ¸³ÖµÒÔÍ⣬ÎÒÃÇͬÑù¿ÉÒÔ¸ø¾²Ì¬Ò³Ãæ,²¢Ê¹ÓÃjavascriptÀ´»ñµÃÏàÐÅÓ¦µÄ²ÎÊýÖµ ¡¡¡¡
·µ»ØÖµ£º?ver=1.0&id=timlq ¡¡¡¡
7,window.location.hash ¡¡¡¡
êµã ¡¡¡¡
·µ»ØÖµ£º#love
¶þ¡¢swf url ²ÎÊý
Ö÷Òª¾ÍÊÇʹÓÃLoaderInfoÀà»ñÈ¡¼ÓÔØswfʱ¼ÓÔزÎÊý
Àý£º
ÍøÒ³¿ÉÒÔͨ¹ýswfµØÖ·¸øflash´«µÝ±äÁ¿£¬ÒÔÖµ¶ÔµÄÐÎʽ´«µÝ£¬ÈçÏ£º
- <object classid="clsid27CDB6E-AE6D-11cf-96B8-444553540000"
- id="LoaderInfoSample" width="100%" height="100%"
- codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
- <param name="movie" value="LoaderInfoSample.swf?a=1&b=2" />
- <param name="quality" value="high" />
- <param name="bgcolor" value="#869ca7" />
- <param name="allowScriptAccess" value="sameDomain" />
- <embed src="LoaderInfoSample.swf?a=1&b=2" quality="high" bgcolor="#869ca7"
- width="100%" height="100%" name="LoaderInfoSample" align="middle"
- play="true"
- loop="false"
- quality="high"
- allowScriptAccess="sameDomain"
- type="application/x-shockwave-flash"
- pluginspage="http://www.adobe.com/go/getflashplayer">
- </embed>
- </object>
ActionSrippt2ʱ£¬ÔÚµÚÒ»Ö¡¾Í¿ÉÒÔÖ±½ÓÒýÓô«µÝ½øÀ´µÄÕâÁ½¸ö±äÁ¿ÖµÁË¡£
AS3Å×ÆúÁËÕâÖÖ²»¹æ·¶µÄÓ÷¨£¬Í¬ÒâʹÓÃLoaderInfoµÄParameterÊôÐÔÀ´Íê³É¡£
LoaderInfoµÄ°ïÖúÎĵµÇë²Î¿¼£ºhttp://livedocs.macromedia.com/l ... lay/LoaderInfo.html
LoaderInfo Õâ¸öÀàÊÇרÃÅÉè¼ÆÀ´±£´æswf£¬Í¼Æ¬£¬»òÕßÆäËûÈÎÒâDisplayObjectµÄ¼ÓÔØÐÅÏ¢µÄ¡£
swf²ÎÊýÒ²ÊôÓÚ¼ÓÔØÐÅÏ¢ÀïµÄÒ»²¿·Ö£¬¿ÉÒÔͨ¹ýLoaderInfoµÄparametersÊôÐÔÈ¡µÃ£¬È¡³öµÄ½á¹ûÊÇÒ»¸öÊý×飬¿ÉÒÔͨ¹ýfor...in±éÀúËûµÄÖµ¡£
ʾÀý´úÂëÈçÏ£º
- package org.flashbbs.sample
- {
- import flash.display.MovieClip;
- import flash.display.LoaderInfo;
- import flash.text.TextField;
-
- public class LoaderInfoSample extends MovieClip
- {
- public function LoaderInfoSample(){
- var key:String;
- var value:String;
- var text1:TextField = new TextField();
- addChild(text1);
- var param:Object = this.root.loaderInfo.parameters;
- for (key in param) {
- value = String(param[key]);
- text1.appendText(key + "=" +value);
- }
- }
- }
- }
»¹ÓÐÒ»µãҪעÒâµÄÊÇ£¬LoaderInfoÊôÓÚAs3µÄÀ࣬Èç¹ûflash°üº¬as1»òÕßas2µÄ´úÂ룬ÔòËüÎÞ·¨È¡³öÖµ£¬Ö»ÄÜÈ¡³önull