2006/08/04 | Alert组件
类别(flash练习) | 评论(0) | 阅读(46) | 发表于 13:08
在库中添加一个Alert组件和一个Button组件,以下代码放在flash文件的第一帧:
import mx.controls.Alert;
import mx.controls.Button;
this.createClassObject(mx.controls.Button, "my_btn", 1, {label:"Play"});
my_btn.setSize(100, 25);
my_btn.move(180, 170);
var myListener:Object = new Object();
myListener.click = function() {
  var myObj:Object = new Object();
  myObj.click = function(evt_obj:Object) {
    if (evt_obj.detail == Alert.OK) {
      var my_fmt:TextFormat = new TextFormat();
      my_fmt.font = "Arial";
      my_fmt.size = 20;
      my_fmt.color = 0xFF0000;
      _root.createTextField("my_txt", 10, 80, 80, 200, 40);
      my_txt.setNewTextFormat(my_fmt);
      my_txt.text = "你开心,我快乐!";
    } else {
      _root.createTextField("my_txt", 10, 100, 100, 200, 20);
      my_txt.text = "让我分担你的忧愁好吗?";
    }
  };
  Alert.buttonWidth = 100;
  Alert.okLabel = "我笑了!:)";
  Alert.noLabel = "今天我没有笑:(";
  Alert.show("今天你笑了吗?", "请回答", Alert.OK | Alert.NO, null, myObj);
};
my_btn.addEventListener("click", myListener);
附效果图:


Flash 动画
0

评论Comments

日志分类
首页[49]
flashcs3[14]
coredraw[1]
flash练习[9]
AS2[7]
生活点滴[14]
资源下载[3]
photoshop[1]