views:

33

answers:

1

Hi, I have a large SWF flash file being loaded by a parent SWF and I would like to start playing the film being loaded, let's say, when it is 50% completed. According to my expected user's bandwidth and the size of my film I will calculate the best moment to do that (the film could be 20%, 30% or 50% loaded). I want to leave users waiting the minimum and I don't need to wait until my flash is 100%.

Ok, that said, here is the problem. I am in ActionScript 3. I have one film loading another and I want to anticipate the loaded film start. I have an onProgressHandler(mProgress:ProgressEvent) function (with listener launched by ProgressEvent.PROGRESS) and I have a regular onLoadComplete(e:Event) function (with listener launched by Event.COMPLETE). I could check for 20% completed during my regular onProgressHandler. But then, when I have identified this point has been reached, how can I anticipate the launching of the film? I mean, my Event.COMPLETE handler passes the e:Event and I can use e.target to get the loaded object into my film. But what happens if I want to start that process before it is complete? I cannot pass this e:Event because the COMPLETE handler hasn't been launched yet...

One important thing to say. The film that is loading is almost empty. It is very light. The heavy film is the one being loaded and I want to attach that film being loaded to a movie clip in my film before it has completed loading. Is that possible?

I hope I have made myself clear. In case I haven't, I will try to explain further.

Any assistance will be very much appreciated. Thank you so much.

A: 

Hi, the progressEvent has a bytesLoaded property that you can use to decide when to start your movie. By knowing the total bytes, and the bytes loaded, all you have to do is set a time interval to determine the user's actual download speed. Once you have all that information, you'll be able to determine if the user has downloaded enough to start the movie.

Check the adobe site for more on ProgressEvent: http://www.adobe.com/livedocs/flash/9.0/ActionScriptLangRefV3/flash/events/ProgressEvent.html

escapetheory.com.au

Garrt
Ok, I get it and I am doing more or less that. My doubt is: how can I invoke the same stuff I would with the Event.COMPLETE before having reached it? I need the e:Event that holds the loaded film in order to do something like the following:var loaderInfo:LoaderInfo = e.target as LoaderInfo;var loaded_swf = e.target.content;loaded_swf.x = 50;loaded_swf.y = 50;mc_control.addChild(loaded_swf);
Marcos Buarque
@Marcos Buarque. Loader is a DisplayObject. You already have a reference to it; if you don't store the loader as a timeline or class variable so you can access it from your event handler. So, you can addChild it instead of the content. You can also change it's `x, `y`, `width`, etc. For most purposes, it's the same as changing the content itself, except you don't have to wait until it's loaded.
Juan Pablo Califano
your function is parsing an Event type argument (for the complete event), but in reality you can take any Event. I think ProgressEvent extends from Event, so your function can be like:onProgressEvent(event:Event):void{if(enoughLoaded){onComplete(event);}}
Garrt