|
-
is there a problem with unloadClip() ?
Hi everybody. I need your help.
I´ve been searching the web about this but noone seems to give a good
answer to the problem.
I´m using several LoadClips at the same time to load multiple parts of different avatars in a blog: There are 7 loadClip() for each avatar and i´m loading 10 different avatars. Each piece is around 1kb.
If the user clicks on another area of the site,I need all avatars to stop loading so I can load the new area. The problem is that i get them to ignore the load,with unloadClip() but apparently they keep loading "in the background" until they´re done even if they won´t show. So, the new area i´m trying to load, won´t load until all of the others are done.
I have done several attempts and tests. I have tried to use unloadClip(), i´ve tried to load a "null" object instead, and I have also tried to remove the listeners. I have even tried all 3 at the same time!!! But none of them do the trick. Is there something i´m missing? Has anyone found this problem?
thanks!
-
Senior Member
try to use delete to delete the clip in conjunction with unloadClip(); the problem is that the garbage collector isn't going to pick up on the unloaded clip asap it has a predetermined schedule so usually things like to completely load before unloading them...might i suggest instead of unloading the clip you replace it with an empty movie clip using loadClip so that it just appears to have unloaded doing so will overwrite the old clip and probably cause it to stop loading.
-
According to the flash docs:
unloadClip()
Removes a movie clip that was loaded by using MovieClipLoader.loadClip(). If you issue this command while a movie is loading, MovieClipLoader.onLoadError is invoked.
i'm not sure how to go about stopping a loading clip, but the above would explain why it doesn't stop loading.
-
i know you said you tried to load a null object...just wondering if this is what you did or not...I found this on another forum.
Code:
mcLoader.loadClip("null", yourContainer);
-
I made some more tests. Including deleting the MovieClipLoader. Also deleting the Listener. and removing the Mc.
Yes, that´s the way i tried to load a "null" object:
Code:
mcLoader.loadClip("null", yourContainer);
but nothing works.
I also tried to load a new swf on each, called voidClip.swf that is empty on the same MovieClipLoader and apparently it still loads first the ones I unloaded and then it starts loading the new ones. That shouldn´t happen. It´s really strange.
I wonder if it is because they are so small that they are considered as a "chunk" of bytes that it can´t stop.
-
Senior Member
yeah its probably already loaded in memory and flash is processing it. maybe you should rethink your routine and make it work a slightly diffrent way that still achives the same objective or at least statifys your objective.
-
i've spent many hour today on this problem
the mcLoader.loadClip("null", mc) method doesn't work for me (search the web, you'll find other)
the only way i've found to stop load jobs in as2 is to call mcLoader.unloadClip AFTER loadStart:
here's the complete and working code for lazy coders (like me):
Code:
this.createEmptyMovieClip("image_mc", this.getNextHighestDepth());
var mclListener:Object = new Object();
var image_mcl:MovieClipLoader = new MovieClipLoader();
mclListener.stopOnStart = false;//used to stop load also if is not started
mclListener.loadStarted = false;//used to know if load is already started
mclListener.mc = image_mc;
mclListener.mcl = image_mcl;
mclListener.onLoadStart = function(target_mc:MovieClip) {
trace("starting load...")
if(this.stopOnStart) this.mcl.unloadClip(target_mc);
else this.loadStarted = true;
};
mclListener.stopLoad = function(){
if(this.loadStarted) this.mcl.unloadClip(this.mc);
else this.stopOnStart = true;
}
image_mcl.addListener(mclListener);
image_mcl.loadClip("http://www.robertedselblog.com/wp-content/uploads/2006/12/happy-face_happyface_smiley_2400x2400.jpg?random="+random(999999999), image_mc);
if(you_want_to_test_before_load_start){
mclListener.stopLoad()
}
else{
button.onRelease = function(){mclListener.stopLoad()}
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|