Skip to main content
Jhon Carlo
Inspiring
October 17, 2016
Question

Quit form swf embedded in a web page

  • October 17, 2016
  • 1 reply
  • 433 views

I have an swf embedded in a web page.

With: "fscommand("quit");" I can quit from exe file.

But in which way I can close a web page with a button? Inside the web page is running an swf?

Thanks.

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
October 17, 2016

there are browser to browser differences, but generally the best you can do is use javascript, window.close().

Jhon Carlo
Inspiring
October 18, 2016

Thank you kglad!

I try this but doesn't  work:

MyquitButton.addEventListener(MouseEvent.CLICK, MyCloseFunction)

function MyCloseFunction(event:MouseEvent)

{

  navigateToURL(new URLRequest("javascript:window.close()"));

}

kglad
Community Expert
Community Expert
October 18, 2016

use externalinterface to execute js:

import flash.external.ExternalInterface;

MyquitButton.addEventListener(MouseEvent.CLICK, MyCloseFunction)

function MyCloseFunction(event:MouseEvent)

{

ExternalInterface.call(closeXML);

}

var closeXML:XML =

<script>

    <![CDATA[

        function(){

            function closeF(){

                window.close();

            };

            closeF();

        }

    ]]>

</script>