URLLoader in action script 3.0

Hi Experts,

I am new to flash action script3.0

I am seeing method submitCompleteHandler

and it is loading url

var loader:URLLoader = URLLoader(event.target);

My first question is how event.target knows about target. Is it passing same as this._backendURL

Is method name onIOErrorHandler called when it is failed to call the URL

or this method is called when url loaded has the error

or on both cases


Another how we receive message from url loaded, if result is success or failure

Please guide

Thanks
protected function submitPOST(variables:URLVariables):void {
	var request:URLRequest = new URLRequest(this._backendURL);
	request.method = URLRequestMethod.POST;
	request.data = variables;

	var loader = new URLLoader();
	loader.dataFormat = URLLoaderDataFormat.VARIABLES;

	trace("DataConnector: url="+this._backendURL+" data="+request.data);

	loader.addEventListener(Event.COMPLETE, submitCompleteHandler);
	loader.addEventListener(IOErrorEvent.IO_ERROR, onIOErrorHandler);

	loader.load(request);
}


// submittion complete handler
protected function submitCompleteHandler(event:Event):void {
	var loader:URLLoader = URLLoader(event.target);
	trace("DataConnector: url="+this._backendURL+"   Feedback=" + loader.data);
}



// submittion error handler
protected function onIOErrorHandler(event:IOErrorEvent):void {
	ExternalInterface.call("alert", "DataConnector: Error submitting your details to the database. \n\n"+event.toString());
	trace("DataConnector: url="+this._backendURL+"   ERROR=" + event.toString());
	//popAlert("Error submitting your details to the database", yourfirstname);
}

Open in new window

tia_kamakshiAsked:
Who is Participating?
 
dgofmanCommented:
Please check a documentation and example

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLLoader.html#includeExamplesSummary 

When you are testing a first time your request I will suggest temporary add all those event listeners

loader.addEventListener(Event.COMPLETE, completeHandler);
loader.addEventListener(Event.OPEN, openHandler);
loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
0
 
tia_kamakshiAuthor Commented:
Thanks for this.

I will check this tmmorow morning and update you with results

Thanks again

Best Regards
0
 
tia_kamakshiAuthor Commented:
Hi,

I have added all the events as you suggested. Still I am getting error

Subscriber Connector: Error submitting your details to the database.

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://dxbmiwwekdev1:1313/aspx/subscribe.aspx"]

and log says:


SubscribeConnector: new connection
Calling submitPOST()
DataConnector: url=http://dxbmiwwekdev1:1313/aspx/subscribe.aspx data=utitle=Mr&joincomp=1&bonus=0&country=AU&sequence=&sendnews=1&lastname=gh&email=jhgjg%40jdk%2Ecom&journeyname=dfgd&firstname=gfhgf&showgallery=1
Dinesh 55
Dinesh 55.1
Dinesh 55.2
Dinesh 55.3
Dinesh 55.4
Dinesh 55.5
Dinesh 55.6
Dinesh 55.7
Calling submitPOST() completed
Calling WebServiceConnector2()
Calling WebServiceConnector2()... completed
Jumping to Page: 13... Dinesh in save form... commented for a while
Jumping to Page: 13... Dinesh ... Done
Data Submitting... done
openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2]
httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=500 responseURL=null]
Dinesh 45.001
Dinesh 45.1: Subscriber Connector: Error submitting your details to the database.

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://dxbmiwwekdev1:1313/aspx/subscribe.aspx"]


Please guide

loader.addEventListener(Event.COMPLETE, submitCompleteHandler);
		trace("Dinesh 55.1");
		loader.addEventListener(Event.OPEN, openHandler);
		trace("Dinesh 55.2");
		loader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
		trace("Dinesh 55.3");
		loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
		trace("Dinesh 55.4");
		loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
		trace("Dinesh 55.5");
		loader.addEventListener(IOErrorEvent.IO_ERROR, onIOErrorHandler);
		trace("Dinesh 55.6");
		
		try {
                loader.load(request);
            } catch (error:Error) {
                trace("Unable to load requested document.");
            }

			
			trace("Dinesh 55.7");
		}
		
		// submittion complete handler
		protected function submitCompleteHandler(event:Event):void {
			trace("Dinesh 64.11");
			trace("DataConnector64: url="+this._backendURL+"   Feedback=" + loader.data);
			var loader:URLLoader = URLLoader(event.target);
			trace("DataConnector: url="+this._backendURL+"   Feedback=" + loader.data);
		}

		// submittion error handler
		protected function onIOErrorHandler(event:IOErrorEvent):void {
			trace("DataConnector: Error submitting your details to the database. \n\n"+event.toString());
			trace("DataConnector: url="+this._backendURL+"   ERROR=" + event.toString());
			ExternalInterface.call("alert", "DataConnector: Error submitting your details to the database. \n\n"+event.toString());
			trace("DataConnector: url="+this._backendURL+"   ERROR=" + event.toString());
			//popAlert("Error submitting your details to the database", yourfirstname);
		}
		
		protected function openHandler(event:Event):void {
            trace("openHandler: " + event);
        }

        protected function progressHandler(event:ProgressEvent):void {
            trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal);
        }

        protected function securityErrorHandler(event:SecurityErrorEvent):void {
            trace("securityErrorHandler: " + event);
        }

        protected function httpStatusHandler(event:HTTPStatusEvent):void {
            trace("httpStatusHandler: " + event);
        }

Open in new window

0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
tia_kamakshiAuthor Commented:
After the above post, Even I have removed my subscribers.aspx file and just calling simple test.html with code

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>test</title>

</head>
<body>
test
</body>
</html>


and it giving still the same error:
[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://dxbmiwwekdev1:1313/aspx/test.html"]


log says:

Saving Data
Test
--------------->string
Dinesh 5
UserData - setFirstName(fg)
Data Saved
Data Submitting...
SubscribeConnector: new connection
Calling submitPOST()
DataConnector: url=http://dxbmiwwekdev1:1313/aspx/test.html data=lastname=dfg&bonus=0&email=dgf%40wer%2Ecom&utitle=Mr&showgallery=1&sequence=&joincomp=1&country=AU&journeyname=sdfgf&firstname=fg&sendnews=1
Dinesh 55
Dinesh 55.1
Dinesh 55.2
Dinesh 55.3
Dinesh 55.4
Dinesh 55.5
Dinesh 55.6
Dinesh 55.7
Calling submitPOST() completed
Calling WebServiceConnector2()
Calling WebServiceConnector2()... completed
Jumping to Page: 13... Dinesh in save form... commented for a while
Jumping to Page: 13... Dinesh ... Done
Data Submitting... done
openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2]
httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=405 responseURL=null]
Dinesh 45.001
Dinesh 45.1: Subscriber Connector: Error submitting your details to the database.

[IOErrorEvent type="ioError" bubbles=false cancelable=false eventPhase=2 text="Error #2032: Stream Error. URL: http://dxbmiwwekdev1:1313/aspx/test.html"]


Please guide
0
 
dgofmanCommented:
Can you point to localhost and run server instead

http://dxbmiwwekdev1:1313/aspx

use
http://localhost:1313/aspx

by the way why you have aspx + test.html
0
 
dgofmanCommented:
You have to pointing to your server responce data not to HTML page

HTML responce is invalid for parsering containts HTML tags
0
 
tia_kamakshiAuthor Commented:
I am testing on development server only by copying the files there. My localhost environment is not setup.

Therefore I cannot do test on localhost

Just for test I have removed subscribers.aspx and used html file instead, thought might be it swf is getting some kind of error when running aspx file

so i used html file instead.

Also the thing is when I use aspx file, my data also got inserted in the database. I only have to insert data from database

Please guide

0
 
dgofmanCommented:
Just think first, HTML is static context how HTML can pass value to the database and create return confermation streaming bytes????

Another problem why I asked to test locally because you may getting crossdomain security exception, but actually should be catched by securityErrorHandler handler
0
 
tia_kamakshiAuthor Commented:
y crossdomain.xml has the access to local server

<allow-access-from domain="*" />

so, I am not getting security error

so, I will put back my aspx file

what kind of response swf file looks from asx file. May be it is not getting valid response from aspx file, so we are getting error

Also, httpStatusHandler is giving status=405 as below

httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=405 responseURL=null]

But before modifying my code, I was not getting any such error

Please suggest
0
 
dgofmanCommented:
0
 
dgofmanCommented:
0
 
tia_kamakshiAuthor Commented:
Hi understand my test.html file is invalid.

It is doing nothing, so I don't need this setting in IIS

Now I am back calling subscribers.aspx file, which can accept POST/GET methods

If you see my post above for aspx file as well it is giving same error

Please help me in solving this issue

Many Thanks again for your co-operation
0
 
tia_kamakshiAuthor Commented:
Sorry, In case of aspx file it is giving 500 error

httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=500 responseURL=null]

that means it is aspx file issue


SubscribeConnector: new connection
Calling submitPOST()
DataConnector: url=http://dxbmiwwekdev1:1313/aspx/subscribe.aspx data=utitle=Mr&joincomp=1&bonus=0&country=AU&sequence=&sendnews=1&lastname=gh&email=jhgjg%40jdk%2Ecom&journeyname=dfgd&firstname=gfhgf&showgallery=1
Dinesh 55
Dinesh 55.1
Dinesh 55.2
Dinesh 55.3
Dinesh 55.4
Dinesh 55.5
Dinesh 55.6
Dinesh 55.7
Calling submitPOST() completed
Calling WebServiceConnector2()
Calling WebServiceConnector2()... completed
Jumping to Page: 13... Dinesh in save form... commented for a while
Jumping to Page: 13... Dinesh ... Done
Data Submitting... done
openHandler: [Event type="open" bubbles=false cancelable=false eventPhase=2]
httpStatusHandler: [HTTPStatusEvent type="httpStatus" bubbles=false cancelable=false eventPhase=2 status=500 responseURL=null]


Please suggest
0
 
tia_kamakshiAuthor Commented:
It was the issue with aspx file only. HttpsatusHandler helped me identifying the issue

Many Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.