如何获取URL的Flash影片嵌入吗? [英] How to obtain URL that Flash movie is embedded on?

查看:145
本文介绍了如何获取URL的Flash影片嵌入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天我试图让在我的Flash电影是坐在URL。

today I'm trying to get the URL where my Flash movie is sitting on.

我发现<一href="http://stackoverflow.com/questions/396412/how-can-my-flash-app-determine-its-own-url">a这里类似的问题 ,这是一个<一个回答href="http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html#includeExamplesSummary"相对=nofollow>链接到Flash的的LoaderInfo 的方法,但我不知道我在正确的使用它作为在这里我测试的电影文本字段:的 http://leongaban.com/stackoverflow/getUrl/ 不显示网址

I found a similar question here, which was answered with a link to Flash's LoaderInfo method, but I'm not sure I'm using it correctly as the textField in my test movie here: http://leongaban.com/stackoverflow/getUrl/ does not display the URL

我需要的是这样的: stage.loaderInfo.url :)

All I needed was this: stage.loaderInfo.url :)

package {

import flash.display.Stage;
import flash.display.DisplayObject;
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.events.Event;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import FontsTest;

public class LoaderInfoExample extends Sprite 
{
    private var myTextField :TextField = new TextField();
    private var urlIs:String = "";

    public function LoaderInfoExample() {

        urlIs = stage.loaderInfo.url;
        trace(stage.loaderInfo.url);
        addEventListener(Event.ADDED_TO_STAGE, initHandler);
    }

    private function initHandler(event:Event):void {

        myTextField.defaultTextFormat = FontsTest.Arial14Bold;
        myTextField.border = true;
        myTextField.antiAliasType = flash.text.AntiAliasType.ADVANCED;
        myTextField.selectable = true;
        myTextField.mouseEnabled = true;
        myTextField.autoSize = TextFieldAutoSize.LEFT;
        myTextField.text = "Url is = "+urlIs;

        addChild(myTextField);
    }
}
}

http://leongaban.com/stackoverflow/getUrl/

推荐答案

如果我正确认识这一点,你这样做只是有点不对劲。你并不需要创建一个新的装载机 - 瑞士法郎持有的引用,在舞台上自己的loaderInfo对象

If I'm understanding this correctly, you're doing it just a little bit wrong. You don't need to create a new loader - the .swf holds a reference to its own loaderInfo object on stage.

所以,如果你想跟踪你的.swf文件的当前位置,做这样的事情:

So if you want to trace out the current location of your .swf file, do something like this:

trace(stage.loaderInfo.url);

帮助吗?

这篇关于如何获取URL的Flash影片嵌入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆