- sendToURL() 과 navigateToURL() 의 차이
- 데이터를 보내고 보낸 결과를 받아 온다.
-
package
-
{
-
import flash.display.Sprite;
-
import flash.events.Event;
-
import flash.net.URLLoader;
-
import flash.net.URLRequest;
-
import flash.net.URLVariables;
-
import flash.text.TextField;
-
-
public class SendAndLoad extends Sprite
-
{
-
public function SendAndLoad()
-
{
-
initializeOutput();
-
sendData();
-
}
-
private function initializeOutput():void
-
{
-
_output = new TextField();
-
_output.width = stage.stageWidth;
-
_output.height = stage.stageHeight;
-
-
addChild(_output);
-
}
-
private function sendData():void
-
{
-
//Create a URLRequest to contain the data to send
-
var request:URLRequest = new URLRequest("process.php");
-
-
//Create name-value pairs to send to the server
-
var varibles:URLVariables = new URLVariables();
-
varibles.method = "getProductDetail";
-
varibles.productId = 2;
-
request.data = varibles;
-
-
//Create a URLLoader to send the data and receive a response
-
var loader:URLLoader = new URLLoader();
-
-
//Expect the script to return URL-encoded variables
-
loader.dataFormat = DataFormat.VARIABLES;
-
-
//Listen for the complete event to red the server response
-
loader.addEventListener(Event.COMPLETE, handleComplete);
-
-
//Send the data in the URLRequest off to the script
-
loader.load(request);
-
}
-
private function handlerComplte(event:Event):void
-
{
-
-
var loader:URLLoader = URLLoader(event.target);
-
-
//Expect the script to return name and description variables
-
//Display these values in a text field on the screen
-
_output.text = "Name: " + loader.data.name + "\n" + "Description :"+loader.data.description;
-
}
-
}
-
}
'Actionscript3.0' 카테고리의 다른 글
TextField selection 내용 추출하기 (0) | 2008.12.11 |
---|---|
CustomTextMotion + MotionCapture (0) | 2008.12.11 |
[AS3.0] Microphone class (마이크를 이용한 작업) (4) | 2008.12.11 |