dcsimg
A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: Bypass preloader in cached

  1. #1
    Member
    Join Date
    Nov 2003
    Posts
    61

    Bypass preloader if cached

    How can I bypass the preloader if someone has the specific swf already cached. I have 2 frames on the main timeline. the first has a stop action in an empty mc and a preloader with the following code:

    onClipEvent (enterFrame) {
    loading = _parent.getBytesLoaded();
    total = _parent.getBytesTotal();
    percent -= (percent-((loading/total)*100))*.25;
    per = int(percent);
    percentage = per+"%";
    loadBar._width = per;
    if (percent>99) {
    _parent.gotoAndStop(2);
    }
    }

    In the second frame I have my main movie. Any help would be great from those of you who know as better than me. Thanks ya'll.

    [pk]
    Last edited by Philip Konya; 07-07-2005 at 04:50 AM.

  2. #2
    nobody
    Join Date
    Aug 2002
    Posts
    269
    on the first frame put
    if (_root.getBytesLoaded() == _root.getBytesTotal()){
    gotoAndStop(2);
    }
    kra, kra

  3. #3
    Member
    Join Date
    Nov 2003
    Posts
    61
    When I do this
    on the first frame put
    if (_root.getBytesLoaded() == _root.getBytesTotal()){
    gotoAndStop(2);
    }
    it bypasses the preloader all together. Even when viewing for the first time. I am not sure why?
    [pk]

  4. #4
    nobody
    Join Date
    Aug 2002
    Posts
    269
    It doesnt check if you're there for the first time or not but if it has loaded. If you want to show preloader for visitors that are there for the first time, use shared object or cookies.
    kra, kra

  5. #5
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    Quote Originally Posted by Philip Konya
    When I do this
    it bypasses the preloader all together. Even when viewing for the first time. I am not sure why?
    [pk]
    because when nothing has loaded both are equal to 0, thus .. equal, and the if statement returns true.
    The usual way to write that line of code is more like:

    if (_root.getBytesLoaded() > 4 && _root.getBytesLoaded()== _root.getBytesTotal())

    ensuring that at least something has started loading.

    gparis

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    To answer your post, you could just set a variable to true when the loading is complete:

    if (percent>99) {
    _parent.loaded = true;
    _parent.gotoAndStop(2);
    }

    then check for that variable first.

    gparis

  7. #7
    nobody
    Join Date
    Aug 2002
    Posts
    269
    I think that would still expose his preloader, even for a second.
    Maybe if the preloader would be visible only if the movie was not loaded into cache.

    I never had problems with preloading main movies (replying to gparis's previous post) and geting their correct size, but only with loading swf's into main movie. However with so many different computer configurations and different browsers, one can never be too carefull.
    kra, kra

  8. #8
    Member
    Join Date
    Nov 2003
    Posts
    61
    I have in my 1st frame an empty keyframe with the following action:
    if (percent>100) {
    _parent.loaded = true;
    _parent.gotoAndPlay(3);
    }

    On frame 2 there is a stop action in an empty keyframe. Under that (still in frame 2) is my preloader with the following action:
    onClipEvent (enterFrame) {
    loading = _parent.getBytesLoaded();
    total = _parent.getBytesTotal();
    percent -= (percent-((loading/total)*100))*.25;
    per = int(percent);
    percentage = per+"%";
    loadBar._width = per;
    if (percent>99) {
    _parent.gotoAndPlay(3);
    }
    }

    The preloader still shows even if it is cached. I am sorry that I keep pestering people with this. Just have not gotten it to work yet. What am I doing wrong?

    [pk]

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