PHP/Flash 集成不一致

发布于 2024-09-07 23:19:26 字数 266 浏览 1 评论 0原文

我的 Flash 应用程序遇到一些一致性问题,当我回显 Flash 获取的变量时,它并不总是获取 PHP 发送的内容,它似乎因 PC 而异。

我正在从数据库获取信息,我需要将其传递到闪存,例如我需要发送 5 个变量 $uid,$name,$points,$from,$page ,我如何才能从PHP 使用 AMFPHP 来刷新?

有人告诉我 AMFPHP 将是在这种情况下使用的最佳工具,但我不知道它是如何工作的,并且网站上的示例代码对我来说并不完全有意义。

提前致谢!

I am having some consistency problems with my flash application, when I echo out variables for flash to get, it doesn't always pick up what PHP is sending, it seems to vary from PC to PC.

I am getting info from a database, and I need to pass it to flash, say for instance I need to send through 5 variables $uid,$name,$points,$from,$page , how could I go about sending these from PHP to flash using AMFPHP?

I was told that AMFPHP would be the best tool to use for such situations, but I have NO knowledge of how it works and the sample code on the site is not making complete sense to me.

Thanx in advance!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

笨死的猪 2024-09-14 23:19:26

您无法将其从 PHP 推送到 Flash - 通信必须由 Flash 端发起。为此,您不需要 AMFPHP;只需使用 URLLoader 即可。

var ldr:URLLoader = new URLLoader();
ldr.addEventListener(Event.COMPLETE, onLoad);
ldr.load(new URLRequest("page.php"));

function onLoad(e:Event):void
{
  var loadedText:String = URLLoader(e.target).data;
  /**
   * Following will throw error if the text 
   * is not in the format `a=something&b=something%20else`
   * */
  var data:URLVariables = new URLVariables(loadedText);
  for(var t:Object in data)
    trace(t + " : " + data[t]);
}

page.php 中,只需执行一个简单的 echo:

//don't forget to urlencode your variables.
echo "uid=$uid&name=$name&points=$points";

You cannot push it from PHP to Flash - the communication has to be initiated by the Flash end. And you don't need AMFPHP for this; just use a URLLoader.

var ldr:URLLoader = new URLLoader();
ldr.addEventListener(Event.COMPLETE, onLoad);
ldr.load(new URLRequest("page.php"));

function onLoad(e:Event):void
{
  var loadedText:String = URLLoader(e.target).data;
  /**
   * Following will throw error if the text 
   * is not in the format `a=something&b=something%20else`
   * */
  var data:URLVariables = new URLVariables(loadedText);
  for(var t:Object in data)
    trace(t + " : " + data[t]);
}

inside the page.php, just do a simple echo:

//don't forget to urlencode your variables.
echo "uid=$uid&name=$name&points=$points";
对岸观火 2024-09-14 23:19:26

仅仅为了将几个变量发送到 flash 文件而使用 AMFPHP 似乎很麻烦。我建议您尝试:

  • Flashvars(尽管它仅限于短变量)
  • LoadVariables
  • XML(从 PHP 以 XML 形式返回所需的值)

以上所有内容对我来说一直有效。

It seems a hassle to get involved with AMFPHP just to send a couple of variables to a flash file. I suggest you try:

  • Flashvars (though it's kind of limited to short variables)
  • LoadVariables
  • XML (returning the values you need as XML from PHP)

All of the above have worked consistently for me.

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