[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

AS3 PHP run php then send a var back to flash

Posted on 2011-03-04
2
Medium Priority
?
440 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
The title says it all. Writing any type of PHP Application or API code that provides high throughput, while under a heavy load, seems to be an arcane art form (Black Magic). This article aims to provide some general guidelines for producing this typ…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
Suggested Courses
Course of the Month20 days, 12 hours left to enroll

864 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