0

I am writing a Flash app in Flex Builder 3. I have a problem. I need the URL of the place where the Flash app has been embedded.

mx.core.Application.application.url

This gives me the address of the original swf file, but I actually need the URL of the HTML file where this SWF has been embedded. is there a way ??? thanks! Ali

4

2 に答える 2

1

2 つのオプションがあります。フレックス:

private function initApp():void {
        browserManager = BrowserManager.getInstance();
        browserManager.addEventListener(BrowserChangeEvent.URL_CHANGE, showURLDetails);            
        browserManager.init("", "Welcome!");            
    }

そして聞き手

        private function showURLDetails(e:BrowserChangeEvent):void {
        var url:String = browserManager.url;
        baseURL = browserManager.base;
        fragment = browserManager.fragment;                
        previousURL = e.lastURL;                

        fullURL = mx.utils.URLUtil.getFullURL(url, url);
        port = mx.utils.URLUtil.getPort(url);
        protocol = mx.utils.URLUtil.getProtocol(url);
        serverName = mx.utils.URLUtil.getServerName(url);
        isSecure = mx.utils.URLUtil.isHttpsURL(url);        
    }

そのコードは、サーバーとローカル ホストの両方で機能します。

それがうまくいかない場合 (最初にここにエラーをアップロードしてください)、URL を返す JS 関数を作成し、flex にこの関数を呼び出すこともできます。

于 2010-07-04T15:22:40.703 に答える
0

私のコメントは読めないので、ここに答えがあります。

SWFObject 内のコードは、ブラウザー マネージャーに関して言えば、Flash の動作を少し奇妙にします。ソリューションは history.js 内にあります (そうでない場合は、最初に HTML に添付してください)。

次に、これらのコード行をコメント アウトします。

if (players.length == 0 || players[0].object == null) {
var tmp = document.getElementsByTagName(‘embed’);
players = tmp;
}

そして、これ

if (player == null || player.object == null) {
    player = document.getElementsByTagName(‘embed’)[0];
    }

これで問題が解決するはずです。

于 2010-07-04T20:19:15.093 に答える