看板 Flash 關於我們 聯絡資訊
先不管 JSP / ASP / PHP 的問題,總之最後都是 HTML,請先確認 HTML 應如下: <!-- saved from url=(0014)about:internet --> <html lang="en"> <!-- Smart developers always View Source. This application was built using Adobe Flex, an open source framework for building rich Internet applications that get delivered via the Flash Player or to desktops via Adobe AIR. Learn more about Flex at http://flex.org // --> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title></title> <script src="AC_OETags.js" language="javascript"></script> <style> body { margin: 0px; overflow:hidden } </style> </head> <body scroll='no'> <script language="JavaScript" type="text/javascript"> <!-- AC_FL_RunContent( "src", "TestHtmlParam", "flashvars", "mainView=123", "width", "100%", "height", "100%", "align", "middle", "id", "TestHtmlParam", "quality", "high", "bgcolor", "#869ca7", "name", "TestHtmlParam", "allowScriptAccess","sameDomain", "type", "application/x-shockwave-flash", "pluginspage", "http://www.adobe.com/go/getflashplayer" ); // --> </script> </body> </html> 重點在於 flashvars 那邊的 mainView 有值~ 第二步驟,因為要取得 html 帶進來的 param,必須透過 stage, 所以你應該是在 ADDED_TO_STAGE 事件之後才能取得,如下: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600" addedToStage="application1_addedToStageHandler(event)"> <mx:Script> <![CDATA[ import mx.events.FlexEvent; protected function application1_addedToStageHandler(event:Event):void { trace("mainView=" + stage.loaderInfo.parameters["mainView"]); } ]]> </mx:Script> </mx:Application> 執行輸出: [SWF] E:\works_test\Test\bin-debug\TestHtmlParam.swf - 636,687 bytes after decompression mainView=123 ※ 引述《cashlalala (快來跟我做朋友)》之銘言: : 各位大大好 : 我在一個jsp中嵌入一個 swf : 而jsp會有一些http request 傳進來的參數要給swf : 我google一下網路上的寫法後 在jsp中寫入下面這一段 : <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" : codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" : width="550" height="400" id="as3flashvars" align="middle"> : <param name="allowScriptAccess" value="sameDomain" /> : <param name="allowFullScreen" value="false" /> : <param name="movie" : value="http://localhost:8080/IncludeVsForward/Flex/EPLMInCaringorm.swf?mainView=<%=request.getParameter("mainView")%>&user=<%=request.getParameter("user")%>" /> : <param name="quality" value="high" /> : <param name="bgcolor" value="#ffffff" /> : <param name="flashVars" : value="mainView=<%=request.getParameter("mainView")%>&user=<%=request.getParameter("user")%>"> : <embed : src="http://localhost:8080/IncludeVsForward/Flex/EPLMInCaringorm.swf?mainView=<%=request.getParameter("mainView")%>&user=<%=request.getParameter("user")%>" : quality="high" bgcolor="#ffffff" width="550" height="400" : name="as3flashvars" align="middle" allowScriptAccess="sameDomain" : allowFullScreen="false" type="application/x-shockwave-flash" : pluginspage="http://www.macromedia.com/go/getflashplayer" : flashVars= : "mainView=<%=request.getParameter("mainView")%>&user=<%=request.getParameter("user")%>" /> : </object> : 不管是直接加在網址後面, 或者是透過flashvars來傳遞我都使用了 : 然後在flex中加入 : protected function application1_creationCompleteHandler(event:FlexEvent):void : { : // TODO Auto-generated method stub : var aa : String = root.loaderInfo.parameters.mainView; : Alert.show(aa); : var mainViewStackEvent :MainViewStackEvent = new MainViewStackEvent(MainViewStackEvent.EVENTNAME,mainViewVO); : mainViewStackEvent.dispatch(); : } : 上網查不外乎都是這樣寫, 但是很怪的是root怎麼樣都是null, : 請問有大大有相關的經驗要如何解決嗎? : 我爬過文似乎沒有跟我很類似的 : 請各位大大不吝指教 謝謝!! -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.147.239.66