从PHP Flash影片请求的数据,在运行时影片、数据、PHP、Flash

2023-09-08 11:36:38 作者:脚踏两只船丶划得更快

是否有可能要求的一些数据,从PHP Flash影片在运行时?也许我的现实世界的实现可以澄清一些事情:

Is it possible to request some data in a Flash movie from PHP at run-time? Maybe my real-world implementation can clarify some things:

我用的Flash影片来存储本地共享对象(因为某种原因,我需要LSO的替代或常规PHP饼干)。 现在,当我加载了一个PHP文件,我想以某种方式检索来自莱索托的数据在运行时,将其分配给一些变量,并通过脚本的其余部分使用的变量。

I use a Flash movie to store a Local Shared Object (because for some reason I need LSO's instead or regular PHP cookies). Now, when I load up a PHP file I want to somehow retrieve the data from the LSO at runtime, assign it to some variables, and use the variables through the rest of the script.

做一些研究使我相信这是不可能的,我打算的方式。因此,任何其他建议,方法或解决方案是非常欢迎的。

Doing some research makes me believe it's not possible in the way I intend. So any other suggestions, methods or solutions are highly welcome.

推荐答案

,以实现它的Flash和PHP的XML的最好方法(不要忘了使用UTF-8!)。

The best way to intercommunicate Flash and PHP is XML (don't forget to use UTF-8!).

在PHP中:

$xml = new DOMDocument('1.0', 'UTF-8');
$doc = $xml->appendChild($xml->createElement('my-root-element'));
...
header('Content-Type: text/xml; charset=utf-8');
echo $xml->saveXML();

在AS3

var myLoader:URLLoader = new URLLoader();
var req:URLRequest = new URLRequest('http://host.com/my_xml.php');
myLoader.addEventListener(Event.COMPLETE, onMyXMLLoad);
myLoader.load(req);

function onMyXMLLoad(evt:Event)
{
    trace(evt.target.data);
    var xml:XML = new XML(evt.target.data);
    ...
}

您也可以了解有关 ExternalInterface的 ......是的,有时它可以帮助...你可能要产生dynamicaly您的JS与Flash动画进行沟通。

You could also read about ExternalInterface... Yes, sometimes it helps... You may want to generate dynamicaly your JS to communicate with flash movie.