从PHP脚本到Flash的ActionScript 3.0传递变量? [英] Passing variables from a PHP script to Flash ActionScript 3.0?

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

问题描述

我有一个运行在一个单独的PHP脚本,然后更新preVIEW URL中的文件已被上传后的图片上传。但我想要做的是有一个Flash的SWF嵌入到正在运行的PHP上传来获取preVIEW URL和Flash应用程序中显示它相同的HTML。

I have an image uploader that runs on a separate PHP script, and then updates the Preview Url after the file has been uploaded. But what I'd like to do is have a Flash SWF embedded in the same HTML that's running the PHP Uploader to get that Preview URL and display it in the Flash Application.

你有什么建议可以去了解发送此PHP变量到Flash的最佳方法是什么?

What would you suggest be the best way to go about sending this PHP variable to Flash?

在此先感谢!

亚伦

推荐答案

您不能异步的发送的从PHP(服务器端)的值闪存(客户端)。你必须通过Flash变量要么通过它在嵌入时间(虽然我怀疑这会在你的情况下工作,因为你想负荷运行后,会出现这种转移的信息),或您的Flash应用程序将需要查询的服务器,已在服务器返回正确的值。

You cannot asynchronously send a value from PHP (server-side) to Flash (client-side). You have to either pass it in on embed-time through a flashvar (although I doubt this will work in your case since you want this transfer of information to occur after a load operation) or your Flash application will need to query the server, and have the server return the correct value.

第三个选择是使用 ExternalInterface的 API在Flash中,让你的HTML通知通过JavaScript的Flash应用程序时,URL是可用的。

A third option would be to use the ExternalInterface API in Flash to let your HTML notify the Flash application via javascript when the URL is available.

由于我不知道你一般的设置,很难推荐一种方法在另一个,但有一个比其他打算的原因一般有:

Since I don't know your general set-up, it's hard to recommend one way over another, but the general reasons for going with one over the other are:

  • 选择在 FlashVar的方法如果当嵌入HTML载入值是已知的,这样就可以在将它传递给SWF,因为它是被初始化,如:使用查询字符串:???myflash.swf previewUrl =< PHP的echo $previewUrl;>
  • 选择在 ExternalInterface的做法如果您使用的是异步的方式(所以上面是不可能的)和HTML应用程序/ JS一部分已经被通知。这样,你可以调用的SWF的JavaScript方法嵌入DOM对象,并将它在您的ActionScript内收到。
  • 选择在服务器查询的办法,如果以上都没有效果的,但你必须知道的一些方法,当上传完成。只需使用普通的的URLLoader 查询服务器为preVIEW URL,指定文件ID或类似的GET或POST变量。
  • Choose the flashvar approach if the value is known when the embedding HTML is loaded, so that you can pass it in to the SWF as it's being initialized, e.g. using the query-string: myflash.swf?previewUrl=<?php echo $previewUrl;?>
  • Choose the ExternalInterface approach if you are using an asynchronous approach (so the above is not possible) and the HTML/JS part of your application already is being notified. This way you can just invoke a javascript method on the SWF embed DOM object, and have it be received inside your ActionScript.
  • Choose the server query approach if none of the above works, but you have some way of knowing when the upload is complete. Just use a regular URLLoader to query the server for the preview URL, specifying the file id or similar as a GET or POST variable.

希望这有助于。请详细说明你的架构的细节调整,以更彻底的答案。

Hope this helps. Please elaborate on the details of your architecture for a more thorough answer.

这篇关于从PHP脚本到Flash的ActionScript 3.0传递变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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