动作3 PHP变量并没有改变 [英] actionscript 3 php variables are not changing

查看:173
本文介绍了动作3 PHP变量并没有改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作在PHP中的随机数发生器,我想结果发送到AS3 (这是很复杂的,但是,这是主要的目的)

I am working on a random number generator in PHP and I want to send the result to the AS3 (it is much complicated but this is the main purpose)

PHP:

<?php
    function random() {
      calculating it...sql query ...blabla
      return $randomNumber;
    }
    print "randomNumber=".random();
?>

AS3:

var loader:URLLoader = new URLLoader();
var myRequest:URLRequest=new URLRequest("mylink");  
function randomPhp():void {     
    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
    loader.addEventListener(Event.COMPLETE, completeRandom);
    loader.load( myRequest );
}
function completeRandom(e:Event):void {
   winner=e.target.data.randomNumber;
   loader.removeEventListener( Event.COMPLETE, completeRandom );
}

第一次产生一个随机数,但在那之后它不改变,如果我把它称为多次。 这是它是否会在cache.I实例不知道如何解决这个问题,或复位等。 如果我跑我的项目,并在时间,我删除了整个PHP,AS3的运行就像什么都没有发生。 请帮助!

The first time it generates a random Number but after that it's not changing if I call it multiple times. It's like if it creates an instance in the cache.I don't know how to fix this or reset it. And if I run my project and in the time I delete the whole PHP , the AS3 is running like nothing happened. Please HELP!!!

推荐答案

有趣的不够,你必须添加一个RandomNumber让你RandomNumber)或更好的时间戳将URLRequest! 否则,你会得到缓存的请求! 为什么你需要从PHP随机数?而不是仅仅使其在AS3?

Funny enough you will have to add a RandomNumber to get your RandomNumber ;) or better a timeStamp to the URLRequest! Otherwise you will get the cached Request! Why do you need the random number from php? and not just make it in as3?

URLRequest("mylink"+"?"+new Date().getTime());

或者就像我说的一个 ... + +的Math.random()* 1000)?;

这篇关于动作3 PHP变量并没有改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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