Solved

AS3 PHP run php then send a var back to flash

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

732 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