Friday, May 10, 2013

Send variabel as3 to php




Tutorial Details
  • Judul: Send variabel as3 to php
  • Difficulty: Beginner
  • Platform: Flash (Flash Player 10)
  • Bahasa Scripth: AS3
  • Software : Flash Professional CS4/Flash Professional CS5/flash profesional cs6
  • Estimated Completion Time: 15 minutes
  • Created:Ricko Nada (Pustaka Flash)





live demo :



Scripth yang digunakan :
function checkComplete(evt:MouseEvent):void {

var myVariables:URLVariables = new URLVariables();

myVariables.candidate = nama.text;

var myRequest:URLRequest = new URLRequest("as3php.php");

myRequest.method = URLRequestMethod.POST;


myRequest.data = myVariables;

var myLoader:URLLoader = new URLLoader;


myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;


myLoader.load(myRequest);

myLoader.addEventListener(Event.COMPLETE, loadComplete);

}

enter_btn.addEventListener(MouseEvent.CLICK, checkComplete);


function loadComplete(evt:Event):void {


output_txt.text = evt.target.data.phpConfirm;

}





scripth phpnya

<?php

// $candidate is the variable send from Flash Actionscript
$yangdiinput= $_POST['candidate'];

// Confirm to Flash ActionScript that the data has been received
echo "phpConfirm= bagus " . $yangdiinput . "! kamu memasukkan " . $yangdiinput . ". Terima kasih" ;

?>



close