• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Hiding a load clip.

New Here ,
Apr 27, 2012 Apr 27, 2012

Copy link to clipboard

Copied

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 ...

TOPICS
ActionScript

Views

8.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 27, 2012 Apr 27, 2012

Copy link to clipboard

Copied

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;
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 27, 2012 Apr 27, 2012

Copy link to clipboard

Copied

Thanks for your reply .... it's not working .... here is the full code. Please tell me if i send you the .fla

import flash.events.MouseEvent;

import flash.display.Loader;

import flash.display.Sprite;

import flash.net.URLRequest;

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;

}

//Boton Monteria

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);

}

//Boton Cucuta

btn_cucuta.addEventListener(MouseEvent.CLICK, cucpress)

function cucpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_cucuta.swf"));

    btn_cerrar.visible = true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Santa Marta

btn_sta.addEventListener(MouseEvent.CLICK, stapress)

function stapress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_sta.swf"));

    btn_cerrar.visible = true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Villavicencio

btn_vll.addEventListener(MouseEvent.CLICK, villpress)

function villpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_villavicencio.swf"));

    btn_cerrar.visible=true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Cartagena

btn_ctg.addEventListener(MouseEvent.CLICK, ctgpress)

function ctgpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_cartagena.swf"));

    btn_cerrar.visible=true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Bogota

btn_bogota.addEventListener(MouseEvent.CLICK, bogpress)

function bogpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_bogota.swf"));

    btn_cerrar.visible=true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Cali

btn_cali.addEventListener(MouseEvent.CLICK, calipress)

function calipress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_cali.swf"));

    btn_cerrar.visible=true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Barranquilla

btn_bll.addEventListener(MouseEvent.CLICK, bllpress)

function bllpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_barranquilla.swf"));

    btn_cerrar.visible=true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Medellin

btn_mdll.addEventListener(MouseEvent.CLICK, mllpress)

function mllpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_medellin.swf"));

    btn_cerrar.visible = true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Dosquebradas

btn_dq.addEventListener(MouseEvent.CLICK, dqpress)

function dqpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_dosquebradas.swf"));

    btn_cerrar.visible = true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Ibague

btn_ibague.addEventListener(MouseEvent.CLICK, ibgpress)

function ibgpress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_ibague.swf"));

    btn_cerrar.visible = true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

//Boton Tunja

btn_tunja.addEventListener(MouseEvent.CLICK, tunjapress)

function tunjapress(Event:MouseEvent){

    newMedia = new Loader;

    cont = new Sprite;

    newMedia.load(new URLRequest("mapa_tunja.swf"));

    btn_cerrar.visible = true;

    cont.x = 10;

    cont.y = 120;

    stage.addChild(cont);

    stage.addChild(btn_cerrar);

    cont.addChild(newMedia);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Apr 27, 2012 Apr 27, 2012

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2012 Jun 26, 2012

Copy link to clipboard

Copied

LATEST

Hi ... i was busy for a long time, so that's why i can't  uset it ...

this is the function cerrar:

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;

}

But how do i call it from each button??? ...

Thanks a lot .... you can seet here how its working

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines