flexjs 严谨模式式怎么取消

FLEX 通过单例模式,轻松关闭所有PopUpManager弹出的窗口-中国学网-中国IT综合门户网站-提供健康,养生,留学,移民,创业,汽车等信息
FLEX 通过单例模式,轻松关闭所有PopUpManager弹出的窗口
来源:互联网 更新时间: 0:33:04 责任编辑:李志喜字体:
怎么关闭所有PopUpManager弹出的窗口?
这一个貌似很简单,缺又凭空增加麻烦和工作量的事情.
如果你按照下面这种模式,那么关闭所有弹出窗口又变得那么简单.
需求: 假设当应用程序出现错误.需要将用户弹出窗口全部关闭.恢复到初始状态.
1. 定义单例类. 用来保存所有弹出窗口的数组
2. 将弹出事件封装,由其去创建弹出窗口.和保存到数组对象
两个重要类:
PopUpEffect.as(弹出事件封装类)
package com.javaeye.jhaij
import mx.managers.PopUpM
public class PopUpEffect
public function PopUpEffect()
public static function show(parent:*,control:*,modal:Boolean=false):void
PopUpManager.addPopUp(control,parent,modal);
PopUpManager.centerPopUp(control);
PopupModellocator.getInstance().push(control);
public static function hide(control:*):void
PopUpManager.removePopUp(control);
PopupModellocator.getInstance().pop(control);
PopupModellocator.as (保存数组对象的单例类,关闭全部调用)
package com.javaeye.jhaij
import com.adobe.utils.ArrayU
[Bindable]
public class PopupModellocator
private static var instance:PopupM
//保存pop出来的窗口
private var popupArray:A
public function DataGridModellocator()
if(instance==null){
instance =
public static function getInstance():PopupModellocator{
if(instance==null){
instance = new PopupModellocator();
public function push(control:*):void{
if(!popupArray){
popupArray = new A
popupArray.push(control);
public function pop(control:*):void{
if(popupArray){
ArrayUtil.removeValueFromArray(popupArray,control);
public function popAll():void{
if(popupArray&&popupArray.length&0){
PopUpEffect.hide(popupArray[popupArray.length-1]);
a. 弹出窗口创建入口: PopUpEffect.show
var p:PopWindow = new PopW
PopUpEffect.show(this,p);
p.setFocus();
b. 弹出窗口单个关闭调用:? PopUpEffect.hide
close="PopUpEffect.hide(this);"
c. 弹出窗口全部关闭调用: popAll - 注意是PopupModellocator的方法
PopupModellocator.getInstance().popAll();
as3corelib.swc
工程编译是用sdk3.5编译的. 你可以修改成4 因为都是as文件.完全向上兼容.
PopUpProjectTest.zip (206.4 KB)
描述: 工程源码
下载次数: 1
查看图片附件
相关文章:
上一篇文章:下一篇文章:
最新添加资讯
24小时热门资讯
Copyright © 2004- All Rights Reserved. 中国学网 版权所有
京ICP备号-1 京公网安备02号1859人阅读
flex(28)
//global css style settting
var sparkTitleWindowCSS:CSSStyleDeclaration=FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration(&ponents.TitleWindow&);
sparkTitleWindowCSS.setStyle(&modalTransparencyColor&, 'white');
sparkTitleWindowCSS.setStyle(&modalTransparencyBlur&, 0.1);
sparkTitleWindowCSS.setStyle(&modalTransparency&, 0.1);
var alertCSS:CSSStyleDeclaration=FlexGlobals.topLevelApplication.styleManager.getStyleDeclaration(&mx.controls.Alert&);
alertCSS.setStyle(&modalTransparencyColor&, 'white');
alertCSS.setStyle(&modalTransparencyBlur&, 0.1);
alertCSS.setStyle(&modalTransparency&, 0.1);
如上: 通过style manager 先获取某个组件的css申明, &然后将设置以下两个属性
modalTransparency & &modalTransparencyBlur
这样设置后通过popupmanager弹出的窗口,背景就更加透明
modalTransparencyColor 此属性可能设置蒙板颜色
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:292991次
积分:4396
积分:4396
排名:第5510名
原创:123篇
转载:64篇
评论:84条
(1)(2)(1)(1)(1)(2)(3)(1)(1)(1)(1)(2)(1)(1)(3)(2)(3)(4)(4)(3)(11)(6)(7)(3)(5)(4)(3)(4)(2)(12)(9)(7)(5)(2)(8)(2)(4)(7)(1)(1)(6)(1)(3)(2)(13)(5)(10)(8)命令模式--撤销恢复 -
- ITeye技术网站
博客分类:
该例子来自阎宏提供的例子程序,以画线为例: 命令接口Command:
package mand.
//命令接口
public interface Command {
abstract public void execute();// 执行操作
abstract public void unexecute();// 取消操作
abstract public boolean canExecute();//是否允许执行操作
abstract public boolean canUnexecute();//是否允许取消操作
添加线命令类AddLineCommand:
/* Generated by Together */
package mand.
//添加线命令类
public class AddLineCommand implements Command {
private D// 画布
private L//直线
public AddLineCommand(Drawing targetDrawing, Line newLine) {
drawing = targetD
line = newL
//执行将直线添加到画布的操作
public void execute() {
drawing.add(line);
//执行将直线从画布中移除的操作
public void unexecute() {
drawing.remove(line);
public boolean canExecute() {
public boolean canUnexecute() {
命令集合类CommandList:
package mand.
import java.util.S
//命令集合类,负责存储执行过的命令和撤销执行的命令
public class CommandList {
private Stack&Command& executedCommands = new Stack&Command&();
private Stack&Command& unexecutedCommands = new Stack&Command&();
private void _execute(Command command) {
command.execute();//执行具体的命令
executedCommands.push(command);//记录执行的命令
//执行命令
public void execute(Command command) {
unexecutedCommands.removeAllElements();
_execute(command);
//撤销执行,每执行一次该方法,将从最近的一次操作开始撤销
public void unexecute() {
Command command = (Command) executedCommands.pop();//出栈最后一次执行命令
command.unexecute();//撤销该命令的执行
unexecutedCommands.push(command);//记录撤销的命令
//恢复执行,每执行一次该方法,将从最近的一次操作开始撤销
public void reexecute() {
Command command = (Command) unexecutedCommands.pop();//出栈最后一次撤销命令
_execute(command);//重新执行
//清空撤销和恢复的缓存
public void reset() {
executedCommands.removeAllElements();
unexecutedCommands.removeAllElements();
//是否允许撤销命令,没有执行过命令就不存在撤销
public boolean canUnexecuteCommand() {
return !executedCommands.empty();
//是否允许恢复命令,没有撤销过命令就不存在恢复
public boolean canReexecuteCommand() {
return !unexecutedCommands.empty();
画布Drawing:
/* Generated by Together */
package mand.
import java.awt.C
import java.awt.C
import java.awt.G
import java.awt.P
import java.awt.event.MouseE
import java.awt.event.MouseL
import java.awt.event.MouseMotionL
import java.util.E
import java.util.V
//(接收者,负责具体实施和执行一个请求)画布,可以在该画布上画任意条直线
public class Drawing extends Canvas implements MouseListener,
MouseMotionListener {
private static final long serialVersionUID = -6351050L;
private SimpleD//应用程序
private Vector&Line&//线集合
private Point startP//画线开始位置
private Point mouseP//鼠标位置
private boolean mouseP//鼠标是否按下
//构造方法,初始化属性信息
public Drawing(SimpleDraw owner) {
lines = new Vector&Line&();
mousePressed =//默认鼠标未按下
setBackground(Color.GREEN);//设置画布背景色
addMouseListener(this);//添加鼠标***器,自己实现了该接口
addMouseMotionListener(this);//添加鼠标移动事件的侦听器,自己实现了该接口
//添加一条线(行动方法)
public void add(Line line) {
lines.addElement(line);
repaint();
//删除一条线(行动方法)
public void remove(Line line) {
lines.removeElement(line);
repaint();
public void paint(Graphics graphics) {
Enumeration&Line& enumeration = lines.elements();
Line currentL
while (enumeration.hasMoreElements()) {
currentLine = (Line) (enumeration.nextElement());
currentLine.paint(graphics);
if (mousePressed) {
graphics.drawLine(startPosition.x, startPosition.y,
mousePosition.x, mousePosition.y);
//鼠标按键在组件上单击(按下并释放)时调用
public void mouseClicked(MouseEvent event) {
//鼠标进入到组件上时调用
public void mouseEntered(MouseEvent event) {
//鼠标离开组件时调用
public void mouseExited(MouseEvent event) {
//鼠标按键在组件上按下时调用
public void mousePressed(MouseEvent event) {
mousePressed =//设置鼠标为按下状态
startPosition = event.getPoint();//记录直线的开始位置
//鼠标按钮在组件上释放时调用
public void mouseReleased(MouseEvent event) {
if (!event.getPoint().equals(startPosition)) {//两点不重合
Line line = new Line(startPosition, event.getPoint());//创建直线
AddLineCommand command = new AddLineCommand(this, line);//创建添加直线的一个命令
applet.execute(command);//请求者请求命令的执行
mousePressed =
public void mouseDragged(MouseEvent event) {
mousePosition = event.getPoint();
repaint();
public void mouseMoved(MouseEvent event) {
直线Line:
package mand.
import java.awt.P
import java.awt.G
public class Line {
public Line( Point startPos, Point endPos ) {
start = startP
end = endP
public void paint( Graphics graphics ) {
graphics.drawLine( start.x, start.y, end.x, end.y );
容器SimpleDraw:
/* Generated by Together */
package mand.
import java.applet.A
import java.awt.BorderL
import java.awt.B
import java.awt.P
import java.awt.event.ActionE
import java.awt.event.ActionL
// 请求者(负责调用命令对象执行请求)
public class SimpleDraw extends Applet implements ActionListener {
private static final long serialVersionUID = 0972428L;
private D// 画布
private CommandL// 命令集合
private Button undoB// 撤销按钮
private Button redoB// 恢复按钮
private Button resetB// 清空撤销和恢复按钮
public void init() {
Panel panel = new Panel();// 面板
commands = new CommandList();// 初始化命令集合
setLayout(new BorderLayout());// 设置布局
drawing = new Drawing(this);// 初始化画布
add("Center", drawing);
undoButton = new Button("撤销");// 初始化撤销按钮
redoButton = new Button("恢复");// 初始化恢复按钮
resetButton = new Button("重置");
undoButton.addActionListener(this);// 添加按钮***器
redoButton.addActionListener(this);// 添加按钮***器
resetButton.addActionListener(this);// 添加按钮***器
panel.add(undoButton);
panel.add(redoButton);
panel.add(resetButton);
add("South", panel);
updateButtons();// 初始化按钮状态
public void execute(Command command) {
commands.execute(command);// 执行命令
updateButtons();
// 更新按钮状态(根据是否能够undo撤销或者是否能够redo恢复)
private void updateButtons() {
undoButton.setEnabled(commands.canUnexecuteCommand());
redoButton.setEnabled(commands.canReexecuteCommand());
// 当点击撤销按钮或者恢复按钮时出发该方法执行
public void actionPerformed(ActionEvent event) {
if (event.getSource() == undoButton) {
commands.unexecute();
updateButtons();
}else if (event.getSource() == redoButton) {
commands.reexecute();
updateButtons();
}else if (event.getSource() == resetButton) {
commands.reset();
updateButtons();
下载次数: 35
AbstractForever
浏览: 215959 次
来自: 成都
[url][url][url][url][url][url][ ...
到结束的时候一直 Can't delete processIn ...

参考资料

 

随机推荐