Public var and External swf

Hello!
I have some problem with vars. The situation is the same I wrote here Re: External swf
I have public var (for example ZZZ) in code of MAIN.swf (main class is Main.as), and I want to access it from code of loaded EXTERNAL.swf.
But nothing helps, flash says:
there is no ZZZ in code of Main
there is no ZZZ on stage.root
there is no ZZZ in any parents.
But if a have ZZZ in code of EXTERNAL, and want to access it from MAIN,  (the reverse situation), ZZZ is easily found.

Worked that:
I should pass to EXTERNAL
this
as exact pass, and then
ExactPass.ZZZ
would be found
in External:
public var GAME_MAIN_CODE:*;
in Main:
EXTERNAL.GAME_MAIN_CODE = this;
Thank you for help!

Similar Messages

  • Problem with volume handle and external SWF

    Hello I'm having 2 problems.
    The first is that when loading an external swf in my main SWF I get this in the output window:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at audio_fla::list_1/frame1()
    at flash.display::Sprite/constructChildren()
    at flash.display::Sprite()
    at flash.display::MovieClip()
    at audio_fla::MainTimeline()
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at audio_fla::MainTimeline/frame1()
    But it still works. Its an mp3 player.
    The other problem is that the loaded SWF has a volume controller. When I test the external SWF by itself it works fine. When I load it on my main SWF when I start to drag the handle on my volume slider and MOUSE_UP outside the handle it still keep dragging the handle.
    The code of my main SWF is:
    import caurina.transitions.*;
    var _currentCategory:String = "";
    var percent:String = "";
    var loader = new Loader();
    loader.name="videoLoader";
    loadermc.visible=false;
    cat.addEventListener(MouseEvent.MOUSE_OVER, onOverCat);
    cat.addEventListener(MouseEvent.MOUSE_OUT, onOutCat);
    cat.addEventListener(MouseEvent.CLICK, onClickCat);
    btnback.addEventListener(MouseEvent.MOUSE_OVER, onOverCat);
    btnback.addEventListener(MouseEvent.MOUSE_OUT, onOutCat);
    btnback.addEventListener(MouseEvent.CLICK, onClickBack);
    cat.buttonMode = true;
    btnback.buttonMode = false;
    btnback.visible = false;
    function onOverCat(e:MouseEvent):void{
         Tweener.addTween(e.target, {alpha:.5 , time:.5});
    function onOutCat(e:MouseEvent):void{
         Tweener.addTween(e.target, {alpha:.25 , time:.5});
    function onClickBack(e:MouseEvent):void{
         loader.unloadAndStop();
         loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
         lcontent.visible = false;
         cat.visible = true;
         Tweener.addTween(cat, {alpha:1, time:1});
         btnback.buttonMode = false;
         btnback.visible = false;
         cat.buttonMode = true;
         toptxt.text = "SELECCIONE UNA CATEGORIA"
    function onClickCat(e:MouseEvent):void{
         lcontent.visible=true;
         cat.buttonMode = false;
         Tweener.addTween(cat, {alpha:0, time:1, onComplete:function(){
                                  cat.visible = false;                                                       
                                  btnback.buttonMode = true;
                                  btnback.visible = true;
                                       loaderTweenIn(e.target.name);
    function loaderTweenIn (c:String):void{
         var category:String = c+".swf";
         trace(category);
         loader.load(new URLRequest(category));
         loader.contentLoaderInfo.addEventListener (Event.COMPLETE, movieLoaded);
            loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, movieProgress);
    function ioErrorHandler(e:IOErrorEvent):void{
         trace("ioErrorHanlder: "+e);
    function movieLoaded(e:Event):void{
         trace("The movie has loaded");
         lcontent.addChild(loader);
         loadermc.visible=false;
    function movieProgress(e:ProgressEvent):void{
         loadermc.visible = true;
    //     percent=String(Math.floor(e.bytesLoaded / e.bytesTotal * 100)) + "%";
         trace("The movie is loading "+Math.floor(e.bytesLoaded / e.bytesTotal * 100));
    The code on my external SWF is:
    import caurina.transitions.*;
    volume_mc.slider_mc.buttonMode = true;
    var myXML:XML;
    var thb:Thbs;
    var myThumbs:XMLList;
    var totalThumbs:Number;
    var thumbHeight:Number=50;
    var i:uint = 0;
    var preloader:LoaderAnim;
    var yCounter:Number = 0;
    var container:MovieClip;
    var musicReq:URLRequest;
    var music:Sound = new Sound();
    var sc:SoundChannel;
    var currentSound:Sound = music;
    var pos:Number;
    var songPlaying:Boolean = false;
    var songlist:XMLList;
    var currentIndex:Number = 0;
    mc_sound.mute.visible=false;
    var xmlLoader:URLLoader = new URLLoader();
    ///////////////////////////PLAYLIST//////////////////
    function initMediaPlayer(e:Event):void{
         myXML = new XML(xmlLoader.data);     
         myThumbs = myXML.*;
         totalThumbs = myThumbs.length();
         trace("The total thumbs are "+totalThumbs);
         createContainer();
         callThumbs();
    xmlLoader.load(new URLRequest("audio.xml"));
    function createContainer():void{
         container = new MovieClip();
         list.ch.addChild(container);
         container.y = 0;
         container.x = 0;
         container.buttonMode = true;
    function onOver(e:MouseEvent):void{
         var t:Loader = Loader(e.target);
         Tweener.addTween(t, {alpha:.5, time:1});
    function onOut(e:MouseEvent):void{     
         var t:Loader = Loader(e.target);
         Tweener.addTween(t, {alpha:1, time:1});
    function callThumbs():void{
              var thumbURL = myThumbs[i].@thumb;
              var thumbTitle:String = myThumbs[i].@title;
              var thumbDesc:String = myThumbs[i];
              trace("Loading "+thumbURL);
              trace("Title "+thumbTitle);
              trace("Desc "+thumbDesc);
              var thumbLoader = new Loader();
              thumbLoader.load(new URLRequest(thumbURL));
              thumbLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, thumbLoaded);
              thumbLoader.name=i;
              thumbLoader.x=5;
              thumbLoader.y=5;
              thb = new Thbs();
              container.addChild(thb);
              thb.thb_title.htmlText = thumbTitle;
              thb.thb_desc.autoSize = TextFieldAutoSize.LEFT;
              thb.thb_desc.htmlText = thumbDesc;
              thb.y = (thumbHeight+2)*yCounter;
              preloader = new LoaderAnim();
              preloader.x = thb.x + 20;
              preloader.y = thb.y+ 20;
              container.addChild(preloader);
              yCounter++;
    function thumbLoaded(e:Event):void{
         var thbx:Loader = Loader(e.target.loader);
         thb.addChild(thbx);
         thbx.addEventListener(MouseEvent.MOUSE_OVER, onOver);
         thbx.addEventListener(MouseEvent.MOUSE_OUT, onOut);
         container.removeChild(preloader);
         i++;
         if (i<totalThumbs){
              callThumbs();
         if (i==totalThumbs){
              startAudio();
    xmlLoader.addEventListener(Event.COMPLETE, initMediaPlayer);
    ///////////////////////////////////////AUDIO//////////////////////////
    function startAudio():void{
         songlist = myXML.*;;//this is the same as myXML.*;
         trace("This is the first song "+songlist[0].@song);
         musicReq = new URLRequest(songlist[0].@song);
         music.load(musicReq);
         sc = music.play();
         sc.addEventListener(Event.SOUND_COMPLETE, nextSong);     
    next_btn.addEventListener(MouseEvent.CLICK, nextSong);
    prev_btn.addEventListener(MouseEvent.CLICK, prevSong);
    pause_btn.addEventListener(MouseEvent.CLICK,pauseSong);
    stop_btn.addEventListener(MouseEvent.CLICK,stopSong);
    function nextSong(e:Event):void
         if (currentIndex < (songlist.length() - 1))
              currentIndex++;
         else
              currentIndex = 0;
         var nextReq:URLRequest = new URLRequest(songlist[currentIndex].@song);
         var nextTitle:Sound = new Sound(nextReq);
         sc.stop();
         sc = nextTitle.play();
         songPlaying = true;
         currentSound = nextTitle;
         sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
    function prevSong(e:Event):void
         if (currentIndex > 0)
              currentIndex--;
         else
              currentIndex = songlist.length() - 1;
         var nextReq:URLRequest = new URLRequest(songlist[currentIndex].@song);
         var prevTitle:Sound = new Sound(nextReq);
         sc.stop();
         sc = prevTitle.play();
         songPlaying = true;
         currentSound = prevTitle;
         sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
    function pauseSong(e:Event):void
         pos = sc.position;
         sc.stop();
         songPlaying = false;
         play_btn.addEventListener(MouseEvent.CLICK,playSong);
    function playSong(e:Event):void
         if(songPlaying == false)
              sc = currentSound.play(pos);
              sc.addEventListener(Event.SOUND_COMPLETE, nextSong);
              songPlaying = true;
              play_btn.removeEventListener(MouseEvent.CLICK,playSong);
    function stopSong(e:Event):void
         sc.stop();
         pos = 0;
         songPlaying = false;
         play_btn.addEventListener(MouseEvent.CLICK,playSong);
    ///////////////////////////////VOLUME/////////////////////////////
    var xOffset:Number;
    var xMin:Number = 0;
    var xMax:Number = volume_mc.track.width;
    volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, sliderDown);
    volume_mc.slider_mc.addEventListener(MouseEvent.MOUSE_UP, sliderUp);
    stage.addEventListener(MouseEvent.MOUSE_UP, sliderUp);
    function sliderDown(e:MouseEvent):void{
         stage.addEventListener(MouseEvent.MOUSE_MOVE, sliderMove);
         xOffset = mouseX - volume_mc.slider_mc.x;
    function sliderUp(e:MouseEvent):void{
         stage.removeEventListener(MouseEvent.MOUSE_MOVE, sliderMove);
    function sliderMove(e:MouseEvent):void{
         volume_mc.slider_mc.x = mouseX - xOffset;
         if(volume_mc.slider_mc.x<=xMin){
              volume_mc.slider_mc.x = xMin;
         if(volume_mc.slider_mc.x>=xMax){
              volume_mc.slider_mc.x = xMax;
         var vol:Number = volume_mc.slider_mc.x*.01;
         var st:SoundTransform = new SoundTransform(vol,0);
         sc.soundTransform = st;
         trace("The volume is "+vol);
         if(vol==0){
              mc_sound.mute.visible=true;
         }else{
              mc_sound.mute.visible=false;
         e.updateAfterEvent();

    I found the solution.

  • Flv and external swf files

    Hi,
    Does somebody knows what is happening?
    I'm using the mcLoader class to load all my external swf
    files, everything worket perfectly until I decided to use
    flvPlayBack on one of those external files. If the player is on my
    main stage it works great and if I run directly the loaded swf it
    also works, but now when i run the external swf through the
    mcLoader the player doesn't appears.
    my mcLoader code:
    var mcLoader01:MovieClipLoader = new MovieClipLoader();
    mcLoader01.loadClip("clientes/targetTrade.swf",mcConatiner);
    The flvPlayer should be on the second frame of this
    targetTrade.swf ("click to watch the video")
    thanks,
    Peter

    Hi,
    You said swfs are Flash 8. Did you also set them to
    Actionscript 2? If it's
    Actionscript 3, that may be the problem. You may be
    interested in looking at the
    Flash Video templates I have at:
    http://www.deansdirectortutorials.com/FlashVideo/
    regards
    Dean
    Director Next Roadmap Survey
    http://www.deansdirectortutorials.com/survey/DirectorRoadmap/
    Director Lecturer / Consultant / Director Enthusiast
    http://www.deansdirectortutorials.com/
    http://www.multimediacreative.com.au
    email: [email protected]

  • Buttons and external swfs

    I would like to automatically load an external swf inside an existing empty mc (or a new one)  and load/unload different external swf on several button click fuctions.  I've read the other posts, but none that quite facilitates accomplishing this.
    This is what I have, I know it's messy- but I've been trying so many different methods until its probably loaded with irrelevant functions!
    var myLoader:Loader = new Loader(); addChild(myLoader); var url:URLRequest = new URLRequest("homepage.swf"); myLoader.load(url);
      myLoader.x=477;
      myLoader.y=0;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    button_1.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF);
    var fl_Loader:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad:Boolean = true;
    function fl_ClickToLoadUnloadSWF(event:MouseEvent):void
    if(fl_ToLoad)
      fl_Loader = new Loader();
      fl_Loader.load(new URLRequest("homepage.swf"));
      fl_Loader.x=477;
      fl_Loader.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4
      addChild(fl_Loader);
    else
      fl_Loader.unload();
      removeChild(fl_Loader);
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4);
      fl_Loader = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad = !fl_ToLoad;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    movieClip_2.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_2);
    var fl_Loader_2:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad_2:Boolean = true;
    function fl_ClickToLoadUnloadSWF_2(event:MouseEvent):void
    if(fl_ToLoad_2)
      fl_Loader_2 = new Loader();
      fl_Loader_2.load(new URLRequest("portfolio.swf"));
      fl_Loader_2.x=477;
      fl_Loader_2.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4);
      addChild(fl_Loader_2);
    else
      fl_Loader_2.unload();
      removeChild(fl_Loader_2);
      removeChild(fl_Loader);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_4);
      fl_Loader_2 = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad_2 = !fl_ToLoad_2;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    movieClip_3.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_3);
    var fl_Loader_3:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad_3:Boolean = true;
    function fl_ClickToLoadUnloadSWF_3(event:MouseEvent):void
    if(fl_ToLoad_3)
      fl_Loader_3 = new Loader();
      fl_Loader_3.load(new URLRequest("about.swf"));
      fl_Loader_3.x=477;
      fl_Loader_3.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader);
      removeChild(fl_Loader_4);
      addChild(fl_Loader_3);
    else
      fl_Loader_3.unload();
      removeChild(fl_Loader_3);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader);
      removeChild(fl_Loader_4);
      fl_Loader_3 = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad_3 = !fl_ToLoad_3;
    /* Click to Load/Unload SWF or Image from a URL.
    Clicking on the symbol instance loads and displays the specified SWF or image URL. Clicking on the symbol instance a second time unloads the SWF or image.
    Instructions:
    1. Replace "http://www.helpexamples.com/flash/images/image1.jpg" below with the desired URL address of the SWF or image. Keep the quotation marks ("").
    2. Files from internet domains separate from the domain where the calling SWF resides cannot be loaded without special configuration.
    movieClip_4.addEventListener(MouseEvent.CLICK, fl_ClickToLoadUnloadSWF_4);
    var fl_Loader_4:Loader;
    //This variable keeps track of whether you want to load or unload the SWF
    var fl_ToLoad_4:Boolean = true;
    function fl_ClickToLoadUnloadSWF_4(event:MouseEvent):void
    if(fl_ToLoad_4)
      fl_Loader_4 = new Loader();
      fl_Loader_4.load(new URLRequest("contact.swf"));
      fl_Loader_4.x=477;
      fl_Loader_4.y=0;
      removeChild(myLoader);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader);
      addChild(fl_Loader_4);
    else
      fl_Loader_4.unload();
      removeChild(fl_Loader_4);
      removeChild(fl_Loader_2);
      removeChild(fl_Loader_3);
      removeChild(fl_Loader);
      fl_Loader_4 = null;
    // Toggle whether you want to load or unload the SWF
    fl_ToLoad_4 = !fl_ToLoad_4;

    Kglad I read up on that but it's still not stopping.I'm publishing for  fp 10 and have tried several different variations including:
    function gofolio (e:MouseEvent):void{
    imageLoader.load(navfolio);
    addChild(imageLoader);
    imageLoader.unloadAndStop(true);
    folio_btn.addEventListener(MouseEvent.CLICK, gofolio);
    function goabout (e:MouseEvent):void{
    imageLoader.load(navabout);
    addChild(imageLoader);
    imageLoader.unloadAndStop(true);
    removeChild(imageLoader)
    imageLoader=null
    about_btn.addEventListener(MouseEvent.CLICK, goabout);
    ....still not working.

  • MouseEvent and external SWF

    I'm loading an external SWF to use as a "skin" (no components
    are involved, only MovieClips). The external SWF contains a number
    of MovieClips, each exported for Actionscript and with an
    associated class. One of these classes is, for example, called
    "Thing1".
    I'm successfully loading the SWF using Loader, etc. - I'm
    also setting its ApplicationDomain to that same one as the loading
    SWF. I can then successfully create an instance of Thing1 and add
    it to a child MovieClip of the loading SWF. All is good.. the
    problem occurs when I try to add an event listener to the instance
    of Thing1 - the event doesn't trigger.
    Here are some curious facts: IF Thing1 consists only of
    graphics, ie. no child MovieClips, then the event DOES trigger.
    Also, if I add an event listener, not to a child of Thing1, but to
    a child of a child of Thing1, then it works. BUT, a mouse event
    added to the stage of that MovieClip doesn't trigger.
    There seems to be some problem with mouse events bubbling
    across the "boundary" between Thing1 and the loading SWF.
    Anyone??

    Ha.. in the process of preparing simplified code, I figured
    out the problem. I'm developing locally, and I was loading the
    external SWF via localhost, eg.
    http://localhost/skin.swf. If
    I instead load skin.swf, the problem disappears (I was using
    localhost because I'm also loading data via PHP scripts). Thank you
    kglad, for indirectly helping me find the solution ;)

  • Both main movie and external swf preloader - confusion!

    Hi there!
    I have a webite with my main movie (88kb) and an external swf
    soundloop (1mb). I made a preloader, but it only loaded the main
    movie, meaning that after the intro, the soundloop would not start.
    I loaded the soundloop onto level 1, and then tried to make a
    preloader with this code (I thoguht it worked but it really was a
    total guess).
    stop();
    this.onEnterFrame = function() {
    bl = _level1.getBytesLoaded()+this.getBytesLoaded();
    bt = _level1.getBytesTotal()+this.getBytesTotal();
    if (bt<=0) {
    bt = 99;
    bar.gotoAndStop(Math.floor((bl/bt)*100));
    if ((bl == bt) && (bt>0)) {
    delete this.onEnterFrame;
    gotoAndPlay("Intro", 1);
    Now when I test the movie, everything loads, but when the
    soundloop is loaded after the intro, the preloader movie clip
    appears and starts playing and repeating itself!
    How on earth do I get rid of this?! You can see the problem
    here:-
    http://www.vanitee.co.uk/princess.swf
    Thanks in advance

    Please! Still in great need of help. Have tried all sorts
    =(

  • Hyperlinks and External SWF Files

    I am building a site for the company I work for and within
    the main flash CS3 document for the site I have a portfolio gallery
    with 8 sections. I created a flash file for each category and made
    a swf file where I loaded them in my main flash document. They each
    have their own layer and on their layer I placed a loader component
    for each movie so the gallery will show up when I click on that
    specific button.
    My problem is that in some of the galleries I want to direct
    my viewers to another place within another swf file.
    Example: If I have a picture displaying a piece of artwork
    and I have another piece of artwork that relates to it and I want
    to see that also.
    How do I create that link to go to another place in another
    movie (swf file). Is this even possible? Help me please.
    I am using actionscript 2.0 I have attached a temporary site
    address for a better idea of what I need help with. Go to the
    portfolio section.
    http://manganinc.pieper.com/piepert/index.htm
    null">null

    problem solved. Solution? Redo the entire f&%#ing thing. For what ever reason, it now works.
    Thanks anyways.
    James

  • How to Load/Unload external SWF

    Hey all, I'm in a desperate struggle to meet a deadline for college coursework. I am unable to UNLOAD an external SWF file that I have put inside another SWF file. The problem that is occurring is, although it loads successfully, when I attempt to navigate to another page after viewing the external SWF, I expect it to close as it goes on to another page however, it remains in place. If i then go back on to the page that it is loading from, it will start to keep adding more and more SWF's. The print screens should explain it easier... Below i'll post the code that I'm using currently. The external SWF I am trying to load/unload is an interactive hangman game (whether it being interactive has an effect I do not know), but any and all help with this would be seriously appreciated!
    The code currently being used is:
    var _swfLoader:Loader;
    var _swfContent:MovieClip;
    loadSWF("Real Hangman.swf");
    function loadSWF(path:String):void {
       var _req:URLRequest = new URLRequest();
       _req.url = path;
       _swfLoader = new Loader();
       setupListeners(_swfLoader.contentLoaderInfo);
       _swfLoader.load(_req);
    function setupListeners(dispatcher:IEventDispatcher):void {
       dispatcher.addEventListener(Event.COMPLETE, addSWF);
       dispatcher.addEventListener(ProgressEvent.PROGRESS, preloadSWF);
    function preloadSWF(event:ProgressEvent):void {
       var _perc:int = (event.bytesLoaded / event.bytesTotal) * 100;
       // swfPreloader.percentTF.text = _perc + "%";
    function addSWF(event:Event):void {
       event.target.removeEventListener(Event.COMPLETE, addSWF);
       event.target.removeEventListener(ProgressEvent.PROGRESS, preloadSWF);
       _swfContent = event.target.content;
       _swfContent.addEventListener("close", unloadSWF);
       addChild(_swfContent);
    function unloadSWF(event:Event):void {
       _swfLoader.unloadAndStop();
    removeChild(_swfContent);
       _swfContent = null;
    This printscreen is showing what it looks like in the Flash view (plain background and external SWF loads when this SWF is published)
    What it looks like when loaded as published swf
    Picture of the external SWF working inside the other SWF
    Picture of it not being able to unload when i navigate to another page!
    Finally, a picture of it doubling up when i proceed to go on the 'game' page again, it just keeps loading the SWF's rather than unloading them!

    for example, file1 consits of two buttons, and also considered as main page. As i click on these two buttons , it will lead me go to open the external file2.swf, and file3.swf respectively. (file2.swf and file3.swf could have other navigation buttons, however, i am just simplify here).
    the code you provided is working fine. but i want to totally remove/unlink the orginal file (file1.swf) when i click on either buttons which could lead me to other page (file1.swf or file2.swf).
    Besides that, in file2.swf and file3.swf could have another "back" button to turn it back to the main page (file1.swf). When the user click on that back button, the file2.swf will unloaded...and file1.swf will be called back again...
    can it  be done?
    so sorry if my poor explanation makes you confuse..
    thank you.

  • External SWF Parent??

    hello there guys..,
    i need help in understanding external swf parent,let me describe it a little more about what i mean:
    "is it by default when we load and external swf and eventhought we add it as a child of container (an instance of sprite class which we create and then add it to the stage) that the parent of that loaded swf is stage??? "
    i do ask this question because i tried to load an external swf and then add it to the container but when i trace it the loaded swf does not count as the child of the container but the stage (i do this by tracing the stage.numChildren and container.numChildren)
    thanks for your time and your help..,
    i do appreciate any help greatly..,

    if you load a swf (using the loader class), the swf is a child of the loader and the swf's parent is the loader.
    if you add the loader to the displaylist, then the loaded swf's parent.parent is a displaylist object.

  • AS3: How to access and control embedded sounds in an external swf?

    I rarely use sounds in AS3/Flash. I am using Flash Pro CS6, but I can't seem to figure out how to access, control (play, stop, etc) sounds embedded in an external SWF loaded into the main SWF.
    It's easy to control them when embedded on the main swf. However, on an externally loaded SWR, I get all kinds of errors. For this app, I really need to embed them in the external SWF.
    I read several solutions, but none seem to work.
    I embed the sound an mp3 file called soundSegment1.mp3 using Flash CS6 import tool and then open the actionscript properties panel on flash to select the class name: SoundSegment1. Then I edit the class code and create a file called SoundSegment1.as and it's saved right next to my document class main.as in the same directory. The code of the SoundSegment1 class looks like this:
    package  {
        import flash.media.*;
        public class SoundSegment1 extends Sound
            public function SoundSegment1 ()
                // no code in here
            public function playSound()
                var soundSegment1:Sound = new SoundSegment1();
                var channel:SoundChannel = soundSegment1.play();
    Then, in my main.as, I have done several attempts to play this sound such as:
    var fileLocation:URLRequest = new URLRequest(SWFToLoad); loader.load(fileLocation); loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressListener); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeListener); loader.contentLoaderInfo.addEventListener(Event.INIT, initListener); 
    function initListener(e:Event):void // I also placed this code on the completeListener and it didn't work {      loader.content.soundSegment1.playSound(); // doesn't work.  }
    I get:
    Line XXX 1061: Call to a possibly undefined method playSound through a reference with static type flash.display:DisplayObject.
    or, I also read that I should be able to do something like this anywhere in the Main.as file:
    var theClass:Class = Class(loader.content.getDefinitionByName("SoundSegment1")); var theSound:theClass = new theClass(); theSound.play()  //doesn't work either.
    I also tried on the completeListener:
    var TheClass:Class = e.target.applicationDomain.getDefinition("SoundSegment1") as Class; var theSound:TheClass = new TheClass();
    theSound.play()  //doesn't work either.
    I get:
    ReferenceError: Error #1065: Variable SoundSegment1 is not defined. at flash.system::ApplicationDomain/getDefinition()
    I am stuck and I really need to get this to work. I would be genuinely grateful for your help.
    Thank you in advance for any help provided. I really need to get it to work, because I can't simply embed them in the main SWF or load them individually externally one by one.
    Thanks again!

    THANK YOU!
    I think your code may be over my head though. I think you are using an anonymous function which is not something I am familiar with (but I want to learn about if it's useful).
    I also don't know where the classS came from. I see that it's a parameter sent along with the event, but I don't really see where that came from.
    Someone at: http://www.kirupa.com/forum/showthread.php?305098-Playing-a-embedded-sound-in-an-external- swf&p=2658098#post2658098
    Is showing what seems to be an easier solution, but my problem there is I can't access the source file of the "child" swf....  ayayay.....
    I am going to tinker with your solution and see if it gets me anywhere. Thanks so much for your help again.

  • Transition_Manager and unloading external swf problems

    Hi there
    I´m having a few problems with my project which i although it work it has some unpleasant bugs that i´m trying to solve for days.
    When i load external swf´s they show up on top of the Menu button.Maybe because the button i´m pressing is inside the same movieclip as the Menu.
    Explaining better here´s a little diagram of my site:
    con2 MC (Instance of Menu) ---> cont3 MC (Instance of subMenu) and mainButton MC (Instance of Main)
    Here´s the general code which is inside the Painel.as
    package {
        import com.greensock.TweenLite;
        import com.greensock.TweenMax;
        import com.greensock.*;
        import com.greensock.easing.*;
        import flash.display.*;
        import flash.events.*;
        import flash.display.MovieClip;
        import fl.transitions.*;
        import fl.transitions.easing.*;
        import flash.net.URLRequest;
        import flash.display.Loader;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        public class Painel3 extends MovieClip
            private var inFocus:MovieClip;
            public function Painel3():void
                setupClips();
                addEventListener(Event.ENTER_FRAME, loop);
            private function setupClips():void
            con2.mainButton.addEventListener(MouseEvent.ROLL_OVER, onOver);
            con2.mainButton.addEventListener(MouseEvent.ROLL_OUT, onOut);
            con2.mainButton.addEventListener(MouseEvent.CLICK, onClick);
                var len:int = con2.cont3.numChildren;
                for(var i:int=0; i<len; i++)
                    var mc:MovieClip = MovieClip(con2.cont3.getChildAt(i));
                    mc.buttonMode = true;
                    mc.loc = [mc.x, mc.y];
                    mc.addEventListener(MouseEvent.CLICK, onClick);
                    con2.cont3.visible = false;
            private function onOver(e:MouseEvent):void
            private function onOut(e:MouseEvent):void
            private function onClick(e:MouseEvent):void
                con2.cont3.visible = true;
    TransitionManager.start(con2.cont3, {type:Wipe, direction:Transition.IN, duration:1, easing:None.easeNone, startPoint:5} );                       
            private function loop(e:Event):void
                var distx:Number = mouseX / 1400;
                var disty:Number = mouseY / 1400;
                TweenLite.to(con2, 2, {
                            rotationY:(-70 +(145*distx)),
                            rotationX:(70 -(145*disty)),
                            ease:Expo.easeOut
    And then inside the subMenu.as class for the movieclip subMenu i have the buttons that load the external swf´s:
    package  {
        import com.greensock.TweenLite;
        import com.greensock.TweenMax;
        import com.greensock.*;
        import com.greensock.easing.*;
        import flash.display.*;
        import flash.events.*;
        import flash.display.MovieClip;
        import flash.net.URLRequest;
        import flash.display.Loader;
        import flash.events.Event;
        import flash.events.ProgressEvent;
        import fl.transitions.*;
        import fl.transitions.easing.*;
        public class subMenu extends MovieClip {
            public function subMenu() {
                // constructor code
                menu1.buttonMode = true;
                menu2.buttonMode = true;
                menu3.buttonMode = true;
                menu4.buttonMode = true;
                 menu1.addEventListener(MouseEvent.CLICK,link1);
                 menu2.addEventListener(MouseEvent.CLICK,link2);
                 menu3.addEventListener(MouseEvent.CLICK,link3);
                 menu4.addEventListener(MouseEvent.CLICK,link4);
            function link1(e:MouseEvent) {
               function startLoad()
                var mLoader:Loader = new Loader();
                var mRequest:URLRequest = new URLRequest("AugmentedReality_v1.swf");
                mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
                mLoader.load(mRequest);
    function onCompleteHandler(e:Event):void {
    var swf:DisplayObject = e.target.content;
    swf.x = -400;    
    swf.y = -300;    
    addChild(swf);
    function onProgressHandler(mProgress:ProgressEvent)
           var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
           trace(percent);
    startLoad();
            function link2(e:MouseEvent) {
                function startLoad()
                var mLoader:Loader = new Loader();
                var mRequest:URLRequest = new URLRequest("Fotos.swf");
                mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
                mLoader.load(mRequest);
    function onCompleteHandler(e:Event):void {
    var swf:DisplayObject = e.target.content;
    swf.x = -400;    
    swf.y = -300;    
    addChild(swf);
    function onProgressHandler(mProgress:ProgressEvent)
           var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
           trace(percent);
    startLoad();
            function link3(e:MouseEvent) {
            function link4(e:MouseEvent){
                function startLoad()
                var mLoader:Loader = new Loader();
                var mRequest:URLRequest = new URLRequest("Texto.swf");
                mLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler);
                mLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
                mLoader.load(mRequest);
    function onCompleteHandler(e:Event):void {
    var swf:DisplayObject = e.target.content;
    swf.x = -400;    
    swf.y = -300;    
    addChild(swf);
    function onProgressHandler(mProgress:ProgressEvent)
           var percent:Number = mProgress.bytesLoaded/mProgress.bytesTotal;
           trace(percent);
    startLoad();
    Like i said the swf´s show up on top of the Menu and i need it to dissapear.
    Also i want to unload the swf currently in scene so that when i load another one they don´t pile on top of each other.
    Pls help. Thanks

    Oh btw, i´m having an error 1069 Property TransitionManager not found in subMenu and there is no default value
    at fl.transitions::TransitionManager$/start()
        at Painel3/onClick()
    This doesn´t happen when i uncheck the Export for actionscript in the subMenu class but i can´t do that or else the buttons wont work.

  • Loading external SWF fila and accessing variables/functions

    Hello everybody!
    My first post here. Actually I do search google for answers all the time, but now - it's tough one.
    public function loadScreen(swf:File):void {
         _content = swf;
         var swfBytes:ByteArray = new ByteArray();
         var file:File = _content;  
         var loadStream:FileStream = new FileStream();
              loadStream.open( file, FileMode.READ );
              loadStream.readBytes( swfBytes );
              loadStream.close();
         var loader:Loader = new Loader();
         var loaderContext:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain);
              loaderContext.allowLoadBytesCodeExecution = true;
              loader.loadBytes( swfBytes, loaderContext);
              loader.contentLoaderInfo.addEventListener(Event.INIT, accessSWF);
              loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
    public function errorHandler(e:Event):void {
         trace("PROBLEM LOADING BYTES");
    public function accessSWF(e:Event):void {
         var moduleLoader:LoaderInfo = LoaderInfo(e.target);
         moduleLoader.content.addEventListener(Event.INIT, readyHandler);
    public function readyHandler(e:Event):void {
         _initOptions = new NativeWindowInitOptions();
         with(_initOptions) {
              resizable = true;
              transparent = false;
         var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
         _window = new NativeWindow(_initOptions);
         with(_window) {
              activate();
              bounds = boundsWin;
              stage.scaleMode = "noScale";
    The problem is that application loads the external swf with loadBytes, but it's not executing the script. Actually, I'm not able to use the loaded swf. I'm not able even to add it to Stage. But message in output still shows, that the swf file is loaded "[SWF] file.swf/[[DYNAMIC]]/1 - 2746 bytes after decompression"
    There are many solutions for this problem on the internet, but they're old (written in 2008 most of all) and not working either, because those solutions work only in older AIR versions
    Any help?

    Well I got a bit further:
    public function loadScreen(swf:File):void {
         var loadStream:FileStream = new FileStream();
         with(loadStream) {
              openAsync( swf, FileMode.READ );
              addEventListener(ProgressEvent.PROGRESS, loadProgress);
              addEventListener(IOErrorEvent.IO_ERROR, errorHandler);
              addEventListener(Event.COMPLETE, loadComplete);
    public function loadProgress(e:ProgressEvent):void {
         trace("Loading " + e.target.bytesAvailable);
    public function errorHandler(e:IOErrorEvent):void {
         trace("Error ");
    public function loadComplete(e:Event):void {
         var swfBytes:ByteArray = new ByteArray();
         FileStream(e.target).readBytes( swfBytes );
         var loaderContext:LoaderContext = new LoaderContext();
         with(loaderContext) {
              allowLoadBytesCodeExecution = true;
         var loader:Loader = new Loader();
         with(loader) {
              loadBytes( swfBytes, loaderContext);
              contentLoaderInfo.addEventListener(Event.INIT, completedSWF);
    public function completedSWF(e:Event):void {
         var moduleLoader:LoaderInfo = LoaderInfo(e.target);
         moduleLoader.addEventListener(Event.COMPLETE, initiatedFinally);
    public function initiatedFinally(e:Event):void {
         _initOptions = new NativeWindowInitOptions();
         with(_initOptions) {
              resizable = true;
              transparent = false;
         var boundsWin:Rectangle = new Rectangle(100, 100, 423, 430);
         _window = new NativeWindow(_initOptions);
         with(_window) {
              activate();
              bounds = boundsWin;
              stage.scaleMode = "noScale";
         var loader:Loader = e.target.loader;
         loader.addEventListener(Event.ADDED_TO_STAGE, irAdded);
         _window.stage.addChild(loader);
    public function irAdded(e:Event):void {
         trace(e.target.content.vars); // Object Dictionary
    At this point ( function irAdded ) I'm able to retrieve external SWF's variables. But stil, it's not visible on the stage. And yet - there's another problem - rendering the same script , every second time application unloads the external swf movie.

  • Load and unload the external swf file using AS3(for window, IOS and android)

    For the external swf file loading, I use this code
    load2.addEventListener(MouseEvent.MOUSE_DOWN, newvid);
    function newvid(event:MouseEvent) {
              trace("you clicked me");
              var loadit = new Loader();
              addChild(loadit);
        var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
        loadit.load(new URLRequest("scene02.swf"), _lc);
    its working great but I don’t know how to unload the loaded swf files (looking: unload one by one and unload all)
    in AS2 we have
    on (release) {
              loadMovieNum("scene2.swf", 1);
              unloadMovieNum(2);
              unloadMovieNum(3);
    but i need in AS3

    Now I use this code and this time I got these compiler errors
    package {
                    import flash.display.SimpleButton;
                    import flash.display.MovieClip;
                    import flash.events.MouseEvent;
                    //import flash.display.URLRequest;
                    //import flash.display.Loader;
                    import flash.events.Event;
                    import flash.system.ApplicationDomain;
                    import flash.net.URLRequest;
                    import flash.system.LoaderContext;            
                                    public class load1 extends SimpleButton {
                                                    var loadit:Loader;              
                                                    public function load1() {
                                                                    this.addEventListener(MouseEvent.MOUSE_DOWN, loadfile);
                                                    private function loadfile(event:MouseEvent):void {
                                                                    trace("you clicked me");
                                                                    loadit = new Loader();
                                                                    this.parent.addChild(loadit);
                                                                    var _lc:LoaderContext = new LoaderContext(false, ApplicationDomain.currentDomain, null);
                                                                    loadit.load(new URLRequest("s01.swf"), _lc);
                                                    private function unloadfile(event:MouseEvent):void {
                                                                    loadit.unloadAndStop();

  • Remove / unload external swf file(s) from the main flash file and load a new swf file and garbage collection from memory.

    I can't seem to remove / unload the external swf files e.g when the carousel.swf (portfolio) is displayed and I press the about button the about content is overlapping the carousel (portfolio) . How can I remove / unload an external swf file from the main flash file and load a new swf file, while at the same time removing garbage collection from memory?
    This is the error message(s) I am receiving: "TypeError: Error #2007: Parameter child must be non-null.
    at flash.display::DisplayObjectContainer/removeChild()
    at index_fla::MainTimeline/Down3()"
    import nl.demonsters.debugger.MonsterDebugger;
    var d:MonsterDebugger=new MonsterDebugger(this);
    stage.scaleMode=StageScaleMode.NO_SCALE;
    stage.align=StageAlign.TOP_LEFT;
    stage.addEventListener(Event.RESIZE, resizeHandler);
    // loader is the loader for portfolio page swf
    var loader:Loader;
    var loader2:Loader;
    var loader3:Loader;
    var loader1:Loader;
    //  resize content
    function resizeHandler(event:Event):void {
        // resizes portfolio page to center
    loader.x = (stage.stageWidth - loader.width) * .5;
    loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    /*loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;*/
    addEventListener(Event.ENTER_FRAME, onEnterFrame,false, 0, true);
    function onEnterFrame(ev:Event):void {
    var requesterb:URLRequest=new URLRequest("carouselLoader.swf");
    loader = null;
    loader = new Loader();
    loader.name ="carousel1"
    //adds gallery.swf to stage at begining of movie
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requesterb);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    // stop gallery.swf from duplication over and over again on enter frame
    removeEventListener(Event.ENTER_FRAME, onEnterFrame);
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent):void {
    // re adds listener for contact.swf and about.swf
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
    var requester:URLRequest=new URLRequest("carouselLoader.swf");
        loader = null;
    loader = new Loader();
    loader.name ="carousel"
    loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader);
    loader.x = (stage.stageWidth - 739) * .5;
    loader.y = (stage.stageHeight - 500) * .5;
    removeChild( getChildByName("about") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of gallery.swf
    MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    function Down1(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    var requester:URLRequest=new URLRequest("contactLoader.swf");
    loader2 = null;
    loader2 = new Loader();
    loader2.name ="contact"
    loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader2.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader2);
    loader2.x = (stage.stageWidth - 658.65) * .5;
    loader2.y = (stage.stageHeight - 551.45) * .5;
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
    //adds eventlistner so that info.swf can be loaded
    MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    function Down3(event:MouseEvent):void {
    //this re-adds the EventListener for portfolio so that end user can view again if they wish.
    MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
    var requester:URLRequest=new URLRequest("aboutLoader.swf");
    loader3 = null;
    loader3 = new Loader();
    loader3.name ="about"
    loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
    function ioError(event:IOErrorEvent):void {
    trace(event);
    try {
    loader3.load(requester);
    } catch (error:SecurityError) {
    trace(error);
    addChild(loader3);
    loader3.x = (stage.stageWidth - 482) * .5 - 260;
    loader3.y = (stage.stageHeight - 492) * .5 - 140;
    removeChild( getChildByName("carousel") );
    removeChild( getChildByName("carousel1") );
    // remove eventlistner and prevents duplication of info.swf
    MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
    stop();

    Andrei1,
    Thank you for the helpful advice. I made the changes as you suggested but I am receiving a #1009 error message even though my site is working the way I wan it to work. I would still like to fix the errors so that my site runs and error free. This is the error I am receiving:
    "TypeError: Error #1009: Cannot access a property or method of a null object reference."
    I'm sure this is not the best method to unload loaders and I am guessing this is why I am receiving the following error message.
         loader.unload();
         loader2.unload();
         loader3.unload();
    I also tried creating a function to unload the loader but received the same error message and my portfolio swf was not showing at all.
         function killLoad():void{
         try { loader.close(); loader2.close; loader3.close;} catch (e:*) {}
         loader.unload(); loader2.unload(); loader3.unload();
    I have a question regarding suggestion you made to set Mouse Event to "null". What does this do setting the MouseEvent do exactly?  Also, since I've set the MouseEvent to null do I also have to set the loader to null? e.g.
    ---- Here is my updated code ----
    // variable for external loaders
    var loader:Loader;
    var loader1:Loader;
    var loader2:Loader;
    var loader3:Loader;
    // makes borders resize with browser size
    function resizeHandler(event:Event):void {
    // resizes portfolio page to center
         loader.x = (stage.stageWidth - loader.width) * .5;
         loader.y = (stage.stageHeight - loader.height) * .5;
    // resizes about page to center
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
    //adds gallery.swf to stage at begining of moviie
         Down();
    //PORTFOLIO BUTTON
    //adds eventlistner so that gallery.swf can be loaded
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
    function Down(event:MouseEvent = null):void {
    // re adds listener for contact.swf and about.swf
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
    //unloads gallery.swf from enter frame if users presses portfolio button in nav
         var requester:URLRequest=new URLRequest("carouselLoader.swf");
         loader = new Loader();
         loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader.load(requester);
         } catch (error:SecurityError) {
         trace(error);
         this.addChild(loader);
         loader.x = (stage.stageWidth - 739) * .5;
         loader.y = (stage.stageHeight - 500) * .5;
    // sure this is not the best way to do this - but it is unload external swfs
         loader.unload();
         loader2.unload();
         loader3.unload();
    // remove eventlistner and prevents duplication of gallery.swf
         MovieClip(root).nav.portfolio.removeEventListener(MouseEvent.MOUSE_DOWN, Down);
    //INFORMATION BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         function Down1(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         var requester:URLRequest=new URLRequest("contactLoader.swf");
         loader2 = null;
         loader2 = new Loader();
         loader2.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);    
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader2.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader2);
         loader2.x = (stage.stageWidth - 658.65) * .5;
         loader2.y = (stage.stageHeight - 551.45) * .5;
    loader.unload();
    loader2.unload();
    loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.info.removeEventListener(MouseEvent.MOUSE_DOWN, Down1);
    //ABOUT BUTTON
         //adds eventlistner so that info.swf can be loaded
         MovieClip(root).nav.about.addEventListener(MouseEvent.MOUSE_DOWN, Down3, false, 0, true);
         function Down3(event:MouseEvent = null):void {
         //this re-adds the EventListener for portfolio so that end user can view again if they wish.
         MovieClip(root).nav.portfolio.addEventListener(MouseEvent.MOUSE_DOWN, Down, false, 0, true);
         MovieClip(root).nav.info.addEventListener(MouseEvent.MOUSE_DOWN, Down1, false, 0, true);
         var requester:URLRequest=new URLRequest("aboutLoader.swf");
         loader3 = null;
         loader3 = new Loader();
         loader3.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioError);
         function ioError(event:IOErrorEvent):void {
         trace(event);
         try {
         loader3.load(requester);
    }      catch (error:SecurityError) {
         trace(error);
         addChild(loader3);
         loader3.x = (stage.stageWidth - 482) * .5 - 260;
         loader3.y = (stage.stageHeight - 492) * .5 - 140;
         loader.unload();
         loader2.unload();
         loader3.unload();
         // remove eventlistner and prevents duplication of info.swf
         MovieClip(root).nav.about.removeEventListener(MouseEvent.MOUSE_DOWN, Down3);
         stop();

  • Loading an external swf and unloading the parent one

    Hi there i have made a navigation in flash and 3 buttons that load some external swf's. Problem is that when they load the parent swf keeps playing in the background. How can i make them play separately and make the navigation stage dissapear completely when they load?

    I have attempted to use the same Loader but it doesnt replace it i dont know why.
    var myLoader:Loader = new Loader();       
    var myLoaderMain:URLRequest = new URLRequest("main1.swf");
    var myLoaderQuiz:URLRequest = new URLRequest("quiz.swf");
    var myLoaderAnimation:URLRequest = new URLRequest("athens_animation.swf");
    var myLoaderVideo:URLRequest = new URLRequest("videogallery.swf");
    videogallerybtn.addEventListener(MouseEvent.CLICK, videoFunc);
    function videoFunc(curEvt:MouseEvent) {
              myLoader.load(myLoaderVideo);
              addChild(myLoader);
    Quizbtn.addEventListener(MouseEvent.CLICK, quizFunc);
    function quizFunc(curEvt:MouseEvent) {
              myLoader.load(myLoaderQuiz);
              addChild(myLoader);
    Animationbtn.addEventListener(MouseEvent.CLICK, AnimationFunc);
    function AnimationFunc(curEvt:MouseEvent) {
              myLoader.load(myLoaderAnimation);
              addChild(myLoader);

Maybe you are looking for