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);        
    }

该代码在服务器和本地主机上都有效。

如果这对您不起作用(首先在此处上传错误),但您也可以创建一个 JS 函数,该函数将返回 URL 并让 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 回答