Flex从页面(*.swf)url获取参数
Flex从页面url获取参数(总结)
Flash Builder 4下载地址:http://g.csdn.net/5128184
 
关于flex如何向某个页面传递参数,我以前有这方面的笔记,flex通 过非AmfPHP途径与后台交互  中URLLoader+URLRequest+URLVariables方法也可以用于向flex页面传参数。后  台php端接收参数很简单,现在讨论一下flex端如何处理页面url传递过来的参数。
 
网上这方面文章不少,不过都多少有些问题,我总结一下,写在这里。
 
方法一: flex接收网页传值!~ 
 
  1
 <? xml version = " 1.0 "  encoding = "  utf-8 " ?>
 <? xml version = " 1.0 "  encoding = "  utf-8 " ?> 2
 < mx:Application xmlns:mx = "  http://www.adobe.com/2006/mxml  "  layout = " absolute "
  < mx:Application xmlns:mx = "  http://www.adobe.com/2006/mxml  "  layout = " absolute " 3
 applicationComplete = " initApp() " >
    applicationComplete = " initApp() " > 4
 
   5
 < mx:Label text =
  < mx:Label text = 6
 " Will run the app deployed at http://{serverURL}:{port}/MyGreatApp.html  "   />
  " Will run the app deployed at http://{serverURL}:{port}/MyGreatApp.html  "   /> 7
 < mx:Script >
  < mx:Script > 8
 <! [CDATA[
     <! [CDATA[9
 [Bindable]
        [Bindable]10
 var serverURL:String;
        var serverURL:String;11
 
       12
 [Bindable]
        [Bindable]13
 var port:String;
        var port:String;14
 
       15
 function initApp(): void  {
         function initApp(): void  {16
 serverURL = Application.application.parameters.serverURL;
            serverURL = Application.application.parameters.serverURL;17
 port =  Application.application.parameters.port
            port =  Application.application.parameters.port18
 }
        }  19
 ]] >
    ]] >  20
 </ mx:Script >
  </ mx:Script > 21
 </ mx:Application >
  </ mx:Application >   作者在文章最后写:“外部以test.swf?serverURL=String&port=String  的形式在网页中调用!”
 
这样做确实没有问题,但平时的flex程序都是以html为容器将swf文件包装了起来。如果用 test.html?serverURL=String& amp;  amp;port=String的方式传递参数,再用该文章中提供的代码就不能获取参数了。
 
                    
                 
  
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号