[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Swftools-common] Preloading Images.
From: |
Chris Pugh |
Subject: |
Re: [Swftools-common] Preloading Images. |
Date: |
Sat, 14 Feb 2009 14:27:42 +0000 |
Apologies .. called you Robert instead of Richard. Comes of having two
two separate mails open at the same time.
C.
2009/2/14 Chris Pugh <address@hidden>:
> If you'll forgive me saying so Robert, unnecessarily complcated!! ;o)
> You also need to watch your references. Hope the snippet below helps
> guide you in the rigth direction..
>
> --------------------------------------------------------------------------------------
> .flash filename="001v3.swf" bbox=300x200 version=10 fps=60 compress
> .font tahoma "fonts/tahoma.ttf"
> .box placeholder color=blue height=100 width=100 fill=blue
> .edittext etext text="--" color=white font=tahoma size=10pt width=40
> height=22
>
> .sprite images
> .put placeholder x=0 y=0
> .action:
> this.loadMovie("a.jpg");
> .end
> .end
> .action:
> this.attachMovie("images","i",1);
> i._height=10;
> i._width=10;
> i._x=0;
> i._y=0;
> var v=i.getBytesLoaded();
> // (or) var v=i.getBytesTotal();
> // (or) var v=i._framesloaded;
>
> etext.text=v.toString();
> .end
> .put etext x=120 y=120
>
> .end
>
> ---------------------------------------------------------------------------------------
>
> Regards,
>
>
> Chris.
>
> 2009/2/12 Richard Anderson <address@hidden>:
>> Greetings, all.
>>
>> I'm writing what is essentially a fancy slide show using SWFC. On load,
>> the slideshow requests a list of images using loadVariables. The
>> response to this request ends with "eof=true" so I can tell when it's
>> done loading.I've got a preload screen which waits for this request to
>> finish and then replaces its own onEnterFrame with a function that
>> *should* be waiting for all of the images to preload. Unfortunately,
>> I've had no luck with getBytesLoaded() and getBytesTotal().
>>
>> I don't need a progress bar, and if there's a better way to go about
>> this, I'm open to it.
>>
>> Here's a code snippet:
>> .sprite loader
>> .frame 1
>> .put loading_animation pin=center x=360 y=203
>> .frame 13
>> .change loading_animation rotate=330
>>
>> .action:
>> this.onEnterFrame=function()
>> {
>> if (_root.eof == "true" && this.ranonce==undefined)
>> {
>> // To make sure this doesn't get run twice if it
>> takes longer than one frame to finish everything.
>> this.ranonce=true;
>>
>> // Some housekeeping stuff here.
>>
>> _root.createEmptyMovieClip("holder", 2);
>> _root.holder._visible = false;
>>
>> // Sets this.toload to an array of the following form:
>> // ["/path/to/image.jpg","/path/to/image.jpg",...]
>> this.toload = _root.getImagesToLoad();
>>
>> this.onEnterFrame=function()
>> {
>> next = false;
>>
>> if (this.loadindex == undefined)
>> {
>> this.loadindex = 0;
>> next = true;
>> }
>> else
>> {
>> loaded = _root.holder.getBytesLoaded();
>> total = _root.holder.getBytesTotal();
>> if (total > 0 && loaded == total && loaded
>> != undefined && total != undefined)
>> {
>> this.loadindex++;
>> next = true;
>> };
>> };
>>
>> if (next)
>> {
>> if (this.loadindex > this.toload.length-1)
>> {
>> // Add controls, the slide movie clip,
>> start the slideshow playing, etc...
>> this.stop();
>> this._visible = false;
>> delete this.onEnterFrame;
>> return;
>> };
>>
>> loadMovie(this.toload[this.loadindex],
>> _root.holder);
>> };
>> };
>> };
>> };
>> .end
>> .end
>>
>> Everything I've been able to test works beautifully except for
>> _root.holder.getBytesLoaded() and _root.holder.getBytesTotal(). Both of
>> them always return zero.
>>
>> Thanks in advance for your help. I'm a huge fan of this project. I've
>> been looking for something like this for years, and haven't found it
>> until now.
>>
>> Richard
>>
>>
>>
>>
>