A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Textual Preloader

  1. #1
    Junior Member
    Join Date
    Sep 2010
    Posts
    22

    Textual Preloader

    Hi,

    I have a container movie clip on the stage, and it loads another SWF.

    What I'm trying to do while the preloading is happening, is to have a dynamic text field update itself with new text strings after every 200KB are loaded.

    This is the code I wrote for the preloading:

    PHP Code:
    var swfLoader:Loader = new Loader();
    holderMC1.addChild(swfLoader);
    var 
    bgURL:URLRequest = new URLRequest("main.swf");

    var 
    total:Number swfLoader.loaderInfo.bytesTotal;
    var 
    loaded:Number swfLoader.loaderInfo.bytesLoaded;

    if (
    loaded 200000) {
        
    dynamicText.Text "Loading...";
    }

    if (
    loaded 200000 && loaded 400000) {
        
    dynamicText.text "Still Loading...";
    }

    swfLoader.load(bgURL); 
    For some reason, the dynamic text field does not update the second time.
    Any ideas why?

    Thanks a lot!

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Use "View" from the menu when the movie is showing and go to "simulate download".
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    Sep 2010
    Posts
    22
    Hi,

    I did do that - it still doesn't work.
    The first line shows up ("Loading..."), but it stays all the way through the preloading process and does not change according to the bytes loaded (into "Still Loading...").

  4. #4
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    You need to use a ProgressEvent because all you did was set the text before the loader even starts loading.

    PHP Code:
    var swfLoader:Loader = new Loader(); 
    holderMC1.addChild(swfLoader); 
    var 
    bgURL:URLRequest = new URLRequest("main.swf"); 
    swfLoader.addEventListener (ProgressEvent.PROGRESSonProgressfalse0true);

    function 
    onProgress (e:ProgressEvent) {
    var 
    total:Number swfLoader.loaderInfo.bytesTotal
    var 
    loaded:Number swfLoader.loaderInfo.bytesLoaded

      if (
    loaded 200000) { 
          
    dynamicText.Text "Loading..."
      } 

      if (
    loaded 200000 && loaded 400000) { 
          
    dynamicText.text "Still Loading..."
      } 
    }
    swfLoader.load(bgURL); 
    So that event will fire every time the loader makes some....progress in loading.

  5. #5
    Junior Member
    Join Date
    Sep 2010
    Posts
    22
    Okay, I've used your code (with all the correct instance names etc.), and now the text box stays empty all through the preloading process...

  6. #6
    Senior Member
    Join Date
    Jul 2008
    Posts
    391
    I made a mistake, it should be
    PHP Code:
    var swfLoader:Loader = new Loader(); 
    holderMC1.addChild(swfLoader); 
    var 
    bgURL:URLRequest = new URLRequest("main.swf"); 
    swfLoader.contentLoaderInfo.addEventListener (ProgressEvent.PROGRESSonProgressfalse0true);

    function 
    onProgress (e:ProgressEvent) {
    var 
    total:Number e.bytesTotal
    var 
    loaded:Number e.bytesLoaded

      if (
    loaded 200000) { 
          
    dynamicText.Text "Loading..."
      } 

      if (
    loaded 200000 && loaded 400000) { 
          
    dynamicText.text "Still Loading..."
      } 
    }
    swfLoader.load(bgURL); 
    I only use loaderInfo for the main SWF's preloader, I use contentLoaderInfo for any loading I have to do inside of the main SWF.

  7. #7
    Junior Member
    Join Date
    Sep 2010
    Posts
    22
    It still loads just the first line ("Loading..."), and doesn't change into "Still Loading..." etc.

    Sorry for the truoble, but it just doesn't seem to work...

Tags for this Thread

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center