A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Making preloader wait for external files to load

Hybrid View

  1. #1
    Junior Member
    Join Date
    Oct 2003
    Location
    UK
    Posts
    6

    Making preloader wait for external files to load

    Hi there, I've had a search around and can't find what I'm looking for, so I come to you guys in my hour of need (ok, not so melodramatic, but I'd appreciate some help )

    Here's the site I'm working on www.savethebarrels.co.uk

    Which has basically been put together from tutorials from here (thanks guys) and from experience and experimentation, the only real problem I'm having is that if the user is max'ing out their bandwidth, or is on a low bandwidth connection then when they click to go to one of the other sections, then sometimes the externally loaded txt file won't load in time, so the scrollbar goes squiffy, and also there is no text displayed until you click it again.

    So my question is this: Is it possible to place into my preloader, something to make it wait for the external files to load, i'm not bothered about it contributing to the %age loaded, I just want to make sure it'll wait for them to load, so in pseudo code I'm looking for:

    PHP Code:
    this.loadVariables("news.txt?nocache=" + new Date().getTime);  
    this.loadVariables("nands.txt?nocache=" + new Date().getTime);  
    this.loadVariables("faq.txt?nocache=" + new Date().getTime);
    if 
    txt files loaded  
    and if (_root.getBytesLoaded() == _root.getBytesTotalgetTime)  
    then gotoandplay next scene 
    any help would be much appreciated, ta
    Timofee

  2. #2
    Member
    Join Date
    Jan 2003
    Posts
    78
    not quite sure what you mean and since i only have dsl i cant test if for my self, but i give you some pointers.

    When you are loading in seperate .swf make sure thos flash files have there own pre loaders built into them. I will also asume the scroll bar is built into the sepeate .swf's, if not why dont you go ahead and try that. That way your .swfs will have time to load and come up when they are completly done.
    chris davis

  3. #3
    Junior Member
    Join Date
    Oct 2003
    Location
    UK
    Posts
    6
    Sorry, I'm obviously not explaining very well.

    Basically there is one main swf file, containing the layout and gfx of all the site, so when you click an item on the menu you are still within the same swf file, merely in a different frame.

    The content, ie all the text you see (with the exception of a small amount) is loaded externally from a .txt file which contains stored variables which in turn relate to displaying the text you see.

    My problem is if the user doesnt download the .txt file in time (at least I assume that is what is causing it) then it will, quite obviously, not display (because it hasnt loaded yet). This has happened to me, and various other people quite a few times, and I'm on 1meg, but I was downloading heavily.

    My Question is, is there any way to make my preloader load, and then check they are fully loaded, external txt files.

    For example I want it to load up news.txt, which contains all the news items, and then, and only then can it actually proceed to take you to the main site.
    Timofee

  4. #4
    Senior Member Shotsy247's Avatar
    Join Date
    Apr 2001
    Location
    Be there in a minute!
    Posts
    1,386
    This is straight from Flash Help.

    code:
    var my_lv:LoadVars = new LoadVars();
    my_lv.onLoad = function(success:Boolean) {
    if (success) {
    trace(this.toString());
    } else {
    trace("Error loading/parsing LoadVars.");
    }
    };
    my_lv.load("http://www.flash-mx.com/mm/params.txt");



    The onLoad is triggered when the data has loaded. Put the stuff you want done in there.

    _t
    I don't feel tardy.

  5. #5
    Junior Member
    Join Date
    Oct 2003
    Location
    UK
    Posts
    6
    That didn't work at all for me, however it made me realise how incredibly dumb I was being.

    I just needed to add: -

    Code:
    onClipEvent(data) {
    	numnews = newsitemCount;
    	_root.window.title = eval("title"+numnews+"txt");
    	_root.window.textbox = eval("news"+numnews+"txt");
    	_root.window.postdate = eval("date"+numnews+"txt");
    	updateScrollBarPos();
    }
    which means as soon as the data is loaded, it all updates.

    Cheers anyway
    Timofee

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