Solved

AS3 PHP run php then send a var back to flash

Posted on 2011-03-04
2
437 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The goal of the tutorial is to teach the user how to how to record live broadcast.

705 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