将变量从 flash 传递到 HTML/php [英] Passing variable FROM flash to HTML/php

查看:23
本文介绍了将变量从 flash 传递到 HTML/php的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能就我在决定如何解决时遇到的问题提供一些见解.

I was hoping maybe someone could provide some insight on a problem I'm having a tough time deciding how to solve.

我有一个相当简单的 flash 应用程序,用户可以在连接时快速创建用户名,并且用户名是在 flash swf 中创建的.

I have a rather simple flash application users can make a quick username when connected, and the username is created inside the flash swf.

现在,我有一个 cron 作业,每十分钟删除一次不活动的用户名(在我的 mysql 数据库中,这些用户名都被在线其他人存储和访问),这很好.但是,如果一群人同时签署,它仍然会变得混乱,在 cron 工作清除他们之前还有 10 分钟的窗口.

Now, I have a cron job deleting inactive usernames every ten minutes (on my mysql database where these usernames are all stored and accessed by the other people online) which is fine. But it can still get cluttered up if a bunch of people sign off at once, there is still that 10 minute window before the cron job clears them.

用户可以选择在 Flash 应用程序中单击注销,这很好,效果很好.但当然很多人选择不点击注销,他们只是点击浏览器 x.

The users have an option to click log out in the flash application which is fine and works great. But of course many choose not to click log off they just click the browser x.

我已经研究了 onbeforeunload 和 jquery 的 .unload 但我仍然需要一种方法来获取闪存到 HTML 中的用户名变量,然后使用 php 脚本运行删除用户名 mysql 查询.

I've looked into onbeforeunload and jquery's .unload but I still need a way to get the username variable that's IN flash INTO the HTML, then use a php script to run the delete username mysql query.

有更简单的解决方案吗?

Is there an easier solution?

如果没有,在用户输入用户名之后我如何将用户名变量传递给 html 以保留它,以便它可以参与运行 php 脚本的 .unload 函数?

If not, any insight on how I might pass the username variable to the html to hold onto it after the user makes their username so it can be involved with the .unload function running the php script?

:::: 也许有没有办法用 php 创建一个唯一的数字字符串,然后将该 var 传递给 flash 以包含在 mysql 行中,然后因为我已经有了那个 var,因为它是在 html 端创建的,与卸载一起,是否删除具有该唯一 ID 的行?

:::: Maybe is there a way to create a UNIQUE string of numbers with php then pass that var to flash to include with the mysql row then since i already have that var since it was created on the html side, just along with the unload, have it delete the row that has that unique id?

如果有人认为这个想法是最好的方法,如果我使用像 md5(uniqid(microtime()) . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']) 这样的东西来制作随机 iD我怎样才能将结果存储在一个 var 中,我可以将其放在 flash vars 参数中,然后再次在 jquery unload 或 javascript onbeforeunload 中,如果这样会更好的话.我只是更熟悉 jquery

If anyone things this idea would be the best approach, and if i used something like md5(uniqid(microtime()) . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']) to make a random iD how could i go about storing the result in a var i could place in the flash vars param then again in the jquery unload or javascript onbeforeunload if that would be better . im just more familiar with jquery

推荐答案

您实际上可以调用 ExternalInterface 命令来填充来自 SWF 组件的 HTML 中的隐藏字段.

You could actually invoke an ExternalInterface command to populate a hiddenfield in your HTML coming from your SWF component.

if (ExternalInterface.available) 
{
  var js:String = "yourJavaScriptFunction";
  var valToPass:String;
  ExternalInterface.call(js(valToPass));
}

在你的 HTML 页面中,你编写了一个 javascript 函数:

And in your HTML page, you write a javascript function:

<script language="javascript" type="text/javascript">
function yourJavaScriptFunction(valToPass)
{
  document.getElementById('yourHiddenField').value = valToPass;
}

从页面触发的卸载事件中,您可以访问从 SWF 传递的值.

And from the unload event fired up by your page, you can access the value which was passed from your SWF.

请注意,您可以在获得用户的登录凭据后立即从 SWF 调用 javascript 函数.

Take note that you can call the javascript function from your SWF as soon as you get the login credentials of your user.

希望这会有所帮助.

这篇关于将变量从 flash 传递到 HTML/php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆