如何访问 AS3 中的 flashvars,并将它们添加到现有文本字段?
编辑:我开始意识到我面临的主要问题是我想要一个已经存在于影片剪辑或舞台上的文本字段来从 flashvar 中获取字符串。由于某种原因它不会这样做。如何更改预先存在的文本字段以匹配 flashvar 文本?
Html:
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="29px" id="egnewsTicker" align="middle">
<param name="movie" value="egnewsTicker.swf" />
<param name="flashvars" value="newslisttest=this is my test" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="showall" />
<param name="menu" value="false" />
<param name="devicefont" value="false" />
<param name="salign" value="lt" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="egnewsTicker.swf" width="100%" height="29px">
<param name="movie" value="egnewsTicker.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="showall" />
<param name="menu" value="false" />
<param name="devicefont" value="false" />
<param name="salign" value="lt" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="flashvars" value="newslisttest=this is my test" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
我知道这应该是一个简单的任务,并且我找到了几篇提供示例的网络文章,但当我尝试编写自己的代码时,我根本无法使其工作。我想做的就是传递一个 flashvar 字符串,并能够使用 AS3 在 flash 中按名称访问它,但我似乎无法实现这一点。
我正在尝试:
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
newsItem.newsHeadline.text = String(paramObj[varName]);
我也尝试过:
newsItem.newsHeadline.text = this.loaderInfo.parameters.newslisttest;
我尝试的任何东西都不起作用,它总是保持空白。在 flash as3 中访问 flashvars 的技巧是什么?我只是不明白,而且我在任何地方都找不到好的解释......
Edit: I've come to realize the main problem I'm facing is that I want a text field that already exists in a movieclip or on the stage to take the string from a flashvar. For some reason it will not do that. How do I make a pre-existing text field change to match the flashvar text?
Html:
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="100%" height="29px" id="egnewsTicker" align="middle">
<param name="movie" value="egnewsTicker.swf" />
<param name="flashvars" value="newslisttest=this is my test" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="showall" />
<param name="menu" value="false" />
<param name="devicefont" value="false" />
<param name="salign" value="lt" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="egnewsTicker.swf" width="100%" height="29px">
<param name="movie" value="egnewsTicker.swf" />
<param name="quality" value="high" />
<param name="bgcolor" value="#ffffff" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name="wmode" value="transparent" />
<param name="scale" value="showall" />
<param name="menu" value="false" />
<param name="devicefont" value="false" />
<param name="salign" value="lt" />
<param name="allowScriptAccess" value="sameDomain" />
<param name="flashvars" value="newslisttest=this is my test" />
<!--<![endif]-->
<a href="http://www.adobe.com/go/getflash">
<img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
</a>
<!--[if !IE]>-->
</object>
<!--<![endif]-->
</object>
</div>
I know this is supposed to be a simple task, and I have found several web articles that give examples, but I simply cannot make it work when I'm trying to do my own code. All I want to do is pass a flashvar string and be able to access it by name in flash using AS3, but I can't seem to accomplish that.
I'm trying:
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
newsItem.newsHeadline.text = String(paramObj[varName]);
I've also tried:
newsItem.newsHeadline.text = this.loaderInfo.parameters.newslisttest;
Nothing I try works, it always just stays blank. What is the trick to accessing flashvars in flash as3? I'm just not getting it and I can't find a good explanation anywhere...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
试试这个:
stage.loaderInfo.parameters.yourparam
或stage.loaderInfo.parameters["yourparam"]
您可以发布您的 html 代码,以便我们了解您如何传递flashvars 到 Flash。
Try this:
stage.loaderInfo.parameters.yourparam
orstage.loaderInfo.parameters["yourparam"]
Can you post your html code, so we can see how you pass the flashvars to Flash.
我整天都在浪费时间......
AS3:
HTML:
I've been wasted all the day long for that...
AS3:
HTML:
如果您仍然遇到此问题,请按照以下步骤操作。
我使用了 flash vars,它们对我来说工作得很好。
我的 html 脚本是:
我的加载变量的 AS 代码是
If you are still having this problem, follow below lines.
I used flash vars, they work fine for me.
My html script was:
and my AS code to load vars is