Link to home
Start Free TrialLog in
Avatar of tia_kamakshi
tia_kamakshiFlag for United Arab Emirates

asked on

Setting event.target in URLLoader(event.target);

Hi Experts,

In my flash website.

I have a form called saveForm on submit button click I am calling method submitData.

I can see using trace debugger that I can reach to method submitPOST()

and I am able to reach till trace
      trace("Dinesh 55");
      
Then further it is not printing trace("Dinesh 55.1");

therefore I assume I am getting error at line
      loader.addEventListener(Event.COMPLETE, submitCompleteHandler);
      
and it is going to method "onIOErrorHandler" from base class

When calling method "submitCompleteHandler" it is also printing Dinesh 54 from trace and giving exception

Looks it is giving error at line

             var loader:URLLoader = URLLoader(event.target);
             
How do I fix event.target, if this is the issue

Please help
public class SaveForm extends MovieClipBase { 

	private function submitData():void {                 
		var subscribeconnector:Subscri<wbr ></wbr>beConnecto<wbr ></wbr>r2 = new SubscribeConnector2(variab<wbr ></wbr>les.utitle<wbr ></wbr>, variables.firstname, variables.lastname, variables.email, variables.sendnews, variables.country, variables.joincomp, variables.showgallery, variables.sequence, variables.bonus, variables.journeyname);                
		}
} // End of class SaveForm     



public class SubscribeConnector2 extends DataConnector2 {

	public function SubscribeConnector2(utitle<wbr ></wbr>:String, firstname:String, lastname:String, email:String, sendnews:int, country:String, joincomp:int, showgallery:int, sequence:String, bonus:int, journeyname:String) {                                
	
		trace("SubscribeConnector:<wbr ></wbr> new connection");                                
		//this.url = Settings.getInstance().Sub<wbr ></wbr>scribeURL;<wbr ></wbr>  
		this.url = SiteConstants2.SUBSCRIBE_A<wbr ></wbr>SPX_URL;
		this._variables = new URLVariables(); 
		this._variables.utitle = utitle;
		this._variables.firstname = firstname;
		this._variables.lastname = lastname;  
		this._variables.email = email; 
		this._variables.sendnews = sendnews;
		this._variables.country = country; 
		this._variables.joincomp = joincomp;    
		this._variables.showgaller<wbr ></wbr>y = showgallery; 
		this._variables.sequence = sequence;
		this._variables.bonus = bonus;   
		this._variables.journeynam<wbr ></wbr>e = journeyname;
		this._variables.journeynam<wbr ></wbr>e = journeyname; 
		trace("Calling submitPOST()");
		submitPOST(this._variables<wbr ></wbr>);
		trace("Calling submitPOST() completed");  
		//submitSaveFormPOST(this.<wbr ></wbr>_variables<wbr ></wbr>);  
		//trace(_variables); 
		// post to company CRIS database through EK webservices API   
		trace("Calling WebServiceConnector2()");    
		//var webservice:WebServiceConne<wbr ></wbr>ctor2 = new WebServiceConnector2();   
		//webservice.addMember(uti<wbr ></wbr>tle, firstname, lastname, email, country, sendnews); 
		trace("Calling WebServiceConnector2()... completed");                
		}
		
		
		protected function submitPOST(variables:URLVa<wbr ></wbr>riables):v<wbr ></wbr>oid {  
			var request:URLRequest = new URLRequest(this._backendUR<wbr ></wbr>L);
			request.method = URLRequestMethod.POST; 
			request.data = variables;
			var loader = new URLLoader(); 
			loader.dataFormat = URLLoaderDataFormat.VARIAB<wbr ></wbr>LES; 
			trace("DataConnector: url="+this._backendURL+" data="+request.data);    
			trace("Dinesh 55"); 
			loader.addEventListener(Ev<wbr ></wbr>ent.COMPLE<wbr ></wbr>TE, submitCompleteHandler); 
			trace("Dinesh 55.1");
			loader.addEventListener(IO<wbr ></wbr>ErrorEvent<wbr ></wbr>.IO_ERROR,<wbr ></wbr> onIOErrorHandler);              
			trace("Dinesh 55.2");
			loader.load(request);   
			trace("Dinesh 55.3");
		} 
		
		
		 // submittion complete handler                
		 
		 protected function submitCompleteHandler(even<wbr ></wbr>t:Event):v<wbr ></wbr>oid { 
		 trace("Dinesh 54");
		 var loader:URLLoader = URLLoader(event.target);   
		 trace("DataConnector: url="+this._backendURL+"   Feedback=" + loader.data); 
		 } 
		 
		 // submittion error handler  
		 protected function onIOErrorHandler(event:IOE<wbr ></wbr>rrorEvent)<wbr ></wbr>:void { 
			 trace("DataConnector: Error submitting your details to the database. \n\n"+event.toString());                                trace("DataConnector: url="+this._backendURL+"   ERROR=" + event.toString());                                ExternalInterface.call("al<wbr ></wbr>ert", "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);
		 }
		 
} // End of class SubscribeConnector2



public class DataConnector2 { 

	// submittion complete handler    
	protected function submitCompleteHandler(even<wbr ></wbr>t:Event):v<wbr ></wbr>oid {
		trace("Dinesh 54");
		var loader:URLLoader = URLLoader(event.target); 
		trace("DataConnector: url="+this._backendURL+"   Feedback=" + loader.data);     
	}

	// submittion error handler 
	protected function onIOErrorHandler(event:IOE<wbr ></wbr>rrorEvent)<wbr ></wbr>:void {   
		trace("DataConnector: Error submitting your details to the database. \n\n"+event.toString());   
		trace("DataConnector: url="+this._backendURL+"   ERROR=" + event.toString());   
		ExternalInterface.call("al<wbr ></wbr>ert", "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);  
	}
} // End of class DataConnector2

Open in new window

Avatar of dgofman
dgofman
Flag of United States of America image

The first of all check if you "_backendURL" is correct URL. Try to past that value on the browser and validate if your server will receive a request
Avatar of tia_kamakshi

ASKER

_backendURL is printing correct value. Server also recieves the request.

Will flash code consider if url (.net 2.0 ) throws exception.

How flash comes to know, as per my underatanding it has just executed the url with parameteres

in the url as query string?

How event.target knows the URL. Where we set URL target to "event.target"

I am also not understanding another thing. I am putting another question with log and code files

Please guide
ASKER CERTIFIED SOLUTION
Avatar of dgofman
dgofman
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
My aspx file is called to submit data in database.

My data got inserted and also I get the error saying

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

Please suggest
And when you are testing this link on browser it's working for you?

http://dxbmiwwekdev1:1313/aspx/subscribe.aspx
yes
It even inserts the data in the database
Let's clean your code and tell me what you will get

private var SUBSCRIBE_ASPX_URL:String = "http://dxbmiwwekdev1:1313/aspx/subscribe.aspx";
           
                public function SubscribeConnector2(utitle:String, firstname:String, lastname:String, email:String, sendnews:int, country:String, joincomp:int, showgallery:int, sequence:String, bonus:int, journeyname:String):void{                                
                    var variables:URLVariables = new URLVariables();
                    variables.utitle = utitle;
                    variables.firstname = firstname;
                    variables.lastname = lastname;  
                    variables.email = email;
                    variables.sendnews = sendnews;
                    variables.country = country;
                    variables.joincomp = joincomp;    
                    variables.showgallery = showgallery;
                    variables.sequence = sequence;
                    variables.bonus = bonus;  
                    variables.journeyname = journeyname;
                    variables.journeyname = journeyname;
                    submitPOST(SUBSCRIBE_ASPX_URL, variables);
                }

                protected function submitPOST(url:String, variables:URLVariables):void {
                    var request:URLRequest = new URLRequest();
                    request.url = url;
                    request.method = URLRequestMethod.POST;
                    request.data = variables;
                    var loader:URLLoader = new URLLoader();
                    loader.dataFormat = URLLoaderDataFormat.VARIABLES;
                    loader.addEventListener(Event.COMPLETE, submitCompleteHandler);
                    loader.addEventListener(IOErrorEvent.IO_ERROR, onIOErrorHandler);
                    try{
                        loader.load(request);
                    }catch (error:Error){
                        trace("Unable to load URL");
                    }
                }
               
               
                // submittion complete handler                
               
                protected function submitCompleteHandler(event:Event):void {
                    var loader:URLLoader = URLLoader(event.target);  
                    trace("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());
                }
I will try this tommorow in Office. I bought some code and discussing all issues from home

I have my log file inside zip file and code file as well

If you click on link
http://www.companymusicaljourney.com/indexbk.html

- and then click Create your journey link
- Close pop window
- drag any county music say drag new york at bottom area blank textbox in bown
- click play
- after some movie form will come

Once you fill the form and click submit entry button (saveForm.fla)
button name is _submitBtn

data is going to database
and shareForm.fla is called

at the same time I am getting this error on development env

You can see in log that I can reach till line 529 in file SaveForm.as
and it is printing
Data Submitting... done
in log file

Then it is moving to method ~onIOErrorHandler" in file SubscribeConnector2.as

without going to method submitCompleteHandler (as value from trace is not printed)

why this is happening


Please help


data is also going in database
saveForm.zip
I don't all these steps without any errors except a first one when page is loaded

TypeError: Error #1009: Cannot access a property or method of a null object reference.
      at com.saatchi.sitetemplate.controller.audios::XMLAudioManager/getAudioByPage()
      at com.saatchi.sitetemplate.controller.audios::AudioLoader/loadByPage()
      at com.saatchi.sitetemplate::Main/loadAudio()
      at com.saatchi.sitetemplate::Main/onSettingsInit()
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at com.saatchi.sitetemplate.controller.config::Settings/dispatchEvent()
      at com.saatchi.sitetemplate.controller.config::Settings/onXMLDataLoaded()
      at flash.events::EventDispatcher/dispatchEventFunction()
      at flash.events::EventDispatcher/dispatchEvent()
      at flash.net::URLLoader/onComplete()



Its in development env. These trace is not in production

We are trying to change some of the small bits.

I have added these trace in dev and send you the log file and code files
It was the issue with aspx file only. HttpsatusHandler helped me identifying the issue

Many Thanks