Preload a SWF with Javascript?

  • thepopol777
  • Born
  • Born
  • thepopol777
  • Posts: 2

Post 3+ Months Ago

Hi everyone.
First of all, thanks for this great forum and community. I found it while searching a solution for my problem. ( Unfortunatly, didn't find the solution :cry: ).

Ok here I go, I got a Javascript preloader for Images, working perfectly. Here it is:

Code: [ Select ]
<script type="text/javascript"> // JavaScript Document
  var time = 3;
  
  var maxtime = 120;
 
   
    var done = 1;
    time = time * 1000;
    maxtime = maxtime * 1000;
    loaded = new Array();
 
    function Pre_load()
    {
      for( index = 0; index < document.images.length; index++ )
      {
        loaded[ index ] = false;
      }
    }
 
 
  window.setTimeout( "document.getElementById('Loading_Img').style.visibility='hidden';", maxtime );
    
  function Preload_Img()
  {
    imgs = document.images;
 
      for( index = 0; index < imgs.length; index++ )
      {  
        if( done >= imgs.length )
        {
          break;
        }
          else if( imgs[ index ].complete && loaded[ index ] == false )
        {
          done++;
          loaded[ index ] = true;
        }
      }
      
      if( done >= imgs.length )
      {
        window.setTimeout( "document.getElementById('Loading_Img').style.visibility='hidden';", time );
      }
        else
      {
        window.setTimeout( "Preload_Img()", '58' );
      }


      if( done == imgs.length )
      {
        window.setTimeout( "window.location.href='intro.html';", time);
      }
 
    PRC = Math.round( ( ( done / imgs.length ) * 100 ) );
     
    barwidth = PRC * 2.13 ;
     
    preview =
        
        '<img src="images/loadingbar.gif" width=' + barwidth + ' height = 13/>'
        +'<br />'+'<br />'
        + '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'+ PRC + '&nbsp;' + '%'
 
    document.getElementById('Loading_Img').innerHTML = preview;
  }
  
  Pre_load();
  Preload_Img();

</script>
  1. <script type="text/javascript"> // JavaScript Document
  2.   var time = 3;
  3.   
  4.   var maxtime = 120;
  5.  
  6.    
  7.     var done = 1;
  8.     time = time * 1000;
  9.     maxtime = maxtime * 1000;
  10.     loaded = new Array();
  11.  
  12.     function Pre_load()
  13.     {
  14.       for( index = 0; index < document.images.length; index++ )
  15.       {
  16.         loaded[ index ] = false;
  17.       }
  18.     }
  19.  
  20.  
  21.   window.setTimeout( "document.getElementById('Loading_Img').style.visibility='hidden';", maxtime );
  22.     
  23.   function Preload_Img()
  24.   {
  25.     imgs = document.images;
  26.  
  27.       for( index = 0; index < imgs.length; index++ )
  28.       {  
  29.         if( done >= imgs.length )
  30.         {
  31.           break;
  32.         }
  33.           else if( imgs[ index ].complete && loaded[ index ] == false )
  34.         {
  35.           done++;
  36.           loaded[ index ] = true;
  37.         }
  38.       }
  39.       
  40.       if( done >= imgs.length )
  41.       {
  42.         window.setTimeout( "document.getElementById('Loading_Img').style.visibility='hidden';", time );
  43.       }
  44.         else
  45.       {
  46.         window.setTimeout( "Preload_Img()", '58' );
  47.       }
  48.       if( done == imgs.length )
  49.       {
  50.         window.setTimeout( "window.location.href='intro.html';", time);
  51.       }
  52.  
  53.     PRC = Math.round( ( ( done / imgs.length ) * 100 ) );
  54.      
  55.     barwidth = PRC * 2.13 ;
  56.      
  57.     preview =
  58.         
  59.         '<img src="images/loadingbar.gif" width=' + barwidth + ' height = 13/>'
  60.         +'<br />'+'<br />'
  61.         + '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;'+ PRC + '&nbsp;' + '%'
  62.  
  63.     document.getElementById('Loading_Img').innerHTML = preview;
  64.   }
  65.   
  66.   Pre_load();
  67.   Preload_Img();
  68. </script>


The probleme is that I got a HUGE swf to load, and I really cannot find out how to include the possibility to load it from my image preloader... Any ideas how to proceed? :roll:

Thanks a lot :)
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • thepopol777
  • Born
  • Born
  • thepopol777
  • Posts: 2

Post 3+ Months Ago

Not even a clue? :'(

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 95 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.