Create an Account!

Adobe Flash Community Forum for all your Flash, Actionscript and Swift3D Support

Search:
FlashDevils Community
 Recommend Us
 About FlashDevils Community
 Can i become a moderator?
 How do i add Flash to my post?
 
Flash Community Register Flash Forum Control Panel Calendar Member List FAQ Search FLA Files
FlashDevils Community FlashDevils Community > Board > Flash > Flash ActionScript > AS2 Custom Load Screen Issue


  Last Thread   Next Thread
Author
Thread Post New Thread    Post A Reply
Mezmiro
Little Devil

Registered: Jul 2010
Local time: 05:35 PM
Location:
Posts: 1

AS2 Custom Load Screen IssuePost #1

I'm designing a website for a friend of mine and I'm having issues with the load screen code.

The first frame of this site contains ten circles, named circ1, circ2 and so on. These movie clips should tween at 10% load intervals, and yet nothing appears to happen when I try a bandwidth profile.

Here is the code on frame 1 of the action layer.

ActionScript:

import mx.transitions.Tween;
import mx.transitions.easing.*;

var getPercent = 0;

_root.onEnterFrame = function()
{
        getPercent = [Math.round(this.getBytesLoaded())/Math.round(this.getBytesTotal())]*100;
        if(getPercent == 10)
        {
                new Tween("circ1","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 20)
        {
                new Tween("circ2","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 30)
        {
                new Tween("circ3","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 40)
        {
                new Tween("circ4","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 50)
        {
                new Tween("circ5","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 60)
        {
                new Tween("circ6","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 70)
        {
                new Tween("circ7","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 80)
        {
                new Tween("circ8","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 90)
        {
                new Tween("circ9","_alpha", Strong.easeOut,20,100,5,true);
        }
        if(getPercent == 100)
        {
                new Tween("circ10","_alpha", Strong.easeOut,20,100,5,true);
                delete _root.onEnterFrame;
                gotoAndStop(2);
        }
}




I'm sure there's a better way to condense this function, but at the moment I'm more concerned with why it doesn't operate correctly in the first place.



Report this post to a moderator | IP: Logged

Old Post 07-26-2010 10:35 PM
Mezmiro is offline Click Here to See the Profile for Mezmiro Click here to Send Mezmiro a Private Message Find more posts by Mezmiro Add Mezmiro to your buddy list Edit/Delete Message Reply w/Quote
viktor
Little Devil

Registered: Mar 2010
Local time: 05:35 PM
Location: Sweden
Posts: 10

Post #2

why this code:
getPercent = [Math.round(this.getBytesLoaded())/Math.round(this.getBytesTotal())]*100;


why not:
getPercent = (Math.round(this.getBytesLoaded())/Math.round(this.getBytesTotal()))*100;



Report this post to a moderator | IP: Logged

Old Post 08-26-2010 09:59 AM
viktor is offline Click Here to See the Profile for viktor Click here to Send viktor a Private Message Click Here to Email viktor Visit viktor's homepage! Find more posts by viktor Add viktor to your buddy list Edit/Delete Message Reply w/Quote
viktor
Little Devil

Registered: Mar 2010
Local time: 05:35 PM
Location: Sweden
Posts: 10

Post #3

And another thing which is probably the real problem the way you're doing your checks ,"getPercent == 10" etc doesn't really work as the chance of hitting exactly 10 when loading is very slim.

You could check "getPercent >= 10" and you also need to keep track so you don't do the tween several times for each circle. Maybe have an array of booleans:

var alreadyDone = new Array(10);
if (getPercent >= 10 && !alreadyDone[0]") alreadyDone[0] = true.

etc. etc.



Report this post to a moderator | IP: Logged

Old Post 08-26-2010 10:19 AM
viktor is offline Click Here to See the Profile for viktor Click here to Send viktor a Private Message Click Here to Email viktor Visit viktor's homepage! Find more posts by viktor Add viktor to your buddy list Edit/Delete Message Reply w/Quote
All times are GMT. The time now is 05:35 PM. Post New Thread    Post A Reply
  Last Thread   Next Thread
Advertising
Show Printable Version | Email this Page | Unsubscribe from this thread | Download thread

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
 

< FlashDevils - Terms of use >

Copyright, FlashDevils Community, 2002 -
Flash Archive

Links
Books