Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
May 21, 2014 May 21, 2014

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

10130MB-FSO-Textfields-300x250.jpg

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 = "";

}

TOPICS
ActionScript
330
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , May 22, 2014 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.

Translate
LEGEND ,
May 21, 2014 May 21, 2014

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 22, 2014 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 22, 2014 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 22, 2014 May 22, 2014
LATEST

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines