如何编写 Actionscript 来传递 flashvars?

发布于 2024-10-09 03:24:21 字数 1862 浏览 2 评论 0原文

我对 Flash 确实是个新手。所以我正在尝试制作一个显示 Vimeo 视频的 Flash 容器。这是我的动作脚本。

var videoContainer:Sprite = new Sprite();
var moogaloop:Sprite; // the video player
var moogaplayer:*; // reference to the moogaloop api
var player_width :int = stage.stageWidth;
var player_height:int = stage.stageHeight;
var _loading:Boolean = false;

var vidId:String;

function open ( $id:String ) : void
{
    if(moogaplayer){
        moogaplayer.api_loadVideo( $id );
    }else{
        loadPlayer( $id );
    }
}

function loadPlayer ( $id:String) : void
{
    var v_loader:Loader = new Loader();
    var v_request:URLRequest = new URLRequest("http://bitcast.vimeo.com/vimeo/swf/moogaloop.swf?server=vimeo.com&force_embed=0&clip_id=" + $id + "&width=" + player_width + "&height=" + player_height);
    v_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    v_loader.load(v_request);
}

function onCompleteHandler(e:Event):void
{
    moogaloop = new Sprite();
    moogaplayer = moogaloop.addChild(e.currentTarget.content);

    var v_mask:Sprite = new Sprite();
    with( v_mask.graphics ) {
        beginFill(0x000000, 1);
        drawRect(moogaloop.x, moogaloop.y, player_width, player_height);
        endFill();
    }

    this.addChild(v_mask);
    moogaloop.mask = v_mask;

    videoContainer.addChild(moogaloop);
}

function onProgressHandler(e:ProgressEvent):void
{
    var percent:Number = e.bytesLoaded / e.bytesTotal;
    trace(percent);
}

Security.allowDomain("http://bitcast.vimeo.com");
open( vidId );

this.addChild( videoContainer );

我想通过 URL 设置 vidId。例如: http://dl.dropbox.com/u/389232/bhssfinearts /vimeoz.swf?vidId=17439665 但这不起作用。 如果我在 open () 中设置视频 ID,它就可以正常工作,

我该如何让它工作? 非常感谢您抽出时间。

I am really new at Flash. So I am trying to make a flash container that display Vimeo videos. Here is my actionscript.

var videoContainer:Sprite = new Sprite();
var moogaloop:Sprite; // the video player
var moogaplayer:*; // reference to the moogaloop api
var player_width :int = stage.stageWidth;
var player_height:int = stage.stageHeight;
var _loading:Boolean = false;

var vidId:String;

function open ( $id:String ) : void
{
    if(moogaplayer){
        moogaplayer.api_loadVideo( $id );
    }else{
        loadPlayer( $id );
    }
}

function loadPlayer ( $id:String) : void
{
    var v_loader:Loader = new Loader();
    var v_request:URLRequest = new URLRequest("http://bitcast.vimeo.com/vimeo/swf/moogaloop.swf?server=vimeo.com&force_embed=0&clip_id=" + $id + "&width=" + player_width + "&height=" + player_height);
    v_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
    v_loader.load(v_request);
}

function onCompleteHandler(e:Event):void
{
    moogaloop = new Sprite();
    moogaplayer = moogaloop.addChild(e.currentTarget.content);

    var v_mask:Sprite = new Sprite();
    with( v_mask.graphics ) {
        beginFill(0x000000, 1);
        drawRect(moogaloop.x, moogaloop.y, player_width, player_height);
        endFill();
    }

    this.addChild(v_mask);
    moogaloop.mask = v_mask;

    videoContainer.addChild(moogaloop);
}

function onProgressHandler(e:ProgressEvent):void
{
    var percent:Number = e.bytesLoaded / e.bytesTotal;
    trace(percent);
}

Security.allowDomain("http://bitcast.vimeo.com");
open( vidId );

this.addChild( videoContainer );

And I want to set the vidId by URL. For example:
http://dl.dropbox.com/u/389232/bhssfinearts/vimeoz.swf?vidId=17439665
And it doesn't work.
It works fine if I set the video id in open ()

How do I get it to work?
Thank you very much for your time.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

も星光 2024-10-16 03:24:21

使用 SWFOjbect,有两种方法,具体取决于您发布 swfobject 的方式:

动态方法:

<script type="text/javascript">
 var flashvars = {};
 flashvars.vidId='blahblah';
</script>

静态方法:

<param name="flashvars" value="vidId='blahblah'" />

在 Flash 代码中,您可以像这样检索变量:

var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;

var vidId:String = paramObj.vidId;

请注意...如果您在 Flash 中测试,这将不起作用。您必须在浏览器中使用 SWFObject 代码打开 html 页面。

Use SWFOjbect, there are two ways depending on how you publish swfobject:

Dynamic method:

<script type="text/javascript">
 var flashvars = {};
 flashvars.vidId='blahblah';
</script>

Static method:

<param name="flashvars" value="vidId='blahblah'" />

And in your flash code you can retrieve variables like so:

var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;

var vidId:String = paramObj.vidId;

Just a note...this won't work if you test in Flash. You have to open your html page with SWFObject code inside of a browser.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文