Skip to main content
New Participant
May 21, 2014
Answered

Passing Variables to ASPX to the URL String from AS3 - Message Failed

  • May 21, 2014
  • 1 reply
  • 381 views

Im freaking out! Im trying to send three variables (fname, lname, and email) to append them to the URL string like this http://www.whatever.com?address=&firstname=&lastname=&email= , but it traced as "Message Failed" I wondered what I did wrong with this code.

in Flash 'fname_txt', 'lname_txt', and 'email_txt' are the instance names of the Input Text

import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.net.navigateToURL;

mcButton
.addEventListener(MouseEvent.MOUSE_UP, onClick);
function onClick(e:MouseEvent😞void {
var scriptRequest:URLRequest = new URLRequest("../index.aspx");
var scriptLoader:URLLoader = new URLLoader();
var scriptVars:URLVariables = new URLVariables();

scriptLoader
.addEventListener(Event.COMPLETE, handleLoadSuccessful);
scriptLoader
.addEventListener(IOErrorEvent.IO_ERROR, handleLoadError);

scriptVars
.fname = fname_txt.text;
scriptVars
.lname = lname_txt.text;
scriptVars
.email = mail_txt.text;

scriptRequest
.method = URLRequestMethod.POST;
scriptRequest
.data = scriptVars;

scriptLoader
.load(scriptRequest);

function handleLoadSuccessful($evt:Event😞void
{
trace
("Message sent.");
}

function handleLoadError($evt:IOErrorEvent😞void
{
trace
("Message failed.");
}

fname_txt
.text = "";
lname_txt
.text = "";
email_txt
.text = "";

}

This topic has been closed for replies.
Correct answer Ned Murphy

More than likely... you cannot load a file if it doesn't exist yet, and failing to do that will result in a loading error.  If you need to test withot the file, don't try to load it.

1 reply

Ned Murphy
Brainiac
May 21, 2014

Have you tried tracing the $evt to see what the error is?

magnix2kAuthor
New Participant
May 22, 2014

It showed

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: file:///Y|/Creative/projects/Banners/10130%20%2D%20MediaBuys%20%2D%20May%20%2D%20BannerAds%20%2D%20Flash/Creative/index.aspx"]

After putting trace($evt);

Does that mean the aspx file is not found? If so, its not created yet.

Ned Murphy
Ned MurphyCorrect answer
Brainiac
May 22, 2014

More than likely... you cannot load a file if it doesn't exist yet, and failing to do that will result in a loading error.  If you need to test withot the file, don't try to load it.