Solved

AS3 PHP run php then send a var back to flash

Posted on 2011-03-04
2
429 Views
Last Modified: 2012-05-11
the tut in this link has everything for the most part that i want to do.
http://www.developphp.com/Flash_tutorials/show_tutorial.php?tid=39

what i want to do different is only send "parse"
i dont want to send "uname"

one more thing :
i only want one  var in the php file. so i want to get rid of var two.
and in the complete listener in flash render out trace(var1)

this might be verrry simple but i am having a really hard time figuring out what i'm doing wrong even with the awesome tut in the link. please help i am going nuts! lol
0
Comment
Question by:conagraman
  • 2
2 Comments
 
LVL 10

Accepted Solution

by:
conagraman earned 0 total points
ID: 35043520
i was able to figure it out.
//////////////////////////////////////////////php

<?php if ($_POST['sendRequest'] == "DoIt") {print "var1=Did It";} ?>

///////////////////////////////////////////////as3 code:  
submit_btn.addEventListener(MouseEvent.CLICK, btnDown);

function btnDown(event:MouseEvent):void {
var path:String  = "http://127.0.0.1/mypath.php";
var variables:URLVariables = new URLVariables();
var varSend:URLRequest = new URLRequest(path);
      varSend.method = URLRequestMethod.POST;
      varSend.data = variables;
var varLoader:URLLoader = new URLLoader;
      varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
      varLoader.addEventListener(Event.COMPLETE, completeHandler);
              
               variables.sendRequest = "DoIt";      
               varLoader.load(varSend);
            
function completeHandler(event:Event):void{
      var phpVar1 = event.target.data.var1;
                      trace(phpVar1);
}      
}



0
 
LVL 10

Author Closing Comment

by:conagraman
ID: 35043535
what i can do with this code is send a request to my phpfile. my php file can then perform a function for me then once the function is complete my as3 will know because of the complete event.
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now