dongsu0308 2009-02-06 18:30
浏览 32
已采纳

flash到php发送和接收变量

I Have a unique id generated for each record that I store into the database I want to pass that id to PHP and run a select statement against that and get a value back from the database and pass it back to flash, what is the best possible way to do it?

PS: I am using AS3

  • 写回答

2条回答 默认 最新

  • doushi5024 2009-02-10 09:20
    关注

    You have to call the php script which makes the sql connection and gets the value.

    Here: http://livedocs.adobe.com/flex/2/langref/flash/net/URLLoader.html#includeExamplesSummary

    The important part is here:

    public function URLLoaderExample() {
            var loader:URLLoader = new URLLoader();
            configureListeners(loader);
    
            var request:URLRequest = new URLRequest("urlLoaderExample.txt");
            try {
                loader.load(request);
            } catch (error:Error) {
                trace("Unable to load requested document.");
            }
        }
    

    And here:

    private function completeHandler(event:Event):void {
            var loader:URLLoader = URLLoader(event.target);
            trace("completeHandler: " + loader.data);
    
            var vars:URLVariables = new URLVariables(loader.data);
            trace("The answer is " + vars.answer);
        }
    

    In your php script you just have a print at the end:

    <?php
       $value = Select Statement to get that damn value out of the damn database
       print $value;
    ?>
    

    You will be able to read $value out of loader.data.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程