duannaikuang1301 2013-07-19 08:28
浏览 47
已采纳

即时通讯必须以奇怪的方式将php数据传递给actionscript [关闭]

I have some values in a loop.php that generate a link like "page.php?id=1" "page.php?id=2" ecc.

I need to pass the value of "id" into actionscript3, who read a link page.php like this:

var myVars:URLVariables = new URLVariables(); 
myVars.flashVar = "myValue";

var myRequest:URLRequest = new URLRequest("page.php");
myRequest.method = URLRequestMethod.POST;
myRequest.data = myVars;

var myLoader:URLLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, completeHandler);
myLoader.load(myRequest);

function completeHandler(e:Event){
    var receiveVars:URLVariables = new URLVariables(e.target.data);


    vartxt1.text = receiveVars.phpVar1;

the problem is that i could change the link in actionscript like this:

var myRequest:URLRequest = new URLRequest("page.php?id=1");

but the problem is that is a static link, and if my value is changing to "4", then the link is working always with the value of "1".

i have think that maybe i could write an .xml with the value, and put actionscript to read that file...practically:

page.php?id=1 => page.xml.php (writing the xml) => redirect to page-with-swf-file.html

and when i'm on the page-with-swf-file.html i read the page.xml.php for the "id", and then load all the rest of the data that i need.

Is there an easier way of doing all this go-forward then go-back...?

  • 写回答

1条回答 默认 最新

  • doubeishuai6598 2013-07-19 11:37
    关注

    Is page.php a valid link as well? Just off the top of my head, some ways to do it:

    • Flash contacts page.php, and it returns an array of all the values (id=1, id=2...)
    • Flash contacts another page that returns an array of all the values
    • Flash controls the generates the variables (i.e. in a loop do "page?id=" + i)
    • Flash just starts with "page?id=1" and in the return, php tells it the next page
    • Php passes all the values to flash vars when writing the embed code for the swf
    • Php writes all the values to an xml files, and flash loads it
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 在获取boss直聘的聊天的时候只能获取到前40条聊天数据
  • ¥20 关于URL获取的参数,无法执行二选一查询
  • ¥15 液位控制,当液位超过高限时常开触点59闭合,直到液位低于低限时,断开
  • ¥15 marlin编译错误,如何解决?
  • ¥15 有偿四位数,节约算法和扫描算法
  • ¥15 VUE项目怎么运行,系统打不开
  • ¥50 pointpillars等目标检测算法怎么融合注意力机制
  • ¥20 Vs code Mac系统 PHP Debug调试环境配置
  • ¥60 大一项目课,微信小程序
  • ¥15 求视频摘要youtube和ovp数据集