Skip to main content
Inspiring
August 28, 2008
Question

MovieClipLoader's loadClip method is loading swf before its downloaded 100%??

  • August 28, 2008
  • 6 replies
  • 831 views
Hello everyone,

I created a MovieClipLoader a few days ago that is reuseable. I will be using the same preloader graphics when I am loading in external swf on my stage. My MovieClipLoader functions fine with jpegs and smaller sized swf files. But whenever I load a larger sizes swf it loads the movie before it has fully downloaded in simulation mode. The odd part is that everything works fine with smaller swf files but not larger ones . I have tested a few movies and that seems to be the common theme.

In the example below main.swf is the clip I am loading into "mcBackground".

var mclTV : MovieClipLoader = new MovieClipLoader ();
var loadListener : Object = new Object ();
// events it will handle
loadListener.onLoadStart = function ()
{
trace ("onLoadStart");
trace (this._target);
progress_mc._y == 268;
txtLoaded._visible = true;
progress_mc._visible = true;
};
loadListener.onLoadProgress = function (target : MovieClip, bytesLoaded : Number, bytesTotal : Number)
{
txtLoaded.text = String (Math.floor (bytesLoaded / bytesTotal * 100)) + "% loaded";
progress_mc._xscale = bytesLoaded / bytesTotal * 100;
};
loadListener.onLoadComplete = function ()
{
trace ("onLoadComplete");
txtLoaded._visible = false;
progress_mc._visible = false;
};
mclTV.addListener (loadListener);
mclTV.loadClip ("main.swf", mcBackground); //mcBackground is an empty movieClip on the stage
txtLoaded._visible = false;
progress_mc._visible = false;


This topic has been closed for replies.

6 replies

fcastro75Author
Inspiring
September 4, 2008
Sorry Rothrock!! I must have been really tired yesterday when I posted back. Very interesting I think I understand what you are getting at now. I am going to give it a go and post back as soon as I get my work done :)

Inspiring
September 4, 2008
Dave's not here man. :)

Nope. Not at all what I'm saying, and maybe Dave does it differently.

This code would go into the file that is the external file.

Then in your onLoadInit handler you would have:

target.activate();

fcastro75Author
Inspiring
September 4, 2008
Dave thanks for the input.

So your saying to create a function called activate and place is it within the onLoadInit and then have an if/else statement placed with the onLoadStart?

Inspiring
September 4, 2008
Not sure exactly what Dave does, but here is what I would do:

On the first frame of the main timeline of your clip:

var home:MovieClip=this;

function activate{
home.play();
delete activate;
}

if(this != _root){
this.stop();
} else {
delete activate;
}

I would also put artwork on the frame of a alpha=0 rectangle the size of the stage so that loading documents would be able to figure out the size of the swf.

The first bit defines the current timeline as "home." The next bit defines the activate function. By saying home.play() we are sure that it is the scope of the loaded swf and not the scope calling the function (maybe the event handler scope)? And finally deletes itself when it has been called. This should prevent some kind of accidental multiple call when you don't want.

The next bit checks to see if the main timeline is the _root. If it isn't then we stop and wait. If it is the main timeline then we don't stop and we delete the activate function.

I haven't tested it, but that seems like what I would do.

fcastro75Author
Inspiring
September 4, 2008
Dave thanks for the reply.

I have traced the problem to be that the movie that I have loading in does not have a stop action on the first frame (similar to what you mean't by suppose to stream). So what I did was added a stop(); withing the onLoad and then a play(); with in the onLoadInit.

I tried inserting a stop() within the movie I was loading but it seems flash only sees the main container I am loading into and not the actual movie.

I am interested in this approach about adding a activate() function could you post an example? I don't see a way of targeting the movie clip that is loading. I can target the container which is why the play and stop work.
Inspiring
August 28, 2008
You should use onLoadInit instead of onLoadComplete.

Also, depending on the file you're loading - swf files are meant to stream.
What I do is all my content files have an activate() function in them. That
function is called in the onLoadInit method of the loader.

--
Dave -
www.offroadfire.com
Head Developer
http://www.blurredistinction.com
Adobe Community Expert
http://www.adobe.com/communities/experts/