Tengo este codigo, pero la unica parte que me interesa es entender lo del texto basico y botones, y no lo de php, sendandload y operaciones matematicas..
Como me doy cuenta para saber que pongo y que saco.
Código :
var btnphpbd:Button;
var btnphpbas:Button;
var btntxtava:Button;
var btntxtbas:Button;
var btnSendAndLoad:Button;
var btnMath:Button;
var fuenteBasico:LoadVars = new LoadVars();
var fuenteAvanzado:LoadVars = new LoadVars();
var fuenteMath:LoadVars = new LoadVars();
var texto:TextField;
texto.html = true;
texto.wordWrap = true;
texto.multiline = true;
fuenteBasico.onLoad = function (exito:Boolean){
if (exito){
texto.htmlText= "<p><b>"+this.titulo+"</b></p><br>";
texto.htmlText+= "<p>"+this.texto+"</p>";
texto.htmlText+= "<p align='right'><i>"+this.autor+"</i></p><br><br>";
} else{
managerError("fuenteBasico");
}
}
fuenteAvanzado.onLoad = function (exito:Boolean){
if (exito){
texto.htmlText="";
for (var i:Number=0; this["titulo"+i]!=undefined;i++){
texto.htmlText+= "<p><b>"+this["titulo"+i]+"</b></p><br>";
texto.htmlText+= "<p>"+this["texto"+i]+"</p>";
texto.htmlText+= "<p align='right'><i>"+this["autor"+i]+"</i></p><br><br>";
}
} else{
managerError("fuenteAvanzado");
}
}
fuenteMath.onLoad = function (exito:Boolean){
if (exito){
var acum:Number = 0;
for (var op in this){
if (!isNaN(this[op])){
acum+= Number(this[op]);
}
}
texto.htmlText = String(acum);
} else{
managerError("fuenteAvanzado");
}
}
/**** Definicion de todos los eventos onRelease de los botones ****/
btntxtbas.onRelease = btntxtava.onRelease = btnphpbd.onRelease = btnphpbas.onRelease = btnSendAndLoad.onRelease = btnMath.onRelease = function(){
texto.htmlText = "Cargando informacion, por favor espere...";
manager(this._name);
}
function manager(name){
switch (name){
case "btntxtbas": fuenteBasico.load("txt/texto1.txt"); break;
case "btntxtava": fuenteAvanzado.load("txt/texto2.txt"); break;
case "btnphpbas": fuenteBasico.load("http://localhost/tutorial/loadvars/php/articulo.php"); break;
case "btnphpbd": fuenteAvanzado.load("http://localhost/tutorial/loadvars/php/articulobd.php"); break;
case "btnSendAndLoad":
fuenteBasico.titulo = "Enviar caracteres especiales con loadvars de flash";
fuenteBasico.texto = "Los caracteres especiales (áéíóúñ) se envian normales desde flash, en php se debe recibir con la funcion utf8_decode, si usas otro lenguaje busca una función similar ;)";
fuenteBasico.test= "á";
fuenteBasico.autor= "Maikel";
fuenteBasico.sendAndLoad("http://localhost/tutorial/loadvars/php/sendAndLoad.php",fuenteBasico,"GET");
break;
case "btnMath": fuenteMath.load("txt/variables.txt"); break;
default: fuenteBasico.load("txt/texto1.txt"); break;
}
}
function managerError(name:String){
texto.htmlText = "No se pudo cargar la data";
trace("En "+name+" corrige la direccion del archivo fuente o algo más pudo haber pasado, verifica");
}
manager();
stop();