Skip navigation
Currently Being Moderated

Hiding a load clip.

Apr 27, 2012 7:36 AM

Tags: #problem #script #button #action_script_3 #actionscript3 #function

Hi to everyone, i'm working in a flash proyect using this action for each button/city (it's a map).

 

 

btn_monteria.addEventListener(MouseEvent.CLICK, montpress)
function montpress(Event:MouseEvent){
    //Crear una variable cargador para mostar el swf
    newMedia = new Loader;
    //Crear una variable para un clip vacio (anteriormente host)
    cont = new Sprite;
    //ruta para cargar la pelicula
    newMedia.load(new URLRequest("mapa_monteria.swf"));
    //mostar el boton cerrar
    btn_cerrar.visible = true;
    //Posicion x que va a tener el host
    cont.x = 10;
    cont.y = 120;
    stage.addChild(cont);
    stage.addChild(btn_cerrar);
    cont.addChild(newMedia);
}

 

and in the top of the actions have this code to load the swf

 

 

stop();
btn_cerrar.visible = false;
//Listener para cada una de las variables
//Creacion de la variable cargador
var newMedia:Loader;
var cont:Sprite;
//Listener y funciones para boton cerrar, asi como la visibilidad
btn_cerrar.addEventListener(MouseEvent.CLICK, cerrar)
function cerrar(Event:MouseEvent){
    btn_cerrar.visible = false;
    cont.removeChild(newMedia);
    newMedia.unload();
    newMedia = null;
}

 

As you can see works fine, but there is a little problem, if you press one city and then other city (with out pressing the close button) it doesn't hide the first city.

 

It is a way for each time that press a button the other ones keep hiding????

 

You can see it here

 

Thanks ...

 
Replies
  • Currently Being Moderated
    Apr 27, 2012 7:49 AM   in reply to Jose Diego Diaz Cuellar
    btn_monteria.addEventListener(MouseEvent.CLICK, montpress)
    function montpress(Event:MouseEvent){
     
     
        cerrar();
     
        //Crear una variable cargador para mostar el swf
        newMedia = new Loader();
        //Crear una variable para un clip vacio (anteriormente host)
        cont = new Sprite();
        //ruta para cargar la pelicula
        newMedia.load(new URLRequest("mapa_monteria.swf"));
        //mostar el boton cerrar
        btn_cerrar.visible = true;
        //Posicion x que va a tener el host
        cont.x = 10;
        cont.y = 120;
        stage.addChild(cont);
        stage.addChild(btn_cerrar);
        cont.addChild(newMedia);
    }
    

     

     

    stop();
    btn_cerrar.visible = false;
    //Listener para cada una de las variables
    //Creacion de la variable cargador
    var newMedia:Loader;
    var cont:Sprite;
    //Listener y funciones para boton cerrar, asi como la visibilidad
    btn_cerrar.addEventListener(MouseEvent.CLICK, cerrar)
    function cerrar(event:MouseEvent = null){
        btn_cerrar.visible = false;
         if (cont.contains(newMedia))
         {
             cont.removeChild(newMedia);
         }
         if (newMedia != null)
         {
             newMedia.unload();
         }
        newMedia = null;
    }
    
     
    |
    Mark as:
  • Currently Being Moderated
    Apr 27, 2012 8:38 AM   in reply to Jose Diego Diaz Cuellar

    you need to call cerrar() at the start of all your press functions i.e.

     

    montpress

    cucpress

    stapress

    villpress

    ctgpress

    bogpress

    calipress

    bllpress

    mllpress

    dqpress

    ibgpress and

    tunjapress

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points