Error #1502: A script has executed for longer than …


Hi all !

I have a website that serves a flash movie ( swf ). There is a loader movie, that loads the main movie and communicates with php. However while loading the main movie, I get the error in the heading above. The main movie has almost 110 sound files besides other clips buttons etc. After struggling a lot and ruling out error due to any other reason, I deleted the 110 sound movies and lo ! the movie worked !! Then i started adding the sound files again and was able to add about a 47 of them without any error. The movie loaded within 5 seconds max. However beyond that point, if I add just one more sound file, the movie fails to load and I get this error.

Now all search on Error 1502 says it occurs due to infinite loops etc or bad code. However nothing on file size etc. or the limit on adding the size of the library. Please can someone make a suggestion how to solve this issue?

I would also like to mention that the file size of the main flash file is only 1952kb and that of the corresponding swf is 712 kb , ceratainly not great by any means.

I would like to especially thank Zwetan, for his invaluable help on this earlier.

Thanks all !


so that error 1502

1502 A script has executed for longer than 15 seconds.

is simply a problem of how much you try to load within a frame of a SWF

if you check your compiler options

$ ./mxmlc -help advanced

-default-background-color <int>
-default-frame-rate <int>
-default-script-limits <max-recursion-depth> <max-execution-time>
-default-size <width> <height>

$ ./mxmlc -help advanced limit

-default-script-limits <max-recursion-depth> <max-execution-time>
    default script execution limits (may be overridden by root
    attributes) (advanced)

by default the script limit is set to 15 seconds
that is reading, parsing, interpreting, validating, etc. the content of the SWF file

You have about 3 solutions to that

  • set a bigger limit
    with for ex -default-script-limits 512 30
    eg. 512 max-recursion-depth and 30 (seconds) max-execution-time
  • change the way you use the sound
    instead of embedding them in the SWF
    you could for ex use external mp3 that you load dynamically
  • split the load of the SWF other many frames instead of one
    with another option -frames.frame [label] [classname] [...]

So I’m not sure what is exactly wrong as I see no code but the general idea is that you try to do too much over only 1 frame of a SWF.

You can find more infos about the option -frames.frame
on the wiki page ActionScript3 undocumented

$ ./mxmlc -help advanced frame

-frames.frame [label] [classname] [...]
    alias -frame
    A SWF frame label with a sequence of classnames that will be linked
    onto the frame. (advanced, repeatable)

you would use it like that
$ mxmlc -frame=0,Frame1Class -frame=1,Frame2Class -frame=2,Frame3Class

and with embedding sound you could do that

package assets.sound

    // extends Sound
    [Embed( source="foobar.mp3" )]
    public class foobar extends Sound
        public function foobar(){}
    import assets.sound.foobar;

    public var sound1:Sound = new foobar();
    //public var sound2:Sound = new something();
    //public var sound3:Sound = new otherthing();

    public class Frame1Class
        public function Frame1Class(){}

you embed a mp3 per class, you organise group of sounds with Frame1Class
and then you decide on which frame to load it with -frame=0,Frame1Class

in such class as Frame1Class you can define 10 or 20 etc. sounds
then you can have Frame2Class, Frame3Class, etc.

and then you got your MainClass that you load at the end to start the app

$ mxmlc -frame=0,Frame1Class \             <-- 20 sounds, max 15sec
        -frame=1,Frame2Class \             <-- 20 sounds, max 15sec
        -frame=2,Frame3Class \             <-- 20 sounds, max 15sec
        -frame=3,MainClass                 <-- main code, max 15sec

each frame will be limited by -default-script-limits, by default 15 sec
but you could also change that

but once you reach the frame of MainClass all the other data in the previously loaded frames will be available


    import assets.sound.*;

    public class MainClass
        public function MainClass()
            // will work without waiting to load the sound
            var sound:Sound = new foobar();

the SWF does not have to be big, it really depends on how the code works and the time to interpret the SWF (big or small).

The SWF format has been defined to be a stream of bytecode, you’re not forced to load everything on the very first frame, most of the time it will work and be enough but not always.

Personally I would go with a small’ish SWF that load external .mp3 but I can understand someone who would want to embed all the sound within the SWF as there are use cases for that too (multiple domain, virality, etc.).



Thanks for that awesome detailed answer. You were dead right in pointing that i was overloading the first frame. I used your 2nd suggestion to solve the issue by distributing the loading of sound files over the 1st 3 frames/scenes

I am using Flash CS3 and so i used IMPORT TO STAGE instead of import to library with the 2nd and then the 3rd frame selected and distributed 50 sound files across each them each. However I have not done this in my actual project file but in a trial file that i created for testing purposes. Tomorrow I will implement the changes in the actual file ( which is bigger with over a 100 frames ) but i am confident that it will work.

Thanks yet again for a brilliant answer !


Hi Zwetan,

Is there a way i can upload my compressed project on the forum? While your suggestion has cleared the problem and the movie now loads fine, yet it does not play the sounds for some strange reason. I have created a small project and wanted to upload for your perusal.

Please let me know,