Preloading

First preloader (site preloader)

In Base.as you will find this code:

public function onSiteLoadStart():void
{
    preloader.tf_file.text = "";
    preloader.visible = true;
    TweenNano.to(preloader, .5,{alpha:1, delay:.2});
}
public function onSiteLoadProgress(event:Object):void
{
    preloader.gotoAndStop(event.percentOverall);
    preloader.tf_file.text = event.loadingFile + " (" + event.percentOverall + "%)";
}
public function onSiteLoadComplete():void
{
    TweenNano.killTweensOf(preloader);
    preloader.gotoAndStop(100);
    preloader.tf_file.text = "Loading complete!";
    TweenNano.to(preloader, .5,{alpha:0, delay:.3, onComplete:sitePreloaderInvisible});
}
private function sitePreloaderInvisible():void
{
    preloader.visible = false;
}

Content pages preloaders

In Main.as, you'll find this code:

private function onPageLoadStart(event:FlebEvent):void
{
    varcentral.basePreloader.visible = true;
    TweenLite.to(varcentral.basePreloader, .5,{alpha:1, delay:.2});
}
private function onPageLoadProgress(event:FlebEvent):void
{
    varcentral.basePreloader.gotoAndStop(event.params.percent);
}
private function onPageLoadComplete(event:FlebEvent):void
{
    TweenLite.killTweensOf(varcentral.basePreloader);
    varcentral.basePreloader.gotoAndStop(100);
    TweenLite.to(varcentral.basePreloader, .5,{alpha:0, delay:.3,      onComplete:pagePreloaderInvisible});
}
private function pagePreloaderInvisible():void
{
    // Hide the preloader completely after the fade out animation
    varcentral.basePreloader.visible = false;
}

Testing the preloaders

Before uploading our site to the web servers, it is important to check if the preloaders work as expected. FlashDevelop does not provide a "Simulate Download" tool , as Flash IDE does. An very useful alternative is to use sloppy.

Using sloppy with fleb

  • Download sloppy from the link above.
  • Run sloppy.jnpl.
  • The sloppy window will open. In the address field enter:

http://localhost/my_flebsite/deploy

  • Select the connection speed to simulate (eg. 512K).
  • Press Go.

That's it! Don't forget to clear the browser cache everytime you want to simulate it.

 

More coming soon…

Post A Comment

Anti-Spam Quiz: