A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 31 of 31

Thread: code help....preloader blues??

  1. #21
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    Code:
    onClipEvent (enterFrame) {
    	tb = math.round(_root.container.getBytesTotal()/1024);
    	lb = math.round(_root.container.getBytesLoaded()/1024);
    	if (tb>0 && lb>0) {
    		_parent.percent = math.round((lb/tb)*100);
    		this.gotoAndPlay(_parent.percent);
    		if (lb>=tb) {
    			_parent.gotoAndPlay(17);
    		}
    	}
    }
    made some adjustments...
    Put a stop action on the first frame og the bar.

    Anyway, if you want to use xscale instead, it's almost the same...

  2. #22
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Thanks for the help....

    So basically just add this line?

    Code:
    if (tb>0 && lb>0)
    Can you explain why this makes it all work?

    Is this just to 'start' everything? (so to speak) Thanks for all your help..I wil be testing this and also testing the _xscale line as well.

    this.gotoAndPlay(_parent.percent);

    Can I use this?

    this._xscale(parent.percent)

    Or would I use something like: this._xscale=_parent.percent? DO I need the ( ) around the percent variable?

    Can I directly use the lb variable? Like this?

    this._xscale=lb
    or
    this._xscale(lb)

    Thanks for all your help..I couldnt have done it without you. (actually..."YOU" did it..)

    But now I know how...so I think I should be good for next time.

    -whispers-

  3. #23
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    you have to make sure that they are both >0 because as it takes some moments to start loading. So, they are both 0; so the "if (lb>=tb)" would be true and it would play at once.

    xscale is a property, not a function; so it doesn't get arguments, neither "()".
    this._xscale=_parent.percent

    but if I were you I would use
    this.gotoAndPlay(_parent.percent);

    because it is already done, and you'll have to change the way you build the bar, as a movieClip, to use the xscale.

  4. #24
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Thanks.. I think I understand now.

    Only question/Comment I got is:

    You said "because it is already done, and you'll have to change the way you build the bar, as a movieClip, to use the xscale."

    All I would have to do is make the loader_bar a movie clip correct?
    SO basically delete the 100 frame tween...and just make it an MC at its fullest length...correct?

    Thanks again for your help.

    -whispers-

  5. #25
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Sorry to bother you again....but I have one more question fo rya.

    When looking at your example you posted for me....it all works great..I can see the text..and loading bar.
    But when I go back to the same link...(the about.swf would have already been loaded once into cache)...the loader bar SHOULD be at 100% correct?....just the text says 100...but the loader bar stays at its first FRAME animation....it should be at framme 100 right?

    Thanks

    -whispers-

  6. #26
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    yes, you would have to make a new bar and use the target path to it.

    As the movie has already loaded once, when you revit the page, as soon as the player founds out that the if statment is true, it exscutes it, which means that it it won't show the text nor the bar.

  7. #27
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    But it does show the text as being 100 and the bar..but it is only at frame 1 (of the bar tween) state.....
    Anyways...here is a link to my example..I just put my OLD about section in there for something to load....so dont mind the messy stuff in there. But this is what is happening now (as you will see)
    is the loader bar starts 'growing'...the dynamic text isnt apparent until a couple seconds later, then the loader bar...is jerky like 35 to 67-95...then never to 100...just playing outro of transition.

    When I check out your version of it...it plays smooth...and every number is displayed..even 100.

    Anyways here is my link.....

    http://www.dmstudios.net/Transition_Site/index.html

    Thanks

    -whispers-

  8. #28
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    P.S...

    this is my code...I dont even think I changed anything yet. (but who knows..I have so many files on my computer as of late)

    Code:
    onClipEvent (enterFrame) {
        tb = math.round(_root.container.getBytesTotal()/1024);
        lb = math.round(_root.container.getBytesLoaded()/1024);
        if (tb>0 && lb>0) {
            _parent.percent = math.round((lb/tb)*100);
            this.gotoAndPlay(_parent.percent);
            if (lb>=tb) {
                _parent.gotoAndPlay(17);
            }
        }
    }
    -whispers-

  9. #29
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    I'm sure you didn't put the stop() action in the bar as I told you. So it starts playing imediately, and then it goes back.
    I used a bigger file, so the loading is smoother. If you had a slower connection, it would be smoother.

  10. #30
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Also.. (I know....Im a pain) sorry...

    How do you have the about.swf loading?...Did you keep it as I had it? With a frame action inside the 'transition' timeline? Or did you do something different? I am just tryign to find out why mine is buggy..and yours runs so smooth. just trying t do some troublshooting here.

    My text doesnt even appear until around 19 percent or so..then it jumps to 58-68 percent directly after.

    -whispers-

  11. #31
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    Ahh..you are correct..I forgot the 'STOP' action...thanks...

    -whispers-

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