A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Who can help me mixing these two pieces of code in Flash5?

  1. #1
    Member
    Join Date
    Jun 2001
    Posts
    68

    Who can help me mixing these two pieces of code in Flash5?

    Hi all,

    I want to blend two scripts into one:

    A preloader script + a script where the MC is being faded to 0% alpha.

    I want to combine them so that when the percentage reaches <99%, the preloader MC (preloader) is being faded to alpha 0%.

    code:

    onClipEvent (enterFrame) {
    if (this._alpha>=1) {
    this._alpha = this._alpha -= 10;
    }
    }





    but because of the IF statement of the alpha fade script, I can't really implement it correctly in the if (percent>99) { action. I want it where I now have the _visible property.

    And if it would be possible, I would like the '_root.content.gotoAndPlay(3);' line to wait untill _root.coverover.preloader.alpha = 0; (so that would be another IF statement)...
    So how to I mix all this into one working actionscript???? Hope someone can help me


    code:

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

    _root.coverover.preloader._visible = 0;
    _root.content.gotoAndPlay(3);
    }
    }


  2. #2

    Re: Who can help me mixing these two pieces of code in Flash5?

    Originally posted by ericinho
    code:

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

    _root.coverover.preloader._visible = 0;
    _root.content.gotoAndPlay(3);
    }
    }

    Well, I'm not sure what this line is supposed to do.

    percent -= (percent-((loading/total)*100))*.25;

    this translates into
    percent = percent - (percent-((loading/total)*100))*.25;

    couldn't you so something like
    code:

    var loaded = _root.content.getBytesLoaded();
    var total = _root.content.getBytesTotal();
    var percent = Math.floor(loaded / total * 100);
    _root.MCToMakeFade._alpha = 100 - percent;
    if(percent == 100){
    // continue
    }


  3. #3
    Member
    Join Date
    Jun 2001
    Posts
    68
    basically it does this:

    percent -= (percent-((loading/total)*100))*.25;
    What it effectivly does is add a 'lag' to the progress of the loading. For example, when the percent of the .swf file loaded goes from 10% to 30%, the old style of preloader would do the same, the loading bar would jump straight from 10% to 30%. This line of the script makes the loading bar smoothly move up from 10% to 30%, instead of jumping straight up.

    and I don't want to alter the existing preload code, since it works like a charm. But nevertheless thanks for your suggestion.

    Anyone?

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