Solved

AS3 PHP run php then send a var back to flash

Posted on 2011-03-04
2
432 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The goal of the tutorial is to teach the user how to how to record live broadcast.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

810 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