El asunto es que el pgp deve generarme un codigo en formato JSON, pero as3 me estar cargando todo el codigo, es decir lo lee y me sale error.
import com.adobe.serialization.json.*;
Código PHP:
var loader:URLLoader = new URLLoader();
var request:URLRequest = new URLRequest();
//reading data from txt file
//Json can be called from any file like .txt .php etc. i Used here .txt
request.url = "test2.php";
loader.load(request);
//On load i'm calling this event which call decoding json class file
loader.addEventListener(Event.COMPLETE, decodeJSON);
//decoding funtion
function decodeJSON(event:Event):void{
var loader:URLLoader = URLLoader(event.target);
trace(loader.data);
var People:Array = JSON.decode(loader.data);
/*Trace the JSON data, remember it used to look like this ([ {"name":"Jaylo", "number":"3243251"}, {"name":"Jenny", "phone":"8675309"}])*/
trace(People[0].name) ; //Jaylo
trace(People[0].number) ; //3243251
//trace(People[1].name) ; //Jenny
//trace(People[1].number) ; //8675309
//text box
dataText.text = People[1].name +" "+ People[1].number;
}
Código PHP:
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" );
header("Cache-Control: no-cache, must-revalidate" );
header("Pragma: no-cache" );
header("Content-type: text/x-json");
$data['nombre'][0]="juan ";
$data['numero'][1]="83787329";
//echo json_encode($data);
?>
Como puedo hacer esto??