Fleb Framework 1.27 released: Cache and preloading
March 15, 2010 by: ChristianSome time ago I stumbled upon this post and I decided to implement it in the Fleb Framework. It’s about cache and preloading. I also optimized the initialization of a Website created with Fleb. You can now define which files need to be preloaded before the main site starts. There is a new node you can set in structure.xml, “preload_cache”. It’s optional. If set, the files (images and SWFs) are loaded to cache before the site starts.
Example:
<preload_cache> <data file="mainBtn.swf" bytes="63351"/> <data file="images/b1africanl001.jpg" bytes="16384"/> <data file="images/b2architecturals018.jpg" bytes="16759"/> <data file="images/b4architecture_interiors002.jpg" bytes="19810"/> <data file="images/b6nature_animals_sea000.jpg" bytes="18644"/> <data file="images/b10mechanics019.jpg" bytes="19458"/> <data file="images/b12architecture_interiors002.jpg" bytes="16384"/> <data file="images/b19nature_animals_sea039.jpg" bytes="13505"/> </preload_cache>
Quick links (more info etc.):
Download the Fleb Framework
XML Attributes (structure.xml in detail)
Fleb documentation
Cheers,
Christian





Hi Christian!
A little advice needed…
So, say that I want to load an big background image,preload cache is the place to add it?
For example:
And after this, in Main class what is the proper way to add it?
By using addchild? How do I retrieve it?
An how can I add it in base class (so that it is behind everything and occupies full screen)?
Thanx in advance
Correction to the previous post
….For example:
data file=”images/background.jpg” bytes=”18644″
And after this,….
You can use preload cache if you want, but if the image is loaded only once at start time and then remains throughout the session, it is not needed. Anyway, you place the background image in main.swf behind the mc “website”. Just add an empty movieclip (or dynamically create one) into which you load the background image. In main.as is already a function “positionWebsite” and an event listener “onStageResize”. Just add your code there (image resizing, positioning etc.) Remember, base.swf should contain as little as possible to keep it small. Try it in the demosite!
Hope that helps,
Christian