Skip to main content
Inspiring
October 27, 2009
Question

loaded external swfs with transitions

  • October 27, 2009
  • 1 reply
  • 1302 views

I need help getting my loaded swf files to play the "out" transition before the next movie loads. I have a main swf with 5 buttons (movie clips) that load external swf onto the stage. package {     import flash.display.MovieClip;     import flash.display.SimpleButton;     import flash.display.Loader;     import flash.net.URLRequest;     import flash.events.MouseEvent;     import flash.events.*;        public class V2 extends MovieClip     {         private var sections_array:Array;         private var section_buttons_array:Array;                private var loader:Loader;               private var sectionHolder  : MovieClip;                private var swf:String;                private var currentSection:int=0;         private var nextSection:int;                private var id:int=0;         private var homeLoc = "./swfs/home.swf";                public function V2()         {             init();         }                private function init():void         {             stop();             stage.frameRate=31;                        preloader_mc.visible=false;             preloader_mc.fill_mc.width=0;                        sectionHolder = new MovieClip();             sectionHolder.x = 37;             sectionHolder.y = 42;                       addChild( sectionHolder );                                  sections_array = new Array('./swfs/section1.swf',             './swfs/section2.swf',             './swfs/section3.swf',             './swfs/section4.swf',             './swfs/section5.swf');             section_buttons_array = new Array(btn1,btn2,btn3,btn4,btn5);                        addMenuListener();             addMenuEvents();             loadHome();                    }            private function addMenuListener():void         {             for(var i:int=0;i < section_buttons_array.length;i++)             {                 section_buttons_array.id=i;                 section_buttons_array.addEventListener(MouseEvent.MOUSE_DOWN,loadSectionHand ler);             }         }                   private function loadHome():void         {             swf=homeLoc;//sections_array[0];             var request:URLRequest=new URLRequest(swf);             loader=new Loader();             initListeners(loader.contentLoaderInfo);             loader.load(request);             id=0;                    }                private function changeSection(m:MouseEvent):void         {             id=m.currentTarget.id+1;             loader.unload();             //             sectionHolder.removeChild(loader);             removeListeners(loader.contentLoaderInfo);             loadSection(m.target.parent.id+1);                    }                private function loadSectionHandler(evt:MouseEvent)         {             id = evt.currentTarget.id;             loadSection(id);                    }                       private function loadSection(n:int):void         {             swf=sections_array[id];             var request:URLRequest=new URLRequest(swf);             initListeners(loader.contentLoaderInfo);             loader.load(request);                               }                private function initListeners(dispatcher:IEventDispatcher):void         {             dispatcher.addEventListener(Event.OPEN,start);             dispatcher.addEventListener(ProgressEvent.PROGRESS,atLoading);             dispatcher.addEventListener(Event.COMPLETE,completed);         }                private function removeListeners(dispatcher:IEventDispatcher):void         {             dispatcher.removeEventListener(Event.OPEN,start);             dispatcher.removeEventListener(ProgressEvent.PROGRESS,atLoading);             dispatcher.removeEventListener(Event.COMPLETE,completed);         }                private function start(event:Event):void         {             preloader_mc.visible=true;         }                private function atLoading(event:ProgressEvent):void         {             var n:uint=(event.bytesLoaded/event.bytesTotal)*100;             preloader_mc.fill_mc.width=n;         }                   private function completed(event:Event):void         {             sectionHolder.addChild(loader);              preloader_mc.visible=false;         }                private function stopAll():void         {             for(var i:int=0;i < section_buttons_array.length;i++)             {                 section_buttons_array.stop();                 sections_array.stop();                            }         }                private function addMenuEvents():void         {             for(var i:int=0;i < section_buttons_array.length;i++)             {                 section_buttons_array.mouseChildren=false;                 section_buttons_array.buttonMode=true;                                section_buttons_array.id=i;                 section_buttons_array.isPressed=false;                                section_buttons_array.addEventListener(MouseEvent.MOUSE_OVER,setOver);                 section_buttons_array.addEventListener(MouseEvent.MOUSE_OUT,setOut);                 section_buttons_array.addEventListener(MouseEvent.MOUSE_DOWN,setDown);                 section_buttons_array.addEventListener(MouseEvent.MOUSE_UP,setUp);             }         }                private function setOver(evt:MouseEvent):void         {             if(evt.target.isPressed==false)                 evt.target.gotoAndStop(2);         }                private function setOut(evt:MouseEvent):void         {             if(evt.target.isPressed==false)                 evt.target.gotoAndStop(1);         }                private function setDown(evt:MouseEvent):void         {             nextSection=evt.target.id;             checkState(evt.target.id);                        evt.target.gotoAndStop(3);             loadSection(1);             currentSection=evt.target.id;                    }         private function setUp(evt:MouseEvent):void         {             if(evt.target.isPressed==false)                 evt.target.gotoAndStop(1);         }                private function checkState(n:int):void         {             for(var i:int=0;i < section_buttons_array.length;i++)             {                 if(i==n)                     section_buttons_array.isPressed=true;                 else                 {                     section_buttons_array.isPressed=false;                     section_buttons_array.gotoAndStop(1);                                    }             }         }                       private function removeSWF(e:Event):void         {             loader.unload();             removeEventListener("removeMe", removeSWF);             var request:URLRequest = new URLRequest(swf);             loader.load(request);         }                private function onClick(e:MouseEvent):void         {         targetID = e.currentTarget.id;         addEventListener("removeMe", removeSWF);         MovieClip(loader.content).play();         }         private function removeSWF(e:Event):void         {         loader.unload();         removeEventListener("removeMe", removeSWF);                }     } } The loaded swf has a stop() an intro animation and on the last frame have. dispatchEvent(new Event("removeMe", true));

This topic has been closed for replies.

1 reply

BlokeAuthor
Inspiring
October 29, 2009

Can anyone help me? Thanks.

October 30, 2009

your isse begins here ..

loadSection()

you use the same loader to not only load files but you are tyring to use it to target the movieClip you also want to play.

The issue is loader.  The loader can only reference one load at a time.. otherwise you screw up your listeners and the ability to unload files properly.

You should load all files in Your current system as its own variable so that while one loads you can still control a movie.

So what type of end transitions do your files have?

What exactly with this seems like youre getting an issue.. looking at it looks alright aside from the fact that some methods are not used at all by your class
BlokeAuthor
Inspiring
October 30, 2009

Right now its a simple text moving on the screen. Then it stops. Then a simple "out transitions plays. Then on the last frame I have:

dispatchEvent(new Event("removeMe", true));