SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2005
    Posts
    70
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JavaScript causes "Out of memory at line..."

    Hello,
    I have a script that works fine in Firefox but causes an "Out of Memory" error in Internet Explorer. I heard that it has something to do with the string manipulation that eats up the memory. Here is the script:

    <script language="javascript">
    var playersPerPage = 7;
    function stopTheSound(movieName){
    var i;
    for(i = 1; i <= playersPerPage; i++){
    var currentMovie = ("movie_" + i);
    if(currentMovie == movieName){
    continue;
    } else {
    var movie = thisMovie(currentMovie);
    movie.TPlay("_level0/soundStop_mc");
    }
    }
    }
    function thisMovie(movieName) {
    // IE and Netscape refer to the movie object differently.
    // This function returns the appropriate syntax depending on the browser.
    if (navigator.appName.indexOf ("Microsoft") !=-1) {
    return window[movieName];
    } else {
    return document[movieName];
    }
    }
    </script>

    How can I solve the problem?

    Thanks in advance!

    Regards,
    Mirza

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,163
    Mentioned
    190 Post(s)
    Tagged
    2 Thread(s)

    memory

    It looks like your code is trying to play 6 movies at a time. This would be a memory size problem.
    HTML Code:
    for(i = 1; i <= playersPerPage; i++){
        var currentMovie = ("movie_" + i);
        if(currentMovie == movieName){
            continue;
        } else {
            var movie = thisMovie(currentMovie);
            movie.TPlay("_level0/soundStop_mc");
        }
    }
    It looks like what the stopTheSound function does is not stop the sound, but (try to) play all the others.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •