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

Problem close external swf Actionscript 3

Explorer ,
Dec 01, 2016 Dec 01, 2016

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

}

868
Translate
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
Community Expert ,
Dec 02, 2016 Dec 02, 2016

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

Loader(this.parent).unloadAndStop();

Translate
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
Explorer ,
Dec 02, 2016 Dec 02, 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

Translate
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
Community Expert ,
Dec 02, 2016 Dec 02, 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.

Translate
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
Explorer ,
Dec 02, 2016 Dec 02, 2016

swf-externo.jpg

This is my external swf. It has the close button (top, right), instance name "cierra_btn".

The code inside external swf, but it does not work,

If the code works, if the close button is in the main swf

Translate
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
Explorer ,
Dec 04, 2016 Dec 04, 2016

Someone knows how this can be done .. Can anyone help me?

Translate
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
Community Expert ,
Dec 04, 2016 Dec 04, 2016

can you see message 1?

if yes, can you see the code in message 1?

if yes, why aren't you using that code?

Translate
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
Explorer ,
Dec 04, 2016 Dec 04, 2016

That option I answered on 02/12/2016 07:40

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

Surely it is badly loaded .. that is why I consult you where and how the code goes .. since I am not an expert.

But as I indicated .. with that code does not load the external swf.

When I call it from the main swf, it does not load.

I remove that code (Loader (this.parent) .unloadAndStop) and reload the file

error.jpg

Translate
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
Community Expert ,
Dec 04, 2016 Dec 04, 2016

that code goes in your button listener:  the same place where your have removeChild(SWF).

Translate
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
Explorer ,
Dec 04, 2016 Dec 04, 2016

The removeChild, I have it in the main swf.

The close button I want it in the external swf.

I leave you an example of what I need, so you can identify what exactly my problem is.

I leave attached the 2 file, swf main and external

http://sd-1197583-h00001.ferozo.net/external-swf.zip

Translate
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
Community Expert ,
Dec 04, 2016 Dec 04, 2016

that code (and the close button) goes in the loaded swf.  that's what you asked for.

is that still what you want?

Translate
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
Explorer ,
Dec 04, 2016 Dec 04, 2016

Yes .. that's what I need.

Try, but it does not work, as I indicated before, if I add that code to the close button of the swf-external file, when I load it from the main one, it does not work

I already tried it, and it does not work

Translate
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
Community Expert ,
Dec 04, 2016 Dec 04, 2016

show the code in your external (loaded) swf.

Translate
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
Explorer ,
Dec 04, 2016 Dec 04, 2016
LATEST

Sorry friend, but I do not understand you.

Already add the code that you indicate to the button to close. I've shown you the image with the code, instance name, etc. Since I'm not an expert, I can not understand you

Translate
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