problemas para pasar un detector de eventos var a PHP

  • beaner
  • Novice
  • Novice
  • No Avatar
  • Registrado: Dic 09, 2009
  • Mensajes: 15
  • Status: Offline

Nota Enero 7th, 2010, 8:23 am

¡Hola a todos,
Tengo un cuadro combinado que es leído por un detector de eventos. Si rastrear el var de la escucha que recibe la información correcta. Lo estoy perplejo es cómo hacer a continuación, pasar esta variable al remitente de mi php. Cualquier ayuda sería appriciated. aquí está mi código de AS2:

Código: [ Select ]
myComboBoxListener = new Object();
myComboBoxListener.change = function(eventObj) {
   var eventSource = eventObj.target;
   var theSelectedItem = eventSource.selectedItem;
   var theSelectedItemLabel = theSelectedItem.data;
   trace("You selected "+theSelectedItemLabel+".");
};
myComboBox.addEventListener("change", myComboBoxListener);
  1. myComboBoxListener = new Object();
  2. myComboBoxListener.change = function(eventObj) {
  3.    var eventSource = eventObj.target;
  4.    var theSelectedItem = eventSource.selectedItem;
  5.    var theSelectedItemLabel = theSelectedItem.data;
  6.    trace("You selected "+theSelectedItemLabel+".");
  7. };
  8. myComboBox.addEventListener("change", myComboBoxListener);
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Enero 7th, 2010, 8:23 am

  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Enero 7th, 2010, 9:54 am

Pues tienes dos problemas. En primer lugar de su edificio una variable que sólo existe en función de la. Cambio. Debido a cuestiones de su ámbito de aplicación va a tener dificultades para acceder a él fuera de la función.

Para solucionar esto es necesario crear una variable fuera de la función y establezca su valor cuando el cambio en materia de incendios. Así:
ACTIONSCRIPT Código: [ Select ]
// create holder varialbes
var selItem = "";
var selLabel = "";
 
myComboBoxListener = new Object();
  myComboBoxListener.change = function(eventObj) {
  var eventSource = eventObj.target;
  var theSelectedItem = eventSource.selectedItem;
  var theSelectedItemLabel = theSelectedItem.data;
  // attach your vars to the holder vars
  selItem = theSelectedItem;
  selLabel = theSelectedLabel;
 
  // trace the variables here to show that they've changed
  trace("item = "+selItem+" and label= "+selLabel);
};
myComboBox.addEventListener("change", myComboBoxListener);
 
// If you trace the vars here they'll be blank because the event hasn't fired yet.
trace("item = "+selItem+" and label= "+selLabel);
 
 
  1. // create holder varialbes
  2. var selItem = "";
  3. var selLabel = "";
  4.  
  5. myComboBoxListener = new Object();
  6.   myComboBoxListener.change = function(eventObj) {
  7.   var eventSource = eventObj.target;
  8.   var theSelectedItem = eventSource.selectedItem;
  9.   var theSelectedItemLabel = theSelectedItem.data;
  10.   // attach your vars to the holder vars
  11.   selItem = theSelectedItem;
  12.   selLabel = theSelectedLabel;
  13.  
  14.   // trace the variables here to show that they've changed
  15.   trace("item = "+selItem+" and label= "+selLabel);
  16. };
  17. myComboBox.addEventListener("change", myComboBoxListener);
  18.  
  19. // If you trace the vars here they'll be blank because the event hasn't fired yet.
  20. trace("item = "+selItem+" and label= "+selLabel);
  21.  
  22.  


Ahora, dependiendo de lo que tiene que hacer con las variables en PHP que podría hacer que el derecho dentro de la convocatoria en función de su cambio, pero probablemente más fácil tener una función separada para manejar todo eso que llaman en el interior del oyente.

ACTIONSCRIPT Código: [ Select ]
// create holder varialbes
var selItem = "";
var selLabel = "";
 
myComboBoxListener = new Object();
  myComboBoxListener.change = function(eventObj) {
  var eventSource = eventObj.target;
  var theSelectedItem = eventSource.selectedItem;
  var theSelectedItemLabel = theSelectedItem.data;
  // attach your vars to the holder vars
  selItem = theSelectedItem;
  selLabel = theSelectedLabel;
 
  // function to run
  cbchanged();
 
};
myComboBox.addEventListener("change", myComboBoxListener);
 
// function to run on change
function cbchanged(){
  trace("cb changed. new item = "+selItem+" and new label= "+selLabel);
}
 
  1. // create holder varialbes
  2. var selItem = "";
  3. var selLabel = "";
  4.  
  5. myComboBoxListener = new Object();
  6.   myComboBoxListener.change = function(eventObj) {
  7.   var eventSource = eventObj.target;
  8.   var theSelectedItem = eventSource.selectedItem;
  9.   var theSelectedItemLabel = theSelectedItem.data;
  10.   // attach your vars to the holder vars
  11.   selItem = theSelectedItem;
  12.   selLabel = theSelectedLabel;
  13.  
  14.   // function to run
  15.   cbchanged();
  16.  
  17. };
  18. myComboBox.addEventListener("change", myComboBoxListener);
  19.  
  20. // function to run on change
  21. function cbchanged(){
  22.   trace("cb changed. new item = "+selItem+" and new label= "+selLabel);
  23. }
  24.  


Es obvio que hay un montón de maneras de simplificar ese código pero es bueno saber que hay de nuevo.

En segundo lugar hay un par de maneras de pasar los datos a php / javascript, etc Echa un vistazo a los dos sendAndLoadVars y ExternalInterface para encontrar el mejor para su configuración.
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • beaner
  • Novice
  • Novice
  • No Avatar
  • Registrado: Dic 09, 2009
  • Mensajes: 15
  • Status: Offline

Nota Enero 8th, 2010, 8:36 am

Muchas gracias por su aportación. Después de leer tu mensaje he podido pasar la variable de la comboBox. Función de elección en una variable global.

Ahora puedo ver la variable de fuera de la función, cuando se traza.
Todo parece estar funcionando bien, pero cuando trato de tomar la variable global y lo remitirá a la PHP mailer, junto con los otros aún no se quiere ir.... hmm perplejo!

aquí está mi código de cualquier comentario sería appriciated.

Enviar código del botón:
Código: [ Select ]
            loadVariables("wasserMail.php", "", "POST");
            
            showerror("Sending data...");

            varSender = new LoadVars();
            varSender.cname = cname;
            varSender.email = email;
            varSender.company = company;
            varSender.msg = msg;
            
            varSender.selLabel = selLabel;
            trace (selLabel);
            trace (_global.selLabel);

            varSender.sendAndLoad(url, varSender, "POST");
  1.             loadVariables("wasserMail.php", "", "POST");
  2.             
  3.             showerror("Sending data...");
  4.             varSender = new LoadVars();
  5.             varSender.cname = cname;
  6.             varSender.email = email;
  7.             varSender.company = company;
  8.             varSender.msg = msg;
  9.             
  10.             varSender.selLabel = selLabel;
  11.             trace (selLabel);
  12.             trace (_global.selLabel);
  13.             varSender.sendAndLoad(url, varSender, "POST");



Y aquí está mi código de PHP
Código: [ Select ]
$to=(isset($_POST['selLabel'])) ? $_POST['selLabel'] : false;
$cname=(isset($_POST['cname'])) ? $_POST['cname'] : false;
$email=(isset($_POST['email'])) ? $_POST['email'] : false;
$company=(isset($_POST['company'])) ? $_POST['company'] : false;
$msg=(isset($_POST['msg'])) ? $_POST['msg'] : false;
$result=(isset($_POST['result'])) ? $_POST['result'] : false;



$body = "
Wasser Website - E-mail Contact: \n
Name: $cname \n
Email: $email \n
Company: $company \n
Message: $msg \n
To: $to \n

";


$subject = "Wasser Website - E-mail Contact";
mail($to, $subject, $body);
  1. $to=(isset($_POST['selLabel'])) ? $_POST['selLabel'] : false;
  2. $cname=(isset($_POST['cname'])) ? $_POST['cname'] : false;
  3. $email=(isset($_POST['email'])) ? $_POST['email'] : false;
  4. $company=(isset($_POST['company'])) ? $_POST['company'] : false;
  5. $msg=(isset($_POST['msg'])) ? $_POST['msg'] : false;
  6. $result=(isset($_POST['result'])) ? $_POST['result'] : false;
  7. $body = "
  8. Wasser Website - E-mail Contact: \n
  9. Name: $cname \n
  10. Email: $email \n
  11. Company: $company \n
  12. Message: $msg \n
  13. To: $to \n
  14. ";
  15. $subject = "Wasser Website - E-mail Contact";
  16. mail($to, $subject, $body);
  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Enero 8th, 2010, 9:10 am

¿Recibe alguno de los datos varSender en el PHP? También lo hace la traza producen cuando el botón de envío?
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • beaner
  • Novice
  • Novice
  • No Avatar
  • Registrado: Dic 09, 2009
  • Mensajes: 15
  • Status: Offline

Nota Enero 8th, 2010, 9:20 am

Tengo todos los datos varSender pero el "varSender.selLabel = selLabel;"
Y cuando pulse enviar la traza produce el dato correcto elegido el ComboBox....
  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Enero 8th, 2010, 9:22 am

hacer ambas producen la misma cosa?
#trace (selLabel);
#trace (_global.selLabel);

Prueba también el seguimiento:
varSender.selLabel
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • beaner
  • Novice
  • Novice
  • No Avatar
  • Registrado: Dic 09, 2009
  • Mensajes: 15
  • Status: Offline

Nota Enero 8th, 2010, 9:30 am

Todos 3 rastros devolver el artículo elegido el ComboBox...

Si puedo rastrear la varSender.selLabel entonces Im suponiendo que no hay tal vez algo malo con mi php.... extraño
  • graphixboy
  • Control + Z
  • Mastermind
  • Avatar de Usuario
  • Registrado: Jul 11, 2005
  • Mensajes: 1828
  • Loc: In the Great White North
  • Status: Offline

Nota Enero 8th, 2010, 9:48 am

Ese fue mi pensamiento también. A menos que los theres de la remota posibilidad de que su paso (y seguimiento) una referencia de objeto en vez de una cadena que PHP no entiende.

intente esto:
ACTIONSCRIPT Código: [ Select ]
var selLabelString = selLabel.toString();
varSender.selLabel = selLabelString;
 
  1. var selLabelString = selLabel.toString();
  2. varSender.selLabel = selLabelString;
  3.  
If at first you don't succeed F1... If that doesn't work try Google!
//// Designer, Developer & Teacher - Interactive, Motion and 3D \\\\
Portfolio at WhenImNotSleeping.com
  • beaner
  • Novice
  • Novice
  • No Avatar
  • Registrado: Dic 09, 2009
  • Mensajes: 15
  • Status: Offline

Nota Enero 8th, 2010, 10:03 am

hmmm pongo el código que escriba en mi botón de enviar, pero todavía no es algo que pasa .. soy tan fuera de las ideas...

Publicar Información

  • Total de mensajes en este tema: 9 mensajes
  • Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 32 invitados
  • No puede abrir nuevos temas en este Foro
  • No puede responder a temas en este Foro
  • No puede editar sus mensajes en este Foro
  • No puede borrar sus mensajes en este Foro
  • No puede enviar adjuntos en este Foro
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC