Mer*_*rcy 3 apache-flex actionscript-3 flash-cs5
我正在使用Flash Pro(CS5)中的Actionscript 3.0开发一个项目.我想创建一个确认框.如果我使用Flex SDK,我可以使用mx.controls包中的Alert类来完成此操作.但是,似乎标准Flash库中没有类似的控件,任何数量的Google搜索引导我进入Flex引用.
试试这堂课
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 {}
Run Code Online (Sandbox Code Playgroud)