2 Replies Latest reply on Apr 15, 2009 2:25 PM by Michael Borbor

    Script Terminated After 15 Seconds?

    alice_data Level 1



        I have something here I am trying to achieve. I am reading an XML output using e4x format from the attribute value of the event name and its date. What I am trying to achieve is when instance is matched, who are the ones that match the criteria of the name of the event and has the same date value as the ones originally accessed. However, I seem to be constantly running into problems where the code wouldn't stop executing and then eventually gets killed after 15 seconds. My XML file is 1.2MB in size.


      Here is the code:


      private function useDate(event:MouseEvent):void {
               if (event.currentTarget.selectedDate == null) {   // Make sure selectedDate is not null.
                     //don't do a thing
                else {  //Access the Date object from the event object.  
                  var date:String=DateChooser(event.currentTarget).selectedDate.getDate().toString();
                  var month:String= DateChooser(event.currentTarget).selectedDate.getMonth().toString();
                  var year:String= DateChooser(event.currentTarget).selectedDate.getFullYear().toString();   
                  wholeDate= new Date(year,month,date);       
                  var xlc3:XMLListCollection = new XMLListCollection(searchResult..book.@name);
                  var xlc5:XMLListCollection = new XMLListCollection(searchResult..book.(@name == selectedName).appt.@date);
                  var xlc4:XMLListCollection = new XMLListCollection(searchResult..book..@date);
                  for each (var xml3:XML in xlc3) {               
                      for each (var xml4:XML in xlc4) {
                      var schedule_item_day:String= xml4.toString();           
                      var schedule_date:Date = new Date(schedule_item_day);
                  for each (var xml5:XML in xlc5) {
                         var real_date:Date = new Date(xml5.toString());                  
                          var schedule_name:String= xml5.parent().@type.toString();
                            if (wholeDate.toDateString() === real_date.toDateString() === schedule_date.toDateString()) {
                                 trace (schedule_name);  
                             } //end if wholeDate statement
                      }         //end for each xlc5   
                    } //end for each xlc4
            } //end the else statement        


      Is there something I have done wrong here that makes my code unstoppable after 15 seconds?
      If there is nothing wrong, how can I increase the amount of time before the code timeouts?


      Thanks in advance.



        • 1. Re: Script Terminated After 15 Seconds?
          _Natasha_ Level 4

          Execution time depends not only on your code. It depends on the amout of data processed. If XML is big - it can take more then 15 sec. But after 15 sec it's not killed, user can stop this script or continue.

          Application has properties scriptTimeLimit="60" - it's the limit after script is being killed.


          You can add try\catch block to catch runtime Error 1502 and 1503 to continue your procedure.

          • 2. Re: Script Terminated After 15 Seconds?
            Michael Borbor Level 4

            Dear Alice, as a complement to what Natasha stated you must know that the Flash Player is single threaded so that's why it has a short timeout period because if it doesn't your app will freeze the browser and that's not at all desirable. Maybe you could send the data back to your backend server and let it do the search there and then return the result to Flex.