如何创建的ActionScript3警报对话框? [英] How to Create Alert Dialog in ActionScript3?

查看:195
本文介绍了如何创建的ActionScript3警报对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ActionScript 3.0在Flash专业版(CS5)的一个项目。我想创建一个确认框。如果我使用Flex SDK,我可以使用的 mx.controls使用包快递类。然而,似乎没有类似的控制存在于标准的Flash图书馆和谷歌搜索的任何数量只是让我flex参考。

I'm working on a project with Actionscript 3.0 in Flash Pro (CS5). I want to create a confirmation box. If I were using the Flex SDK I could do this using the Alert class in the mx.controls package. However, it seems that no similar control exists in the standard Flash library and any amount of Googling just leads me to Flex references.

推荐答案

试试这个类

package com.whatever {

//Imports
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.Rectangle;
import flash.events.MouseEvent;

//Class
public class AlertBox extends Sprite {

    //Vars
    protected var box:Shape;
    protected var yesBtn:Sprite;

    //Constructor
    public function AlertBox($:Rectangle):void {

        //Initialise
        box = new Shape()
        yesBtn = new Sprite()
        addChild(box)
        addChild(yesBtn)

        //Render
        with (box.graphics) {
            lineStyle(1)
            beginFill(0, 0.4)
            drawRect($.x, $.y, $.width, $.height)
            endFill()
        }

        with (yesBtn.graphics) {
            lineStyle(1, 0x00FF00)
            beginFill(0x00FF00, 0.4)
            drawRect($.x+$.width-100, $.y$.height-40, 80, 20)
            endFill()
        }

        //Events
        yesBtn.addEventListener(MouseEvent.CLICK, yesClickHandler, false, 0, true) 
        yesBtn.addEventListener(MouseEvent.MOUSE_OVER, yesOverHandler, false, 0, true) 

    }

    //Handlers
    protected function yesClickHandler($):void {}
    protected function yesOverHandler($):void {}

这篇关于如何创建的ActionScript3警报对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆