Jump to content
Search Community

stop a loading?

Sil3noz test
Moderator Tag

Recommended Posts

hello!

im tryin to load into 2 different swapping mc (mcSwap1 and mcSwap2) some images.

private var backgroundLoader:ImageLoader;
private var backgroundLoader2:ImageLoader;
private var mcSwap1:MovieClip;
private var mcSwap2:MovieClip;

im gonna write here only methods of the first mc to keep it simple:

backgroundLoader = new ImageLoader("../images/full/"+url, {name:"backgroundImage1", container:mcSwap1, onComplete:fadeInBackground });
backgroundLoader.load();

...when the loading is finished, i start the fadein of the mcs with fadeInBackground

private function fadeInBackground(event:LoaderEvent):void
{
event.target.content.alpha=0;
//swap dephts of mcs
swapChildren(mcSwap1,mcSwap2);
TweenMax.to(event.target.content, .5, {alpha:1,onComplete:cleanPreviousBackground});
}

when the fadein is finished, i succesfully clean the memory, without make null the backgroundLoader2 ( i need the movieclip swap2 visible )

private function cleanPreviousBackground():void{ backgroundLoader2.unload(); backgroundLoader2.dispose(); }

 

the question is...how can i abort a loading when i fastclick on some thumbnail, without cleaning it with null? i need the movieclip visible!

thanks a lot

Link to comment
Share on other sites

You just need to change the logic in your code to account for fast clicks. Maybe something like:

 

var curBgLoader:ImageLoader;
var nextBgLoader:ImageLoader;
var exitingBgLoaders:Array = [];

private function setBackground(url:String):void {
   nextBgLoader = new ImageLoader(url, {onComplete:onBgLoadComplete});
   nextBgLoader.load();
}

private function onBgLoadComplete(event:LoaderEvent):void {
   if (nextBgLoader == event.target) {
       if (curBgLoader != null) {
           TweenLite.to(curBgLoader.content, 0.5, {alpha:0, onComplete:killLoader, onCompleteParams:[curBgLoader]});
       }
       curBgLoader = nextBgLoader;
       addChild(curBgLoader.content);
       TweenLite.from(curBgLoader.content, 0.5, {alpha:0});
   } else {
       event.target.dispose(); //it's not the latest bg, so just dump it (fast clicks could account for another one supplanting this before it loaded)
   }
}

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...