Jump to content
Search Community

selfLoader & progress problem ( progress not updating )

amitkhanna test
Moderator Tag

Recommended Posts

Hi there,

 

I recently found LoaderMax and was just wondering why did I never looked at it while all time I was using TweenMax :) TweenMax is the coolest :)

 

Ok the thing is, I have a simple swf with 3-4 images in a mc in it on frame 10.. this sizes upto 350kb. Now i want to show a preloader/progress bar as soon as this swf loads

Problem is that the progress is never updated and thus progress bars(any kind, component, scaleX etc..) doesnt work. Rather in the end trace shows progress: 1 LoaderMax 'mainQueue' complete

 

I have the following code taken from the docs on frame 1...

I am guessing that because my images are in frame 10 thus the loader isnt able to find them and has nothing to acount for ??

any pointers on it??

 

Thanks a lot,

ak

 

import com.greensock.loading.*;
import com.greensock.events.LoaderEvent;
var loader:SelfLoader = new SelfLoader(this, {name:"self", onProgress:progressHandler, onComplete:completeHandler});
var queue:LoaderMax = new LoaderMax({name:"mainQueue", onProgress:progressHandler, onComplete:completeHandler});
queue.append( loader );
queue.load();

function progressHandler(event:LoaderEvent):void {
trace("progress: " + event.target.progress);
}

function completeHandler(event:LoaderEvent):void {
trace(event.target + " complete");
}

Link to comment
Share on other sites

Ok I tried putting all images on frame 1 where all my loader code also exists, but still the same.. no progress update.

 

But if I put all these images in an external swf and load that with SWFLoader things work ok. I noticed one thing here that my loaded swf is displayed at 70% itself and the progress bar doesnt reach the 100% mark.

 

Cheers,

ak

Link to comment
Share on other sites

I'm a little unclear about your setup - could you please post a simple set of FLA files that I can publish to see the problem reproduced?

 

In your first example with just the SelfLoader, it sounds like you're creating it AFTER the swf has already fully loaded, so it would make sense that no PROGRESS events would fire. You can double-check that by doing trace(loaderInfo.bytesLoaded / loaderInfo.bytesTotal) right before you create the SelfLoader and if it's 1, you know it has fully loaded already.

 

As for your SWFLoader - were you saying that the SWFLoader's progress never exceeds 0.7? I've never heard of any such problem, but I'd sure love to see an example. Don't forget to zip your files before posting here (and again, the simpler the better - no need to post your production files).

Link to comment
Share on other sites

Yep, that's to be expected. If you put your image on the first frame, that means that EVERYTHING loads on the first frame and when your SelfLoader is created, the swf has already fully downloaded, therefore no progress events would be dispatched by the SelfLoader. However, if you put the image i the second frame, then when the SelfLoader is created on the first frame, the swf hasn't fully loaded and you'll get progress events.

 

Also, there's no reason to put your SelfLoader into a LoaderMax queue if that's all you're loading. It's not "wrong" - just unnecessary. Extra code with no benefit. So I shortened things for you.

 

I'm still not clear on the issue you brought up previously about progress being stuck at 70% on a SWFLoader - did you resolve that problem?

Link to comment
Share on other sites

Hey,

 

Thanks a lot for looking into the problem and for the tips :)

I'll have a look at the file you have attached... I am using the queue as I plan to load various other swfs later during the project.

 

Regarding the 70% problem, i typed incorrect estimatedSize which I checked later using the target.bytesLoaded and filled in the retrieved bytes, then loader went till 100%.

 

Thanks a lot again for creating & updating your libraries...

ak

Link to comment
Share on other sites

  • 4 weeks later...

Hey there,

 

Hope you are doing great. Have been using LoaderMax now and really like its simplicity.

 

I have a similar question as last time(in above posts). Last time I had all the code on a frame in a fla file and when I shifted my flash assets on frame 2 and defined SelfLoader on frame 1, it started working fine.

This time I have an action script project where my fla file doesnt have anything except for a document class. Now if I specify SelfLoader in my Document class, it doesnt show correct progress, jumps straight to 1 i guess..

 

Can you please guide me on how to correctly use SelfLoader for such a project?

 

Also I am using a videoLoader along with SelfLoader so I guess its best to put these loaders in LoaderMax queue but I have a question.. How do I specify ON_PROGRESS/ON_COMPLEE events for individual loaders?

 

Thanks a lot,

Cheers,

ak

Link to comment
Share on other sites

If you simply have a document class, then everything is on the first frame of your swf. That means that by the time the swf inits (plays the first frame), the ENTIRE thing has already loaded. So SelfLoader's behavior that you described is to be expected. Generally it is considered a best practice to use a separate swf file to load your main one. This allows the parent (let's call it preloader.swf) file to be very small and only focused on loading while you can have your main swf be unconcerned with spreading things out across multiple frames, telling any assets that are exported for ActionScript to only do so after frame 1, etc. So that would be my recommendation for you - use a preloader.swf to do your loading.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...