Jump to content
Search Community

problems with controlling loaded swfs in TimeLineMax

poundcake test
Moderator Tag

Recommended Posts

I'm hoping for some help on an issue that I can't resolve.

 

I have a swf load up when the user clicks on a nav item and the section plays. What I'm trying to achieve is when the user clicks on a button within the section, the original swf is then replaced but whats happening is that I have two swfs loaded on stage. The original swf that loads up stays and I can't get rid of it. Any other swf controlled by the buttons will work fine and will disapear when another section is clicked or replaced by another button click.

 

This all worked fine and dandy but when I incorporated TimeLineMax in the script, the above is what happened.

 

Please, could I get some help?

 

var mytl:TimelineMax = new TimelineMax();

var loader:SWFLoader;

function LoadMySwf():void {	
	loader  =new SWFLoader("swfs/pic1.swf" ,{container:holder,x:170,y:300})
	loader.load();
}

function resetProjects():void {
     TweenLite.to(loader.content, 0.5, {alpha:0,onComplete:disposeLoader}); 		
}	
function disposeLoader() {           
             loader.unload(); 
}

mytl.addLabel("projects_in", mytl.duration);
mytl.appendMultiple(TweenMax.allTo([projects_mc,btn_arrowLeft,btn_arrowRight], 0, {alpha:1, immediateRender:false, onStart:setSection, onStartParams:["projects"]}));
mytl.appendMultiple(TweenMax.allTo(mcs, 0.8,{currentProgress:1,y:100, ease:Back.easeOut, onComplete:LoadMySwf},-0.1));
mytl.addLabel("projects_complete", mytl.duration);
mytl.append(TweenMax.to(projects_mc, 0.25, {alpha:0,onComplete:resetProjects}));
mytl.appendMultiple(TweenMax.allTo([btn_arrowLeft,btn_arrowRight],0.8, {scaleX:0.5, scaleY:0.5, alpha:0, ease:Back.easeOut}, 0.4))

function btnClick1(e:MouseEvent) {
if(loader){
	loader.dispose(true);
       }				
	 loader  =new SWFLoader("swfs/pic1.swf" ,{container:holder,x:170,y:-100,alpha:0,onComplete:completeHandler})		
      	         loader.load();		
}   

function btnClick2(e:MouseEvent) {
if(loader){
	loader.dispose(true);
       }		
        loader  =new SWFLoader("swfs/pic2.swf" ,{container:this,x:170,y:-100,alpha:0,onComplete:completeHandler})        
       	loader.load();
}   
function completeHandler(e:LoaderEvent):void {
        TweenLite.to(e.target.content, 0.75, {alpha:1});
}

Link to comment
Share on other sites

I didn't notice any glaring issues except that you didn't make sure that you killed any tweens of the old/stale swf before disposing its loader. If there are still tweens of it running, it could get in the way of garbage collection - that's not a bug/problem with LoaderMax or TweenLite; it's just how Flash gc works. Try killing your timeline or use TweenLite.killTweensOf() to kill the tweens of your object before disposing the swf's loader. If that doesn't work, please post a simple set of files that we can publish to see the problem replicated. Oh, and make sure you've got the latest version(s) of the GreenSock classes.

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