如何将2个变量传递给Flash?
首先,我使用的是Flash CS5.5、AS3。
我试图将代表姓名和电子邮件地址的变量传递给 swf 文件。 swf 使用用户网络摄像头拍照并将图像发送到 save.php 进行进一步处理。目前,我有供用户输入姓名和电子邮件的文本字段,但我想删除它们并在幕后添加信息。基本上这就是我想要实现的目标:
1.Page loads and stores name and email address in variables(index.php).
2.I'd like to pass name and email address variables to flash to be included with
the image the swf sends to a php file for processing (save.php)
3.Page loads flash content(take_picture.swf) and does it's thing.
我使用 Zend AMF 在类似的情况下工作,其中 swf 获取从访问数据库的另一个页面传回的所有信息。在这里,我无需访问数据库即可获得所需的数据。我已经使用 FlashVars 尝试了许多变体,但还没有任何效果。我似乎缺少的一件事是,当我发布 fla 时,Flash 发布的 html 代码中没有 ac_fl_runcontent
。并且也没有
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="760" height="1000" id="take_picture" align="middle">
<param name="movie" value="take_picture.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="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="take_picture.swf" width="760" height="1000">
<param name="movie" value="take_picture.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="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![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>
我试过 与操作面板中的
this.loaderInfo.parameters.first_name
和 this.loaderInfo.parameters[first_name]
类似的内容以及一些其他事情,但还没有开始工作。任何帮助将不胜感激。
非常感谢,
马克
编辑:这是我最新的尝试:
var f_name:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
f_name = String(paramObj[first_name]);
first_name.text=f_name;
在 html 中使用此内容:
<param name="FlashVars" value="first_name=<?php echo $first_name; ?>"/>
First off, I'm using Flash CS5.5, AS3.
I'm trying to pass variables representing name and email address to a swf file. The swf takes a picture with the users webcam and sends the image to save.php for further processing. Currently I have text fields for the user to enter name and email, but I'd like to eliminate them and add the info behind the scenes. Basically this is what I'm trying to accomplish:
1.Page loads and stores name and email address in variables(index.php).
2.I'd like to pass name and email address variables to flash to be included with
the image the swf sends to a php file for processing (save.php)
3.Page loads flash content(take_picture.swf) and does it's thing.
I've got this working in a similar situation using Zend AMF, where the swf gets all the info passed back from another page accessing the database. Here I have the data I need without accessing the database. I've tried many variations using FlashVars, but nothing has worked yet. One thing I seem to be missing is when I publish the fla, there is no ac_fl_runcontent
in the html code Flash publishes. And there is no <embed src=...
either. This div is the body of the html file Flash gives me:
<div id="flashContent">
<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="760" height="1000" id="take_picture" align="middle">
<param name="movie" value="take_picture.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="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--[if !IE]>-->
<object type="application/x-shockwave-flash" data="take_picture.swf" width="760" height="1000">
<param name="movie" value="take_picture.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="window" />
<param name="scale" value="showall" />
<param name="menu" value="true" />
<param name="devicefont" value="false" />
<param name="salign" value="" />
<param name="allowScriptAccess" value="sameDomain" />
<!--<![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've tried <param name="FlashVars" value="first_name=<?php echo $first_name; ?>&email=<?php echo $email ?>" />
with something along the lines of this.loaderInfo.parameters.first_name
and this.loaderInfo.parameters[first_name]
in the actions panel along with some other things but haven't gotten it to work yet. Any help would be appreciated.
Thanks very much,
Mark
EDIT: This is my latest attempt:
var f_name:String;
var paramObj:Object = LoaderInfo(this.root.loaderInfo).parameters;
f_name = String(paramObj[first_name]);
first_name.text=f_name;
With this in the html:
<param name="FlashVars" value="first_name=<?php echo $first_name; ?>"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这里有一些简单的东西可以给你一个想法:
嵌入:
AS3:
Here's something simple to give you an idea:
Embed:
AS3:
将 SWF 添加到 html 页面的最佳/最简单方法是 SWFObject。
只需将脚本添加到您的文件中,
然后您就可以添加所有必要的属性/参数,如下所示:
我认为这并不像编辑 EMBED 和 OBJECT 标记那么令人困惑,您只需更改一次属性,SWFObject 就会完成其余的工作。绝对值得一看...
the best/easiest way to add a SWF to your html page is SWFObject.
just add the script to your file
you can then add all necessary attributes/params like this:
i think this is not so confusing as to edit both EMBED and OBJECT tag and you only have to change an attribute once and SWFObject does the rest. definitely worth taking a look...