Skip to main content
Participant
August 31, 2006
Answered

LoadVars always undefined when viewing uploaded movie

  • August 31, 2006
  • 3 replies
  • 461 views
Hello,

I created a flash movie that has a "Contact us" form, that sends name, email, phone number and comments to an ASP.NET web page that acts as an email relay. If it is able to contact the ASP page, then it displays a "success" message. If it is unable to contact the server or if the ASP page returns an error, then it displays an "error" message.

When I test the movie on my computer (be it directly from Flash or from a webpage in my hard drive) it does what it's supposed to do: send the contact info to the webserver and then display a "success" or "error" message, but when I upload the movie to a server (even a local server) it always returns "undefined". I have already tested it on 4 different servers (including the local server) and it always behaves the same.

What am I missing that causes this behavior?

Thank you for any help that you may provide.
This topic has been closed for replies.
Correct answer Newsgroup_User
1. Place last
email.sendAndLoad(' http://www.promocasa.com.mx/tools/formaCorreo.aspx',
emailResponse, "GET");
You have a potential timing issue where emailResponse.onLoad =
function(success:Boolean) is not assigned before the response is registered.
something = function is a run time assignment and needs to be processed
before it has potential to be used.

2. Did you try "POST" instead of "GET"?


3. Is Flash Movie on the same domain as www.promocasa.com.mx. If not you
need a crossdomain.xml file.

4. Try a very basic Flash movie that simply sends and receives some static
data from your server.

5. Add some traces to the emailResponse.onLoad
trace ("emailResponse.onLoad - succes:"+success);

6. Be sure you do not have a cached old version of the Flash movie in your
web browser. A quick way is to rename it temporarily and upload.

7. Not sure about your scoping since it works locally, but for a test define
var email:LoadVars = new LoadVars();
var emailResponse:LoadVars = new LoadVars(); on the timeline and comment
inside the on(click)






--
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"saldillo" <webforumsuser@macromedia.com> wrote in message
news:ed70m3$6ei$1@forums.macromedia.com...
> Yup, I already did that.
>
> I created a basic HTML page that has a bunch of hidden fields that
> represent
> the data being sent by the flash movie. I uploaded it to the same server
> where
> I uploaded the SWF to see if it had anything to do with the server but
> alas,
> when I press the submit button on the HTML page it shows the OK message
> that is
> being sent by the ASP page, and I received the email just fine.
>
> I never receive the email when I press the submit button on my uploaded
> SWF
> movie, which leads me to believe that the ASP page is not receiving the
> information.
>
> I'm attaching my AS code, I forgot to do so in my original posting.
>
> Thank you for your replies.
>
>
>
> on (click) {
> var email:LoadVars = new LoadVars();
> var emailResponse:LoadVars = new LoadVars();
>
> // This is the data that the user entered in the contact form.
> email.txtNombre = _parent.txtNombre.text;
> email.txtEmail = _parent.txtEmail.text;
> email.txtTelefono = _parent.txtTelefono.text;
> email.txtComentarios = _parent.txtComentarios.text;
>
> // My ASP page should work for any SWF movie so I put this here for each
> movie that
> // sends data to the server. Once I get this working the way it
> should, I'll load the info from a text file to
> // avoid hard coding it in the movie.
> email.txtEmailReceptor = "aldo.herrera@promocasa.com.mx"; // Who should
> receive the email
> email.txtEmailEmisor = "contactos@barcelonaresidencial.com.mx";
> email.txtDesarrollo = "Barcelona Residencial"; // What webpage
> originated
> this request
> email.txtAsunto = "BARCELONA: Forma de contacto del sitio web Barcelona
> Residencial"; //Subject
> email.txtMensaje = "Se ha recibido una petici?n de informaci?n del sitio
> web
> Barcelona Residencial."; //
> email.sendAndLoad(' http://www.promocasa.com.mx/tools/formaCorreo.aspx',
> emailResponse,
> "GET");
>
> emailResponse.onLoad = function(success:Boolean) {
> var strSuccess:String = "?Gracias por tu inter?s! Uno de nuestros
> asesores
> recibi? tu petici?n y se pondr? en contacto para atenderte.";
> var strError:String = "Lo sentimos. Hubo un error t?cnico al enviar tu
> informaci?n. Por favor cont?ctanos por tel?fono para poder atenderte.
> Disculpa
> las molestias.";
> var strMensaje:String = this.mensaje;
>
> if ( success) {
> _parent.estado_txt.text = strMensaje; // Print the message to a
> dynamic text field called "estado_txt"
> _parent.nextFrame(); // This removes my input form and shows the
> estado_txt field.
> }
> /*
> if ("OK" == strMensaje.substr(0,2) )
> _parent.estado_txt.text = strSuccess;
> else
> _parent.estado_txt.text = strError;
>
> _parent.nextFrame();
> */
> };
> }
>


3 replies

saldilloAuthor
Participant
September 11, 2006
Thank you very much! #3 Solved the problem, and I did #1 just in case. You were a big help.

Best regards,
Aldo
Inspiring
August 31, 2006
I always create a quick HTML page to send the data to the server script in
these cases and see what I get back outside of Flash. Sometimes it is a
install configuration issue having nothing to do with Flash.


--
Lon Hosford
www.lonhosford.com
Flash, Actionscript and Flash Media Server examples:
http://flashexamples.hosfordusa.com
May many happy bits flow your way!
"saldillo" <webforumsuser@macromedia.com> wrote in message
news:ed5k22$ggp$1@forums.macromedia.com...
> Hello,
>
> I created a flash movie that has a "Contact us" form, that sends name,
> email,
> phone number and comments to an ASP.NET web page that acts as an email
> relay.
> If it is able to contact the ASP page, then it displays a "success"
> message. If
> it is unable to contact the server or if the ASP page returns an error,
> then it
> displays an "error" message.
>
> When I test the movie on my computer (be it directly from Flash or from a
> webpage in my hard drive) it does what it's supposed to do: send the
> contact
> info to the webserver and then display a "success" or "error" message, but
> when
> I upload the movie to a server (even a local server) it always returns
> "undefined". I have already tested it on 4 different servers (including
> the
> local server) and it always behaves the same.
>
> What am I missing that causes this behavior?
>
> Thank you for any help that you may provide.
>


saldilloAuthor
Participant
August 31, 2006
Yup, I already did that.

I created a basic HTML page that has a bunch of hidden fields that represent the data being sent by the flash movie. I uploaded it to the same server where I uploaded the SWF to see if it had anything to do with the server but alas, when I press the submit button on the HTML page it shows the OK message that is being sent by the ASP page, and I received the email just fine.

I never receive the email when I press the submit button on my uploaded SWF movie, which leads me to believe that the ASP page is not receiving the information.

I'm attaching my AS code, I forgot to do so in my original posting.

Thank you for your replies.

Inspiring
August 31, 2006
Be sure that the data file that you are loading with LoadVar has the correct path. On your hard drive the file might be in a subdirectory, so either create a directory on your server with the same name or place the data file in the same directory as the swf.