Jump to content
Search Community

Preloader won't count to 100

azuki test
Moderator Tag

Recommended Posts

This is a bit trivial but I'm wondering what's going on. Basically, I'm using a SWFLoader to load swfs and preloading them with this:

 

function progressHandler(event:LoaderEvent):void
{
preloader_mc.visible = true;
TweenLite.to(preloader_mc, .5, {y:280,alpha:1, ease:Sine.easeOut});
var percent:Number = event.target.progress;
preloader_mc.progressBar_mc.text = String(Math.floor(percent * 100));
if (preloader_mc.progressBar_mc.text == "100")
{
	TweenLite.to(preloader_mc, .5, {y:270,alpha:0, ease:Sine.easeOut});
	preloader_mc.visible = false;
}
}

 

Everything works fine except I noticed the count will always stop at 99 before fading out. What am I missing here?

 

thanks!

Link to comment
Share on other sites

I see a few problems:

 

1) You're using Math.floor() on your percent which always rounds down. So Math.floor(99.99999999) would be 99. Obviously it hits 100 at some point (because you said it does eventually go away), so the problem isn't related to SWFLoader. You could use Math.round() instead, but that would make the value hit 100 a little bit early (99.5 and above).

 

2) You set the preloader_mc.visible = false immediately after you create your tween which means that as soon as the value hits 100, you're making it invisible (that explains why you never see it) but also it doesn't allow it to fade out gradually. You'll never see the tween. It would be better to use autoAlpha which automatically toggles visible to false once alpha hits 0.

 

TweenLite.to(preloader_mc, .5, {y:270, autoAlpha:0, ease:Sine.easeOut});

 

Just don't forget to activate() the AutoAlphaPlugin (see the Plugin Explorer for details/code).

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...