Jump to content
Search Community

poundcake

Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by poundcake

  1. 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}); }
  2. Thanks again Carl for your thorough reply. Yes I did have some missing code and I'm taking your advice and moving all script to the main timeline which is solving an issue I have with a video player. Writing a functions from within a TimelineLite with a delayed call appears to be a godsend, so I will tackle it next. Thanks again for all your time and help!
  3. I apologize to drag this on from a previous post (viewtopic.php?f=6&t=5042&p=19915#p19915) but I was wondering how can I unload the swfs that are inside a movieclip from the root timeline? I have four nav sections/movieclips set up on the stage, one of which is titled "gallery_mc". Within this "gallery_mc" are buttons that load the swfs. I implemented the TimelineLite system which will unload and load each section depending on the selection. However when I click to go back to "gallery_mc", any swf that was previously loaded will still be visible. The only workable solution I have is using the TimeLineLite method by putting the following script on frame 1 of the "gallery_mc." while moving the rest of script to frame 2 of the MC. Code on Frame 1 of "gallery_mc" loader.unload(); TweenLite.to(loader.content, 1, {alpha:0}); Code on Frame 2 of "gallery_mc" pic1.addEventListener(MouseEvent.CLICK, btnClick1); pic2.addEventListener(MouseEvent.CLICK, btnClick2); pic1.buttonMode=true; pic2.buttonMode=true; function btnClick1(e:MouseEvent) { if(loader){ loader.dispose(true); } loader =new SWFLoader("swfs/pic1.swf" ,{container:this,x:170,y:300,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:300,alpha:0,onComplete:completeHandler}) loader.load(); } function completeHandler(e:LoaderEvent):void { TweenLite.to(e.target.content, 0.75, {alpha:1}); } function navOut(e:MouseEvent):void { TweenLite.to(loader.content, 1, {alpha:0, onComplete:disposeLoader}); } function disposeLoader() { loader.unload(); } While this code is on the main timeline tl.addLabel("gallery_in", tl.duration); tl.append(TweenMax.to(gallery_mc, 0, {alpha:1, immediateRender:false, onStart:setSection, onStartParams:["gallery"]})); tl.append(TweenMax.to(gallery_mc, 1.1, {frame:2})); tl.addLabel("gallery_complete", tl.duration); tl.append(TweenMax.to(gallery_mc, .25, {alpha:0})) However I get the error "TypeError: Error #1009: Cannot access a property or method of a null object reference." Would a possible solution be to write a new event listener on the main timeline? I'm not sure how to approach this. I would be grateful for any direction.
  4. This works great, thanks! I'm learning from your 2nd example as well. Cheers!
  5. Thanks for the reply. I apologize as I don't think I was clear but what I was aiming to do was for multiple buttons to load in external swfs but replace one another, similar to what is achieved in my first post. The code below loads one on top of another, atlhough I'm not entirely sure if what I have is correct. stop(); import com.greensock.*; import com.greensock.loading.*; import com.greensock.easing.*; import com.greensock.events.LoaderEvent; pic1.addEventListener(MouseEvent.CLICK, btnClick); pic2.addEventListener(MouseEvent.CLICK, btnClick); pic1.buttonMode=true; pic1.buttonMode=true; var loader:SWFLoader; function btnClick(e:MouseEvent) { loader =new SWFLoader(e.target.name + ".swf",{container:this,x:150,y:0,alpha:0,name:"swfs/",onComplete:completeHandler}); loader.load(); } function completeHandler(e:LoaderEvent):void { TweenLite.to(e.target.content, 1, {alpha:1}); } function navOut(e:MouseEvent):void { TweenLite.to(loader.content, 1, {alpha:0, onComplete:disposeLoader}); } function disposeLoader() { loader.unload(); }
  6. I'm new to AS3 and really enjoying the tweening engine. Unfortunately I'm a tad out of my element when it comes to loading swfs and I can't quite grasp what I would like to achieve using the LoaderMax engine. Essentially I would like to have multiple buttons that will load external swfs. I found this code useful for what I was trying to achieve, though I don't know if its the most effecient way... var Xpos:Number = 50; var Ypos:Number = 180; var swf:MovieClip; var loader:Loader = new Loader(); var defaultSWF:URLRequest = new URLRequest("swfs/example1.swf"); loader.load(defaultSWF); loader.x = Xpos; loader.y = Ypos; addChild(loader); //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Btns Universal function function btnClick(event:MouseEvent):void { removeChild(loader); var newSWFRequest:URLRequest = new URLRequest("swfs/" + event.target.name + ".swf"); loader.load(newSWFRequest); loader.x = Xpos; loader.y = Ypos; addChild(loader); } // Btn listeners example1.addEventListener(MouseEvent.CLICK, btnClick); example2.addEventListener(MouseEvent.CLICK, btnClick); example3.addEventListener(MouseEvent.CLICK, btnClick); example3.addEventListener(MouseEvent.CLICK, btnClick); However, I would like to incorporate the tweening engine to alpha in the images similar to this past forum post below. My knowledge of syntax is weak and I'm just not sure how to reference the container. It would be great to have specific control for each button. Any help would be immensely appreciated. Thanks! viewtopic.php?f=6&t=4693&p=18813&hilit=load+external+swf#p18813 op(); import com.greensock.*; import com.greensock.loading.*; import com.greensock.easing.*; import com.greensock.events.LoaderEvent; example1.addEventListener(MouseEvent.CLICK, btnClick); example1.buttonMode=true; var loader:SWFLoader =new SWFLoader("swfs/example1.swf",{container:this,x:150,y:0,alpha:0,name:"swf1",onComplete:completeHandler}); trace(loader); function btnClick(e:MouseEvent) { loader.load(); } //this function was nested in navOver I moved it out function completeHandler(e:LoaderEvent):void { TweenLite.to(e.target.content, 1, {alpha:1}); } function navOut(e:MouseEvent):void { TweenLite.to(loader.content, 1, {alpha:0, onComplete:disposeLoader}); } function disposeLoader() { loader.unload(); }
×
×
  • Create New...