Skip to main content
huskyl63341171
Participating Frequently
December 2, 2016
Question

Problem close external swf Actionscript 3

  • December 2, 2016
  • 1 reply
  • 1012 views

Hi .. I'm working on my project and I need help. I'm not an expert.

I have a main swf, and this one has several external swf (test1, test2)

I have menu and submenu, which load external swf.

Load well external swf.

Create the close button in the main swf, and close the external swf correctly.

THE PROBLEM is always visible the close button

I would like the close button to be visible only when loading the external swf. But always be hidden

I would prefer to place the close button on each of the external swf, is it possible ?.

Or does the close button have to be in the main swf?

thanks for your help

........................code................

import flash.events.MouseEvent;

ruta0_btn.removeEventListener(MouseEvent.ROLL_OVER, activar)

activador_mc.addEventListener(MouseEvent.ROLL_OVER, desactivar);

function desactivar (event:MouseEvent):void

    {

        gotoAndPlay("fuera");

    }

           

import flash.display.Loader;

import flash.net.URLRequest;

var SWF:Loader = new Loader();

SWF.name = "holder"

/* Comienzo BOTON 1 */

ruta1_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);

function fl_MouseClickHandler(event:MouseEvent):void

{

   var ruta:URLRequest = new URLRequest ("images/test1.swf");

  

   SWF.load(ruta);

   SWF.contentLoaderInfo.addEventListener(Event.COMPLETE, añadir);

  

stage.frameRate = 50;

}

/* Fin BOTON 1 */

/* Comienzo BOTON 2 */

ruta2_btn.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);

function fl_MouseClickHandler_2(event:MouseEvent):void

{

   var ruta:URLRequest = new URLRequest ("images/test2.swf");

  

   SWF.load(ruta);

   SWF.contentLoaderInfo.addEventListener(Event.COMPLETE, añadir)

   stage.frameRate = 50;

}

/* Fin BOTON 2 */

function añadir (e:Event):void {

      if(!this.getChildByName('holder')){

         addChild(SWF);

         SWF.x = -32;

         SWF.y = -470;

      }

   }

  

/* CLOSE BUTTON */ 

  

borra_btn.addEventListener(MouseEvent.CLICK, borrarSWF);

function borrarSWF(event:MouseEvent):void {

removeChild(SWF);

}

    This topic has been closed for replies.

    1 reply

    kglad
    Community Expert
    Community Expert
    December 2, 2016

    the close button can be in the loaded swf's.

    Loader(this.parent).unloadAndStop();

    huskyl63341171
    Participating Frequently
    December 2, 2016

    thanks for answering.


    Could you indicate how I should do it? ... where should I place the code, in the external swf? ...
    Or do you have an example where I can check?
    I proceeded to create the close button in the external swf, add the code that you indicate to me, it did not work.
    Stop loading the external swf

    kglad
    Community Expert
    Community Expert
    December 2, 2016

    is your button on the main timeline of your external swf?  did you test after publishing your external swf and then testing the main swf?

    if so, show the button's code.