swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swftools-common] help with a counting loader


From: Pablo Rodríguez
Subject: Re: [Swftools-common] help with a counting loader
Date: Sat, 28 Feb 2009 16:00:39 +0100
User-agent: Thunderbird 2.0.0.19 (X11/20090114)

Chris Pugh wrote:
2009/2/25 Pablo Rodríguez <address@hidden>:
[...]
   .sprite images
       .put placeholder alpha=0%
       .action:
           first_loading = new Object();
           first_loading.onMouseDown = function () {
               if (gettimer()-firstclick<300) {
                   load_swf = new MovieClipLoader();
                   load_swf.loadClip("lessig-freeculture.swf", placeholder);
               } else {
                   firstclick = gettimer();
               }
           };
           Mouse.addListener(first_loading);
       .end
   .end
[...]

I would like to get a functioning loading counter for the external SWF that
might look like the code bellow. I don't know how to add it to the code
above, since adding a new frame breaks the loading of the external file.

   .action:
       load_text = (String (Math.round ((_root.loader.getBytesLoaded() /
(1024*1024)) * 100) / 100) + " MB / " + String (Math.round
((_root.loader.getBytesTotal() / (1024*1024)) * 100) / 100) + " MB " + " ("
+ String (Math.round ((_root.load_swf.getBytesLoaded() * 100) /
_root.load_swf.getBytesTotal())) + "%)" );

       if (_root.getBytesLoaded() < _root.getBytesTotal()) {
           gotoAndPlay(1);
       }
   .end

Any ideas?

Thanks for your help,


Pablo

Try loading it as a separate movie ( sprite ), then use the 'Interval'
event timer to check the
load progress of the other movie.  It may well be worth doing the
calculation and the conversion
to a text string for display separately too, since..

MovieLoader.loadClip() includes an onLoadProgress handler that allows to do what I was trying to.

To include the load_text variable that was inside the onLoadProgress handler, I had to rename it to _root.load_text (new script below, http://www.archive.org/download/Lessig-Free_Culture/lessig-freeculture-loader.swf).

But I still have an issue with this loader. All getBytesLoaded and getBytesTotal are counted with uncompressed sizes and since the actual file is compressed, these size numbers are wrong. Is there any way to get the actual compressed bytes with getBytesLoaded?

Thanks for your help,


Pablo



.flash filename="lessig-freeculture-loader.swf" version=7 fps=12
.font roman "/usr/share/fonts/TTF/FreeSansBold.ttf" glyphs=" %()MB0123456789/:,.PDuk[]resntiocanbld!" .edittext newloader font=roman color=#ffff00 size=30% width=300 height=30 border=none align="right" noselect variable=load_text
.box placeholder width=720 height=540

.swf first_slide "orphanworks-first.swf"

.frame 1
    .put first_slide
    .stop first_slide
    .put newloader
    .stop newloader

    .action:
        slide_height=Stage.height;
        slide_width=Stage.width;
        counter_percent=(slide_width/800)*100;
newloader._x = slide_width-(newloader._width*(counter_percent/100)*1.5);
        newloader._y = slide_height-(newloader._height*3);
        newloader._xscale=counter_percent;
        newloader._yscale=counter_percent;
        load_text = "[Double click to start]";
    .end

    .sprite images
        .put placeholder alpha=0%
        .action:
            the_presentation = "lessig-freeculture.swf";
            first_loading = new Object();
            first_loading.onMouseDown = function () {
                if (gettimer() - firstclick < 400) {
                    load_swf = new MovieClipLoader();
                    load_swf.loadClip(the_presentation, placeholder);
                    listen_loading = new Object();
listen_loading.onLoadProgress = function(mvclip, bytesLoaded, bytesTotal) {
                        keeping_awake = setInterval(function() {}, 1000);
_root.load_text = (String (Math.round ((bytesLoaded / (1024*1024)) * 100) / 100) + " MB / " + String (Math.round ((bytesTotal / (1024*1024)) * 100) / 100) + " MB " + " (" + String (Math.round ((bytesLoaded * 100) / bytesTotal)) + "%)" );
                    };
                    listen_loading.onLoadError = function(){
                        _root.load_text.textColor = 0xFF0000;
_root.load_text = "Presentation cannot be loaded!!!";
                    };
                    listen_loading.onLoadInit = function(){
                        clearInterval(keeping_awake);
                        _root.first_slide._visible = false;
                        _root.load_text = "";
                    };
                    load_swf.addListener(listen_loading);
                } else {
                    firstclick = gettimer();
                }
            };
            Mouse.addListener(first_loading);
        .end
    .end

    .action:
        this.attachMovie("images","i",1);
    .end

.end




reply via email to

[Prev in Thread] Current Thread [Next in Thread]