[osflash] "splitting" the load percentage feedback in different stages
Marcelo de Moraes Serpa
celoserpa at gmail.com
Sat Jul 1 20:08:17 EDT 2006
Hey David... I tried to implement the formulas you gave me, but with no
success... here´s the code I´m using in the onLoadProgress event of the
LibStack class (pixlib), in other words, this method gets called until the
whole LibStack gets loaded:
First, the LibStack setup:
private function dotherest() {
var lib1:GraphicLib = new GraphicLib(this.createEmptyMovieClip
('lib1',0),10,false);
var lib2:GraphicLib = new GraphicLib(this.createEmptyMovieClip
('lib2',1),11,false);
var lib3:GraphicLib = new GraphicLib(this.createEmptyMovieClip
('lib3',2),12,false);
var AppForm:GraphicLib = new GraphicLib(this.createEmptyMovieClip
('appform_cont',3),13,false);
var lib:LibStack = new LibStack();
lib.enqueue(lib1,'Fuse','files/library/Fuse.swf');
//
lib.enqueue(lib2,'Componentes','files/library/Componentes.swf');
// lib.enqueue(lib3,'Framework','files/library/Framework.swf');
lib.enqueue
(AppForm,'ApplicationForm','files/forms/ApplicationForm.swf');
lib.addEventListener( LibStack.onLoadProgressEVENT, this,
onLoadProgress);
lib.addEventListener( LibStack.onLoadCompleteEVENT, this,
onLoadComplete);
totalSwfs = lib.getElements().length;
lib.execute();
}
Now, the onLodProgress callback:
public function onLoadProgress(lib:LibEvent) {
var currentSwfPercentDone = lib.getPerCent();
Log.it(currentSwfPercentDone);
totalPercentDone = Math.round((this.swfsDone / this.totalSwfs) +
(currentSwfPercentDone / this.totalSwfs));
currentStar = Math.round(totalPercentDone * totalStars);
currentStarPercent = (totalPercentDone - (currentStar/totalStars)) *
totalStars;
this['label' + currentStar + '_txt'].text = String(Math.round
(currentStarPercent));
if(currentSwfPercentDone >= 100) this.swfsDone += 1;
Log.it('---------------------------------------------------');
Log.it('lib name: ' + lib.getName());
Log.it('totalSwfs:' + this.totalSwfs);
Log.it('swfsDone: ' + this.swfsDone);
Log.it('currentSwfPercentDone: ' + currentSwfPercentDone);
Log.it('currentStar: ' + currentStar);
Log.it('totalPercentDone: ' + totalPercentDone);
Log.it('---------------------------------------------------');
}
The totalPercentDone formula doesn´t seem to work, it only goes up to 34
value, and each time a new lib gets loaded, it starts from zero, to go up to
34 again... the currentStar formula also isn´t working. It only returns a
valid value (4, the last star) when the swfDone = 2, totalSwf = 3,
currentSwfPercentDone = 0 and the totalPercentDone = 1 (don´t know why!)
Marcelo.
On 7/1/06, David Rorex <drorex at gmail.com> wrote:
>
> You can use this formula to get an overall percentage:
> totalPercentDone = (swfsDone / totalSwfs) + (currentSwfPercentDone /
> totalSwfs)
>
> to find the current star to be showing:
> currentStar = round(totalPercentDone * numberOfStars);
>
> to find the percent of the current star to be animating:
> currentStarPercent = (totalPercentDone - (currentStar/totalStars)) *
> totalStars;
>
> Just some basic algebra, really. I hope i've understood your question
> correctly.
>
> hope this helps,
> David R
>
> On 6/30/06, Marcelo de Moraes Serpa <celoserpa at gmail.com> wrote:
> > Hello list,
> >
> > I´m redesigning my RIA´s preloader. The graphic´s artist came with a
> nice
> > idea, but with this idea came the difficulties, let me try to explain it
> > better:
> >
> > I have several SWF´s that I have to load in the main preloader as well
> as
> > the ApplicationForm.swf. The artist thought in "splitting" the load
> percent
> > feedback in differnet parts - in the different stars (see the
> screenshot).
> > I would need to somehow totalize the swf´s download percentage and only
> show
> > 0-20% on the first star, 20%-40% on the star and so on...I want all the
> > swf´s download percentage to be treated as if it was only one... and to
> show
> > the feedback in "parts"... the problem is that I really don´t how how
> could
> > I do that. I´m currently using pixlib LibStack to load my swf libraries.
> >
> > You can see a screenshot here:
> > http://chapeco-online.com.br/flash.JPG, and hopefully you
> > will get a better idea on what I want to do ;)
> >
> > Thanks,
> >
> > Marcelo.
> >
> > _______________________________________________
> > osflash mailing list
> > osflash at osflash.org
> > http://osflash.org/mailman/listinfo/osflash_osflash.org
> >
> >
> >
>
> _______________________________________________
> osflash mailing list
> osflash at osflash.org
> http://osflash.org/mailman/listinfo/osflash_osflash.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://osflash.org/pipermail/osflash_osflash.org/attachments/20060701/523e7978/attachment.htm
More information about the osflash
mailing list