Comunidad de diseño web y desarrollo en internet online

Flash y AMFPHP - Pasar arreglo.

Citar            
MensajeEscrito el 30 May 2006 04:55 pm
Hola. ¿Cómo puedo pasar una gran cantidad de datos de Flash a AMFPHP?. He pasado arreglos de AMFPHP a Flash sin ningún problema de la siguiente manera:

En mi servicio Service001.php tengo ésto:

Código :

<?php
 class Service001
 {function Service001()
  {$this->methodTable=array(
   "Function001"=>array(
    "description"=>"Function001 - Devuelve la información de una tabla ordenado por NC.",
    "access"=>"remote",));}
 function Function001()
 {$link=mysql_connect('localhost','root','');
  mysql_select_db("construrama"); 
  $sql="SELECT * FROM clientes ORDER BY nc";;
  $result=mysql_query($sql);
  while($row=mysql_fetch_array($result))
  {$a[]=$row;}
  return $a;
  mysql_free_result($result);
  mysql_close($link);}}
?>


Y sin ningún problema recibo en un MovieClip en Flash así:

Código :

onClipEvent(load)
{import mx.remoting.Service;
 import mx.remoting.PendingCall;
 import mx.rpc.ResultEvent;
 import mx.rpc.RelayResponder;
 urlGateway="http://localhost/amfphp/gateway.php";
 var myService:Service=new Service(urlGateway,null,"Service001",null,null);
 var Call:PendingCall=myService.Function001();
 Call.responder=new RelayResponder(this,"getData");
 function getData(re:ResultEvent):Void
 {var a1;
  for(this.a1=0;this.a1<re.result.length;this.a1++)
  {this._parent.a[this.a1]=re.result[this.a1];}
  this._parent.b=re.result.length;
  this._parent.gotoAndStop(26);}}


¿De acuerdo?, ahora, ¿cómo hago para hacerlo al reves?, enviar de Flash a AMFPHP un arreglo. Gracias por su tiempo.

MQ.

Por Manuel Quintero

53 de clabLevel



Genero:Masculino  

msie
Citar            
MensajeEscrito el 30 May 2006 06:13 pm

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 31 May 2006 01:25 am
No, no lo he intentado porque no lo sé, por esa cuestión lo pregunto. ¿Me puedes ayudar?, es que la verdad no sé como pasar un arreglo de Flash a AMFPHP, no sé como mandarlo de Flash ni recibirlo en una clase de AMFPHP, ¿me puedes dar un ejemplo?. Gracias.

MQ.

Por Manuel Quintero

53 de clabLevel



Genero:Masculino  

msie
Citar            
MensajeEscrito el 31 May 2006 03:29 am

Código :

import mx.remoting.NetServices;
import mx.remoting.Connection;
mx.remoting.debug.NetDebug.initialize();
                                  //Pon la URL de tu gateway aqui
NetServices.setDefaultGatewayUrl("http://localhost/remoting/gateway.php"); 
conexion = NetServices.createGatewayConnection();

capturaRespuesta = new Object();
servicio = conexion.getService("MyArray",capturaRespuesta);

capturaRespuesta.onStatus = function (data){
   trace("Error por:" +data.description);
}
capturaRespuesta.setArray_Result = function (data){
   var total:Number = data.length;
   
   for (var i:Number = 0; i<total;i++){
      trace(data[i]);
   }
   
}
var miArreglo:Array = new Array();

miArreglo.push("valor");
miArreglo.push("valor2");

servicio.setArray(miArreglo);


Código :

<?php
    class MyArray{ 
         function MyArray (){ 
            $this->methodTable = array( 
                     "setArray" => array ( 
                        "description" => "retorna el array que recibe",  
                        "access" => "remote", 
                        "arguments" => array("arrayUser") 
                     )
            );
         }
         function setArray($arrayUser){
                  foreach ($arrayUser as $elem){
                  $arrayService[]=$elem;
               }
                  return $arrayService;
         }
    }
?>


Como ves es igual, y una vez más te recomiendo que leas el tutorial que te di arriba

saludos

Por Maikel

BOFH

5575 de clabLevel

22 tutoriales
5 articulos

Genero:Masculino   Team Cristalab

Claber de baja indefinida

firefox
Citar            
MensajeEscrito el 31 May 2006 03:39 pm
¡Es todo Maikel 8) !, 1000 gracias por toda tu ayuda. Saludos.

MQ.

Por Manuel Quintero

53 de clabLevel



Genero:Masculino  

msie

 

Cristalab BabyBlue v4 + V4 © 2011 Cristalab
Powered by ClabEngines v4, HTML5, love and ponies.