如何将2个变量传递给Flash?

发布于 2024-12-07 06:20:12 字数 3451 浏览 4 评论 0原文

首先,我使用的是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_runco​​ntent 。并且也没有 。这个div是Flash给我的html文件的主体:

 <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_namethis.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 技术交流群。

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

发布评论

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

评论(2

情释 2024-12-14 06:20:12

这里有一些简单的东西可以给你一个想法:

嵌入:

<object width="800" height="600">
    <param name="flashvars" value="first_name=blah&email=blah" />
    <embed src="clipping.swf?first_name=blah&email=blah" width="800" height="600" />
</object>

AS3:

var parsed:Object = root.loaderInfo.parameters;

trace(
    parsed.first_name,
    parsed.email
);

Here's something simple to give you an idea:

Embed:

<object width="800" height="600">
    <param name="flashvars" value="first_name=blah&email=blah" />
    <embed src="clipping.swf?first_name=blah&email=blah" width="800" height="600" />
</object>

AS3:

var parsed:Object = root.loaderInfo.parameters;

trace(
    parsed.first_name,
    parsed.email
);
冷默言语 2024-12-14 06:20:12

将 SWF 添加到 html 页面的最佳/最简单方法是 SWFObject

只需将脚本添加到您的文件中,

<script type="text/javascript" src="swfobject.js"></script>

然后您就可以添加所有必要的属性/参数,如下所示:

<script type="text/javascript">
    // <![CDATA[

    var width = 800;
    var height = 600;

    var flashVersion = "9.0.115";

    var movie = "clipping.swf";

    var movieName = "flashMovie";
    var bgColor = "#ffffff";

    var express = "expressInstall.swf";

    var replaceDiv = "flashContent";

    var flashvars = {};
    flashvars.first_name = "<?php echo $first_name; ?>";
    flashvars.email = "<?php echo $email; ?>";

    var params = {};
    params.bgcolor = bgColor;
    params.menu = "false";
    params.scale = "noscale";
    params.allowFullScreen = "true";
    params.allowScriptAccess = "always";

    var attributes = {};
    attributes.id = movieName;

    swfobject.embedSWF(movie, replaceDiv, width, height, flashVersion, express, flashvars, params, attributes);


  // ]]>
</script>

我认为这并不像编辑 EMBED 和 OBJECT 标记那么令人困惑,您只需更改一次属性,SWFObject 就会完成其余的工作。绝对值得一看...

the best/easiest way to add a SWF to your html page is SWFObject.

just add the script to your file

<script type="text/javascript" src="swfobject.js"></script>

you can then add all necessary attributes/params like this:

<script type="text/javascript">
    // <![CDATA[

    var width = 800;
    var height = 600;

    var flashVersion = "9.0.115";

    var movie = "clipping.swf";

    var movieName = "flashMovie";
    var bgColor = "#ffffff";

    var express = "expressInstall.swf";

    var replaceDiv = "flashContent";

    var flashvars = {};
    flashvars.first_name = "<?php echo $first_name; ?>";
    flashvars.email = "<?php echo $email; ?>";

    var params = {};
    params.bgcolor = bgColor;
    params.menu = "false";
    params.scale = "noscale";
    params.allowFullScreen = "true";
    params.allowScriptAccess = "always";

    var attributes = {};
    attributes.id = movieName;

    swfobject.embedSWF(movie, replaceDiv, width, height, flashVersion, express, flashvars, params, attributes);


  // ]]>
</script>

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...

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