Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
Problem:
You have entered the realm of “Flash Infinite Loop” or at least a really long loop. This is very common when running loops, especially do…while loops. The timeout is now set to 15 seconds (see image below).
Fix:
Make sure that you are not executing a loop that will never break out. Those poor loops running in circles for all of us Flashers/Flexers.
*******************Warning*******************
The Bad Code below will send your Flex/Flash into and infinite loop and will potentially crash your Development Tool. DO NOT COPY and PASTE the BAD CODE EXAMPLES BELOW.
Bad Code:
var myLength:int = 2;
for (var i:int = 0; i < myLength ; i–);
trace(i);
}
Good Code:
var myLength:int = 2;
for (var i:int = 0; i < myLength ; i++);
trace(i);
}
The code examples above have the var i starting with a number that is smaller than the number it is trying to iterate to. This code basically says as long as i is smaller than myLength then loop and each time I loop make i even smaller.
Bad Code:
*********This code crashed my Flash multiple times.*******
var myArray:Array = [“joe”, “bob”,”pam”];
var randNum:int = Math.round(Math.random()*myArray.length-1);
var curNum:int = 1;
do {
trace(randNum);
} while (randNum == curNum);
The key to using do…while loops in Flash is to make sure that the variable that you are validating against is changed inside the loop itself. Unless the variable that you are validating against changes within the loop itself it will loop forever. This example of a do…while loop is valid but will very likely put Flash into an infinite loop because the likelihood that the number will be 1 is very high, especially considering that the code is rounding and the number 1 is the middle digit of the three. This loop can execute quickly if Flash happens to choose another number or it can loop infinitely. The reason you might be doing this kind of loop is because you want to pull things out of an array, xml, or some other list and don’t want to get duplicates. A better way to do this is to either use the splice() methods in Flash or Flex or if you don’t want to affect the original array you can slice() out a duplicate without the curNum value and then the value will never be repeated because it no longer exists in the items that you are evaluating against. That way you know for sure the item that you don’t want repeated is gone.
There are many other ways to run into an infinite loop. These are just a couple. Feel free to post any questions you have in the comments section and I will answer them promptly.
Thanks and Happy Flashing.
hello champs,
I am also facing the same problem and there is no infinite loop, can anyone there who can help me out.
Thanks in advance
how to override the default timeout limit in flex
I’m trying to create a particle system using the number “1” as my MovieClip. I named the MovieClip “one” and linked it to my ActionScript 3.0 file named Particles.as. The class name is “One”. Every time the MovieClip regenerates it freezes then crashes Flash. I ran a “debug movie” feature and it gave me an error #1502. I opened “Publish Settings” so that I can change the “Script Time Limit, but that didn’t work.
Please help, thank you!!!
This is my ActionScript 3.0 file named Particles.as:
package tions.part
{
import flash.display.*;
import flash.events.Event;
public class Particles extends MovieClip
{
public var xVelocity:Number;
public var yVelocity:Number;
public function Particles()
{
xVelocity = 0;
yVelocity = 0;
}
public function update():void
{
this.x += xVelocity;
this.x += yVelocity;
}
}
}
This is my code on my actions frame in my .fla file:
var numOfParticles:uint = 20;
var particles_ary:Array = [];
function updateStage(event:Event):void
{
if(particles_ary.length < numOfParticles)
{
var one:One = new One();
addChild(one);
one.xVelocity = Math.random() * 10 – 5;
one.yVelocity = Math.random() * 10 – 5;
one.x = stage.stageWidth/2;
one.y = stage.stageHeight/2;
particles_ary.push(one);
}
for(var i:uint = 0; i stage.stageWidth + particle.width/2 ||
particle.x stage.stageHeight + particle.height/2 ||
particle.y < -particle.height/2)
{
particle.xVelocity = Math.random() * 10 – 5;
particle.yVelocity = Math.random() * 10 – 5;
particle.x = stage.stageWidth/2;
particle.y = stage.stageHeight/2;
}
}
}
addEventListener(Event.ENTER_FRAME, updateStage);
Hello,
I’m trying to create a particle system. I have an ActionScript 3.0 file named Particles.as which is exported into my .fla file. In the .fla file, the name of the MovieClip is “one”. The class name is “One”. My first problem is that when I publish this code the MovieClip that I animate regenerates in the center of the movie and in the bottom right corner of the movie. How can I get it to regenerate only from the center of the stage? My next issue is that when the movie is published it gradually slows down then it stops and crashes my Flash CS3 program or my Web browser. I did a debug on the movie and and an error was presented (Error: Error #1502).
Do you have any suggestions?
Particles.as code:
package tions.part
{
import flash.display.*;
import flash.events.Event;
public class Particles extends MovieClip
{
public var xVelocity:Number;
public var yVelocity:Number;
public function Particles()
{
xVelocity = 0;
yVelocity = 0;
}
public function update():void
{
this.x += xVelocity;
this.x += yVelocity;
}
}
}
The code in my .fla file:
var numOfParticles:uint = 20;
var particles_ary:Array = [];
function updateStage(event:Event):void
{
if(particles_ary.length < numOfParticles)
{
var one:One = new One();
addChild(one);
one.xVelocity = Math.random() * 10 – 5;
one.yVelocity = Math.random() * 10 – 5;
one.x = stage.stageWidth/2;
one.y = stage.stageHeight/2;
particles_ary.push(one);
}
for(var i:uint = 0; i stage.stageWidth + particle.width/2 ||
particle.x stage.stageHeight + particle.height/2 ||
particle.y < -particle.height/2)
{
particle.xVelocity = Math.random() * 10 – 5;
particle.yVelocity = Math.random() * 10 – 5;
particle.x = stage.stageWidth/2;
particle.y = stage.stageHeight/2;
}
}
}
addEventListener(Event.ENTER_FRAME, updateStage);
can anyone help me out
I am new to flex and getting the runtime error #1502: A script has executed for longer than the default timeout period of 15 seconds.
I am trying to retreive data value from webservice and addind it to datagrid all at once. I am able to get all the data value in temp variable but while assigning to the datatprovider it shows or crashes.
-regards
kumar
Is there a possiblity to increase the timeout value?
Adg
Please somebody help me! 🙁
I got this message: ONLY IN IE7…not in Firefox!!!!
Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at flash.external::ExternalInterface$/flash.external:ExternalInterface::_argumentsToXML()
at flash.external::ExternalInterface$/call()
at index_fla::MainTimeline/irAl5()
I got a script for open mini-popus inserted en html code:
And in my AS3 code I have this one:
function irAl1(evt:MouseEvent):void {ExternalInterface.call(“makePopup(‘pages/libro01.html’,’Libro Destacado’,’350′,’350′)”);}
function irAl2(evt:MouseEvent):void {ExternalInterface.call(“makePopup(‘pages/libro02.html’,’Libro Destacado’,’350′,’350′)”);}
function irAl3(evt:MouseEvent):void {ExternalInterface.call(“makePopup(‘pages/libro03.html’,’Libro Destacado’,’350′,’350′)”);}
function irAl4(evt:MouseEvent):void {ExternalInterface.call(“makePopup(‘pages/libro04.html’,’Libro Destacado’,’350′,’350′)”);}
function irAl5(evt:MouseEvent):void {ExternalInterface.call(“makePopup(‘pages/libro05.html’,’Libro Destacado’,’350′,’350′)”);}
BUT ALWAY THE MESSAGE ERROR APPEARS!!!
Any opinion my friends????
Hey! Great Stuff.
This is the code that was killing my script:
var index = String(event.target.name);
while (index != String(uint(index))){
index = index.substr(2);
}
Pingback: Common ActionScript 3 Errors and Explanations | Jake Rutter - XHTML/CSS Developer
I am using webservice with flex application to get the result (which i am getting in the e.message.toString() through Alert.show() method). After that it gives me the Error: 1502.
instead of going into the MyFunction_result()
it goes to MyFunction_fault() method
message shown in the Alert.show() is given below:
———————————-
(mx.messaging.messages::AcknowledgeMessage)#0
body = ”
1823
Sample
UserNone
Muser@sample.com
000
Abkhazia
”
clientId = “DirectHTTPChannel0”
correlationId = “AF002F25-B40D-D1C6-7B00-5DBC7079D6D2”
destination = “”
headers = (Object)#1
messageId = “250505C5-D00E-9186-6A34-5DBD5DC79C30”
timestamp = 0
timeToLive = 0
——————————————
and the flex code is here:
{NetworkID}
public function MyFunction_Fault(e:FaultEvent):void
{
Alert.show(e.fault.message.toString(), “Message”);
}
public function MyFunction():void
{
this.MyWebservice.MyFunction.send();
// this is working fine and sending me the result
// i am able to get the result in the Alert.show(e.message.toString())
// but this function is unable to move to MyFunction_Result()
// instead of showing me “result” in alert message
// it is showing me the error in the alert message
}
private function MyFunction_Result(e:ResultEvent):void
{
Alert.show(“Reults”);
}
Thanks,
Jatin Sahotra
Kuhan,
You may either want to rethink the downloading of so many records or, you may want to use Flash Remoting. Remoting can dramatically speed up the Server execution time, transfer time, the parsing time, and display/render time of the data. You can really see the difference at this website. http://www.jamesward.org/census/
Thanks,
Curtis J. Morley
Error #1502: A script has executed for longer than the default timeout period of 15 seconds
hai i am using Httpservice to fetch the records through xml generated by JSP, my problem is when i get thousands of records the operation creates errors like the abouve!!!
What should i do to to avoid getting such error???
I am binding the result to a dataGrid…
Pingback: curtismorley.com » Flex / Flash CS3 Warning# 3551
Sam,
I would suggest (without seeing the rest of your code) that it has nothing to do with this small snippet or the javascript alert popping up. I am willing to wager that you either have another script that is executed at the same time or that the culprit is wating for further instructions from the javascript. This is a guess because I can’t see the script but if the error doesn’t pop-up if you click “OK” then the click somehow interrupts the already looping script that would have given you the error.
Check all of your loops. ‘While’ loops are serious rogues when it comes to this error. Please let me know if you find the solution or what else I can do to help you.
Thanks,
Curtis J. Morley
In my flex app, this actionscript function is called on form submission for validation:
…
if (strDt.text == “” || strDt.text == ” “) {
strDt.errorString = “Enter the report date here”;
strDt.setFocus();
// Display error to user by calling js function
errmsg = “ERROR: You need to enter the report date.”;
ExternalInterface.call(“swfAlerts”, errmsg);
return;
}
The javascript function swfAlerts calls the browsers alert message box and displays the error message:
function swfAlerts(usrmsg) {
alert(usrmsg);
}
Everything works successfully, and flex executes the swfAlerts function if the required text field is empty. But when the browser alert message box pops up, if the user doesn’t click the “OK” button to dismiss the message box within 15 seconds, flash gives the #1502 error:
Error: Error #1502: A script has executed for longer than the default timeout period of 15 seconds.
at flash.external::ExternalInterface$/flash.external:ExternalInterface::_toAS()
at flash.external::ExternalInterface$/call()
at date/::validateSubmit()
at date/___Button1_click()
Any idea how this can be avoided?
I get that error with this code:
var pressed_down_button:Boolean = false;
public function pro():void
{
for (var i:int = 0; i
How can I fix the problem?
Thanks!