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

问题描述 投票:0回答:3

我目前正在用Flash撰写论文。有人知道退出该应用程序之前会发出警告吗?就像用户单击“ X”按钮时一样,“您确定要退出吗?是吗?否?”会弹出吗?另外,它在f

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

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

因此,单击时会自动关闭该应用程序。非常感谢!

actionscript-3 button exit
3个回答
1
投票

下面的代码说明了如何使用Adobe AIR和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="onClosingMainWindow(event)">

<fx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.events.CloseEvent;
        protected function onClosingMainWindow(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, onClosingMainWindow);
}

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

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

0
投票
import flash.desktop.NativeApplication;
import flash.events.Event;

addEventListener(MouseEvent.CLICK, CloseApp);

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

应该做这项工作


-1
投票

//只需在按钮中添加以下脚本

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

© www.soinside.com 2019 - 2024. All rights reserved.