如何将多个 Flashvars 变量放入 Flash(不使用 swfobject)

发布于 2024-09-06 11:17:56 字数 1655 浏览 5 评论 0原文

我正在为我的客户重建这个嵌入式播放器,视频文件 URL 和其他几个变量在 HTML 中为 Flashvars。我怀疑查找 flashvars 的代码有问题。

显示绿色框的顶部部分是播放器未加载的位置,因为它无法从 HTML 获取 Flashvars。下面的播放器将 Flashvars 字符串硬编码到播放器中,因此它可以工作。

我相信问题出在下面的某个地方,也许我尝试引入 Flashvars 的方式有问题?

// LIVE Embedded
   //vidURL = stage.loaderInfo.parameters.fvar;
   vidURL = this.loaderInfo.parameters.fvar;            

   fvarText.text = "vidURL = this.loaderInfo.parameters.fvar"

   vidSplit = vidURL.split(".flv")[0].split("/");
   varVid   = vidURL.toLowerCase().split("&vid=")[1].split("&")[0];
   varChid  = vidURL.toLowerCase().split("&chid=")[1].split("&")[0];

// Hardcode Testing 
//(This creates the player that works at the bottom of the test page)
   /*vidURL   = "http://";
   vidSplit = vidURL.split(".flv")[0].split("/");
   varVid   = vidURL.toLowerCase().split("&vid=")[1].split("&")[0];
   varChid  = vidURL.toLowerCase().split("&chid


当我从以下位置导出时收到此错误Flash:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.Player::Embed/init()
at com.Player::Embed()

我预计会出现此错误,因为显然 Flash 尚未嵌入,但此错误是否可以解释为什么我的播放器无法获取 FlashVars 链接然后自行渲染?

HTML 嵌入代码:

<object width="640" height="395" border="0">
<param name="flashvars" value="fvar=http://360.flv&amp;VID=1273&amp;CHID=4" />
<embed src="http://dev.site.com/flash.swf" width="640" height="395" flashvars="fvar=http://360.flv&amp;VID=1273&amp;CHID=4">
</embed>
</object>

I'm rebuilding this embedable player for a client of mine, the video file URL and a couple of other variables are in the HTML as Flashvars. I suspect something is wrong with the code that looks for the flashvars.

The top part showing the green box is where the player didn't load because it was unable to obtain the Flashvars form the HTML. The player below has the Flashvars string hardcoded into the player so it works.

I believe the problem lies somewhere below Perhaps something wrong with the way I'm trying to pull in the Flashvars?

// LIVE Embedded
   //vidURL = stage.loaderInfo.parameters.fvar;
   vidURL = this.loaderInfo.parameters.fvar;            

   fvarText.text = "vidURL = this.loaderInfo.parameters.fvar"

   vidSplit = vidURL.split(".flv")[0].split("/");
   varVid   = vidURL.toLowerCase().split("&vid=")[1].split("&")[0];
   varChid  = vidURL.toLowerCase().split("&chid=")[1].split("&")[0];

// Hardcode Testing 
//(This creates the player that works at the bottom of the test page)
   /*vidURL   = "http://";
   vidSplit = vidURL.split(".flv")[0].split("/");
   varVid   = vidURL.toLowerCase().split("&vid=")[1].split("&")[0];
   varChid  = vidURL.toLowerCase().split("&chid

I get this error when I export from Flash:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.Player::Embed/init()
at com.Player::Embed()

I expect this error however since obviously the Flash isn't embedded yet, but could this error shed any light on why my player isn't able to get the FlashVars link and then render itself?

The HTML embed code:

<object width="640" height="395" border="0">
<param name="flashvars" value="fvar=http://360.flv&VID=1273&CHID=4" />
<embed src="http://dev.site.com/flash.swf" width="640" height="395" flashvars="fvar=http://360.flv&VID=1273&CHID=4">
</embed>
</object>

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

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

发布评论

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

评论(2

☆獨立☆ 2024-09-13 11:17:56

您需要在对象和嵌入标签中设置 flashVars 参数。查看此链接 http://livedocs.adobe。 com/flex/3/html/help.html?content=passingarguments_3.html

<object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab' height='100%' width='100%'>
        <param name='src' value='FlashVarTest.swf'/>
        <param name='flashVars' value='firstName=Nick&lastName=Danger'/>
        <embed name='mySwf' src='FlashVarTest.swf' pluginspage='http://www.adobe.com/go/getflashplayer' height='100%' width='100%' flashVars='firstName=Nick&lastName=Danger'/>
    </object>

在 Flash 中获取值。使用这个:

var firstName:String = stage.loaderInfo.parameters.firstName;
var lastName:String = stage.loaderInfo.parameters.lastName;

You need to set the flashVars param in both the object as well as the embed tag. Check out this link http://livedocs.adobe.com/flex/3/html/help.html?content=passingarguments_3.html

<object id='mySwf' classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab' height='100%' width='100%'>
        <param name='src' value='FlashVarTest.swf'/>
        <param name='flashVars' value='firstName=Nick&lastName=Danger'/>
        <embed name='mySwf' src='FlashVarTest.swf' pluginspage='http://www.adobe.com/go/getflashplayer' height='100%' width='100%' flashVars='firstName=Nick&lastName=Danger'/>
    </object>

To get values inside Flash. Use this:

var firstName:String = stage.loaderInfo.parameters.firstName;
var lastName:String = stage.loaderInfo.parameters.lastName;
风情万种。 2024-09-13 11:17:56

正如 George 所说,您可以尝试对 和 标签使用 flashvars。另外,我引用我的属性值并转义我的与号 (&)。以下代码应该可以工作:

<object width="640" height="395" border="0">
    <param name="flashvars" value="file=http://how.llnwd.net/o18/UpDo_H_828-640x360.flv&VID=1273&CHID=4" />
    <embed src="http://dev.site.com/flash.swf" width="640" height="395" flashvars="file=http://how.llnwd.net/o18/UpDo_H_828-640x360.flv&VID=1273&CHID=4">
    </embed>
</object>

Like George said, you could try using flashvars for both the and tag. Also, I quote my attribute values and escape my ampersand (&). The following code should work:

<object width="640" height="395" border="0">
    <param name="flashvars" value="file=http://how.llnwd.net/o18/UpDo_H_828-640x360.flv&VID=1273&CHID=4" />
    <embed src="http://dev.site.com/flash.swf" width="640" height="395" flashvars="file=http://how.llnwd.net/o18/UpDo_H_828-640x360.flv&VID=1273&CHID=4">
    </embed>
</object>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文