Foros del Web » Creando para Internet » Flash y Actionscript »

Enviar variable PHP a actionscript

Estas en el tema de Enviar variable PHP a actionscript en el foro de Flash y Actionscript en Foros del Web. Buenos días, necesito que actionscript me leea una variable mandada desde get, PHP (Toy null en actionscript una ayudita ;))...
  #1 (permalink)  
Antiguo 19/09/2010, 09:01
Avatar de raxper  
Fecha de Ingreso: enero-2010
Ubicación: ------
Mensajes: 472
Antigüedad: 14 años, 4 meses
Puntos: 2
Enviar variable PHP a actionscript

Buenos días, necesito que actionscript me leea una variable mandada desde get, PHP (Toy null en actionscript una ayudita ;))

Última edición por raxper; 19/09/2010 a las 09:07
  #2 (permalink)  
Antiguo 19/09/2010, 09:33
 
Fecha de Ingreso: abril-2003
Mensajes: 587
Antigüedad: 21 años
Puntos: 5
Respuesta: Enviar variable PHP a actionscript

Lo puedes hacer con la funcion LoadVars()

saludos
__________________
Si la vida te da la espalda tocale el culo
  #3 (permalink)  
Antiguo 19/09/2010, 11:38
Avatar de Bandit
Moderador
 
Fecha de Ingreso: julio-2003
Ubicación: Lima - Perú
Mensajes: 16.726
Antigüedad: 20 años, 10 meses
Puntos: 406
Respuesta: Enviar variable PHP a actionscript

Hola raxper:
Revisa éste link: http://www.solotuweb.com/fs~id~10416.html

Espero haberte sido de ayuda.
__________________
Bandit.
Si no sabes estudia y si sabes enseña.
http://www.banditwebdesign.com/
  #4 (permalink)  
Antiguo 19/09/2010, 11:44
Avatar de marmol  
Fecha de Ingreso: marzo-2004
Ubicación: en argentina
Mensajes: 197
Antigüedad: 20 años, 1 mes
Puntos: 4
Respuesta: Enviar variable PHP a actionscript

raxper como estas, bueno aca pongo un ejemplo de como leer desde flash el php
pero si queres que lea el php lea mysql ya es otra historia
crea un texto dinamico y ponele de nombre de instancia texto_txt
y en el primer fotograma pone este codigo

Código:
lecutura = new LoadVars();
lecutura.load("ejemplo_lectura.php",lecutura);
lecutura.onLoad = function() {
	texto_txt.text = this.variable_texto;
};
luego anda al blog de notas y
guarda el archivo con el nombre ejemplo_lectura.php
Código:
<?
print "&variable_texto=hola envio texto a flash";

?>
este otro ejemplo de enviar datos de un formulario y recibir "texto como respuesta si todo ha salido "ok"
en php:
Cita:
<?

// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
$DBhost = "localhost"; // Database Server
$DBuser = "root"; // Database User
$DBpass = ""; // Database Pass
$DBName = "turorials"; // Database Name
$table = "guestbook"; // Database Table
$numComments = 10; // Number of Comments per page

// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Error in GuestBook Application: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Error in GuestBook Application: " . mysql_error());

// Part Two - Choose what action to perform
$action = $_GET['action'];

switch($action) {


case 'write' :
// Recieve Variables From Flash
$name = ereg_replace("&", "%26", $_POST['yourname']);
$email = ereg_replace("&", "%26", $_POST['youremail']);
$comments = ereg_replace("&", "%26", $_POST['yourcomments']);
$submit = $_POST['submit'];

// Current system date in yyyy-mm-dd format
$submitted_on = date ("Y-m-d H:i:s",time());

// Check if its submitted from Flash
if($submit == 'Yes'){
// Insert the data into the mysql table
$sql = 'INSERT INTO ' . $table .
' (`ID`,
`name`,
`email`,
`comments`,
`time`
)
VALUES
(\'\','
. '\'' . $name . '\','
. '\'' . $email . '\','
. '\'' . $comments . '\','
. '\'' . $submitted_on . '\'
)';
$insert = mysql_query($sql, $DBConn) or die("Error in GuestBook Application: " . mysql_error());


//aca enviamos a flash texto
print "&gb_status=este es el texto que voy a recibir en flash.&done=yes&";
return;
}
print "&_root.write.gb_status=Error!&";
break;
}
?>
en flash
Cita:
on(click){
/*
Modify these reference paths to yours if you
have changed them. Also modify gb_status
reference path if required
*/
yourname = _parent._parent.write.yourname.text;
youremail = _parent._parent.write.youremail.text;
yourcomments = _parent._parent.write.yourcomments.text;

// Check variable data
if (yourname eq "") {
_parent._parent.write.gb_status.text = "Required: Name";
} else if (youremail eq "") {
_parent._parent.write.gb_status.text = "Required: Email Address";
} else if (!youremail.length || youremail.indexOf("@") == -1 || youremail.indexOf(".") == -1) {
_parent._parent.write.gb_status.text = "Required: Valid Email Address";
} else if (yourcomments eq "") {
_parent._parent.write.gb_status.text = "Required: Comments";
} else {
_parent._parent.write.gb_status.text = "Please wait...";
newEntry = new LoadVars()
newEntry.ref = this
newEntry.submit = "Yes"
newEntry.yourname = yourname
newEntry.youremail = youremail
newEntry.yourcomments = yourcomments
newEntry.sendAndLoad("GuestBook.php?action=write&r ="+random(999), newEntry, "POST")
newEntry.onLoad = function(success){
if(success){
_parent._parent.write.gb_status.text = this.gb_status;
_parent._parent.read.loadEntries("Default", 10);
// Clear fields
_parent._parent.write.yourname.text = "";
_parent._parent.write.youremail.text = "";
_parent._parent.write.yourcomments.text = "";
}
}
}
}
el link de descarga
http://www.flash-db.com/Tutorials/download.php?id=159
Vale aclarar que para que podamos leer o escribir php debe estar alojado en un servidor; espero que te haya podido ayudar saludos!
__________________
Fabricante Maquina industriales
http://www.guidobatanmaquinarias.com

Última edición por marmol; 19/09/2010 a las 11:56
  #5 (permalink)  
Antiguo 03/10/2010, 20:08
Avatar de raxper  
Fecha de Ingreso: enero-2010
Ubicación: ------
Mensajes: 472
Antigüedad: 14 años, 4 meses
Puntos: 2
Respuesta: Enviar variable PHP a actionscript

Gracias X), borthers, lo que había pedido era leer desde una url variables como en php
jaja ustedes me enseñaron como desde action script leer variables alojadas en un documento.php, pero aparte de eso me enseñaron a crear lo que necesitaba


Luego enseñaré mis resultados, cuidense y gracias :D

Etiquetas: actionscript, enviar, php, variables
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 15:03.