如何在全屏swf文件中创建退出按钮?

时间:2014-06-25 04:25:14

标签: actionscript-3 button exit

我目前正在Flash中撰写论文。有没有人知道如何在退出应用程序之前发出警告?就像当用户点击" X"按钮,a"你确定要退出吗?是?无&#34?;会弹出?此外,它是在f

到目前为止,我的退出按钮代码是

addEventListener(MouseEvent.CLICK, CloseApp);
function CloseApp(e:MouseEvent) {
fscommand("quit");
}

因此,点击时,它会自动关闭应用。非常感谢你!

3 个答案:

答案 0 :(得分:1)

以下代码说明了如何使用Adobe AIR& amp; Flex SDK。

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" 
                   closing="onClisingMainWindow(event)">

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.events.CloseEvent;
        protected function onClisingMainWindow(event:Event):void
        {
            event.preventDefault();

            Alert.show('Are you sure?','',Alert.YES|Alert.NO,null,function(event:CloseEvent):void{
                if(event.detail == Alert.YES)
                    nativeApplication.exit();
            });
        }

    ]]>
</fx:Script>
</s:WindowedApplication>

在Flash Pro中使用Adobe AIR的结果相同。 (纯AS3)

import flash.desktop.NativeApplication;
import flash.events.Event;

//activeWindow will be null until the frame will not be constructed.
stage.addEventListener(Event.FRAME_CONSTRUCTED, onFrameConstructed);

function onFrameConstructed(event:Event){
    stage.removeEventListener(Event.FRAME_CONSTRUCTED, onFrameConstructed);

    NativeApplication.nativeApplication.activeWindow.addEventListener(Event.CLOSING, onClisingMainWindow);
}

function onClisingMainWindow(event:Event):void
{
    event.preventDefault();

    //The following code will close the app.
    //NativeApplication.nativeApplication.exit();
}

答案 1 :(得分:0)

import flash.desktop.NativeApplication;
import flash.events.Event;

addEventListener(MouseEvent.CLICK, CloseApp);

function CloseApp(e:MouseEvent) {
    stage.nativeWindow.close();
}

应该做的工作

答案 2 :(得分:-1)

//只需在按钮

中添加以下脚本即可

href =“javascript:history.go(-1)”