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

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

问题描述

我希望也许有人可以提供一些问题的见解,我有一个艰难的时间决定如何解决。



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



现在,我有一个cron作业每十分钟删除不活动的用户名(在我的mysql数据库,其中这些用户名都被存储在其他人在线访问)这是好的。但是,如果一堆人立即签名,仍然可能会混乱起来,在cron作业清除之前还有10分钟的时间。

用户有一个选项点击注销在Flash应用程序,这是好的,很好的工作。但是,当然,许多人选择不点击注销,他们只是点击浏览器x。

我已经调查onbeforeunload和jquery的.unload,但我仍然需要一种方法来获得用户名变量是IN flash INTO HTML,然后使用php脚本运行删除用户名mysql query。



有没有简单的解决方案?



如果不是的话,任何有关如何将用户名变量传递给html以在用户输入用户名之后保持它的任何见解,以便可以使用运行php脚本的.unload函数?

::::也许有一种方法来创建一个唯一的数字字符串与PHP然后传递该变量闪存包括与MySQL的行,然后因为我已经有了这个变种,因为它是在HTML端创建的,只是随着卸载,让它删除具有该唯一ID的行?

如果有任何东西这个想法是最好的办法,如果我使用类似md5(uniqid(microtime())。$ _SERVER ['REMOTE_ADDR']。$ _SERVER ['HTTP_USER_AGENT'])来做一个随机的iD我怎么能把结果存储在一个变种我可以放在闪存变量的参数,然后再次在jQuery的卸载或javascript onbeforeunload,如果这样会更好。我只是更熟悉jquery

解决方案

实际上,您可以调用ExternalInterface命令来填充来自SWF组件的HTML中的隐藏字段。
$ b $ pre $ if(ExternalInterface.available)
{
var js:String =yourJavaScriptFunction;
var valToPass:String;
ExternalInterface.call(js(valToPass));





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

 < script language =javascripttype =text / javascript> 
函数yourJavaScriptFunction(valToPass)
{
document.getElementById('yourHiddenField')。value = valToPass;
}

从页面启动的unload事件中,您可以访问该值这是从您的SWF传递。



请注意,只要您获得用户的登录凭据,即可从SWF调用JavaScript函数。



希望这有助于。


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

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

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.

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.

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?

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?

EDIT::::: 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?

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

解决方案

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));
}

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

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

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

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

Hope this helps.

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

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