Copy link to clipboard
Copied
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 = "";
}
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.
Copy link to clipboard
Copied
Have you tried tracing the $evt to see what the error is?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
I changed it to
function handleLoadError($evt:IOErrorEvent😞void
{
trace(scriptVars);
}
and it showed email=cluneborg%40hotmail%2Ecom&lname=Luneborg&fname=Christian
that tells me its working except the aspx file wasnt found yet.
Thank you!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now