如何编写 Actionscript 来传递 flashvars?
我对 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 SWFOjbect,有两种方法,具体取决于您发布 swfobject 的方式:
动态方法:
静态方法:
在 Flash 代码中,您可以像这样检索变量:
请注意...如果您在 Flash 中测试,这将不起作用。您必须在浏览器中使用 SWFObject 代码打开 html 页面。
Use SWFOjbect, there are two ways depending on how you publish swfobject:
Dynamic method:
Static method:
And in your flash code you can retrieve variables like so:
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.