├── .gitignore
├── README.md
├── doc
├── DXR.png
├── DXR.xmind
├── Dll配置文件.png
├── Dll配置文件.xmind
├── FlexLite.png
├── FlexLite.xmind
├── GRP.png
├── GRP文件格式.xmind
├── MVC参考实现
│ └── src
│ │ └── code
│ │ ├── app
│ │ ├── AppInit.as
│ │ ├── CommonData.as
│ │ ├── CommonView.as
│ │ ├── ControllerList.as
│ │ ├── mvc
│ │ │ ├── Actor.as
│ │ │ ├── Command.as
│ │ │ ├── Context.as
│ │ │ ├── Controller.as
│ │ │ └── ↓ [MVC核心类]
│ │ └── ↓ [项目初始化和全局配置类]
│ │ ├── common
│ │ ├── commands
│ │ │ └── ↓ [模块间通讯命令]
│ │ ├── components
│ │ │ └── ↓ [公共组件]
│ │ ├── utils
│ │ │ └── ↓ [通用工具类]
│ │ └── ↑ [公共模块]
│ │ └── module
│ │ └── ↑ [功能模块]
├── Panel.dxml
├── Skin分离机制.png
├── Skin分离机制.xmind
├── config.xml
├── flexlite-manifest.xml
├── skin-part.xml
└── 记录.txt
└── src
└── org
└── flexlite
├── domCore
├── IBitmapAsset.as
├── IInvalidateDisplay.as
├── IMovieClip.as
├── Injector.as
└── dx_internal.as
├── domDisplay
├── DxrBitmap.as
├── DxrData.as
├── DxrFile.as
├── DxrMovieClip.as
├── DxrShape.as
├── IDxrDisplay.as
├── RepeatBitmap.as
├── Scale9GridBitmap.as
├── codec
│ ├── DxrDecoder.as
│ ├── DxrDrawer.as
│ └── IBitmapDecoder.as
├── events
│ └── MovieClipPlayEvent.as
└── image
│ ├── Jpeg32Decoder.as
│ └── PngDecoder.as
├── domDll
├── Dll.as
├── core
│ ├── ConfigItem.as
│ ├── DllConfig.as
│ ├── DllItem.as
│ ├── DllLoader.as
│ ├── IDllConfig.as
│ └── IResolver.as
├── events
│ └── DllEvent.as
└── resolvers
│ ├── AmfResolver.as
│ ├── BinResolver.as
│ ├── DxrResolver.as
│ ├── GrpResolver.as
│ ├── ImgResolver.as
│ ├── RslResolver.as
│ ├── SoundResolver.as
│ ├── SwfResolver.as
│ ├── TxtResolver.as
│ └── XmlResolver.as
├── domUI
├── collections
│ ├── ArrayCollection.as
│ ├── ICollection.as
│ ├── ITreeCollection.as
│ ├── ObjectCollection.as
│ └── XMLCollection.as
├── components
│ ├── Alert.as
│ ├── Button.as
│ ├── CheckBox.as
│ ├── ComboBox.as
│ ├── DataGroup.as
│ ├── DropDownList.as
│ ├── EditableText.as
│ ├── Group.as
│ ├── HScrollBar.as
│ ├── HSlider.as
│ ├── IItemRenderer.as
│ ├── IItemRendererOwner.as
│ ├── ITreeItemRenderer.as
│ ├── Label.as
│ ├── List.as
│ ├── PageNavigator.as
│ ├── Panel.as
│ ├── PopUpAnchor.as
│ ├── ProgressBar.as
│ ├── ProgressBarDirection.as
│ ├── RadioButton.as
│ ├── RadioButtonGroup.as
│ ├── Rect.as
│ ├── RectangularDropShadow.as
│ ├── Scroller.as
│ ├── SkinnableComponent.as
│ ├── SkinnableContainer.as
│ ├── SkinnableDataContainer.as
│ ├── Spacer.as
│ ├── StateSkin.as
│ ├── TabBar.as
│ ├── TabBarButton.as
│ ├── TabNavigator.as
│ ├── TextArea.as
│ ├── TextInput.as
│ ├── TitleWindow.as
│ ├── ToggleButton.as
│ ├── ToolTip.as
│ ├── Tree.as
│ ├── UIAsset.as
│ ├── UIMovieClip.as
│ ├── VScrollBar.as
│ ├── VSlider.as
│ ├── ViewStack.as
│ └── supportClasses
│ │ ├── ButtonBase.as
│ │ ├── DefaultSkinAdapter.as
│ │ ├── DropDownController.as
│ │ ├── DropDownListBase.as
│ │ ├── GroupBase.as
│ │ ├── ItemRenderer.as
│ │ ├── ListBase.as
│ │ ├── Range.as
│ │ ├── ScrollBarBase.as
│ │ ├── ScrollerLayout.as
│ │ ├── Skin.as
│ │ ├── SkinBasicLayout.as
│ │ ├── SkinnableTextBase.as
│ │ ├── SliderBase.as
│ │ ├── TextBase.as
│ │ ├── ToggleButtonBase.as
│ │ ├── TrackBase.as
│ │ └── TreeItemRenderer.as
├── core
│ ├── DomGlobals.as
│ ├── DragSource.as
│ ├── IContainer.as
│ ├── IDisplayText.as
│ ├── IEditableText.as
│ ├── IEffect.as
│ ├── IInvalidating.as
│ ├── ILayoutElement.as
│ ├── ISkin.as
│ ├── ISkinAdapter.as
│ ├── ISkinnableClient.as
│ ├── IStateClient.as
│ ├── IToolTip.as
│ ├── ITranslator.as
│ ├── IUIComponent.as
│ ├── IViewStack.as
│ ├── IViewport.as
│ ├── IVisualElement.as
│ ├── IVisualElementContainer.as
│ ├── NavigationUnit.as
│ ├── PopUpPosition.as
│ ├── ScrollPolicy.as
│ ├── Theme.as
│ ├── UIComponent.as
│ └── UITextField.as
├── effects
│ ├── Fade.as
│ ├── Move.as
│ ├── Resize.as
│ ├── Scale.as
│ ├── animation
│ │ ├── Animation.as
│ │ ├── MotionPath.as
│ │ └── RepeatBehavior.as
│ ├── easing
│ │ ├── Bounce.as
│ │ ├── EaseInOutBase.as
│ │ ├── EasingFraction.as
│ │ ├── Elastic.as
│ │ ├── IEaser.as
│ │ ├── Linear.as
│ │ ├── Power.as
│ │ └── Sine.as
│ └── supportClasses
│ │ └── Effect.as
├── events
│ ├── CloseEvent.as
│ ├── CollectionEvent.as
│ ├── CollectionEventKind.as
│ ├── DragEvent.as
│ ├── EffectEvent.as
│ ├── ElementExistenceEvent.as
│ ├── IndexChangeEvent.as
│ ├── ListEvent.as
│ ├── MoveEvent.as
│ ├── PopUpEvent.as
│ ├── PropertyChangeEvent.as
│ ├── PropertyChangeEventKind.as
│ ├── RendererExistenceEvent.as
│ ├── ResizeEvent.as
│ ├── SkinPartEvent.as
│ ├── StateChangeEvent.as
│ ├── ToolTipEvent.as
│ ├── TrackBaseEvent.as
│ ├── TreeEvent.as
│ └── UIEvent.as
├── layouts
│ ├── BasicLayout.as
│ ├── ColumnAlign.as
│ ├── HorizontalAlign.as
│ ├── HorizontalLayout.as
│ ├── RowAlign.as
│ ├── TileLayout.as
│ ├── TileOrientation.as
│ ├── VerticalAlign.as
│ ├── VerticalLayout.as
│ └── supportClasses
│ │ └── LayoutBase.as
├── managers
│ ├── DragManager.as
│ ├── FocusManager.as
│ ├── IDragManager.as
│ ├── IFocusManager.as
│ ├── ILayoutManagerClient.as
│ ├── IPopUpManager.as
│ ├── ISystemManager.as
│ ├── IToolTipManager.as
│ ├── IToolTipManagerClient.as
│ ├── LayoutManager.as
│ ├── PopUpManager.as
│ ├── SystemContainer.as
│ ├── SystemManager.as
│ ├── ToolTipManager.as
│ ├── dragClasses
│ │ └── DragProxy.as
│ ├── impl
│ │ ├── DragManagerImpl.as
│ │ ├── PopUpManagerImpl.as
│ │ └── ToolTipManagerImpl.as
│ └── layoutClass
│ │ └── DepthQueue.as
├── skins
│ ├── VectorSkin.as
│ ├── themes
│ │ └── VectorTheme.as
│ └── vector
│ │ ├── AlertSkin.as
│ │ ├── ButtonSkin.as
│ │ ├── CheckBoxSkin.as
│ │ ├── ComboBoxButtonSkin.as
│ │ ├── ComboBoxSkin.as
│ │ ├── ComboBoxTextInputSkin.as
│ │ ├── DropDownListButtonSkin.as
│ │ ├── DropDownListSkin.as
│ │ ├── HScrollBarSkin.as
│ │ ├── HScrollBarThumbSkin.as
│ │ ├── HScrollBarTrackSkin.as
│ │ ├── HSliderSkin.as
│ │ ├── HSliderTrackHighlightSkin.as
│ │ ├── HSliderTrackSkin.as
│ │ ├── ItemRendererSkin.as
│ │ ├── ListSkin.as
│ │ ├── PageNavigatorSkin.as
│ │ ├── PanelSkin.as
│ │ ├── ProgressBarSkin.as
│ │ ├── ProgressBarThumbSkin.as
│ │ ├── ProgressBarTrackSkin.as
│ │ ├── RadioButtonSkin.as
│ │ ├── ScrollBarDownButtonSkin.as
│ │ ├── ScrollBarLeftButtonSkin.as
│ │ ├── ScrollBarRightButtonSkin.as
│ │ ├── ScrollBarUpButtonSkin.as
│ │ ├── ScrollerSkin.as
│ │ ├── SliderThumbSkin.as
│ │ ├── TabBarButtonSkin.as
│ │ ├── TabBarSkin.as
│ │ ├── TabNavigatorSkin.as
│ │ ├── TextAreaSkin.as
│ │ ├── TextInputSkin.as
│ │ ├── TitleWindowCloseButtonSkin.as
│ │ ├── TitleWindowSkin.as
│ │ ├── ToggleButtonSkin.as
│ │ ├── TreeDisclosureButtonSkin.as
│ │ ├── TreeItemRendererSkin.as
│ │ ├── VScrollBarSkin.as
│ │ ├── VScrollBarThumbSkin.as
│ │ ├── VScrollBarTrackSkin.as
│ │ ├── VSliderSkin.as
│ │ ├── VSliderTrackHighlightSkin.as
│ │ └── VSliderTrackSkin.as
├── states
│ ├── AddItems.as
│ ├── IOverride.as
│ ├── OverrideBase.as
│ ├── SetProperty.as
│ ├── State.as
│ └── StateClientHelper.as
└── utils
│ ├── GraphicsUtil.as
│ ├── LayoutUtil.as
│ ├── OnDemandEventDispatcher.as
│ ├── SkinPartUtil.as
│ └── callLater.as
└── domUtils
├── CRC32Util.as
├── Debugger.as
├── Recycler.as
└── SharedMap.as
/.gitignore:
--------------------------------------------------------------------------------
1 | # Build and Release Folders
2 | bin-debug/
3 | bin-release/
4 | bin/
5 |
6 | # Project property files
7 | .actionScriptProperties
8 | .flexProperties
9 | .settings/
10 | .project
11 | .svn
12 | .gitignore
13 | .flexLibProperties
14 |
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | framework
2 | =========
3 |
4 | This is an open source UI framework for flash games,
5 | under the MIT License.
6 |
7 |
8 | 使用之前请务必先查看Wiki,检出说明及编译条件:
9 | http://wiki.flexlite.org/index.php?doc-view-61
10 |
11 | 教程索引:
12 | http://wiki.flexlite.org/index.php?doc-view-52
13 |
--------------------------------------------------------------------------------
/doc/DXR.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/DXR.png
--------------------------------------------------------------------------------
/doc/DXR.xmind:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/DXR.xmind
--------------------------------------------------------------------------------
/doc/Dll配置文件.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/Dll配置文件.png
--------------------------------------------------------------------------------
/doc/Dll配置文件.xmind:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/Dll配置文件.xmind
--------------------------------------------------------------------------------
/doc/FlexLite.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/FlexLite.png
--------------------------------------------------------------------------------
/doc/FlexLite.xmind:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/FlexLite.xmind
--------------------------------------------------------------------------------
/doc/GRP.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/GRP.png
--------------------------------------------------------------------------------
/doc/GRP文件格式.xmind:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/GRP文件格式.xmind
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/AppInit.as:
--------------------------------------------------------------------------------
1 | package code.app
2 | {
3 | import code.app.mvc.Actor;
4 | import code.app.mvc.Context;
5 |
6 | import flash.display.Stage;
7 |
8 | /**
9 | * 程序初始化启动类
10 | * @author dom
11 | */
12 | public class AppInit extends Actor
13 | {
14 | /**
15 | * 构造函数
16 | */
17 | public function AppInit(stage:Stage)
18 | {
19 | Context.getInstance().setStage(stage);
20 | }
21 |
22 | /**
23 | * 控制器列表
24 | */
25 | private var controllerList:ControllerList = new ControllerList();
26 | /**
27 | * 初始化程序
28 | */
29 | public function start():void
30 | {
31 | //==============================
32 | // 这里做一些启动控制器前的初始化操作
33 | //==============================
34 |
35 | controllerList.start();
36 | }
37 | }
38 | }
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/CommonData.as:
--------------------------------------------------------------------------------
1 | package code.app
2 | {
3 | import flash.utils.Dictionary;
4 |
5 | /**
6 | * 公共数据
7 | * @author dom
8 | */
9 | public class CommonData extends Dictionary
10 | {
11 | /**
12 | * 构造函数
13 | */
14 | public function CommonData()
15 | {
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/CommonView.as:
--------------------------------------------------------------------------------
1 | package code.app
2 | {
3 | import flash.utils.Dictionary;
4 |
5 | /**
6 | * 公共视图
7 | * @author dom
8 | */
9 | public class CommonView extends Dictionary
10 | {
11 | /**
12 | * 构造函数
13 | */
14 | public function CommonView()
15 | {
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/ControllerList.as:
--------------------------------------------------------------------------------
1 | package code.app
2 | {
3 | /**
4 | * 控制器列表
5 | * @author dom
6 | */
7 | public class ControllerList
8 | {
9 | /**
10 | * 构造函数
11 | */
12 | public function ControllerList()
13 | {
14 | }
15 |
16 | /**
17 | * 启动所有控制器
18 | */
19 | public function start():void
20 | {
21 | }
22 | }
23 | }
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/mvc/Command.as:
--------------------------------------------------------------------------------
1 | package code.app.mvc
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 命令基类
7 | * @author dom
8 | */
9 | public class Command extends Event
10 | {
11 | /**
12 | * 构造函数
13 | * @param type 命令类型字符串
14 | * @param data 命令携带的数据
15 | */
16 | public function Command(type:String,data:*)
17 | {
18 | super(type,false,true);
19 | this.data = data;
20 | }
21 | /**
22 | * 命令携带的数据
23 | */
24 | public var data:*;
25 |
26 | override public function clone():Event
27 | {
28 | return new Command(type,data);
29 | }
30 | }
31 | }
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/mvc/Context.as:
--------------------------------------------------------------------------------
1 | package code.app.mvc
2 | {
3 | import code.app.CommonData;
4 | import code.app.CommonView;
5 |
6 | import flash.display.Stage;
7 | import flash.events.EventDispatcher;
8 |
9 |
10 | /**
11 | * 命令总线上下文
12 | * @author dom
13 | */
14 | public class Context extends EventDispatcher
15 | {
16 | /**
17 | * 构造函数
18 | */
19 | public function Context()
20 | {
21 | super();
22 | if(_instance!=null)
23 | {
24 | throw new Error("实例化单例Context出错!");
25 | }
26 | }
27 |
28 | private static var _instance:Context;
29 | /**
30 | * 获取单例
31 | */
32 | public static function getInstance():Context
33 | {
34 | if(_instance==null)
35 | {
36 | _instance = new Context;
37 | }
38 | return _instance;
39 | }
40 |
41 | private var _stage:Stage;
42 |
43 | /**
44 | * 舞台引用
45 | */
46 | public function get stage():Stage
47 | {
48 | return _stage;
49 | }
50 | /**
51 | * 在项目启动时注入舞台实例
52 | */
53 | public function setStage(value:Stage):void
54 | {
55 | if(!value)
56 | return;
57 | _stage = value;
58 | }
59 |
60 | private var _commonView:CommonView = new CommonView();
61 | /**
62 | * 公共视图
63 | */
64 | public function get commonView():CommonView
65 | {
66 | return _commonView;
67 | }
68 |
69 | private var _commonData:CommonData = new CommonData();
70 | /**
71 | * 公共数据
72 | */
73 | public function get commonData():CommonData
74 | {
75 | return _commonData;
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/mvc/Controller.as:
--------------------------------------------------------------------------------
1 | package code.app.mvc
2 | {
3 | /**
4 | * 控制器基类
5 | * @author dom
6 | */
7 | public class Controller extends Actor
8 | {
9 | /**
10 | * 构造函数
11 | */
12 | public function Controller()
13 | {
14 | super();
15 | }
16 |
17 | /**
18 | * 启动控制器
19 | */
20 | public function start():void
21 | {
22 | }
23 | }
24 | }
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/mvc/↓ [MVC核心类]:
--------------------------------------------------------------------------------
1 | Actor:命令总线通讯基类。项目里需要模块间通信的类,比如Model和Controller都应该是它的子类。
2 | Command:命令基类。扩展自Event,使用原生的事件流机制来实现命令通信。这个类起到区分模块间命令和视图事件的作用。所有自定义命令都应该是它的子类。
3 | Context:命令总线上下文。它是命令的实际监听和抛出对象,并包含舞台引用,公共数据和公共视图三个属性。它已经注入到Actor类里。因此所有Actor子类都可以访问到那三个属性。
4 | Controller:控制器基类。所有控制器都应该是它的子类。扩展自Actor,仅添加了个start()方法,必须确保子类控制器的逻辑代码都在start()里启动,而不是构造函数。
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/app/↓ [项目初始化和全局配置类]:
--------------------------------------------------------------------------------
1 | AppInit:程序初始化启动类。负责程序的启动顺序,确保需要的资源都已经获得后再启动控制器列表的start()方法。
2 | CommonData:公共数据类。模块间共享的数据都定义在这里面。它是一个静态数据类,里面不应该有任何逻辑代码,只起到存储共享的作用。
3 | CommonView:公共视图类。模块间共享的视图都定义在这里面。规则同上。
4 | ControllerList:控制器列表。所有功能模块的控制器都在这里实例化。并在start()方法里按一定顺序启动。最后由AppInit启动它。
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/common/commands/↓ [模块间通讯命令]:
--------------------------------------------------------------------------------
1 | 模块间通讯的命令定义在这个包下。不同功能类别的命令,应该分类创建在不同子包下。
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/common/components/↓ [公共组件]:
--------------------------------------------------------------------------------
1 | 放置公用的UI组件
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/common/utils/↓ [通用工具类]:
--------------------------------------------------------------------------------
1 | 模块间通用的工具类定义在此处。通常是一些静态方法。
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/common/↑ [公共模块]:
--------------------------------------------------------------------------------
1 | 整个项目通用的代码(被多个功能模块引用,不属于任何单独的一个功能模块)放置在common包下。通常是命令类,工具类。
2 | 也包含各种管理器,比如资源管理器,场景管理器等全局需要引用的代码。
--------------------------------------------------------------------------------
/doc/MVC参考实现/src/code/module/↑ [功能模块]:
--------------------------------------------------------------------------------
1 | 能够按具体功能独立解耦出来的模块放置在module包下。以模块名命名子包名。模块包下创建一个控制器,和两个子包,包名为view和model。
2 | 一个模块只有一个控制器,但是可以有多个model,和多个view。控制器实例化并持有多个model和view。创建的包结构大致如下:
3 | module/sample/SampleController.as
4 | module/sample/view/SampleView.as
5 | module/sample/view/events/SampleEvent.as
6 | module/sample/model/SampleModel.as
7 |
--------------------------------------------------------------------------------
/doc/Panel.dxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | Label文字
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 | 数据1
29 | 数据2
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/doc/Skin分离机制.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/Skin分离机制.png
--------------------------------------------------------------------------------
/doc/Skin分离机制.xmind:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/flexlite/framework/ee357e78f74c2ffb9368db45089240610bc89f57/doc/Skin分离机制.xmind
--------------------------------------------------------------------------------
/doc/config.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | false
7 |
8 | E:\编程文档\Flash\Flexlite\bin\Flexlite.swc
9 | D:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\frameworks\libs\core.swc
10 | D:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\frameworks\libs\authoringsupport.swc
11 | D:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\frameworks\libs\osmf.swc
12 | D:\Program Files\Adobe\Adobe Flash Builder 4.6\sdks\4.6.0\frameworks\libs\textLayout.swc
13 |
14 |
15 | src
16 |
17 |
18 | true
19 |
20 | Flexlite Application
21 | http://www.flexlite.org/
22 | FlexLite
23 | FlexLite
24 | CN
25 |
26 |
27 |
--------------------------------------------------------------------------------
/doc/记录.txt:
--------------------------------------------------------------------------------
1 |
2 | 与Flex区别的地方
3 | 0.针对游戏开发的需求,为了达到性能最优化,去除了绑定机制,绘图元素,全局样式表等比较损耗性能模块的支持。其中List等组件的数据源绑定刷新功能,仍然可以通过ArrayCollection类来实现。
4 | 1.可视化编辑器限制为只能编辑Skin及其基类,为了更好地与原生的纯as项目无缝集成,不允许xml和as代码混排,防止混乱地嵌套影响模块解耦和代码管理。as代码只在项目里编写,xml布局代码只在编辑器里编辑。
5 | 3.配合第1条,ItemRenderer改为继承自SkinnableComponent的子类,同样实现Skin分离机制,因为ItemRenderer内通常含有as代码。
6 | 5.callLater()方法修改为全局函数,增加一个延迟帧数的参数,在经过指定数量帧数后再执行。
7 | 6.考虑到游戏中对特殊文本的需求很少,而且对FP版本兼容性也有要求,Label和EditableText的核心文本对象改用TextField重新实现而非TLF,但是实现了与TLF文本组件几乎一致的外部功能接口。不需要额外编译tlf库。也降低了FP的版本需求。
8 | 7.SkinnableComponent和Skin之间定义的共享组件实例,不需要显式声明[SkinPart]标签,只要两边定义了同名的引用型公开变量,框架底层在附加皮肤的时候就会自动完成实例的注入。
9 | 8.SkinnableComponent与Skin之间完全解耦。除了支持Flex的标准Skin外,SkinnableComponent还可以接受任何类型的显示对象作为皮肤。解析规则由项目注入的皮肤解析适配器决定。
10 | 这样,比如Button等小型的元件,直接设置一个影片剪辑即可。扩展性更强,同样也优化了嵌套过多层级的问题。
11 |
12 | 注意:
13 | 1.为了防止失效验证进入死循环,写组件要遵循以下规则:updateDisplayList()避免调用invalidateSize().或者在updateDisplayList()线程里显式修改size等间接造成invalidateSize();
14 |
15 | 备注:
16 |
17 | 8.为了保持后续版本有持续的向后兼容性,审查每一个public和protected方法,让对外暴露的接口数量最小化。
18 | 13.聊天用的图文混排组件
19 | 14.飘文字组件
20 | 55.多主题切换的需求,利用 的name参数来注入不同主题
21 | 56.优化Layout类的大小
22 | 57.提供PageLayout,支持水平翻页时垂直排列元素。
23 | 58.Accordion组件
24 | 61.增加Image控件,继承UIComponent,集成Scale9GridBitmap,RepeatBitmap以及其他位图效果的直接操作。
25 | 62.Dll增加运行时动态创建组的功能。
26 |
27 |
--------------------------------------------------------------------------------
/src/org/flexlite/domCore/IBitmapAsset.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domCore
2 | {
3 | import flash.display.BitmapData;
4 |
5 |
6 | /**
7 | * 位图素材显示对象接口
8 | * @author dom
9 | */
10 | public interface IBitmapAsset
11 | {
12 | /**
13 | * 当前显示的BitmapData对象
14 | */
15 | function get bitmapData():BitmapData;
16 | /**
17 | * 素材的默认宽度(以像素为单位)。
18 | */
19 | function get measuredWidth():Number;
20 | /**
21 | * 素材的默认高度(以像素为单位)。
22 | */
23 | function get measuredHeight():Number;
24 | }
25 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domCore/IInvalidateDisplay.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domCore
2 | {
3 |
4 | /**
5 | * 具有延迟应用属性功能的显示对象接口
6 | * @author dom
7 | */
8 | public interface IInvalidateDisplay
9 | {
10 | /**
11 | * 立即应用所有标记为延迟验证的属性
12 | */
13 | function validateNow():void;
14 | }
15 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domCore/IMovieClip.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domCore
2 | {
3 | import flash.events.IEventDispatcher;
4 |
5 | /**
6 | * 影片剪辑接口
7 | * @author dom
8 | */
9 | public interface IMovieClip extends IEventDispatcher
10 | {
11 | /**
12 | * 当前播放到的帧索引,从0开始
13 | */
14 | function get currentFrame():int;
15 | /**
16 | * 动画总帧数
17 | */
18 | function get totalFrames():int;
19 | /**
20 | * 返回由FrameLabel对象组成的数组。数组包括整个Dxr动画实例的所有帧标签。
21 | */
22 | function get frameLabels():Array;
23 | /**
24 | * 是否循环播放,默认为true。
25 | */
26 | function get repeatPlay():Boolean;
27 | function set repeatPlay(value:Boolean):void;
28 | /**
29 | * 跳到指定帧并播放
30 | * @param frame 可以是帧索引或者帧标签,帧索引从0开始。
31 | */
32 | function gotoAndPlay(frame:Object):void;
33 | /**
34 | * 跳到指定帧并停止
35 | * @param frame 可以是帧索引或者帧标签,帧索引从0开始。
36 | */
37 | function gotoAndStop(frame:Object):void;
38 | /**
39 | * 从当期帧开始播放
40 | */
41 | function play():void;
42 | /**
43 | * 在当前帧停止播放
44 | */
45 | function stop():void;
46 | /**
47 | * 为指定帧添加回调函数。注意:同一帧只能添加一个回调函数。后添加的回调函数将会覆盖之前的。
48 | * @param frame 要添加回调的帧索引,从0开始。
49 | * @param callBack 回调函数。设置为null,将取消之前添加的回调函数。
50 | */
51 | function addFrameScript(frame:int,callBack:Function):void;
52 | }
53 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domCore/dx_internal.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domCore
2 | {
3 |
4 | /**
5 | * 这个命名空间用于对外屏蔽非公开的API。此命名空间下定义的方法和变量,仅作为框架内部使用。
6 | * 因为在后续的版本中,这些方法和变量都有可能发生改变,所以不建议用户在外部使用他们,否则将会导致兼容问题。
7 | */
8 | public namespace dx_internal =
9 | "http://www.flexlite.org/2012/dx/internal";
10 | }
11 |
--------------------------------------------------------------------------------
/src/org/flexlite/domDisplay/DxrShape.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDisplay
2 | {
3 | import flash.display.BitmapData;
4 | import flash.geom.Point;
5 |
6 | import org.flexlite.domCore.IBitmapAsset;
7 | import org.flexlite.domCore.dx_internal;
8 |
9 | use namespace dx_internal;
10 |
11 | /**
12 | * DXR形状。
13 | * 请根据实际需求选择最佳的IDxrDisplay呈现DxrData。
14 | * DxrShape具有位图九宫格缩放功能,但不具有鼠标事件响应。
15 | * @author dom
16 | */
17 | public class DxrShape extends Scale9GridBitmap implements IDxrDisplay,IBitmapAsset
18 | {
19 | /**
20 | * 构造函数
21 | * @param data 被引用的DxrData对象
22 | * @param smoothing 在缩放时是否对位图进行平滑处理。
23 | */
24 | public function DxrShape(data:DxrData=null,smoothing:Boolean=true)
25 | {
26 | super(null,null,smoothing);
27 | if(data)
28 | dxrData = data;
29 | }
30 |
31 | private var _dxrData:DxrData;
32 | /**
33 | * 被引用的DxrData对象
34 | */
35 | public function get dxrData():DxrData
36 | {
37 | return _dxrData;
38 | }
39 |
40 | public function set dxrData(value:DxrData):void
41 | {
42 | if(value==_dxrData)
43 | return;
44 | _dxrData = value;
45 | if(value)
46 | {
47 | scale9Grid = dxrData._scale9Grid;
48 | _offsetPoint = dxrData.getFrameOffset(0);
49 | var sizeOffset:Point = dxrData.getFilterOffset(0);
50 | if(!sizeOffset)
51 | sizeOffset = new Point();
52 | filterWidth = sizeOffset.x;
53 | filterHeight = sizeOffset.y;
54 | super.bitmapData = dxrData.getBitmapData(0);
55 | }
56 | else
57 | {
58 | scale9Grid = null;
59 | _offsetPoint = null;
60 | filterWidth = 0;
61 | filterHeight = 0;
62 | super.bitmapData = null;
63 | }
64 | }
65 |
66 | /**
67 | * 被引用的BitmapData对象。注意:此属性被改为只读,对其赋值无效。
68 | * IDxrDisplay只能通过设置dxrData属性来显示位图数据。
69 | */
70 | override public function get bitmapData():BitmapData
71 | {
72 | return super.bitmapData;
73 | }
74 | override public function set bitmapData(value:BitmapData):void
75 | {
76 | }
77 |
78 | /**
79 | * 素材的默认宽度(以像素为单位)。
80 | */
81 | public function get measuredWidth():Number
82 | {
83 | if(bitmapData)
84 | return bitmapData.width-filterWidth;
85 | return 0;
86 | }
87 | /**
88 | * 素材的默认高度(以像素为单位)。
89 | */
90 | public function get measuredHeight():Number
91 | {
92 | if(bitmapData)
93 | return bitmapData.height-filterHeight;
94 | return 0;
95 | }
96 | }
97 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDisplay/IDxrDisplay.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDisplay
2 | {
3 |
4 | /**
5 | * 能够解析DxrData的显示对象接口
6 | * @author dom
7 | */
8 | public interface IDxrDisplay
9 | {
10 | /**
11 | * 被引用的DxrData对象
12 | */
13 | function get dxrData():DxrData;
14 | function set dxrData(value:DxrData):void;
15 | }
16 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDisplay/codec/IBitmapDecoder.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDisplay.codec
2 | {
3 | import flash.utils.ByteArray;
4 |
5 | /**
6 | *
7 | * @author dom
8 | */
9 | public interface IBitmapDecoder
10 | {
11 | /**
12 | * 将字节流数据解码为位图数组
13 | * @param byteArray 要解码的字节流数据
14 | * @param onComp 解码完成回调函数,示例:onComp(data:BitmapData);
15 | */
16 | function decode(byteArray:ByteArray,onComp:Function):void;
17 |
18 | /**
19 | * 编解码器标识符
20 | */
21 | function get codecKey():String;
22 | }
23 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDisplay/events/MovieClipPlayEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDisplay.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * IMoveClip播放事件
7 | * @author dom
8 | */
9 | public class MovieClipPlayEvent extends Event
10 | {
11 | /**
12 | * IMoveClip一次播放完成。
13 | */
14 | public static const PLAY_COMPLETE:String = "playComplete"
15 |
16 | public function MovieClipPlayEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
17 | {
18 | super(type, bubbles, cancelable);
19 | }
20 | }
21 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDisplay/image/PngDecoder.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDisplay.image
2 | {
3 | import flash.display.Bitmap;
4 | import flash.display.BitmapData;
5 | import flash.display.Loader;
6 | import flash.display.LoaderInfo;
7 | import flash.events.Event;
8 | import flash.system.LoaderContext;
9 | import flash.utils.ByteArray;
10 | import flash.utils.Dictionary;
11 |
12 | import org.flexlite.domDisplay.codec.IBitmapDecoder;
13 |
14 |
15 | /**
16 | * PNG位图解码器,此解码器同样适用于其他所有普通位图解码。比如jpegxr。
17 | * @author dom
18 | */
19 | public class PngDecoder implements IBitmapDecoder
20 | {
21 | /**
22 | * 构造函数
23 | */
24 | public function PngDecoder()
25 | {
26 | }
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | public function get codecKey():String
32 | {
33 | return "png";
34 | }
35 |
36 | private var onCompDic:Dictionary;
37 | /**
38 | * @inheritDoc
39 | */
40 | public function decode(byteArray:ByteArray,onComp:Function):void
41 | {
42 | var loader:Loader = new Loader();
43 | var loaderContext:LoaderContext = new LoaderContext();
44 | if(loaderContext.hasOwnProperty("imageDecodingPolicy"))//如果是FP11以上版本,开启异步位图解码
45 | loaderContext["imageDecodingPolicy"] = "onLoad";
46 | loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadComp);
47 | if(onCompDic==null)
48 | onCompDic = new Dictionary;
49 | onCompDic[loader] = onComp;
50 | loader.loadBytes(byteArray,loaderContext);
51 | }
52 | /**
53 | * 解码完成
54 | */
55 | private function onLoadComp(event:Event):void
56 | {
57 | var loader:Loader = (event.target as LoaderInfo).loader;
58 | loader.contentLoaderInfo.removeEventListener(Event.COMPLETE,onLoadComp);
59 | var bitmapData:BitmapData = (loader.content as Bitmap).bitmapData;
60 | if(onCompDic[loader]!=null)
61 | {
62 | onCompDic[loader](bitmapData);
63 | }
64 | delete onCompDic[loader];
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/core/ConfigItem.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.core
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 |
5 | /**
6 | * 一项Dll配置文件信息
7 | * @author dom
8 | */
9 | public class ConfigItem
10 | {
11 | /**
12 | * 构造函数
13 | * @param url 配置文件路径
14 | * @param type 配置文件类型
15 | * @param folder 加载项的路径前缀。可将加载项url中重复的部分提取出来作为folder属性。
16 | */
17 | public function ConfigItem(url:String,type:String="xml",folder:String="")
18 | {
19 | this.url = url;
20 | this.type = type;
21 | this.folder = folder;
22 | }
23 | /**
24 | * 配置文件路径
25 | */
26 | public var url:String;
27 | /**
28 | * 配置文件类型
29 | */
30 | public var type:String;
31 | /**
32 | * 加载项的路径前缀。可将加载项url中重复的部分提取出来作为folder属性。
33 | */
34 | public var folder:String;
35 | /**
36 | * 资源名称
37 | */
38 | dx_internal var name:String;
39 | }
40 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/core/IDllConfig.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.core
2 | {
3 |
4 | /**
5 | * Dll配置文件解析器接口
6 | * @author dom
7 | */
8 | public interface IDllConfig
9 | {
10 | /**
11 | * 设置当前的语言环境
12 | */
13 | function setLanguage(value:String):void;
14 | /**
15 | * 解析一个配置文件
16 | * @param data 配置文件数据
17 | * @param folder 加载项的路径前缀。
18 | */
19 | function parseConfig(data:Object,folder:String):void;
20 | /**
21 | * 根据组名获取组加载项列表
22 | * @param name 组名
23 | */
24 | function getGroupByName(name:String):Vector.;
25 | /**
26 | * 创建自定义的加载资源组
27 | * @param name 要创建的加载资源组的组名
28 | * @param keys 要包含的键名列表,key对应配置文件里的name属性或sbuKeys属性的一项。
29 | * @param overrideOld 是否覆盖已经存在的同名资源组,默认false。
30 | * @return 是否创建成功,如果传入的keys为空,或keys全部无效,则创建失败。
31 | */
32 | function createGroup(name:String,keys:Array,overrideOld:Boolean=false):Boolean;
33 | /**
34 | * 获取加载项类型。
35 | * @param key 对应配置文件里的name属性或sbuKeys属性的一项。
36 | */
37 | function getType(key:String):String;
38 | /**
39 | * 获取加载项名称(name属性)
40 | * @param key 对应配置文件里的name属性或sbuKeys属性的一项。
41 | */
42 | function getName(key:String):String;
43 | /**
44 | * 获取加载项信息对象
45 | * @param key 对应配置文件里的name属性或sbuKeys属性的一项。
46 | */
47 | function getDllItem(key:String):DllItem;
48 | }
49 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/core/IResolver.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.core
2 | {
3 | import flash.utils.ByteArray;
4 |
5 |
6 | /**
7 | * 文件解析器接口
8 | * @author dom
9 | */
10 | public interface IResolver
11 | {
12 | /**
13 | * 加载一个资源文件
14 | * @param dllItem 加载项信息
15 | * @param compFunc 加载完成回调函数,示例:compFunc(dllItem:DllItem):void;
16 | * @param onProgress 加载进度回调函数,示例:onProgress(bytesLoaded:int,dllItem:DllItem):void;
17 | */
18 | function loadFile(dllItem:DllItem,compFunc:Function,onProgress:Function):void;
19 | /**
20 | * 通过字节流解析并缓存一个资源文件
21 | * @param bytes 资源文件字节流
22 | * @param name 配置文件中加载项的name属性
23 | */
24 | function loadBytes(bytes:ByteArray,name:String):void
25 | /**
26 | * 同步方式获取解析完成的数据
27 | * @param key 对应配置文件里的name属性或sbuKeys属性的一项。
28 | */
29 | function getRes(key:String):*;
30 | /**
31 | * 异步方式获取解析完成的数据。
32 | * @param key 对应配置文件里的name属性或sbuKeys属性的一项。
33 | * @param compFunc 解析完成回调函数
34 | */
35 | function getResAsync(key:String,compFunc:Function):void;
36 | /**
37 | * 是否已经含有某个资源文件的缓存数据
38 | * @param name 配置文件中加载项的name属性
39 | */
40 | function hasRes(name:String):Boolean;
41 | /**
42 | * 销毁某个资源文件的二进制数据,返回是否删除成功。
43 | * @param name 配置文件中加载项的name属性
44 | */
45 | function destroyRes(name:String):Boolean;
46 | }
47 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/events/DllEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.events
2 | {
3 | import flash.events.Event;
4 |
5 | import org.flexlite.domDll.core.DllItem;
6 |
7 |
8 | /**
9 | * 资源管理器事件
10 | * @author dom
11 | */
12 | public class DllEvent extends Event
13 | {
14 | /**
15 | * 一个加载项加载结束事件,可能是加载成功也可能是加载失败。
16 | */
17 | public static const ITEM_LOAD_FINISHED:String = "itemLoadFinished";
18 | /**
19 | * 配置文件加载并解析完成事件
20 | */
21 | public static const CONFIG_COMPLETE:String = "configComplete";
22 | /**
23 | * 延迟加载组资源加载进度事件
24 | */
25 | public static const GROUP_PROGRESS:String = "groupProgress";
26 | /**
27 | * 延迟加载组资源加载完成事件
28 | */
29 | public static const GROUP_COMPLETE:String = "groupComplete";
30 | /**
31 | * 构造函数
32 | */
33 | public function DllEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
34 | {
35 | super(type, bubbles, cancelable);
36 | }
37 | /**
38 | * 已经加载的字节数
39 | */
40 | public var bytesLoaded:Number=0;
41 | /**
42 | * 要加载的总字节数
43 | */
44 | public var bytesTotal:Number=0;
45 | /**
46 | * 资源组名
47 | */
48 | public var groupName:String;
49 | /**
50 | * 一次加载项加载结束的项信息对象
51 | */
52 | public var dllItem:DllItem;
53 |
54 | /**
55 | * @inheritDoc
56 | */
57 | override public function clone():Event
58 | {
59 | var event:DllEvent = new DllEvent(type,bubbles,cancelable);
60 | event.bytesLoaded = bytesLoaded;
61 | event.bytesTotal = bytesTotal;
62 | event.dllItem = dllItem;
63 | event.groupName = groupName;
64 | return event;
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/resolvers/AmfResolver.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.resolvers
2 | {
3 | import flash.utils.ByteArray;
4 | /**
5 | * 二进制序列化对象解析器
6 | * 将调用ByteArray.writeObject()方法序列化的二进制文件,解析为Object对象。
7 | * @author dom
8 | */
9 | public class AmfResolver extends BinResolver
10 | {
11 | /**
12 | * 构造函数
13 | */
14 | public function AmfResolver()
15 | {
16 | super();
17 | }
18 |
19 | /**
20 | * @inheritDoc
21 | */
22 | override public function getRes(key:String):*
23 | {
24 | if(sharedMap.has(key))
25 | return sharedMap.get(key);
26 | var bytes:ByteArray = fileDic[key];
27 | if(!bytes)
28 | return null;
29 | var data:Object = null;
30 | try
31 | {
32 | bytes.position = 0;
33 | data = bytes.readObject();
34 | }
35 | catch(e:Error){}
36 | sharedMap.set(key,data);
37 | return data;
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/resolvers/DxrResolver.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.resolvers
2 | {
3 | import flash.utils.ByteArray;
4 |
5 | import org.flexlite.domDisplay.DxrData;
6 | import org.flexlite.domDisplay.DxrFile;
7 |
8 | /**
9 | * DXR文件解析器
10 | * @author dom
11 | */
12 | public class DxrResolver extends BinResolver
13 | {
14 | public function DxrResolver()
15 | {
16 | super();
17 | }
18 |
19 | /**
20 | * @inheritDoc
21 | */
22 | override public function loadBytes(bytes:ByteArray,name:String):void
23 | {
24 | if(fileDic[name]||!bytes)
25 | return;
26 | try
27 | {
28 | bytes.uncompress();
29 | }
30 | catch(e:Error){}
31 | fileDic[name] = new DxrFile(bytes,name);
32 | }
33 |
34 | /**
35 | * @inheritDoc
36 | */
37 | override public function getRes(key:String):*
38 | {
39 | var res:* = fileDic[key];
40 | if(res)
41 | return res;
42 | if(sharedMap.has(key))
43 | return sharedMap.get(key);
44 | return null;
45 | }
46 |
47 | /**
48 | * @inheritDoc
49 | */
50 | override public function getResAsync(key:String, compFunc:Function):void
51 | {
52 | if(compFunc==null)
53 | return;
54 | var res:* = getRes(key);
55 | if(res)
56 | {
57 | compFunc(res);
58 | }
59 | else
60 | {
61 | var file:DxrFile;
62 | var found:Boolean = false;
63 | for each(file in fileDic)
64 | {
65 | if(file.hasKey(key))
66 | {
67 | found = true;
68 | break;
69 | }
70 | }
71 | if(found)
72 | {
73 | file.getDxrData(key,function(data:DxrData):void{
74 | sharedMap.set(key,data);
75 | compFunc(data);
76 | });
77 | }
78 | else
79 | {
80 | compFunc(null);
81 | }
82 | }
83 | }
84 | }
85 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/resolvers/RslResolver.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.resolvers
2 | {
3 |
4 | /**
5 | * RSL文件解析器,通常是将共享代码库加载到当前程序域。
6 | * @author dom
7 | */
8 | public class RslResolver extends SwfResolver
9 | {
10 | /**
11 | * 构造函数
12 | */
13 | public function RslResolver()
14 | {
15 | super();
16 | loadInCurrentDomain = true;
17 | }
18 | }
19 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/resolvers/TxtResolver.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.resolvers
2 | {
3 | import flash.utils.ByteArray;
4 |
5 | /**
6 | * 文本文件解析器
7 | * @author dom
8 | */
9 | public class TxtResolver extends BinResolver
10 | {
11 | public function TxtResolver()
12 | {
13 | super();
14 | }
15 |
16 | /**
17 | * @inheritDoc
18 | */
19 | override public function getRes(key:String):*
20 | {
21 | var bytes:ByteArray = fileDic[key];
22 | if(!bytes)
23 | return "";
24 | bytes.position = 0;
25 | return bytes.readUTFBytes(bytes.length);
26 | }
27 | }
28 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domDll/resolvers/XmlResolver.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domDll.resolvers
2 | {
3 | import flash.utils.ByteArray;
4 |
5 | /**
6 | * XML文件解析器
7 | * @author dom
8 | */
9 | public class XmlResolver extends BinResolver
10 | {
11 | /**
12 | * 构造函数
13 | */
14 | public function XmlResolver()
15 | {
16 | super();
17 | }
18 |
19 | /**
20 | * @inheritDoc
21 | */
22 | override public function getRes(key:String):*
23 | {
24 | if(sharedMap.has(key))
25 | return sharedMap.get(key);
26 | var bytes:ByteArray = fileDic[key];
27 | if(!bytes)
28 | return null;
29 | bytes.position = 0;
30 | var resultStr:String = bytes.readUTFBytes(bytes.length);
31 | var xml:XML
32 | try
33 | {
34 | xml = XML(resultStr);
35 | }
36 | catch(e:Error){}
37 | sharedMap.set(key,xml);
38 | return xml;
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/collections/ICollection.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.collections
2 | {
3 | import flash.events.IEventDispatcher;
4 |
5 |
6 | /**
7 | * 列表的集合类数据源对象接口
8 | * @author dom
9 | */
10 | public interface ICollection extends IEventDispatcher
11 | {
12 | /**
13 | * 此集合中的项目数。0 表示不包含项目,而 -1 表示长度未知。
14 | */
15 | function get length():int;
16 | /**
17 | * 获取指定索引处的项目。
18 | * @throws RangeError 如果索引小于 0 或大于长度。
19 | */
20 | function getItemAt(index:int):Object;
21 | /**
22 | * 如果项目位于列表中,返回该项目的索引。否则返回-1。
23 | */
24 | function getItemIndex(item:Object):int;
25 | }
26 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/collections/ITreeCollection.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.collections
2 | {
3 |
4 | /**
5 | * Tree组件的集合类数据源对象接口
6 | * @author dom
7 | */
8 | public interface ITreeCollection extends ICollection
9 | {
10 | /**
11 | * 检查指定的节点是否含有子节点
12 | * @param item 要检查的节点
13 | */
14 | function hasChildren(item:Object):Boolean;
15 |
16 | /**
17 | * 指定的节点是否打开
18 | */
19 | function isItemOpen(item:Object):Boolean;
20 |
21 | /**
22 | * 打开或关闭一个节点
23 | * @param item 要打开或关闭的节点
24 | * @param open true表示打开节点,反之关闭。
25 | */
26 | function expandItem(item:Object,open:Boolean=true):void;
27 |
28 | /**
29 | * 获取节点的深度
30 | */
31 | function getDepth(item:Object):int;
32 | }
33 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/Button.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.components.supportClasses.ButtonBase;
5 |
6 | use namespace dx_internal;
7 |
8 |
9 | [DXML(show="true")]
10 |
11 | /**
12 | * 按钮控件
13 | * @author dom
14 | */
15 | public class Button extends ButtonBase
16 | {
17 | public function Button()
18 | {
19 | super();
20 | }
21 |
22 | /**
23 | * @inheritDoc
24 | */
25 | override protected function get hostComponentKey():Object
26 | {
27 | return Button;
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/CheckBox.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import org.flexlite.domUI.components.supportClasses.ToggleButtonBase;
4 |
5 | [DXML(show="true")]
6 |
7 | /**
8 | * 复选框
9 | * @author dom
10 | */
11 | public class CheckBox extends ToggleButtonBase
12 | {
13 | /**
14 | * 构造函数
15 | */
16 | public function CheckBox()
17 | {
18 | super();
19 | }
20 |
21 | /**
22 | * @inheritDoc
23 | */
24 | override protected function get hostComponentKey():Object
25 | {
26 | return CheckBox;
27 | }
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/DropDownList.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import org.flexlite.domUI.components.supportClasses.DropDownListBase;
4 | import org.flexlite.domUI.core.IDisplayText;
5 | import org.flexlite.domCore.dx_internal;
6 |
7 | use namespace dx_internal;
8 |
9 | [DXML(show="true")]
10 |
11 | /**
12 | * 不可输入的下拉列表控件。带输入功能的下拉列表控件,请使用ComboBox。
13 | * @see org.flexlite.domUI.components.ComboBox
14 | * @author dom
15 | */
16 | public class DropDownList extends DropDownListBase
17 | {
18 | /**
19 | * 构造函数
20 | */
21 | public function DropDownList()
22 | {
23 | super();
24 | }
25 |
26 | /**
27 | * @inheritDoc
28 | */
29 | override protected function get hostComponentKey():Object
30 | {
31 | return DropDownList;
32 | }
33 |
34 | /**
35 | * [SkinPart]选中项文本
36 | */
37 | public var labelDisplay:IDisplayText;
38 | /**
39 | * label发生改变标志
40 | */
41 | private var labelChanged:Boolean = false;
42 |
43 | private var _prompt:String = "";
44 | /**
45 | * 当没有选中项时在DropDownList上要显示的字符串。
46 | * 它通常是一个类似于“请选择一项...”的文本。当下拉列表中的某个项目被选中后,会被替换为该选定项目中的文本。
47 | */
48 | public function get prompt():String
49 | {
50 | return _prompt;
51 | }
52 | public function set prompt(value:String):void
53 | {
54 | if (_prompt == value)
55 | return;
56 |
57 | _prompt = value;
58 | labelChanged = true;
59 | invalidateProperties();
60 | }
61 | /**
62 | * @inheritDoc
63 | */
64 | override protected function commitProperties():void
65 | {
66 | super.commitProperties();
67 |
68 | if (labelChanged)
69 | {
70 | labelChanged = false;
71 | updateLabelDisplay();
72 | }
73 | }
74 |
75 | /**
76 | * @inheritDoc
77 | */
78 | override protected function partAdded(partName:String, instance:Object):void
79 | {
80 | super.partAdded(partName, instance);
81 |
82 | if (instance == labelDisplay)
83 | {
84 | labelChanged = true;
85 | invalidateProperties();
86 | }
87 | }
88 |
89 | /**
90 | * @inheritDoc
91 | */
92 | override dx_internal function updateLabelDisplay(displayItem:* = undefined):void
93 | {
94 | if (labelDisplay)
95 | {
96 | if (displayItem == undefined)
97 | displayItem = selectedItem;
98 | if (displayItem != null && displayItem != undefined)
99 | labelDisplay.text = itemToLabel(displayItem);
100 | else
101 | labelDisplay.text = _prompt;
102 | }
103 | }
104 |
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/HSlider.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import flash.geom.Point;
4 |
5 | import org.flexlite.domUI.components.supportClasses.SliderBase;
6 |
7 | [DXML(show="true")]
8 |
9 | /**
10 | * 水平滑块控件
11 | * @author dom
12 | */
13 | public class HSlider extends SliderBase
14 | {
15 | /**
16 | * 构造函数
17 | */
18 | public function HSlider()
19 | {
20 | super();
21 | }
22 |
23 | /**
24 | * @inheritDoc
25 | */
26 | override protected function get hostComponentKey():Object
27 | {
28 | return HSlider;
29 | }
30 |
31 | /**
32 | * @inheritDoc
33 | */
34 | override protected function pointToValue(x:Number, y:Number):Number
35 | {
36 | if (!thumb || !track)
37 | return 0;
38 |
39 | var range:Number = maximum - minimum;
40 | var thumbRange:Number = track.layoutBoundsWidth - thumb.layoutBoundsWidth;
41 | return minimum + ((thumbRange != 0) ? (x / thumbRange) * range : 0);
42 | }
43 |
44 | /**
45 | * @inheritDoc
46 | */
47 | override protected function updateSkinDisplayList():void
48 | {
49 | if (!thumb || !track)
50 | return;
51 |
52 | var thumbRange:Number = track.layoutBoundsWidth - thumb.layoutBoundsWidth;
53 | var range:Number = maximum - minimum;
54 | var thumbPosTrackX:Number = (range > 0) ? ((pendingValue - minimum) / range) * thumbRange : 0;
55 | var thumbPos:Point = track.localToGlobal(new Point(thumbPosTrackX, 0));
56 | var thumbPosParentX:Number = thumb.parent.globalToLocal(thumbPos).x;
57 |
58 | thumb.setLayoutBoundsPosition(Math.round(thumbPosParentX), thumb.layoutBoundsY);
59 | if(showTrackHighlight&&trackHighlight&&trackHighlight.parent)
60 | {
61 | var trackHighlightX:Number = trackHighlight.parent.globalToLocal(thumbPos).x-thumbPosTrackX;
62 | trackHighlight.x = Math.round(trackHighlightX);
63 | trackHighlight.width = Math.round(thumbPosTrackX);
64 | }
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/IItemRenderer.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import org.flexlite.domUI.core.ILayoutElement;
4 |
5 | /**
6 | * 列表类组件的项呈示器接口
7 | * @author dom
8 | */
9 | public interface IItemRenderer extends ILayoutElement
10 | {
11 | /**
12 | * 要呈示或编辑的数据。
13 | */
14 | function get data():Object;
15 | function set data(value:Object):void;
16 | /**
17 | * 如果项呈示器可以将其自身显示为已选中,则包含 true。
18 | */
19 | function get selected():Boolean;
20 | function set selected(value:Boolean):void;
21 | /**
22 | * 项呈示器的主机组件的数据提供程序中的项目索引。
23 | */
24 | function get itemIndex():int;
25 | function set itemIndex(value:int):void;
26 | /**
27 | * 要在项呈示器中显示的 String。
28 | */
29 | function get label():String;
30 | function set label(value:String):void;
31 | }
32 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/IItemRendererOwner.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | /**
4 | * 项呈示器的主机组件接口
5 | * @author dom
6 | */
7 | public interface IItemRendererOwner
8 | {
9 | /**
10 | * 更新项呈示器数据
11 | */
12 | function updateRenderer(renderer:IItemRenderer, itemIndex:int, data:Object):IItemRenderer;
13 | }
14 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/ITreeItemRenderer.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 |
4 | /**
5 | * 树状列表组件的项呈示器接口
6 | * @author dom
7 | */
8 | public interface ITreeItemRenderer extends IItemRenderer
9 | {
10 | /**
11 | * 图标的皮肤名
12 | */
13 | function get iconSkinName():Object;
14 | function set iconSkinName(value:Object):void;
15 |
16 | /**
17 | * 缩进深度。0表示顶级节点,1表示第一层子节点,以此类推。
18 | */
19 | function get depth():int;
20 | function set depth(value:int):void;
21 |
22 | /**
23 | * 是否含有子节点。
24 | */
25 | function get hasChildren():Boolean;
26 | function set hasChildren(value:Boolean):void;
27 |
28 | /**
29 | * 节点是否处于开启状态。
30 | */
31 | function get opened():Boolean;
32 | function set opened(value:Boolean):void;
33 | }
34 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/Panel.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 |
4 | import org.flexlite.domUI.core.IDisplayText;
5 |
6 | [DXML(show="true")]
7 |
8 | /**
9 | * 带有标题,内容区域的面板组件
10 | * @author dom
11 | */
12 | public class Panel extends SkinnableContainer
13 | {
14 | /**
15 | * 构造函数
16 | */
17 | public function Panel()
18 | {
19 | super();
20 | mouseEnabled = false;
21 | //当面板覆盖在会运动的场景上时,将会导致不断被触发重绘,而如果含有较多矢量子项,
22 | //就会消耗非常多的渲染时间。设置位图缓存将能极大提高这种情况下的性能。
23 | cacheAsBitmap = true;
24 | }
25 |
26 | /**
27 | * @inheritDoc
28 | */
29 | override protected function get hostComponentKey():Object
30 | {
31 | return Panel;
32 | }
33 |
34 | /**
35 | * [SkinPart]标题显示对象
36 | */
37 | public var titleDisplay:IDisplayText;
38 |
39 | private var _title:String = "";
40 | /**
41 | * 标题内容改变
42 | */
43 | private var titleChanged:Boolean;
44 | /**
45 | * 标题文本内容
46 | */
47 | public function get title():String
48 | {
49 | return _title;
50 | }
51 |
52 | public function set title(value:String):void
53 | {
54 | _title = value;
55 |
56 | if (titleDisplay)
57 | titleDisplay.text = title;
58 | }
59 |
60 | /**
61 | * @inheritDoc
62 | */
63 | override protected function partAdded(partName:String, instance:Object):void
64 | {
65 | super.partAdded(partName, instance);
66 |
67 | if (instance == titleDisplay)
68 | {
69 | titleDisplay.text = title;
70 | }
71 | }
72 |
73 | }
74 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/ProgressBarDirection.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 |
4 | /**
5 | * 定义进度条控件增长方向的常量
6 | * @author dom
7 | */
8 | public class ProgressBarDirection
9 | {
10 | /**
11 | * 水平从左到右增长
12 | */
13 | public static const LEFT_TO_RIGHT:String = "leftToRight";
14 | /**
15 | * 水平从右到左增长
16 | */
17 | public static const RIGHT_TO_LEFT:String = "rightToLeft";
18 | /**
19 | * 竖直从上到下增长
20 | */
21 | public static const TOP_TO_BOTTOM:String = "topToBottom";
22 | /**
23 | * 竖直从下到上增长
24 | */
25 | public static const BOTTOM_TO_TOP:String = "bottomToTop";
26 | }
27 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/Spacer.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import org.flexlite.domUI.core.UIComponent;
4 |
5 | [DXML(show="true")]
6 |
7 | /**
8 | * 占位组件,一个布局辅助类。
9 | * 自身完全不可见,但可以在父级容器的布局中分配空间,通常用于垂直和水平布局中,推挤其他组件。
10 | * @author dom
11 | */
12 | public class Spacer extends UIComponent
13 | {
14 | /**
15 | * 构造函数
16 | */
17 | public function Spacer()
18 | {
19 | super();
20 | }
21 | }
22 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/TabBarButton.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import flash.events.Event;
4 |
5 | import org.flexlite.domUI.components.supportClasses.ToggleButtonBase;
6 | import org.flexlite.domCore.dx_internal;
7 |
8 | use namespace dx_internal;
9 |
10 | [DXML(show="false")]
11 | /**
12 | * 数据源发生改变
13 | */
14 | [Event(name="dataChange",type="flash.events.Event")]
15 |
16 | /**
17 | * 选项卡组件的按钮条目
18 | * @author dom
19 | */
20 | public class TabBarButton extends ToggleButtonBase implements IItemRenderer
21 | {
22 |
23 | public function TabBarButton()
24 | {
25 | super();
26 | }
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | override protected function get hostComponentKey():Object
32 | {
33 | return TabBarButton;
34 | }
35 |
36 | private var _allowDeselection:Boolean = true;
37 | /**
38 | * 如果为 true,用户单击当前选定的按钮时即会将其取消选择。
39 | * 如果为 false,用户必须选择不同的按钮才可取消选择当前选定的按钮。
40 | */
41 | public function get allowDeselection():Boolean
42 | {
43 | return _allowDeselection;
44 | }
45 |
46 | public function set allowDeselection(value:Boolean):void
47 | {
48 | _allowDeselection = value;
49 | }
50 |
51 | private var _data:Object;
52 | /**
53 | * @inheritDoc
54 | */
55 | public function get data():Object
56 | {
57 | return _data;
58 | }
59 |
60 | public function set data(value:Object):void
61 | {
62 | _data = value;
63 | dispatchEvent(new Event("dataChange"));
64 | }
65 |
66 | private var _itemIndex:int;
67 | /**
68 | * @inheritDoc
69 | */
70 | public function get itemIndex():int
71 | {
72 | return _itemIndex;
73 | }
74 |
75 | public function set itemIndex(value:int):void
76 | {
77 | _itemIndex = value;
78 | }
79 |
80 | /**
81 | * @inheritDoc
82 | */
83 | override public function set label(value:String):void
84 | {
85 | if (value != label)
86 | {
87 | super.label = value;
88 |
89 | if (labelDisplay)
90 | labelDisplay.text = label;
91 | }
92 | }
93 |
94 | /**
95 | * @inheritDoc
96 | */
97 | override protected function buttonReleased():void
98 | {
99 | if (selected && !allowDeselection)
100 | return;
101 |
102 | super.buttonReleased();
103 | }
104 | }
105 |
106 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/TextInput.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import flash.display.DisplayObject;
4 | import flash.events.Event;
5 |
6 | import org.flexlite.domUI.components.supportClasses.SkinnableTextBase;
7 | import org.flexlite.domUI.core.IViewport;
8 | import org.flexlite.domCore.dx_internal;
9 |
10 | use namespace dx_internal;
11 |
12 | [DefaultProperty(name="text",array="false")]
13 |
14 | [DXML(show="true")]
15 |
16 | /**
17 | * 可设置外观的单行文本输入控件
18 | * @author dom
19 | */
20 | public class TextInput extends SkinnableTextBase
21 | {
22 | /**
23 | * 构造函数
24 | */
25 | public function TextInput()
26 | {
27 | super();
28 | }
29 |
30 | /**
31 | * @inheritDoc
32 | */
33 | override protected function get hostComponentKey():Object
34 | {
35 | return TextInput;
36 | }
37 |
38 | /**
39 | * 控件的默认宽度(使用字号:size为单位测量)。 若同时设置了maxChars属性,将会根据两者测量结果的最小值作为测量宽度。
40 | */
41 | public function get widthInChars():Number
42 | {
43 | return getWidthInChars();
44 | }
45 |
46 | public function set widthInChars(value:Number):void
47 | {
48 | setWidthInChars(value);
49 | }
50 |
51 | /**
52 | * @inheritDoc
53 | */
54 | override public function set text(value:String):void
55 | {
56 | super.text = value;
57 | dispatchEvent(new Event("textChanged"));
58 | }
59 |
60 | /**
61 | * @inheritDoc
62 | */
63 | override protected function partAdded(partName:String, instance:Object):void
64 | {
65 | super.partAdded(partName, instance);
66 |
67 | if (instance == textDisplay)
68 | {
69 | textDisplay.multiline = false;
70 | if(textDisplay is IViewport)
71 | (textDisplay as IViewport).clipAndEnableScrolling = false;
72 | }
73 | }
74 |
75 | /**
76 | * @inheritDoc
77 | */
78 | override dx_internal function createSkinParts():void
79 | {
80 | textDisplay = new EditableText();
81 | textDisplay.widthInChars = 10;
82 | textDisplay.left = 1;
83 | textDisplay.right = 1;
84 | textDisplay.top = 1;
85 | textDisplay.bottom = 1;
86 | addToDisplayList(DisplayObject(textDisplay));
87 | partAdded("textDisplay",textDisplay);
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/ToggleButton.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import org.flexlite.domUI.components.supportClasses.ToggleButtonBase;
4 |
5 | [DXML(show="true")]
6 | /**
7 | * 切换按钮
8 | * @author dom
9 | */
10 | public class ToggleButton extends ToggleButtonBase
11 | {
12 | /**
13 | * 构造函数
14 | */
15 | public function ToggleButton()
16 | {
17 | super();
18 | }
19 |
20 | /**
21 | * @inheritDoc
22 | */
23 | override protected function get hostComponentKey():Object
24 | {
25 | return ToggleButton;
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/VSlider.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components
2 | {
3 | import flash.geom.Point;
4 |
5 | import org.flexlite.domUI.components.supportClasses.SliderBase;
6 |
7 | [DXML(show="true")]
8 | /**
9 | * 垂直滑块控件
10 | * @author dom
11 | */
12 | public class VSlider extends SliderBase
13 | {
14 | /**
15 | * 构造函数
16 | */
17 | public function VSlider()
18 | {
19 | super();
20 | }
21 |
22 | /**
23 | * @inheritDoc
24 | */
25 | override protected function get hostComponentKey():Object
26 | {
27 | return VSlider;
28 | }
29 |
30 | /**
31 | * @inheritDoc
32 | */
33 | override protected function pointToValue(x:Number, y:Number):Number
34 | {
35 | if (!thumb || !track)
36 | return 0;
37 |
38 | var range:Number = maximum - minimum;
39 | var thumbRange:Number = track.layoutBoundsHeight - thumb.layoutBoundsHeight;
40 | return minimum + ((thumbRange != 0) ? ((thumbRange - y) / thumbRange) * range : 0);
41 | }
42 |
43 | /**
44 | * @inheritDoc
45 | */
46 | override protected function updateSkinDisplayList():void
47 | {
48 | if (!thumb || !track)
49 | return;
50 |
51 | var thumbHeight:Number = thumb.layoutBoundsHeight
52 | var thumbRange:Number = track.layoutBoundsHeight - thumbHeight;
53 | var range:Number = maximum - minimum;
54 | var thumbPosTrackY:Number = (range > 0) ? thumbRange - (((pendingValue - minimum) / range) * thumbRange) : 0;
55 | var thumbPos:Point = track.localToGlobal(new Point(0, thumbPosTrackY));
56 | var thumbPosParentY:Number = thumb.parent.globalToLocal(thumbPos).y;
57 |
58 | thumb.setLayoutBoundsPosition(thumb.layoutBoundsX, Math.round(thumbPosParentY));
59 | if(showTrackHighlight&&trackHighlight&&trackHighlight.parent)
60 | {
61 | var trackHighlightY:Number = this.trackHighlight.parent.globalToLocal(thumbPos).y;
62 | trackHighlight.y = Math.round(trackHighlightY+thumbHeight);
63 | trackHighlight.height = Math.round(thumbRange-trackHighlightY);
64 | }
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/supportClasses/DefaultSkinAdapter.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components.supportClasses
2 | {
3 | import flash.display.Bitmap;
4 | import flash.display.BitmapData;
5 | import flash.display.DisplayObject;
6 | import flash.display.Loader;
7 | import flash.events.Event;
8 | import flash.events.IOErrorEvent;
9 | import flash.net.URLRequest;
10 | import flash.utils.ByteArray;
11 |
12 | import org.flexlite.domUI.core.ISkinAdapter;
13 |
14 |
15 | /**
16 | * 默认的ISkinAdapter接口实现
17 | * @author dom
18 | */
19 | public class DefaultSkinAdapter implements ISkinAdapter
20 | {
21 | /**
22 | * 构造函数
23 | */
24 | public function DefaultSkinAdapter()
25 | {
26 | }
27 | /**
28 | * @inheritDoc
29 | */
30 | public function getSkin(skinName:Object,compFunc:Function,oldSkin:DisplayObject=null):void
31 | {
32 | if(skinName is Class)
33 | {
34 | compFunc(new skinName(),skinName);
35 | }
36 | else if(skinName is String||skinName is ByteArray)
37 | {
38 | var loader:Loader = new Loader;
39 | loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,function(event:Event):void{
40 | compFunc(skinName,skinName);
41 | });
42 | loader.contentLoaderInfo.addEventListener(Event.COMPLETE,function(event:Event):void{
43 | if(loader.content is Bitmap)
44 | {
45 | var bitmapData:BitmapData = (loader.content as Bitmap).bitmapData;
46 | compFunc(new Bitmap(bitmapData,"auto",true),skinName);
47 | }
48 | else
49 | {
50 | compFunc(loader.content,skinName);
51 | }
52 | });
53 | if(skinName is String)
54 | loader.load(new URLRequest(skinName as String));
55 | else
56 | loader.loadBytes(skinName as ByteArray);
57 | }
58 | else if(skinName is BitmapData)
59 | {
60 | var skin:Bitmap;
61 | if(oldSkin is Bitmap)
62 | {
63 | skin = oldSkin as Bitmap;
64 | skin.bitmapData = skinName as BitmapData;
65 | }
66 | else
67 | {
68 | skin = new Bitmap(skinName as BitmapData,"auto",true);
69 | }
70 | compFunc(skin,skinName);
71 | }
72 | else
73 | {
74 | compFunc(skinName,skinName);
75 | }
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/supportClasses/ItemRenderer.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components.supportClasses
2 | {
3 |
4 |
5 | import org.flexlite.domUI.components.IItemRenderer;
6 |
7 | [DXML(show="false")]
8 |
9 | /**
10 | * 项呈示器基类
11 | * @author dom
12 | */
13 | public class ItemRenderer extends ButtonBase implements IItemRenderer
14 | {
15 | public function ItemRenderer()
16 | {
17 | super();
18 | mouseChildren = true;
19 | buttonMode = false;
20 | useHandCursor = false;
21 | }
22 |
23 | /**
24 | * @inheritDoc
25 | */
26 | override protected function get hostComponentKey():Object
27 | {
28 | return ItemRenderer;
29 | }
30 |
31 | private var dataChangedFlag:Boolean = false;
32 | private var _data:Object;
33 | /**
34 | * @inheritDoc
35 | */
36 | public function get data():Object
37 | {
38 | return _data;
39 | }
40 | /**
41 | * @inheritDoc
42 | */
43 | public function set data(value:Object):void
44 | {
45 | //这里不能加if(_data==value)return;的判断,会导致数据源无法刷新的问题
46 | _data = value;
47 | if(initialized||parent)
48 | {
49 | dataChangedFlag = false;
50 | dataChanged();
51 | }
52 | else
53 | {
54 | dataChangedFlag = true;
55 | invalidateProperties();
56 | }
57 | }
58 | /**
59 | * 子类复写此方法以在data数据源发生改变时跟新显示列表。
60 | * 与直接复写data的setter方法不同,它会确保在皮肤已经附加完成后再被调用。
61 | */
62 | protected function dataChanged():void
63 | {
64 |
65 | }
66 |
67 | private var _selected:Boolean = false;
68 | /**
69 | * @inheritDoc
70 | */
71 | public function get selected():Boolean
72 | {
73 | return _selected;
74 | }
75 |
76 | public function set selected(value:Boolean):void
77 | {
78 | if(_selected==value)
79 | return;
80 | _selected = value;
81 | invalidateSkinState();
82 | }
83 |
84 | private var _itemIndex:int = -1;
85 | /**
86 | * @inheritDoc
87 | */
88 | public function get itemIndex():int
89 | {
90 | return _itemIndex;
91 | }
92 |
93 | public function set itemIndex(value:int):void
94 | {
95 | _itemIndex = value;
96 | }
97 |
98 | /**
99 | * @inheritDoc
100 | */
101 | override protected function commitProperties():void
102 | {
103 | super.commitProperties();
104 | if (dataChangedFlag)
105 | {
106 | dataChangedFlag = false;
107 | dataChanged();
108 | }
109 | }
110 |
111 | /**
112 | * @inheritDoc
113 | */
114 | override protected function getCurrentSkinState():String
115 | {
116 | if(_selected)
117 | return "down";
118 | return super.getCurrentSkinState();
119 | }
120 |
121 | }
122 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/components/supportClasses/ToggleButtonBase.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.components.supportClasses
2 | {
3 |
4 | import flash.events.Event;
5 |
6 | import org.flexlite.domCore.dx_internal;
7 | import org.flexlite.domUI.events.UIEvent;
8 |
9 | use namespace dx_internal;
10 |
11 | [Event(name="change", type="flash.events.Event")]
12 |
13 | [DXML(show="false")]
14 |
15 | [SkinState("up")]
16 | [SkinState("over")]
17 | [SkinState("down")]
18 | [SkinState("disabled")]
19 | [SkinState("upAndSelected")]
20 | [SkinState("overAndSelected")]
21 | [SkinState("downAndSelected")]
22 | [SkinState("disabledAndSelected")]
23 |
24 | /**
25 | * 切换按钮组件基类
26 | * @author dom
27 | */
28 | public class ToggleButtonBase extends ButtonBase
29 | {
30 | public function ToggleButtonBase()
31 | {
32 | super();
33 | }
34 |
35 | private var _selected:Boolean;
36 | /**
37 | * 按钮处于按下状态时为 true,而按钮处于弹起状态时为 false。
38 | */
39 | public function get selected():Boolean
40 | {
41 | return _selected;
42 | }
43 |
44 | public function set selected(value:Boolean):void
45 | {
46 | if (value == _selected)
47 | return;
48 |
49 | _selected = value;
50 | dispatchEvent(new UIEvent(UIEvent.VALUE_COMMIT));
51 | invalidateSkinState();
52 | }
53 |
54 | /**
55 | * @inheritDoc
56 | */
57 | override protected function getCurrentSkinState():String
58 | {
59 | if (!selected)
60 | return super.getCurrentSkinState();
61 | else
62 | return super.getCurrentSkinState() + "AndSelected";
63 | }
64 | /**
65 | * 是否根据鼠标事件自动变换选中状态,默认true。
66 | */
67 | dx_internal var autoSelected:Boolean = true;
68 | /**
69 | * @inheritDoc
70 | */
71 | override protected function buttonReleased():void
72 | {
73 | super.buttonReleased();
74 | if(!autoSelected||!enabled)
75 | return;
76 | selected = !selected;
77 | dispatchEvent(new Event(Event.CHANGE));
78 | }
79 | }
80 |
81 | }
82 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/DomGlobals.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import flash.display.Stage;
4 | import flash.events.Event;
5 |
6 | import org.flexlite.domCore.Injector;
7 | import org.flexlite.domCore.dx_internal;
8 | import org.flexlite.domUI.managers.FocusManager;
9 | import org.flexlite.domUI.managers.IFocusManager;
10 | import org.flexlite.domUI.managers.ISystemManager;
11 | import org.flexlite.domUI.managers.LayoutManager;
12 |
13 | use namespace dx_internal;
14 |
15 | /**
16 | * 全局静态量
17 | * @author dom
18 | */
19 | public class DomGlobals
20 | {
21 | /**
22 | * 一个全局标志,控制在某些鼠标操作或动画特效播放时,是否开启updateAfterEvent(),开启时能增加平滑的体验感,但是会提高屏幕渲染(Render事件)的频率。默认为true。
23 | */
24 | public static var useUpdateAfterEvent:Boolean = true;
25 |
26 | private static var _stage:Stage;
27 | /**
28 | * 舞台引用,当第一个UIComponent添加到舞台时此属性被自动赋值
29 | */
30 | public static function get stage():Stage
31 | {
32 | return _stage;
33 | }
34 | /**
35 | * 已经初始化完成标志
36 | */
37 | private static var initlized:Boolean = false;
38 | /**
39 | * 初始化管理器
40 | */
41 | dx_internal static function initlize(stage:Stage):void
42 | {
43 | if(initlized)
44 | return;
45 | _stage = stage;
46 | layoutManager = new LayoutManager();
47 | try
48 | {
49 | focusManager = Injector.getInstance(IFocusManager);
50 | }
51 | catch(e:Error)
52 | {
53 | focusManager = new FocusManager();
54 | }
55 | focusManager.stage = stage;
56 | //屏蔽callLaterError
57 | stage.addEventListener("callLaterError",function(event:Event):void{});
58 | initlized = true;
59 | }
60 | /**
61 | * 延迟渲染布局管理器
62 | */
63 | dx_internal static var layoutManager:LayoutManager;
64 | /**
65 | * 焦点管理器
66 | */
67 | dx_internal static var focusManager:IFocusManager;
68 | /**
69 | * 系统管理器列表
70 | */
71 | dx_internal static var _systemManagers:Vector. = new Vector.();
72 | /**
73 | * 顶级应用容器
74 | */
75 | public static function get systemManager():ISystemManager
76 | {
77 | for(var i:int=_systemManagers.length-1;i>=0;i--)
78 | {
79 | if(_systemManagers[i].stage)
80 | return _systemManagers[i];
81 | }
82 | return null;
83 | }
84 | /**
85 | * 是否屏蔽失效验证阶段和callLater方法延迟调用的所有报错。
86 | * 建议在发行版中启用,避免因为一处报错引起全局的延迟调用失效。
87 | */
88 | public static var catchCallLaterExceptions:Boolean = false;
89 | }
90 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/DragSource.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | /**
4 | * DragSource 类中包含正被拖动的数据。数据可以采用多种格式,具体取决于启动拖动的控件的类型。
5 | * 每种数据格式都使用一个字符串进行标识。hasFormat() 方法用于确定对象是否包含使用相应格式的数据。dataForFormat() 方法用于检索指定格式的数据。
6 | * 可以使用 addData() 方法直接添加数据,也可以使用 addHandler() 方法间接添加数据。
7 | * addHandler() 方法会注册一个回调,请求该数据时将调用此回调。添加非本机格式的数据可能需要进行大量计算或转换,此时该方法就非常有用。
8 | * 例如,如果您具有原始声音数据,则可以添加 MP3 格式处理程序。仅当请求 MP3 数据时才执行 MP3 转换。
9 | * @author dom
10 | */
11 | public class DragSource
12 | {
13 | /**
14 | * 构造函数
15 | */
16 | public function DragSource()
17 | {
18 | super();
19 | }
20 |
21 | private var dataHolder:Object = {};
22 |
23 | private var formatHandlers:Object = {};
24 |
25 | private var _formats:Array = [];
26 | /**
27 | * 包含拖动数据的格式,以字符串 Array 的形式表示。
28 | * 使用 addData() 或 addHandler() 方法设置此属性。默认值取决于添加到 DragSource 对象的数据。
29 | */
30 | public function get formats():Array
31 | {
32 | return _formats;
33 | }
34 | /**
35 | * 向拖动源添加数据和相应的格式 String。
36 | * @param data 用于指定拖动数据的对象。这可以是任何对象,如,String,ArrayCollection,等等。
37 | * @param format 描述此数据格式的字符串。
38 | */
39 | public function addData(data:Object, format:String):void
40 | {
41 | _formats.push(format);
42 |
43 | dataHolder[format] = data;
44 | }
45 |
46 | /**
47 | * 添加一个处理函数,当请求指定格式的数据时将调用此处理函数。当拖动大量数据时,此函数非常有用。仅当请求数据时才调用该处理函数。
48 | * @param handler 一个函数,用于指定请求数据时需要调用的处理函数。此函数必须返回指定格式的数据。
49 | * @param format 用于指定此数据的格式的字符串。
50 | */
51 | public function addHandler(handler:Function,
52 | format:String):void
53 | {
54 | _formats.push(format);
55 |
56 | formatHandlers[format] = handler;
57 | }
58 | /**
59 | * 检索指定格式的数据。如果此数据是使用 addData() 方法添加的,则可以直接返回此数据。
60 | * 如果此数据是使用 addHandler() 方法添加的,则需调用处理程序函数来返回此数据。
61 | * @param format 描述此数据格式的字符串。
62 | */
63 | public function dataForFormat(format:String):Object
64 | {
65 | var data:Object = dataHolder[format];
66 | if (data)
67 | return data;
68 |
69 | if (formatHandlers[format])
70 | return formatHandlers[format]();
71 |
72 | return null;
73 | }
74 | /**
75 | * 如果数据源中包含所请求的格式,则返回 true;否则,返回 false。
76 | * @param format 描述此数据格式的字符串。
77 | */
78 | public function hasFormat(format:String):Boolean
79 | {
80 | var n:int = _formats.length;
81 | for (var i:int = 0; i < n; i++)
82 | {
83 | if (_formats[i] == format)
84 | return true;
85 | }
86 |
87 | return false;
88 | }
89 | }
90 |
91 | }
92 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IContainer.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 |
4 | /**
5 | * 容器接口
6 | * @author dom
7 | */
8 | public interface IContainer
9 | {
10 | /**
11 | * 此容器中的可视元素的数量。
12 | * 可视元素包括实现 IVisualElement 接口的类,
13 | */
14 | function get numElements():int;
15 | /**
16 | * 返回指定索引处的可视元素。
17 | * @param index 要检索的元素的索引。
18 | * @throws RangeError 如果在子列表中不存在该索引位置。
19 | */
20 | function getElementAt(index:int):IVisualElement
21 | /**
22 | * 将可视元素添加到此容器中。
23 | * 如果添加的可视元素已有一个不同的容器作为父项,则该元素将会从其他容器中删除。
24 | * @param element 要添加为此容器的子项的可视元素。
25 | */
26 | function addElement(element:IVisualElement):IVisualElement;
27 | /**
28 | * 将可视元素添加到此容器中。该元素将被添加到指定的索引位置。索引 0 代表显示列表中的第一个元素。
29 | * 如果添加的可视元素已有一个不同的容器作为父项,则该元素将会从其他容器中删除。
30 | * @param element 要添加为此可视容器的子项的元素。
31 | * @param index 将该元素添加到的索引位置。如果指定当前占用的索引位置,则该位置以及所有更高位置上的子对象会在子级列表中上移一个位置。
32 | * @throws RangeError 如果在子列表中不存在该索引位置。
33 | */
34 | function addElementAt(element:IVisualElement, index:int):IVisualElement;
35 | /**
36 | * 从此容器的子列表中删除指定的可视元素。
37 | * 在该可视容器中,位于该元素之上的所有元素的索引位置都减少 1。
38 | * @param element 要从容器中删除的元素。
39 | */
40 | function removeElement(element:IVisualElement):IVisualElement;
41 | /**
42 | * 从容器中的指定索引位置删除可视元素。
43 | * 在该可视容器中,位于该元素之上的所有元素的索引位置都减少 1。
44 | * @param index 要删除的元素的索引。
45 | * @throws RangeError 如果在子列表中不存在该索引位置。
46 | */
47 | function removeElementAt(index:int):IVisualElement;
48 | /**
49 | * 返回可视元素的索引位置。若不存在,则返回-1。
50 | * @param element 可视元素。
51 | */
52 | function getElementIndex(element:IVisualElement):int;
53 | /**
54 | * 在可视容器中更改现有可视元素的位置。
55 | * @param element 要为其更改索引编号的元素。
56 | * @param index 元素的最终索引编号。
57 | * @throws RangeError 如果在子列表中不存在该索引位置。
58 | */
59 | function setElementIndex(element:IVisualElement, index:int):void;
60 |
61 | }
62 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IDisplayText.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | /**
4 | * 简单文本显示控件接口。
5 | * @author dom
6 | */
7 | public interface IDisplayText extends IUIComponent
8 | {
9 | /**
10 | * 此文本组件所显示的文本。
11 | */
12 | function get text():String;
13 | function set text(value:String):void;
14 | }
15 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IEffect.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import flash.events.IEventDispatcher;
4 |
5 | /**
6 | * 动画特效接口
7 | * @author dom
8 | */
9 | public interface IEffect extends IEventDispatcher
10 | {
11 | /**
12 | * 要应用此动画特效的对象。若要将特效同时应用到多个对象,请使用targets属性。
13 | */
14 | function get target():Object;
15 | function set target(value:Object):void;
16 | /**
17 | * 要应用此动画特效的多个对象列表。
18 | */
19 | function get targets():Array;
20 | function set targets(value:Array):void;
21 | /**
22 | * 动画持续时间,单位毫秒,默认值500
23 | */
24 | function get duration():Number;
25 | function set duration(value:Number):void;
26 | /**
27 | * 是否正在播放动画,不包括延迟等待和暂停的阶段。
28 | */
29 | function get isPlaying():Boolean;
30 | /**
31 | * 动画已经开始的标志,包括延迟等待和暂停的阶段。
32 | */
33 | function get started():Boolean;
34 | /**
35 | * 正在暂停中
36 | */
37 | function get isPaused():Boolean;
38 | /**
39 | * 正在反向播放。
40 | */
41 | function get isReverse():Boolean;
42 | /**
43 | * 开始正向播放动画,无论何时调用都重新从零时刻开始,若设置了延迟会首先进行等待。
44 | */
45 | function play(targets:Array=null):void;
46 | /**
47 | * 仅当动画已经在播放中时有效,从当前位置开始沿motionPaths定义的路径反向播放。
48 | */
49 | function reverse():void;
50 | /**
51 | * 直接跳到动画结尾
52 | */
53 | function end():void;
54 | /**
55 | * 停止播放动画
56 | */
57 | function stop():void;
58 | /**
59 | * 暂停播放
60 | */
61 | function pause():void;
62 | /**
63 | * 继续播放
64 | */
65 | function resume():void;
66 | /**
67 | * 重置所有属性为初始状态。若正在播放中,同时立即停止动画。
68 | */
69 | function reset():void;
70 | }
71 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IInvalidating.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | /**
4 | * 拥有失效验证机制组件接口
5 | * @author dom
6 | */
7 | public interface IInvalidating
8 | {
9 | /**
10 | * 标记提交过需要延迟应用的属性
11 | */
12 | function invalidateProperties():void;
13 | /**
14 | * 标记提交过需要验证组件尺寸
15 | */
16 | function invalidateSize():void;
17 | /**
18 | * 标记需要验证显示列表
19 | */
20 | function invalidateDisplayList():void;
21 | /**
22 | * 立即应用组件及其子项的所有属性
23 | * @param skipDisplayList 是否跳过显示列表验证阶段,默认false
24 | */
25 | function validateNow(skipDisplayList:Boolean = false):void;
26 | }
27 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/ISkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import org.flexlite.domUI.components.SkinnableComponent;
4 |
5 | /**
6 | * 皮肤对象接口。只有实现此接口的皮肤会被匹配公开同名变量,并注入到主机组件上。
7 | * @author dom
8 | */
9 | public interface ISkin
10 | {
11 | /**
12 | * 主机组件引用,仅当皮肤被应用后才会对此属性赋值
13 | */
14 | function get hostComponent():SkinnableComponent;
15 | function set hostComponent(value:SkinnableComponent):void;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/ISkinAdapter.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import flash.display.DisplayObject;
4 |
5 | /**
6 | * 皮肤适配器接口。
7 | * 若项目需要自定义可设置外观组件的skinName属性的解析规则,需要实现这个接口,然后调用Injector.mapClass()注入到框架即可。
8 | * @author dom
9 | */
10 | public interface ISkinAdapter
11 | {
12 | /**
13 | * 获取皮肤显示对象
14 | * @param skinName 待解析的新皮肤标识符
15 | * @param compFunc 解析完成回调函数,示例:compFunc(skin:Object,skinName:Object):void;
16 | * 回调参数skin若为显示对象,将直接被添加到显示列表,其他对象根据项目自定义组件的具体规则解析。
17 | * @param oldSkin 旧的皮肤显示对象,传入值有可能为null。对于某些类型素材,例如Bitmap,可以重用传入的显示对象,只修改其数据再返回。
18 | */
19 | function getSkin(skinName:Object,compFunc:Function,oldSkin:DisplayObject=null):void;
20 | }
21 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/ISkinnableClient.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 |
4 | /**
5 | * 可设置外观的组件接口
6 | * @author dom
7 | */
8 | public interface ISkinnableClient extends IVisualElement
9 | {
10 | /**
11 | * 皮肤标识符。可以为Class,String,或DisplayObject实例等任意类型。
12 | * 具体规则由项目注入的ISkinAdapter决定,皮肤适配器将在运行时解析此标识符,然后返回皮肤对象给组件。
13 | */
14 | function get skinName():Object;
15 | function set skinName(value:Object):void;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IStateClient.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import flash.events.IEventDispatcher;
4 |
5 | /**
6 | * 具有视图状态的组件接口
7 | * @author dom
8 | */
9 | public interface IStateClient extends IEventDispatcher
10 | {
11 | /**
12 | * 组件的当前视图状态。将其设置为 "" 或 null 可将组件重置回其基本状态。
13 | */
14 | function get currentState():String;
15 |
16 | function set currentState(value:String):void;
17 |
18 | /**
19 | * 为此组件定义的视图状态。
20 | */
21 | function get states():Array;
22 |
23 | function set states(value:Array):void;
24 |
25 | /**
26 | * 返回是否含有指定名称的视图状态
27 | * @param stateName 要检测的视图状态名称
28 | */
29 | function hasState(stateName:String):Boolean
30 | }
31 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IToolTip.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 |
4 | /**
5 | * 工具提示组件接口
6 | * @author dom
7 | */
8 | public interface IToolTip extends IUIComponent
9 | {
10 | /**
11 | * 工具提示的数据对象,通常为一个字符串。
12 | */
13 | function get toolTipData():Object;
14 |
15 | function set toolTipData(value:Object):void;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/ITranslator.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 |
4 | /**
5 | * 多语言文本翻译接口。实现此接口并调用Injector注入后,可以截获并翻译所有文本控件的text属性。
6 | * 提示:text属性可以用特殊标识符分隔开,例如:"key||替换文本1||替换文本2",
7 | * 然后在translate()方法里自定义解析规则,重新组装文本并返回。
8 | * @author dom
9 | */
10 | public interface ITranslator
11 | {
12 | /**
13 | * 翻译指定的文本
14 | * @param text 要翻译的文本
15 | */
16 | function translate(text:String):String;
17 | }
18 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IUIComponent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import org.flexlite.domUI.managers.ISystemManager;
4 |
5 | /**
6 | * UI组件接口
7 | * @author dom
8 | */
9 | public interface IUIComponent extends IVisualElement
10 | {
11 | /**
12 | * 组件是否可以接受用户交互。
13 | */
14 | function get enabled():Boolean;
15 | function set enabled(value:Boolean):void;
16 | /**
17 | * PopUpManager将其设置为true,以指示已弹出该组件。
18 | */
19 | function get isPopUp():Boolean;
20 | function set isPopUp(value:Boolean):void;
21 | /**
22 | * 外部显式指定的高度
23 | */
24 | function get explicitHeight():Number;
25 | /**
26 | * 外部显式指定的宽度
27 | */
28 | function get explicitWidth():Number;
29 | /**
30 | * 设置组件的宽高,w,h均不包含scale值。此方法不同于直接设置width,height属性,
31 | * 不会影响显式标记尺寸属性widthExplicitlySet,_heightExplicitlySet
32 | */
33 | function setActualSize(newWidth:Number, newHeight:Number):void;
34 | /**
35 | * 当鼠标在组件上按下时,是否能够自动获得焦点的标志。注意:UIComponent的此属性默认值为false。
36 | */
37 | function get focusEnabled():Boolean;
38 | function set focusEnabled(value:Boolean):void;
39 | /**
40 | * 设置当前组件为焦点对象
41 | */
42 | function setFocus():void;
43 | /**
44 | * 所属的系统管理器
45 | */
46 | function get systemManager():ISystemManager;
47 | function set systemManager(value:ISystemManager):void;
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IViewStack.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 |
4 | /**
5 | * 层级堆叠容器接口
6 | * @author dom
7 | */
8 | public interface IViewStack
9 | {
10 | /**
11 | * 当前可见子元素的索引。索引从0开始。
12 | */
13 | function get selectedIndex():int;
14 | function set selectedIndex(value:int):void;
15 |
16 | /**
17 | * 当前可见的子元素。
18 | */
19 | function get selectedChild():IVisualElement;
20 | function set selectedChild(value:IVisualElement):void;
21 | }
22 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IViewport.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | /**
4 | * 支持视区的组件接口
5 | * @author dom
6 | */
7 | public interface IViewport extends IVisualElement
8 | {
9 | /**
10 | * 视域的内容的宽度。
11 | * 如果 clipAndEnabledScrolling 为 true, 则视域的 contentWidth 为水平滚动定义限制,
12 | * 且视域的实际宽度定义可见的内容量。要在内容中水平滚动, 请在 0 和 contentWidth - width
13 | * 之间更改 horizontalScrollPosition。
14 | */
15 | function get contentWidth():Number;
16 |
17 | /**
18 | * 视域的内容的高度。
19 | * 如果 clipAndEnabledScrolling 为 true,则视域的 contentHeight 为垂直滚动定义限制,
20 | * 且视域的实际高度定义可见的内容量。要在内容中垂直滚动,请在 0 和 contentHeight - height
21 | * 之间更改 verticalScrollPosition。
22 | */
23 | function get contentHeight():Number;
24 |
25 | /**
26 | * 可视区域水平方向起始点
27 | */
28 | function get horizontalScrollPosition():Number;
29 | function set horizontalScrollPosition(value:Number):void;
30 |
31 | /**
32 | * 可视区域竖直方向起始点
33 | */
34 | function get verticalScrollPosition():Number;
35 | function set verticalScrollPosition(value:Number):void;
36 |
37 | /**
38 | * 返回要添加到视域的当前 horizontalScrollPosition 的数量,以按请求的滚动单位进行滚动。
39 | * @param navigationUnit 要滚动的数量。该值必须是NavigationUnit 常量之一
40 | */
41 | function getHorizontalScrollPositionDelta(navigationUnit:uint):Number;
42 |
43 | /**
44 | * 回要添加到视域的当前 verticalScrollPosition 的数量,以按请求的滚动单位进行滚动。
45 | * @param navigationUnit 要滚动的数量。该值必须是NavigationUnit 常量之一
46 | */
47 | function getVerticalScrollPositionDelta(navigationUnit:uint):Number;
48 |
49 | /**
50 | * 如果为 true,指定将子代剪切到视区的边界。如果为 false,则容器子代会从容器边界扩展过去,而不管组件的大小规范。默认false
51 | */
52 | function get clipAndEnableScrolling():Boolean;
53 | function set clipAndEnableScrolling(value:Boolean):void;
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IVisualElement.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import flash.display.DisplayObjectContainer;
4 |
5 | /**
6 | * 可视元素接口
7 | * @author dom
8 | */
9 | public interface IVisualElement extends ILayoutElement
10 | {
11 | /**
12 | * 此IVisualElement对象的所有者。
13 | * 0.默认情况下,owner指向parent属性的值。
14 | * 1.当此对象被PopUpAnchor组件弹出时,owner指向PopUpAnchor
15 | * 2.当此对象作为皮肤内contentGroup的子项时,owner指向主机组件SkinnableContainer
16 | * 3.当此对象作为ItemRenderer时,owner指向DataGroup或者主机组件SkinnableDataContainer
17 | * 4.当此对象作为非显示对象容器IContainer的子项时,owner指向IContainer。
18 | */
19 | function get owner():Object;
20 | /**
21 | * owner属性由框架内部管理,请不要自行改变它的值,否则可能引发未知的问题。
22 | */
23 | function ownerChanged(value:Object):void;
24 | /**
25 | * 元素名称。此属性在TabNavigator里作为选项卡显示的字符串。
26 | */
27 | function get name():String;
28 | function set name(value:String):void;
29 | /**
30 | * 此组件的父容器或组件。
31 | * 只有可视元素应该具有 parent 属性。
32 | * 非可视项目应该使用其他属性引用其所属对象。
33 | * 一般而言,非可视对象使用 owner 属性引用其所属对象。
34 | */
35 | function get parent():DisplayObjectContainer;
36 |
37 | /**
38 | * 控制此可视元素的可见性。如果为 true,则对象可见。
39 | */
40 | function get visible():Boolean;
41 | function set visible(value:Boolean):void;
42 |
43 | /**
44 | * 表示指定对象的 Alpha 透明度值。有效值为 0(完全透明)到 1(完全不透明)。默认值为 1。alpha 设置为 0 的显示对象是活动的,即使它们不可见。
45 | */
46 | function get alpha():Number;
47 | function set alpha(value:Number):void;
48 | /**
49 | * 组件宽度
50 | */
51 | function get width():Number;
52 | function set width(value:Number):void;
53 |
54 | /**
55 | * 组件高度
56 | */
57 | function get height():Number;
58 | function set height(value:Number):void;
59 |
60 | /**
61 | * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 x 坐标。
62 | * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer
63 | * 的本地坐标系中。因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer
64 | * 的子级将继承逆时针旋转 90 度的坐标系。对象的坐标指的是注册点的位置。
65 | */
66 | function get x():Number;
67 | function set x(value:Number):void;
68 | /**
69 | * 表示 DisplayObject 实例相对于父级 DisplayObjectContainer 本地坐标的 y 坐标。
70 | * 如果该对象位于具有变形的 DisplayObjectContainer 内,则它也位于包含 DisplayObjectContainer
71 | * 的本地坐标系中。因此,对于逆时针旋转 90 度的 DisplayObjectContainer,该 DisplayObjectContainer
72 | * 的子级将继承逆时针旋转 90 度的坐标系。对象的坐标指的是注册点的位置。
73 | */
74 | function get y():Number;
75 | function set y(value:Number):void;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/IVisualElementContainer.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 |
4 | /**
5 | * 具有管理IVisualElement子显示对象的容器接口
6 | * @author dom
7 | */
8 | public interface IVisualElementContainer extends IVisualElement,IContainer
9 | {
10 | /**
11 | * 从容器中删除所有可视元素。
12 | */
13 | function removeAllElements():void;
14 | /**
15 | * 交换两个指定可视元素的索引。所有其他元素仍位于相同的索引位置。
16 | * @param element1 第一个可视元素。
17 | * @param element2 第二个可视元素。
18 | */
19 | function swapElements(element1:IVisualElement, element2:IVisualElement):void;
20 | /**
21 | * 交换容器中位于两个指定索引位置的可视元素。所有其他可视元素仍位于相同的索引位置。
22 | * @param index1 第一个元素的索引。
23 | * @param index2 第二个元素的索引。
24 | * @throws RangeError 如果在子列表中不存在该索引位置。
25 | */
26 | function swapElementsAt(index1:int, index2:int):void;
27 | /**
28 | * 确定指定的 IVisualElement 是否为容器实例的子代或该实例本身。将进行深度搜索,即,如果此元素是该容器的子代、孙代、曾孙代等,它将返回 true。
29 | * @param element 要测试的子对象
30 | */
31 | function containsElement(element:IVisualElement):Boolean;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/NavigationUnit.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import flash.ui.Keyboard;
4 |
5 | /**
6 | * NavigationUnit 类为 IViewport 类的getVerticalScrollPositionDelta()
7 | * 和 getHorizontalScrollPositionDelta() 方法定义可能的值。
8 | * @author dom
9 | */
10 | public final class NavigationUnit
11 | {
12 | /**
13 | * 导航到文档的开头。
14 | */
15 | public static const HOME:uint = Keyboard.HOME;
16 | /**
17 | * 导航到文档的末尾。
18 | */
19 | public static const END:uint = Keyboard.END;
20 | /**
21 | * 向上导航一行或向上“步进”。
22 | */
23 | public static const UP:uint = Keyboard.UP;
24 | /**
25 | * 向上导航一行或向上“步进”。
26 | */
27 | public static const DOWN:uint = Keyboard.DOWN;
28 | /**
29 | * 向上导航一行或向上“步进”。
30 | */
31 | public static const LEFT:uint = Keyboard.LEFT;
32 | /**
33 | * 向右导航一行或向右“步进”。
34 | */
35 | public static const RIGHT:uint = Keyboard.RIGHT;
36 | /**
37 | * 向上导航一页。
38 | */
39 | public static const PAGE_UP:uint = Keyboard.PAGE_UP;
40 | /**
41 | * 向下导航一页。
42 | */
43 | public static const PAGE_DOWN:uint = Keyboard.PAGE_DOWN;
44 | /**
45 | * 向左导航一页。
46 | */
47 | public static const PAGE_LEFT:uint = 0x2397;
48 | /**
49 | * 向左导航一页。
50 | */
51 | public static const PAGE_RIGHT:uint = 0x2398;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/PopUpPosition.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | /**
4 | * 定义弹出位置的常量值。
5 | * 该常量决定目标对象相对于父级组件的弹出位置。
6 | * @author dom
7 | */
8 | public final class PopUpPosition
9 | {
10 | /**
11 | * 在组件上方弹出
12 | */
13 | public static const ABOVE:String = "above";
14 | /**
15 | * 在组件下方弹出
16 | */
17 | public static const BELOW:String = "below";
18 | /**
19 | * 在组件中心弹出
20 | */
21 | public static const CENTER:String = "center";
22 | /**
23 | * 在组件左上角弹出
24 | */
25 | public static const TOP_LEFT:String = "topLeft";
26 | /**
27 | * 在组件左边弹出
28 | */
29 | public static const LEFT:String = "left";
30 | /**
31 | * 在组件右边弹出
32 | */
33 | public static const RIGHT:String = "right";
34 |
35 |
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/ScrollPolicy.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | /**
4 | * 滚动条显示策略常量
5 | * @author dom
6 | */
7 | public class ScrollPolicy
8 | {
9 | /**
10 | * 如果子项超出所有者的尺寸,则显示滚动栏。在显示滚动条时并不会因滚动条尺寸而调整所有者的尺寸,因此这可能会导致 scrollbar 遮蔽控件或容器的内容。
11 | */
12 | public static const AUTO:String = "auto";
13 |
14 | /**
15 | * 从不显示滚动栏。
16 | */
17 | public static const OFF:String = "off";
18 |
19 | /**
20 | * 总是显示滚动栏。scrollbar 的尺寸将自动添加至所有者内容的尺寸,以便在未显式指定所有者尺寸时确定该尺寸。
21 | */
22 | public static const ON:String = "on";
23 | }
24 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/core/Theme.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.core
2 | {
3 | import flash.utils.Dictionary;
4 | import flash.utils.getQualifiedClassName;
5 |
6 | /**
7 | * 主题管理类。
8 | * 在子类调用mapSkin()方法为每个组件映射默认的皮肤。
9 | * @author dom
10 | */
11 | public class Theme
12 | {
13 | /**
14 | * 构造函数
15 | */
16 | public function Theme()
17 | {
18 | }
19 |
20 | /**
21 | * 储存类的映射规则
22 | */
23 | private var skinNameDic:Dictionary;
24 |
25 | /**
26 | * 为指定的组件映射默认皮肤。
27 | * @param hostComponentKey 传入组件实例,类定义或完全限定类名。
28 | * @param skinClass 传递类定义作为需要映射的皮肤,它的构造函数必须为空。
29 | * @param named 可选参数,当需要为同一个组件映射多个皮肤时,可以传入此参数区分不同的映射。在调用getInstance()方法时要传入同样的参数。
30 | */
31 | public function mapSkin(hostComponentKey:Object,skinName:Object,named:String=""):void
32 | {
33 | var requestName:String = getKey(hostComponentKey)+"#"+named;;
34 |
35 | if(!skinNameDic)
36 | {
37 | skinNameDic = new Dictionary;
38 | }
39 | skinNameDic[requestName] = skinName;
40 | }
41 | /**
42 | * 获取完全限定类名
43 | */
44 | private function getKey(hostComponentKey:Object):String
45 | {
46 | if(hostComponentKey is String)
47 | return hostComponentKey as String;
48 | return getQualifiedClassName(hostComponentKey);
49 | }
50 |
51 | /**
52 | * 获取指定类映射的实例
53 | * @param hostComponentKey 组件实例,类定义或完全限定类名
54 | * @param named 可选参数,若在调用mapClass()映射时设置了这个值,则要传入同样的字符串才能获取对应的实例
55 | */
56 | public function getSkinName(hostComponentKey:Object,named:String=""):Object
57 | {
58 | var requestName:String = getKey(hostComponentKey)+"#"+named;;
59 | if(skinNameDic)
60 | {
61 | return skinNameDic[requestName];
62 | }
63 | return null;
64 | }
65 | }
66 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/Fade.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.effects.animation.Animation;
5 | import org.flexlite.domUI.effects.animation.MotionPath;
6 | import org.flexlite.domUI.effects.supportClasses.Effect;
7 |
8 | use namespace dx_internal;
9 |
10 | [DXML(show="false")]
11 |
12 | /**
13 | * 淡入淡出特效,此动画作用于对象的alpha属性。
14 | * @author dom
15 | */
16 | public class Fade extends Effect
17 | {
18 | /**
19 | * 构造函数
20 | * @param target 要应用此动画特效的对象
21 | */
22 | public function Fade(target:Object=null)
23 | {
24 | super(target);
25 | }
26 | /**
27 | * alpha起始值。若不设置,则使用目标对象的当前alpha值。
28 | */
29 | public var alphaFrom:Number = NaN;
30 | /**
31 | * alpha结束值。若不设置,则使用目标对象的当前alpha值。
32 | */
33 | public var alphaTo:Number = NaN;
34 |
35 | /**
36 | * @inheritDoc
37 | */
38 | override public function reset():void
39 | {
40 | super.reset();
41 | alphaFrom = alphaTo = NaN;
42 | }
43 |
44 | /**
45 | * @inheritDoc
46 | */
47 | override protected function createMotionPath():Vector.
48 | {
49 | var alphaFromSet:Boolean = !isNaN(alphaFrom);
50 | var alphaToSet:Boolean = !isNaN(alphaTo);
51 |
52 | var index:int = 0;
53 | var motionPaths:Vector. = new Vector.;
54 | var alphaStart:Number = alphaFrom;
55 | var alphaEnd:Number = alphaTo;
56 | for each(var target:Object in _targets)
57 | {
58 | if(!alphaFromSet)
59 | alphaStart = target["alpha"];
60 | if(!alphaToSet)
61 | alphaEnd = target["alpha"];
62 | motionPaths.push(new MotionPath("alpha"+index,alphaStart,alphaEnd));
63 | index++;
64 | }
65 | return motionPaths;
66 | }
67 |
68 | /**
69 | * @inheritDoc
70 | */
71 | override protected function animationUpdateHandler(animation:Animation):void
72 | {
73 | var index:int = 0;
74 | for each(var target:Object in _targets)
75 | {
76 | target["alpha"] = animation.currentValue["alpha"+index];
77 | index++;
78 | }
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/animation/MotionPath.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.animation
2 | {
3 | /**
4 | * 数值运动路径。用于定义需要在Animation类中缓动的数值范围。
5 | * @author dom
6 | */
7 | public class MotionPath
8 | {
9 | /**
10 | * 构造函数
11 | * @param property 正在设置动画的属性的名称。
12 | * @param valueFrom 缓动的起始值
13 | * @param valueTo 缓动的结束值
14 | */
15 | public function MotionPath(property:String=null, valueFrom:Number=0, valueTo:Number=1)
16 | {
17 | _property = property;
18 | _valueFrom = valueFrom;
19 | _valueTo = valueTo;
20 | }
21 |
22 | private var _property:String;
23 | /**
24 | * 正在设置动画的属性的名称。
25 | */
26 | public function get property():String
27 | {
28 | return _property;
29 | }
30 |
31 | public function set property(value:String):void
32 | {
33 | _property = value;
34 | }
35 |
36 | private var _valueFrom:Number
37 | /**
38 | * 缓动的起始值
39 | */
40 | public function get valueFrom():Number
41 | {
42 | return _valueFrom;
43 | }
44 |
45 | public function set valueFrom(value:Number):void
46 | {
47 | _valueFrom = value;
48 | }
49 |
50 | private var _valueTo:Number
51 | /**
52 | * 缓动的结束值
53 | */
54 | public function get valueTo():Number
55 | {
56 | return _valueTo;
57 | }
58 |
59 | public function set valueTo(value:Number):void
60 | {
61 | _valueTo = value;
62 | }
63 |
64 |
65 | }
66 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/animation/RepeatBehavior.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.animation
2 | {
3 | /**
4 | * RepeatBehavior类定义用于 Animation类的repeatBehavior属性的常量。
5 | * @author dom
6 | */
7 | public class RepeatBehavior
8 | {
9 | /**
10 | * 始终重复正向播放动画
11 | */
12 | public static const LOOP:String = "loop";
13 |
14 | /**
15 | * 每个奇数采用正向播放,偶数次采用逆向播放,交替进行。
16 | */
17 | public static const REVERSE:String = "reverse";
18 | }
19 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/Bounce.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | * Bounce 类实现缓动功能,该功能模拟目标对象上的重力牵引和回弹目标对象。效果目标的移动会向着最终值加速,然后对着最终值回弹几次。
5 | * @author dom
6 | */
7 | public class Bounce implements IEaser
8 | {
9 | /**
10 | * 构造函数
11 | */
12 | public function Bounce()
13 | {
14 | }
15 |
16 | public function ease(fraction:Number):Number
17 | {
18 | return easeOut(fraction, 0, 1, 1);
19 | }
20 |
21 | public function easeOut(t:Number, b:Number,
22 | c:Number, d:Number):Number
23 | {
24 | if ((t /= d) < (1 / 2.75))
25 | return c * (7.5625 * t * t) + b;
26 |
27 | else if (t < (2 / 2.75))
28 | return c * (7.5625 * (t -= (1.5 / 2.75)) * t + 0.75) + b;
29 |
30 | else if (t < (2.5 / 2.75))
31 | return c * (7.5625 * (t -= (2.25 / 2.75)) * t + 0.9375) + b;
32 |
33 | else
34 | return c * (7.5625 * (t -= (2.625 / 2.75)) * t + 0.984375) + b;
35 | }
36 | }
37 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/EaseInOutBase.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | * EaseInOutBase 类是提供缓动功能的基类。
5 | * EaseInOutBase 类将缓动定义为由两个阶段组成:加速,或缓入阶段,接着是减速,或缓出阶段。
6 | * 此类的默认行为会为全部两个缓动阶段返回一个线性插值。
7 | * @author dom
8 | */
9 | public class EaseInOutBase implements IEaser
10 | {
11 | /**
12 | * 构造函数
13 | * @param easeInFraction 缓入过程所占动画播放时间的百分比。剩余即为缓出的时间。
14 | * 默认值为 EasingFraction.IN_OUT,它会缓入前一半时间,并缓出剩余的一半时间。
15 | */
16 | public function EaseInOutBase(easeInFraction:Number = 0.5)
17 | {
18 | this.easeInFraction = easeInFraction;
19 | }
20 |
21 | private var _easeInFraction:Number = .5;
22 | /**
23 | * 缓入过程所占动画播放时间的百分比。剩余即为缓出的时间。
24 | * 有效值为 0.0 到 1.0。
25 | */
26 | public function get easeInFraction():Number
27 | {
28 | return _easeInFraction;
29 | }
30 |
31 | public function set easeInFraction(value:Number):void
32 | {
33 | _easeInFraction = value;
34 | }
35 |
36 | public function ease(fraction:Number):Number
37 | {
38 | var easeOutFraction:Number = 1 - _easeInFraction;
39 |
40 | if (fraction <= _easeInFraction && _easeInFraction > 0)
41 | return _easeInFraction * easeIn(fraction/_easeInFraction);
42 | else
43 | return _easeInFraction + easeOutFraction *
44 | easeOut((fraction - _easeInFraction)/easeOutFraction);
45 | }
46 | /**
47 | * 在动画的缓入阶段期间计算已经缓动部分要映射到的值。
48 | */
49 | protected function easeIn(fraction:Number):Number
50 | {
51 | return fraction;
52 | }
53 |
54 | /**
55 | * 在动画的缓出阶段期间计算已经缓动部分要映射到的值。
56 | */
57 | protected function easeOut(fraction:Number):Number
58 | {
59 | return fraction;
60 | }
61 |
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/EasingFraction.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | *
5 | * @author dom
6 | */
7 | public final class EasingFraction
8 | {
9 | /**
10 | * 指定easing实例花费整个动画进行缓入。这等效于将 easeInFraction 属性设置为 1.0。
11 | */
12 | public static const IN:Number = 1;
13 |
14 | /**
15 | * 指定 easing 实例花费整个动画进行缓出。这等效于将 easeInFraction 属性设置为 0.0。
16 | */
17 | public static const OUT:Number = 0;
18 |
19 | /**
20 | * 指定 easing 实例缓入前半部分并缓出剩余的一半。这等效于将 easeInFraction 属性设置为 0.5。
21 | */
22 | public static const IN_OUT:Number = 0.5;
23 | }
24 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/Elastic.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | * Elastic 类实现缓动功能,此时目标对象移动是由一个指数衰减正弦波定义的。
5 | * 效果目标向着最终值减速,然后继续通过最终值。接着它围绕最终值在越来越小的增量内振荡,最后达到最终值。
6 | * @author dom
7 | */
8 | public class Elastic implements IEaser
9 | {
10 | public function Elastic()
11 | {
12 | }
13 |
14 | public function ease(fraction:Number):Number
15 | {
16 | return easeOut(fraction, 0, 1, 1);
17 | }
18 |
19 | public function easeOut(t:Number, b:Number,
20 | c:Number, d:Number,
21 | a:Number = 0, p:Number = 0):Number
22 | {
23 | if (t == 0)
24 | return b;
25 |
26 | if ((t /= d) == 1)
27 | return b + c;
28 |
29 | if (!p)
30 | p = d * 0.3;
31 |
32 | var s:Number;
33 | if (!a || a < Math.abs(c))
34 | {
35 | a = c;
36 | s = p / 4;
37 | }
38 | else
39 | {
40 | s = p / (2 * Math.PI) * Math.asin(c / a);
41 | }
42 |
43 | return a * Math.pow(2, -10 * t) *
44 | Math.sin((t * d - s) * (2 * Math.PI) / p) + c + b;
45 | }
46 |
47 | }
48 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/IEaser.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | * 为Animation类提供时间缓动功能的接口
5 | * @author dom
6 | */
7 | public interface IEaser
8 | {
9 | /**
10 | * 输入动画播放的当前时刻点,返回转换过后映射的时刻点。
11 | * @param fraction 动画播放的当前时刻点,从 0.0 到 1.0。
12 | */
13 | function ease(fraction:Number):Number;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/Linear.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | * Linear 类使用三个阶段定义缓动:加速、匀速运动和减速。
5 | * 在动画开始时,它会在由 easeInFraction 属性指定的时期内加速,它接着在下一个阶段中使用匀速(线性)运动,
6 | * 最后在由 easeOutFraction 属性指定的时期内减速,直到结束。
7 | * 会计算这三个阶段的缓动值,以使恒定加速、线性运动和恒定减速的行为全部发生在动画的指定持续时间内。
8 | * 通过将 easeInFraction 和 easeOutFraction 设置为 0.0 可以实现严格的线性运动。
9 | * @author dom
10 | */
11 | public class Linear implements IEaser
12 | {
13 | /**
14 | * 构造函数
15 | * @param easeInFraction 在加速阶段中持续时间占总时间的百分比,在 0.0 和 1.0 之间。
16 | * @param easeOutFraction 在减速阶段中持续时间占总时间的百分比,在 0.0 和 1.0 之间。
17 | */
18 | public function Linear(easeInFraction:Number = 0, easeOutFraction:Number = 0)
19 | {
20 | this.easeInFraction = easeInFraction;
21 | this.easeOutFraction = easeOutFraction;
22 | }
23 |
24 | private var _easeInFraction:Number = 0;
25 | /**
26 | * 在加速阶段中持续时间占总时间的百分比,在 0.0 和 1.0 之间。
27 | */
28 | public function get easeInFraction():Number
29 | {
30 | return _easeInFraction;
31 | }
32 |
33 | public function set easeInFraction(value:Number):void
34 | {
35 | _easeInFraction = value;
36 | }
37 |
38 | private var _easeOutFraction:Number = 0;
39 | /**
40 | * 在减速阶段中持续时间占总时间的百分比,在 0.0 和 1.0 之间。
41 | */
42 | public function get easeOutFraction():Number
43 | {
44 | return _easeOutFraction;
45 | }
46 |
47 | public function set easeOutFraction(value:Number):void
48 | {
49 | _easeOutFraction = value;
50 | }
51 |
52 | public function ease(fraction:Number):Number
53 | {
54 |
55 | if (easeInFraction == 0 && easeOutFraction == 0)
56 | return fraction;
57 |
58 | var runRate:Number = 1 / (1 - easeInFraction/2 - easeOutFraction/2);
59 | if (fraction < easeInFraction)
60 | return fraction * runRate * (fraction / easeInFraction) / 2;
61 | if (fraction > (1 - easeOutFraction))
62 | {
63 | var decTime:Number = fraction - (1 - easeOutFraction);
64 | var decProportion:Number = decTime / easeOutFraction;
65 | return runRate * (1 - easeInFraction/2 - easeOutFraction +
66 | decTime * (2 - decProportion) / 2);
67 | }
68 | return runRate * (fraction - easeInFraction/2);
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/Power.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | * Power 类通过使用多项式表达式定义缓动功能。
5 | * 缓动包括两个阶段:加速,或缓入阶段,接着是减速,或缓出阶段。
6 | * 加速和减速的速率基于 exponent 属性。exponent 属性的值越大,加速和减速的速率越快。
7 | * 使用 easeInFraction 属性指定动画加速的百分比。
8 | * @author dom
9 | */
10 | public class Power extends EaseInOutBase
11 | {
12 |
13 | private var _exponent:Number;
14 | /**
15 | * 在缓动计算中使用的指数。exponent 属性的值越大,加速和减速的速率越快。
16 | */
17 | public function get exponent():Number
18 | {
19 | return _exponent;
20 | }
21 |
22 | public function set exponent(value:Number):void
23 | {
24 | _exponent = value;
25 | }
26 |
27 | /**
28 | * 构造函数
29 | * @param easeInFraction 在加速阶段中整个持续时间的部分,在 0.0 和 1.0 之间。
30 | * @param exponent 在缓动计算中使用的指数。exponent 属性的值越大,加速和减速的速率越快。
31 | *
32 | */
33 | public function Power(easeInFraction:Number = 0.5, exponent:Number = 2)
34 | {
35 | super(easeInFraction);
36 | this.exponent = exponent;
37 | }
38 |
39 | /**
40 | * @inheritDoc
41 | */
42 | override protected function easeIn(fraction:Number):Number
43 | {
44 | return Math.pow(fraction, _exponent);
45 | }
46 |
47 | /**
48 | * @inheritDoc
49 | */
50 | override protected function easeOut(fraction:Number):Number
51 | {
52 | return 1 - Math.pow((1 - fraction), _exponent);
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/effects/easing/Sine.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.effects.easing
2 | {
3 | /**
4 | * Sine 类使用 Sine 函数定义缓动功能。
5 | * 缓动包括两个阶段:加速,或缓入阶段,接着是减速,或缓出阶段。使用 easeInFraction 属性指定动画加速的百分比。
6 | * @author dom
7 | */
8 | public class Sine extends EaseInOutBase
9 | {
10 | /**
11 | * 构造函数
12 | * @param easeInFraction 缓入过程所占动画播放时间的百分比。剩余即为缓出的时间。
13 | */
14 | public function Sine(easeInFraction:Number = 0.5)
15 | {
16 | super(easeInFraction);
17 | }
18 |
19 | /**
20 | * @inheritDoc
21 | */
22 | override protected function easeIn(fraction:Number):Number
23 | {
24 | return 1 - Math.cos(fraction * Math.PI/2);
25 | }
26 |
27 | /**
28 | * @inheritDoc
29 | */
30 | override protected function easeOut(fraction:Number):Number
31 | {
32 | return Math.sin(fraction * Math.PI/2);
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/CloseEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 | /**
5 | * 窗口关闭事件
6 | * @author dom
7 | */
8 | public class CloseEvent extends Event
9 | {
10 | public static const CLOSE:String = "close";
11 | /**
12 | * 构造函数
13 | */
14 | public function CloseEvent(type:String, bubbles:Boolean = false,
15 | cancelable:Boolean = false, detail:Object = -1)
16 | {
17 | super(type, bubbles, cancelable);
18 |
19 | this.detail = detail;
20 | }
21 | /**
22 | * 触发关闭事件的细节。某些窗口组件用此属性来区分窗口中被点击的按钮。
23 | */
24 | public var detail:Object;
25 |
26 | /**
27 | * @inheritDoc
28 | */
29 | override public function clone():Event
30 | {
31 | return new CloseEvent(type, bubbles, cancelable, detail);
32 | }
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/CollectionEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 集合类型数据改变事件
7 | * @author dom
8 | */
9 | public class CollectionEvent extends Event
10 | {
11 | /**
12 | * 集合类数据发生改变
13 | */
14 | public static const COLLECTION_CHANGE:String = "collectionChange";
15 |
16 | public function CollectionEvent(type:String, bubbles:Boolean = false,
17 | cancelable:Boolean = false,
18 | kind:String = null, location:int = -1,
19 | oldLocation:int = -1, items:Array = null,oldItems:Array=null)
20 | {
21 | super(type, bubbles, cancelable);
22 |
23 | this.kind = kind;
24 | this.location = location;
25 | this.oldLocation = oldLocation;
26 | this.items = items ? items : [];
27 | this.oldItems = oldItems?oldItems:[];
28 | }
29 | /**
30 | * 指示发生的事件类型。此属性值可以是 CollectionEventKind 类中的一个值,也可以是 null,用于指示类型未知。
31 | */
32 | public var kind:String;
33 | /**
34 | * 受事件影响的项目的列表
35 | */
36 | public var items:Array;
37 | /**
38 | * 仅当kind的值为CollectionEventKind.REPLACE时,表示替换前的项目列表
39 | */
40 | public var oldItems:Array;
41 | /**
42 | * 如果 kind 值为 CollectionEventKind.ADD、 CollectionEventKind.MOVE、
43 | * CollectionEventKind.REMOVE 或 CollectionEventKind.REPLACE,
44 | * CollectionEventKind.UPDATE
45 | * 则此属性为 items 属性中指定的项目集合中零号元素的的索引。
46 | */
47 | public var location:int;
48 | /**
49 | * 如果 kind 的值为 CollectionEventKind.MOVE,
50 | * 则此属性为 items 属性中指定的项目在目标集合中原来位置的从零开始的索引。
51 | */
52 | public var oldLocation:int;
53 |
54 | /**
55 | * @inheritDoc
56 | */
57 | override public function toString():String
58 | {
59 | return formatToString("CollectionEvent", "kind", "location",
60 | "oldLocation", "type", "bubbles",
61 | "cancelable", "eventPhase");
62 | }
63 |
64 | /**
65 | * @inheritDoc
66 | */
67 | override public function clone():Event
68 | {
69 | return new CollectionEvent(type, bubbles, cancelable, kind, location, oldLocation, items,oldItems);
70 | }
71 | }
72 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/CollectionEventKind.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | /**
4 | * 定义 CollectionEvent 类 kind 属性的有效值的常量。
5 | * 这些常量指示对集合进行的更改类型。
6 | * @author dom
7 | */
8 | public class CollectionEventKind
9 | {
10 | /**
11 | * 指示集合添加了一个或多个项目。
12 | */
13 | public static const ADD:String = "add";
14 | /**
15 | * 指示项目已从 CollectionEvent.oldLocation确定的位置移动到 location确定的位置。
16 | */
17 | public static const MOVE:String = "move";
18 | /**
19 | * 指示集合应用了排序或/和筛选。
20 | */
21 | public static const REFRESH:String = "refresh";
22 | /**
23 | * 指示集合删除了一个或多个项目。
24 | */
25 | public static const REMOVE:String = "remove";
26 | /**
27 | * 指示已替换由 CollectionEvent.location 属性确定的位置处的项目。
28 | */
29 | public static const REPLACE:String = "replace";
30 | /**
31 | * 指示集合已彻底更改,需要进行重置。
32 | */
33 | public static const RESET:String = "reset";
34 | /**
35 | * 指示集合中一个或多个项目进行了更新。受影响的项目将存储在 CollectionEvent.items 属性中。
36 | */
37 | public static const UPDATE:String = "update";
38 | /**
39 | * 指示集合中某个节点的子项列表已打开,通常应用于Tree的数据源XMLCollection。
40 | */
41 | public static const OPEN:String = "open";
42 | /**
43 | * 指示集合中某个节点的子项列表已关闭,通常应用于Tree的数据源XMLCollection。
44 | */
45 | public static const CLOSE:String = "close";
46 | }
47 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/DragEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.display.InteractiveObject;
4 | import flash.events.Event;
5 | import flash.events.MouseEvent;
6 |
7 | import org.flexlite.domUI.core.DragSource;
8 |
9 | /**
10 | * 拖拽事件
11 | * @author dom
12 | */
13 | public class DragEvent extends MouseEvent
14 | {
15 | /**
16 | * 拖拽开始,此事件由启动拖拽的组件自身抛出。
17 | */
18 | public static const DRAG_START:String = "dragStart";
19 | /**
20 | * 拖拽完成,此事件由拖拽管理器在启动拖拽的组件上抛出。
21 | */
22 | public static const DRAG_COMPLETE:String = "dragComplete";
23 |
24 | /**
25 | * 在目标区域放下拖拽的数据,此事件由拖拽管理器在经过的目标组件上抛出。
26 | */
27 | public static const DRAG_DROP:String = "dragDrop";
28 | /**
29 | * 拖拽进入目标区域,此事件由拖拽管理器在经过的目标组件上抛出。
30 | */
31 | public static const DRAG_ENTER:String = "dragEnter";
32 | /**
33 | * 拖拽移出目标区域,此事件由拖拽管理器在经过的目标组件上抛出。
34 | */
35 | public static const DRAG_EXIT:String = "dragExit";
36 | /**
37 | * 拖拽经过目标区域,相当于MouseOver事件,此事件由拖拽管理器在经过的目标组件上抛出。
38 | */
39 | public static const DRAG_OVER:String = "dragOver";
40 |
41 |
42 | /**
43 | * 创建一个 Event 对象,其中包含有关鼠标事件的信息。将 Event 对象作为参数传递给事件侦听器。
44 | * @param type 事件类型;指示引发事件的动作。
45 | * @param bubbles 指定该事件是否可以在显示列表层次结构得到冒泡处理。
46 | * @param cancelable 指定是否可以防止与事件相关联的行为。
47 | * @param dragInitiator 启动拖拽的组件。
48 | * @param dragSource 包含正在拖拽数据的DragSource对象。
49 | * @param ctrlKey 指示是否已按下 Ctrl 键。
50 | * @param altKey 指示是否已按下 Alt 键。
51 | * @param shiftKey 指示是否已按下 Shift 键。
52 | */
53 | public function DragEvent(type:String, bubbles:Boolean = false,
54 | cancelable:Boolean = true,
55 | dragInitiator:InteractiveObject = null,
56 | dragSource:DragSource = null,
57 | ctrlKey:Boolean = false,
58 | altKey:Boolean = false,
59 | shiftKey:Boolean = false)
60 | {
61 | super(type, bubbles, cancelable);
62 |
63 | this.dragInitiator = dragInitiator;
64 | this.dragSource = dragSource;
65 | this.ctrlKey = ctrlKey;
66 | this.altKey = altKey;
67 | this.shiftKey = shiftKey;
68 | }
69 | /**
70 | * 启动拖拽的组件
71 | */
72 | public var dragInitiator:InteractiveObject;
73 | /**
74 | * 包含正在拖拽数据的DragSource对象。
75 | */
76 | public var dragSource:DragSource;
77 | /**
78 | * @inheritDoc
79 | */
80 | override public function clone():Event
81 | {
82 | var cloneEvent:DragEvent = new DragEvent(type, bubbles, cancelable,
83 | dragInitiator, dragSource,
84 | ctrlKey,altKey, shiftKey);
85 | cloneEvent.relatedObject = this.relatedObject;
86 | cloneEvent.localX = this.localX;
87 | cloneEvent.localY = this.localY;
88 |
89 | return cloneEvent;
90 | }
91 | }
92 |
93 | }
94 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/EffectEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 动画特效事件
7 | * @author dom
8 | */
9 | public class EffectEvent extends Event
10 | {
11 | /**
12 | * 动画播放结束
13 | */
14 | public static const EFFECT_END:String = "effectEnd";
15 | /**
16 | * 动画播放被停止
17 | */
18 | public static const EFFECT_STOP:String = "effectStop";
19 | /**
20 | * 动画播放开始
21 | */
22 | public static const EFFECT_START:String = "effectStart";
23 | /**
24 | * 动画开始重复播放
25 | */
26 | public static const EFFECT_REPEAT:String = "effectRepeat";
27 | /**
28 | * 动画播放更新
29 | */
30 | public static const EFFECT_UPDATE:String = "effectUpdate";
31 |
32 | /**
33 | * 构造函数
34 | */
35 | public function EffectEvent(eventType:String, bubbles:Boolean = false,
36 | cancelable:Boolean = false)
37 | {
38 | super(eventType, bubbles, cancelable);
39 | }
40 |
41 | /**
42 | * @inheritDoc
43 | */
44 | override public function clone():Event
45 | {
46 | return new EffectEvent(type, bubbles, cancelable);
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/ElementExistenceEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | import org.flexlite.domUI.core.IVisualElement;
6 |
7 | /**
8 | * Group添加或移除元素时分派的事件。
9 | * @author dom
10 | */
11 | public class ElementExistenceEvent extends Event
12 | {
13 | /**
14 | * 元素添加
15 | */
16 | public static const ELEMENT_ADD:String = "elementAdd";
17 | /**
18 | * 元素移除
19 | */
20 | public static const ELEMENT_REMOVE:String = "elementRemove";
21 |
22 | public function ElementExistenceEvent(
23 | type:String, bubbles:Boolean = false,
24 | cancelable:Boolean = false,
25 | element:IVisualElement = null,
26 | index:int = -1)
27 | {
28 | super(type, bubbles, cancelable);
29 |
30 | this.element = element;
31 | this.index = index;
32 | }
33 |
34 | /**
35 | * 指向已添加或删除元素的位置的索引。
36 | */
37 | public var index:int;
38 |
39 | /**
40 | * 对已添加或删除的视觉元素的引用。
41 | */
42 | public var element:IVisualElement;
43 |
44 | /**
45 | * @inheritDoc
46 | */
47 | override public function clone():Event
48 | {
49 | return new ElementExistenceEvent(type, bubbles, cancelable,
50 | element, index);
51 | }
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/IndexChangeEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 索引改变事件
7 | * @author dom
8 | */
9 | public class IndexChangeEvent extends Event
10 | {
11 | /**
12 | * 指示索引已更改
13 | */
14 | public static const CHANGE:String = "change";
15 |
16 | /**
17 | * 指示索引即将更改,可以通过调用preventDefault()方法阻止索引发生更改
18 | */
19 | public static const CHANGING:String = "changing";
20 |
21 | public function IndexChangeEvent(type:String, bubbles:Boolean = false,
22 | cancelable:Boolean = false,
23 | oldIndex:int = -1,
24 | newIndex:int = -1)
25 | {
26 | super(type, bubbles, cancelable);
27 |
28 | this.oldIndex = oldIndex;
29 | this.newIndex = newIndex;
30 | }
31 |
32 | /**
33 | * 进行更改之后的从零开始的索引。
34 | */
35 | public var newIndex:int;
36 |
37 | /**
38 | * 进行更改之前的从零开始的索引。
39 | */
40 | public var oldIndex:int;
41 |
42 | /**
43 | * @inheritDoc
44 | */
45 | override public function clone():Event
46 | {
47 | return new IndexChangeEvent(type, bubbles, cancelable,
48 | oldIndex, newIndex);
49 | }
50 | }
51 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/ListEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.display.InteractiveObject;
4 | import flash.events.Event;
5 | import flash.events.MouseEvent;
6 |
7 | import org.flexlite.domUI.components.IItemRenderer;
8 |
9 | /**
10 | * 列表事件
11 | * @author dom
12 | */
13 | public class ListEvent extends MouseEvent
14 | {
15 | /**
16 | * 指示用户执行了将鼠标指针从控件中某个项呈示器上移开的操作
17 | */
18 | public static const ITEM_ROLL_OUT:String = "itemRollOut";
19 |
20 | /**
21 | * 指示用户执行了将鼠标指针滑过控件中某个项呈示器的操作。
22 | */
23 | public static const ITEM_ROLL_OVER:String = "itemRollOver";
24 |
25 | /**
26 | * 指示用户执行了将鼠标在某个项呈示器上单击的操作。
27 | */
28 | public static const ITEM_CLICK:String = "itemClick";
29 |
30 |
31 | public function ListEvent(type:String, bubbles:Boolean = false,
32 | cancelable:Boolean = false,
33 | localX:Number = NaN,
34 | localY:Number = NaN,
35 | relatedObject:InteractiveObject = null,
36 | ctrlKey:Boolean = false,
37 | altKey:Boolean = false,
38 | shiftKey:Boolean = false,
39 | buttonDown:Boolean = false,
40 | delta:int = 0,
41 | itemIndex:int = -1,
42 | item:Object = null,
43 | itemRenderer:IItemRenderer = null)
44 | {
45 | super(type, bubbles, cancelable, localX, localY, relatedObject, ctrlKey, altKey, shiftKey, buttonDown, delta);
46 |
47 | this.itemIndex = itemIndex;
48 | this.item = item;
49 | this.itemRenderer = itemRenderer;
50 | }
51 |
52 |
53 | /**
54 | * 触发鼠标事件的项呈示器数据源项。
55 | */
56 | public var item:Object;
57 |
58 | /**
59 | * 触发鼠标事件的项呈示器。
60 | */
61 | public var itemRenderer:IItemRenderer;
62 |
63 | /**
64 | * 触发鼠标事件的项索引
65 | */
66 | public var itemIndex:int;
67 |
68 | /**
69 | * @inheritDoc
70 | */
71 | override public function clone():Event
72 | {
73 | var cloneEvent:ListEvent = new ListEvent(type, bubbles, cancelable,
74 | localX, localY, relatedObject,
75 | ctrlKey, altKey, shiftKey, buttonDown, delta,
76 | itemIndex, item, itemRenderer);
77 |
78 | cloneEvent.relatedObject = this.relatedObject;
79 |
80 | return cloneEvent;
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/MoveEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 移动事件
7 | * @author dom
8 | */
9 | public class MoveEvent extends Event
10 | {
11 | public static const MOVE:String = "move";
12 |
13 | public function MoveEvent(type:String, oldX:Number = NaN, oldY:Number = NaN,
14 | bubbles:Boolean = false,
15 | cancelable:Boolean = false)
16 | {
17 | super(type, bubbles, cancelable);
18 |
19 | this.oldX = oldX;
20 | this.oldY = oldY;
21 | }
22 |
23 | /**
24 | * 旧的组件X
25 | */
26 | public var oldX:Number;
27 |
28 | /**
29 | * 旧的组件Y
30 | */
31 | public var oldY:Number;
32 |
33 | /**
34 | * @inheritDoc
35 | */
36 | override public function clone():Event
37 | {
38 | return new MoveEvent(type, oldX, oldY, bubbles, cancelable);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/PopUpEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | import org.flexlite.domUI.core.IVisualElement;
6 |
7 |
8 | /**
9 | * 弹出管理器事件
10 | * @author dom
11 | */
12 | public class PopUpEvent extends Event
13 | {
14 | /**
15 | * 添加一个弹出框,在执行完添加之后抛出。
16 | */
17 | public static const ADD_POPUP:String = "addPopUp";
18 | /**
19 | * 移除一个弹出框,在执行完移除之后抛出。
20 | */
21 | public static const REMOVE_POPUP:String = "removePopUp";
22 | /**
23 | * 移动弹出框到最前,在执行完前置之后抛出。
24 | */
25 | public static const BRING_TO_FRONT:String = "bringToFront";
26 | /**
27 | * 构造函数
28 | */
29 | public function PopUpEvent(type:String,bubbles:Boolean=false,
30 | cancelable:Boolean=false,popUp:IVisualElement=null,
31 | modal:Boolean = false)
32 | {
33 | super(type, bubbles, cancelable);
34 | this.popUp = popUp;
35 | this.modal = modal;
36 | }
37 | /**
38 | * 弹出框对象
39 | */
40 | public var popUp:IVisualElement;
41 | /**
42 | * 弹出窗口是否为模态,此属性仅在事件类型为ADD_POPUP时有效。
43 | */
44 | public var modal:Boolean;
45 | }
46 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/PropertyChangeEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 对象的一个属性发生更改时传递到事件侦听器的事件
7 | * @author dom
8 | */
9 | public class PropertyChangeEvent extends Event
10 | {
11 | /**
12 | * 属性改变
13 | */
14 | public static const PROPERTY_CHANGE:String = "propertyChange";
15 |
16 | /**
17 | * 返回使用指定属性构建的 PropertyChangeEventKind.UPDATE 类型的新 PropertyChangeEvent。
18 | * @param source 发生更改的对象。
19 | * @param property 指定已更改属性的 String、QName 或 int。
20 | * @param oldValue 更改前的属性的值。
21 | * @param newValue 更改后的属性的值。
22 | */
23 | public static function createUpdateEvent(
24 | source:Object,
25 | property:Object,
26 | oldValue:Object,
27 | newValue:Object):PropertyChangeEvent
28 | {
29 | var event:PropertyChangeEvent =
30 | new PropertyChangeEvent(PROPERTY_CHANGE);
31 |
32 | event.kind = PropertyChangeEventKind.UPDATE;
33 | event.oldValue = oldValue;
34 | event.newValue = newValue;
35 | event.source = source;
36 | event.property = property;
37 |
38 | return event;
39 | }
40 |
41 | /**
42 | * 构造函数
43 | */
44 | public function PropertyChangeEvent(type:String, bubbles:Boolean = false,
45 | cancelable:Boolean = false,
46 | kind:String = null,
47 | property:Object = null,
48 | oldValue:Object = null,
49 | newValue:Object = null,
50 | source:Object = null)
51 | {
52 | super(type, bubbles, cancelable);
53 |
54 | this.kind = kind;
55 | this.property = property;
56 | this.oldValue = oldValue;
57 | this.newValue = newValue;
58 | this.source = source;
59 | }
60 |
61 | /**
62 | * 指定更改的类型。可能的值为 PropertyChangeEventKind.UPDATE、PropertyChangeEventKind.DELETE 和 null。
63 | */
64 | public var kind:String;
65 |
66 | /**
67 | * 更改后的属性的值。
68 | */
69 | public var newValue:Object;
70 |
71 | /**
72 | * 更改后的属性的值。
73 | */
74 | public var oldValue:Object;
75 |
76 | /**
77 | * 指定已更改属性的 String、QName 或 int。
78 | */
79 | public var property:Object;
80 |
81 | /**
82 | * 发生更改的对象。
83 | */
84 | public var source:Object;
85 |
86 | /**
87 | * @inheritDoc
88 | */
89 | override public function clone():Event
90 | {
91 | return new PropertyChangeEvent(type, bubbles, cancelable, kind,
92 | property, oldValue, newValue, source);
93 | }
94 | }
95 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/PropertyChangeEventKind.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | /**
4 | * PropertyChangeEventKind 类定义 PropertyChangeEvent 类的 kind 属性的常量值。
5 | * @author dom
6 | */
7 | public class PropertyChangeEventKind
8 | {
9 | /**
10 | * 指示该属性的值已更改。
11 | */
12 | public static const UPDATE:String = "update";
13 |
14 | /**
15 | * 指示该属性已从此对象中删除。
16 | */
17 | public static const DELETE:String = "delete";
18 | }
19 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/RendererExistenceEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | import org.flexlite.domUI.components.IItemRenderer;
6 |
7 | /**
8 | * 在DataGroup添加或删除项呈示器时分派的事件。
9 | * @author dom
10 | */
11 | public class RendererExistenceEvent extends Event
12 | {
13 | /**
14 | * 添加了项呈示器
15 | */
16 | public static const RENDERER_ADD:String = "rendererAdd";
17 | /**
18 | * 移除了项呈示器
19 | */
20 | public static const RENDERER_REMOVE:String = "rendererRemove";
21 |
22 | public function RendererExistenceEvent(type:String, bubbles:Boolean = false,
23 | cancelable:Boolean = false,renderer:IItemRenderer = null,
24 | index:int = -1, data:Object = null)
25 | {
26 | super(type, bubbles, cancelable);
27 |
28 | this.renderer = renderer;
29 | this.index = index;
30 | this.data = data;
31 | }
32 |
33 | /**
34 | * 呈示器的数据项目。
35 | */
36 | public var data:Object;
37 |
38 | /**
39 | * 指向已添加或删除项呈示器的位置的索引。
40 | */
41 | public var index:int;
42 |
43 | /**
44 | * 对已添加或删除的项呈示器的引用。
45 | */
46 | public var renderer:IItemRenderer;
47 |
48 | /**
49 | * @inheritDoc
50 | */
51 | override public function clone():Event
52 | {
53 | return new RendererExistenceEvent(type, bubbles, cancelable,
54 | renderer, index, data);
55 | }
56 | }
57 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/ResizeEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 尺寸改变事件
7 | * @author dom
8 | */
9 | public class ResizeEvent extends Event
10 | {
11 | public static const RESIZE:String = "resize";
12 |
13 | public function ResizeEvent(type:String,oldWidth:Number = NaN, oldHeight:Number = NaN,
14 | bubbles:Boolean = false, cancelable:Boolean = false)
15 | {
16 | super(type, bubbles, cancelable);
17 |
18 | this.oldWidth = oldWidth;
19 | this.oldHeight = oldHeight;
20 | }
21 |
22 | /**
23 | * 旧的高度
24 | */
25 | public var oldHeight:Number;
26 |
27 | /**
28 | * 旧的宽度
29 | */
30 | public var oldWidth:Number;
31 |
32 |
33 | /**
34 | * @inheritDoc
35 | */
36 | override public function clone():Event
37 | {
38 | return new ResizeEvent(type, oldWidth, oldHeight, bubbles, cancelable);
39 | }
40 | }
41 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/SkinPartEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 皮肤组件附加移除事件
7 | * @author dom
8 | */
9 | public class SkinPartEvent extends Event
10 | {
11 | /**
12 | * 附加皮肤公共子部件
13 | */
14 | public static const PART_ADDED:String = "partAdded";
15 | /**
16 | * 移除皮肤公共子部件
17 | */
18 | public static const PART_REMOVED:String = "partRemoved";
19 |
20 | public function SkinPartEvent(type:String, bubbles:Boolean = false,
21 | cancelable:Boolean = false,
22 | partName:String = null,
23 | instance:Object = null)
24 | {
25 | super(type, bubbles, cancelable);
26 |
27 | this.partName = partName;
28 | this.instance = instance;
29 | }
30 |
31 | /**
32 | * 被添加或移除的皮肤组件实例
33 | */
34 | public var instance:Object;
35 |
36 | /**
37 | * 被添加或移除的皮肤组件的实例名
38 | */
39 | public var partName:String;
40 |
41 | /**
42 | * @inheritDoc
43 | */
44 | override public function clone():Event
45 | {
46 | return new SkinPartEvent(type, bubbles, cancelable,
47 | partName, instance);
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/StateChangeEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * 视图状态改变事件
7 | * @author dom
8 | */
9 | public class StateChangeEvent extends Event
10 | {
11 | /**
12 | * 当前视图状态已经改变
13 | */
14 | public static const CURRENT_STATE_CHANGE:String = "currentStateChange";
15 | /**
16 | * 当前视图状态即将改变
17 | */
18 | public static const CURRENT_STATE_CHANGING:String = "currentStateChanging";
19 |
20 | public function StateChangeEvent(type:String, bubbles:Boolean = false,
21 | cancelable:Boolean = false,
22 | oldState:String = null,
23 | newState:String = null)
24 | {
25 | super(type, bubbles, cancelable);
26 |
27 | this.oldState = oldState;
28 | this.newState = newState;
29 | }
30 | /**
31 | * 组件正在进入的视图状态的名称。
32 | */
33 | public var newState:String;
34 |
35 | /**
36 | * 组件正在退出的视图状态的名称。
37 | */
38 | public var oldState:String;
39 |
40 | override public function clone():Event
41 | {
42 | return new StateChangeEvent(type, bubbles, cancelable,
43 | oldState, newState);
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/ToolTipEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | import org.flexlite.domUI.core.IToolTip;
6 |
7 | /**
8 | * 工具提示事件
9 | * @author dom
10 | */
11 | public class ToolTipEvent extends Event
12 | {
13 | /**
14 | * 即将隐藏ToolTip
15 | */
16 | public static const TOOL_TIP_HIDE:String = "toolTipHide";
17 | /**
18 | * 即将显示TooTip
19 | */
20 | public static const TOOL_TIP_SHOW:String = "toolTipShow";
21 |
22 | /**
23 | * 构造函数
24 | */
25 | public function ToolTipEvent(type:String, bubbles:Boolean = false,
26 | cancelable:Boolean = false,
27 | toolTip:IToolTip = null)
28 | {
29 | super(type, bubbles, cancelable);
30 |
31 | this.toolTip = toolTip;
32 | }
33 | /**
34 | * 关联的ToolTip显示对象
35 | */
36 | public var toolTip:IToolTip;
37 |
38 | /**
39 | * @inheritDoc
40 | */
41 | override public function clone():Event
42 | {
43 | return new ToolTipEvent(type, bubbles, cancelable, toolTip);
44 | }
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/TrackBaseEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 | /**
5 | * 从TrackBase组件分派的事件。
6 | * @author dom
7 | */
8 | public class TrackBaseEvent extends Event
9 | {
10 | /**
11 | * 正在拖拽滑块
12 | */
13 | public static const THUMB_DRAG:String = "thumbDrag";
14 |
15 | /**
16 | * 滑块被按下
17 | */
18 | public static const THUMB_PRESS:String = "thumbPress";
19 |
20 | /**
21 | * 滑块被放开
22 | */
23 | public static const THUMB_RELEASE:String = "thumbRelease";
24 |
25 | /**
26 | * 构造函数
27 | */
28 | public function TrackBaseEvent(type:String, bubbles:Boolean = false,cancelable:Boolean = false)
29 | {
30 | super(type, bubbles, cancelable);
31 | }
32 |
33 | /**
34 | * @inheritDoc
35 | */
36 | override public function clone():Event
37 | {
38 | return new TrackBaseEvent(type, bubbles, cancelable);
39 | }
40 | }
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/TreeEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | import org.flexlite.domUI.components.IItemRenderer;
6 | import org.flexlite.domUI.components.ITreeItemRenderer;
7 |
8 |
9 | /**
10 | * Tree事件
11 | * @author dom
12 | */
13 | public class TreeEvent extends Event
14 | {
15 | /**
16 | * 节点关闭,注意:只有通过交互操作引起的节点关闭才会抛出此事件。
17 | */
18 | public static const ITEM_CLOSE:String = "itemClose";
19 | /**
20 | * 节点打开,注意:只有通过交互操作引起的节点打开才会抛出此事件。
21 | */
22 | public static const ITEM_OPEN:String = "itemOpen";
23 | /**
24 | * 子节点打开或关闭前一刻分派。可以调用preventDefault()方法阻止节点的状态改变。
25 | */
26 | public static const ITEM_OPENING:String = "itemOpening";
27 |
28 | public function TreeEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=true,
29 | itemIndex:int = -1,item:Object = null,itemRenderer:ITreeItemRenderer = null)
30 | {
31 | super(type, bubbles, cancelable);
32 | this.item = item;
33 | this.itemRenderer = itemRenderer;
34 | this.itemIndex = itemIndex;
35 | }
36 |
37 | /**
38 | * 触发鼠标事件的项呈示器数据源项。
39 | */
40 | public var item:Object;
41 |
42 | /**
43 | * 触发鼠标事件的项呈示器。
44 | */
45 | public var itemRenderer:ITreeItemRenderer;
46 | /**
47 | * 触发鼠标事件的项索引
48 | */
49 | public var itemIndex:int;
50 | /**
51 | * 当事件类型为ITEM_OPENING时,true表示即将打开节点,反之关闭。
52 | */
53 | public var opening:Boolean;
54 | /**
55 | * @inheritDoc
56 | */
57 | override public function clone():Event
58 | {
59 | var evt:TreeEvent = new TreeEvent(type, bubbles, cancelable,
60 | itemIndex,item, itemRenderer);
61 | evt.opening = opening;
62 | return evt;
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/events/UIEvent.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.events
2 | {
3 | import flash.events.Event;
4 |
5 | /**
6 | * UI事件
7 | * @author dom
8 | */
9 | public class UIEvent extends Event
10 | {
11 | public function UIEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false)
12 | {
13 | super(type, bubbles, cancelable);
14 | }
15 | /**
16 | * 组件初始化开始
17 | */
18 | public static const INITIALIZE:String = "initialize";
19 | /**
20 | * 组件创建完成
21 | */
22 | public static const CREATION_COMPLETE:String = "creationComplete";
23 | /**
24 | * 组件的一次三个延迟验证渲染阶段全部完成
25 | */
26 | public static const UPDATE_COMPLETE:String = "updateComplete";
27 | /**
28 | * 当用户按下ButtonBase控件时分派。如果 autoRepeat属性为 true,则只要按钮处于按下状态,就将重复分派此事件。
29 | */
30 | public static const BUTTON_DOWN:String = "buttonDown";
31 | /**
32 | * 改变结束
33 | */
34 | public static const CHANGE_END:String = "changeEnd";
35 |
36 | /**
37 | * 改变开始
38 | */
39 | public static const CHANGE_START:String = "changeStart";
40 |
41 | /**
42 | * 正在改变中
43 | */
44 | public static const CHANGING:String = "changing";
45 | /**
46 | * 值发生改变
47 | */
48 | public static const VALUE_COMMIT:String = "valueCommit";
49 | /**
50 | * 皮肤发生改变
51 | */
52 | public static const SKIN_CHANGED:String = "skinChanged";
53 |
54 | /**
55 | * 下拉框弹出事件
56 | */
57 | public static const OPEN:String = "open";
58 | /**
59 | * 下拉框关闭事件
60 | */
61 | public static const CLOSE:String = "close";
62 |
63 | /**
64 | * UIMoveClip一次播放完成事件。仅当UIMovieClip.totalFrames>1时会抛出此事件。
65 | */
66 | public static const PLAY_COMPLETE:String = "playComplete"
67 | }
68 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/layouts/ColumnAlign.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.layouts
2 | {
3 | /**
4 | * ColumnAlign 类为 TileLayout 类的 columnAlign 属性定义可能的值。
5 | * @author dom
6 | */
7 | public class ColumnAlign
8 | {
9 | /**
10 | * 不将行两端对齐。
11 | */
12 | public static const LEFT:String = "left";
13 |
14 | /**
15 | * 通过增大水平间隙将行两端对齐。
16 | */
17 | public static const JUSTIFY_USING_GAP:String = "justifyUsingGap";
18 |
19 | /**
20 | * 通过增大行高度将行两端对齐。
21 | */
22 | public static const JUSTIFY_USING_WIDTH:String = "justifyUsingWidth";
23 | }
24 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/layouts/HorizontalAlign.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.layouts
2 | {
3 | /**
4 | * 水平布局策略常量
5 | * @author dom
6 | */
7 | public class HorizontalAlign
8 | {
9 | /**
10 | * 将子项与容器的左侧对齐。
11 | */
12 | public static const LEFT:String = "left";
13 | /**
14 | * 在容器的中心对齐子项。
15 | */
16 | public static const CENTER:String = "center";
17 | /**
18 | * 将子项与容器的右侧对齐。
19 | */
20 | public static const RIGHT:String = "right";
21 |
22 | /**
23 | * 相对于容器对齐子项。这将会以容器宽度为标准,调整所有子项的宽度,使其始终填满容器。
24 | */
25 | public static const JUSTIFY:String = "justify";
26 | /**
27 | * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的内容宽度contentWidth。
28 | * 容器的内容宽度是最大子项的大小。如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。
29 | */
30 | public static const CONTENT_JUSTIFY:String = "contentJustify";
31 | }
32 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/layouts/RowAlign.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.layouts
2 | {
3 | /**
4 | * RowAlign 类为 TileLayout 类的 rowAlign 属性定义可能的值。
5 | * @author dom
6 | */
7 | public class RowAlign
8 | {
9 | /**
10 | * 不进行两端对齐。
11 | */
12 | public static const TOP:String = "top";
13 | /**
14 | * 通过增大垂直间隙将行两端对齐。
15 | */
16 | public static const JUSTIFY_USING_GAP:String = "justifyUsingGap";
17 |
18 | /**
19 | * 通过增大行高度将行两端对齐。
20 | */
21 | public static const JUSTIFY_USING_HEIGHT:String = "justifyUsingHeight";
22 | }
23 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/layouts/TileOrientation.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.layouts
2 | {
3 | /**
4 | * TileOrientation 类为 TileLayout 类的 orientation 属性定义可能的值。
5 | * @author dom
6 | */
7 | public class TileOrientation
8 | {
9 | /**
10 | * 逐行排列元素。
11 | */
12 | public static const ROWS:String = "rows";
13 |
14 | /**
15 | * 逐列排列元素。
16 | */
17 | public static const COLUMNS:String = "columns";
18 | }
19 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/layouts/VerticalAlign.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.layouts
2 | {
3 | /**
4 | * 垂直布局策略常量
5 | * @author dom
6 | */
7 | public class VerticalAlign
8 | {
9 | /**
10 | * 在容器的中央垂直对齐子项。
11 | */
12 | public static const TOP:String = "top";
13 | /**
14 | * 在容器的中央垂直对齐子项。
15 | */
16 | public static const MIDDLE:String = "middle";
17 | /**
18 | * 在容器的底部垂直对齐子项。
19 | */
20 | public static const BOTTOM:String = "bottom";
21 | /**
22 | * 相对于容器对齐子项。这将会以容器高度为标准,调整所有子项的高度,使其始终填满容器。
23 | */
24 | public static const JUSTIFY:String = "justify";
25 | /**
26 | * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的内容高度contentHeight。
27 | * 容器的内容高度是最大子项的大小。如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。
28 | */
29 | public static const CONTENT_JUSTIFY:String = "contentJustify";
30 | }
31 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/DragManager.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.display.DisplayObject;
4 | import flash.display.InteractiveObject;
5 |
6 | import org.flexlite.domCore.Injector;
7 | import org.flexlite.domCore.dx_internal;
8 | import org.flexlite.domUI.core.DragSource;
9 | import org.flexlite.domUI.managers.impl.DragManagerImpl;
10 |
11 | /**
12 | * 拖拽管理器
13 | * 若项目需要自定义拖拽管理器,请实现IDragManager接口,
14 | * 并在项目初始化前调用Injector.mapClass(IDragManager,YourDragManager),
15 | * 注入自定义的拖拽管理器类。
16 | * @author dom
17 | */
18 | public class DragManager
19 | {
20 |
21 | private static var _impl:IDragManager;
22 | /**
23 | * 获取单例
24 | */
25 | private static function get impl():IDragManager
26 | {
27 | if (!_impl)
28 | {
29 | try
30 | {
31 | _impl = Injector.getInstance(IDragManager);
32 | }
33 | catch(e:Error)
34 | {
35 | _impl = new DragManagerImpl();
36 | }
37 | }
38 | return _impl;
39 | }
40 | /**
41 | * 正在拖拽的标志
42 | */
43 | public static function get isDragging():Boolean
44 | {
45 | return impl.isDragging;
46 | }
47 | /**
48 | * 启动拖拽操作。请在MouseDown事件里执行此方法。
49 | * @param dragInitiator 启动拖拽的组件
50 | * @param dragSource 拖拽的数据源
51 | * @param dragImage 拖拽过程中显示的图像
52 | * @param xOffset dragImage相对dragInitiator的x偏移量,默认0。
53 | * @param yOffset dragImage相对dragInitiator的y偏移量,默认0。
54 | * @param imageAlpha dragImage的透明度,默认0.5。
55 | */
56 | public static function doDrag(
57 | dragInitiator:InteractiveObject,
58 | dragSource:DragSource,
59 | dragImage:DisplayObject = null,
60 | xOffset:Number = 0,
61 | yOffset:Number = 0,
62 | imageAlpha:Number = 0.5):void
63 | {
64 | impl.doDrag(dragInitiator, dragSource, dragImage, xOffset,
65 | yOffset, imageAlpha);
66 | }
67 | /**
68 | * 接受拖拽的数据源。通常在dragEnter事件处理函数调用此方法。
69 | * 传入target后,若放下数据源。target将能监听到dragDrop事件。
70 | */
71 | public static function acceptDragDrop(target:InteractiveObject):void
72 | {
73 | impl.acceptDragDrop(target);
74 | }
75 | /**
76 | * 结束拖拽
77 | */
78 | dx_internal static function endDrag():void
79 | {
80 | impl.endDrag();
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/IDragManager.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.display.DisplayObject;
4 | import flash.display.InteractiveObject;
5 |
6 | import org.flexlite.domUI.core.DragSource;
7 |
8 | /**
9 | * 拖拽管理器接口。若项目需要自定义拖拽管理器,请实现此接口,
10 | * 并在项目初始化前调用Injector.mapClass(IDragManager,YourDragManager),
11 | * 注入自定义的拖拽管理器类。
12 | * @author dom
13 | */
14 | public interface IDragManager
15 | {
16 | /**
17 | * 正在拖拽的标志
18 | */
19 | function get isDragging():Boolean;
20 |
21 | /**
22 | * 启动拖拽操作。请在MouseDown事件里执行此方法。
23 | * @param dragInitiator 启动拖拽的组件
24 | * @param dragSource 拖拽的数据源
25 | * @param dragImage 拖拽过程中显示的图像
26 | * @param xOffset dragImage相对dragInitiator的x偏移量,默认0。
27 | * @param yOffset dragImage相对dragInitiator的y偏移量,默认0。
28 | * @param imageAlpha dragImage的透明度,默认0.5。
29 | */
30 | function doDrag(
31 | dragInitiator:InteractiveObject,
32 | dragSource:DragSource,
33 | dragImage:DisplayObject = null,
34 | xOffset:Number = 0,
35 | yOffset:Number = 0,
36 | imageAlpha:Number = 0.5):void;
37 |
38 | /**
39 | * 接受拖拽的数据源。通常在dragEnter事件处理函数调用此方法。
40 | * 传入target后,若放下数据源。target将能监听到dragDrop事件。
41 | */
42 | function acceptDragDrop(target:InteractiveObject):void;
43 |
44 | /**
45 | * 结束拖拽
46 | */
47 | function endDrag():void;
48 | }
49 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/IFocusManager.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.display.Stage;
4 |
5 | /**
6 | * 焦点管理器接口
7 | * @author dom
8 | */
9 | public interface IFocusManager
10 | {
11 | /**
12 | * 舞台引用
13 | */
14 | function get stage():Stage;
15 | function set stage(value:Stage):void;
16 | }
17 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/ILayoutManagerClient.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.display.DisplayObjectContainer;
4 | import flash.events.IEventDispatcher;
5 |
6 | /**
7 | * 使用布局管理器的组件接口
8 | * @author dom
9 | */
10 | public interface ILayoutManagerClient extends IEventDispatcher
11 | {
12 | /**
13 | * 验证组件的属性
14 | */
15 | function validateProperties():void;
16 | /**
17 | * 验证组件的尺寸
18 | */
19 | function validateSize(recursive:Boolean = false):void;
20 | /**
21 | * 验证子项的位置和大小,并绘制其他可视内容
22 | */
23 | function validateDisplayList():void;
24 | /**
25 | * 在显示列表的嵌套深度
26 | */
27 | function get nestLevel():int;
28 |
29 | function set nestLevel(value:int):void;
30 | /**
31 | * 是否完成初始化。此标志只能由 LayoutManager 修改。
32 | */
33 | function get initialized():Boolean;
34 | function set initialized(value:Boolean):void;
35 | /**
36 | * 一个标志,用于确定某个对象是否正在等待分派其updateComplete事件。此标志只能由 LayoutManager 修改。
37 | */
38 | function get updateCompletePendingFlag():Boolean;
39 | function set updateCompletePendingFlag(value:Boolean):void;
40 | /**
41 | * 父级显示对象
42 | */
43 | function get parent():DisplayObjectContainer;
44 | }
45 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/IPopUpManager.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.events.IEventDispatcher;
4 |
5 | import org.flexlite.domUI.core.IVisualElement;
6 |
7 |
8 | /**
9 | * 窗口弹出管理器接口。若项目需要自定义弹出框管理器,请实现此接口,
10 | * 并在项目初始化前调用Injector.mapClass(IPopUpManager,YourPopUpManager),
11 | * 注入自定义的弹出框管理器类。
12 | * @author dom
13 | */
14 | public interface IPopUpManager extends IEventDispatcher
15 | {
16 | /**
17 | * 模态遮罩的填充颜色
18 | */
19 | function get modalColor():uint;
20 | function set modalColor(value:uint):void;
21 |
22 | /**
23 | * 模态遮罩的透明度
24 | */
25 | function get modalAlpha():Number;
26 | function set modalAlpha(value:Number):void;
27 |
28 | /**
29 | * 弹出一个窗口。
30 | * @param popUp 要弹出的窗口
31 | * @param modal 是否启用模态。即禁用弹出窗口所在层以下的鼠标事件。默认false。
32 | * @param center 是否居中窗口。等效于在外部调用centerPopUp()来居中。默认true。
33 | * @param systemManager 要弹出到的系统管理器。若项目中只含有一个系统管理器,可以留空。
34 | */
35 | function addPopUp(popUp:IVisualElement,modal:Boolean=false,
36 | center:Boolean=true,systemManager:ISystemManager=null):void;
37 |
38 | /**
39 | * 移除由addPopUp()方法弹出的窗口。
40 | * @param popUp 要移除的窗口
41 | */
42 | function removePopUp(popUp:IVisualElement):void;
43 |
44 | /**
45 | * 将指定窗口居中显示
46 | * @param popUp 要居中显示的窗口
47 | */
48 | function centerPopUp(popUp:IVisualElement):void;
49 |
50 | /**
51 | * 将指定窗口的层级调至最前
52 | * @param popUp 要最前显示的窗口
53 | */
54 | function bringToFront(popUp:IVisualElement):void;
55 |
56 | /**
57 | * 已经弹出的窗口列表
58 | */
59 | function get popUpList():Array;
60 | }
61 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/ISystemManager.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.display.Stage;
4 | import flash.events.IEventDispatcher;
5 |
6 | import org.flexlite.domUI.core.IContainer;
7 |
8 | /**
9 | *
10 | * @author dom
11 | */
12 | public interface ISystemManager extends IEventDispatcher
13 | {
14 | /**
15 | * 弹出窗口层容器。
16 | */
17 | function get popUpContainer():IContainer;
18 | /**
19 | * 工具提示层容器。
20 | */
21 | function get toolTipContainer():IContainer;
22 | /**
23 | * 鼠标样式层容器。
24 | */
25 | function get cursorContainer():IContainer;
26 | /**
27 | * 舞台引用
28 | */
29 | function get stage():Stage;
30 | }
31 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/IToolTipManager.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.display.DisplayObject;
4 |
5 | import org.flexlite.domUI.core.IToolTip;
6 |
7 | /**
8 | * 工具提示管理器接口。若项目需要自定义工具提示管理器,请实现此接口,
9 | * 并在项目初始化前调用Injector.mapClass(IToolTipManager,YourToolTipManager),
10 | * 注入自定义的工具提示管理器类。
11 | * @author dom
12 | */
13 | public interface IToolTipManager
14 | {
15 | /**
16 | * 当前的IToolTipManagerClient组件
17 | */
18 | function get currentTarget():IToolTipManagerClient;
19 | function set currentTarget(value:IToolTipManagerClient):void;
20 |
21 | /**
22 | * 当前可见的ToolTip显示对象;如果未显示ToolTip,则为 null。
23 | */
24 | function get currentToolTip():IToolTip;
25 | function set currentToolTip(value:IToolTip):void;
26 |
27 | /**
28 | * 如果为 true,则当用户将鼠标指针移至组件上方时,ToolTipManager会自动显示工具提示。
29 | * 如果为 false,则不会显示任何工具提示。
30 | */
31 | function get enabled():Boolean;
32 | function set enabled(value:Boolean):void;
33 |
34 | /**
35 | * 自工具提示出现时起,ToolTipManager要隐藏此提示前所需等待的时间量(以毫秒为单位)。默认值:10000。
36 | */
37 | function get hideDelay():Number;
38 | function set hideDelay(value:Number):void;
39 |
40 | /**
41 | * 当第一个ToolTip显示完毕后,若在此时间间隔内快速移动到下一个组件上,
42 | * 就直接显示ToolTip而不延迟showDelay。默认值:100。
43 | */
44 | function get scrubDelay():Number;
45 |
46 | function set scrubDelay(value:Number):void;
47 |
48 | /**
49 | * 当用户将鼠标移至具有工具提示的组件上方时,等待 ToolTip框出现所需的时间(以毫秒为单位)。
50 | * 若要立即显示ToolTip框,请将toolTipShowDelay设为0。默认值:200。
51 | */
52 | function get showDelay():Number;
53 | function set showDelay(value:Number):void;
54 |
55 | /**
56 | * 全局默认的创建工具提示要用到的类。
57 | */
58 | function get toolTipClass():Class;
59 | function set toolTipClass(value:Class):void;
60 |
61 | /**
62 | * 注册需要显示ToolTip的组件
63 | * @param target 目标组件
64 | * @param oldToolTip 之前的ToolTip数据
65 | * @param newToolTip 现在的ToolTip数据
66 | */
67 | function registerToolTip(target:DisplayObject,
68 | oldToolTip:Object,
69 | newToolTip:Object):void;
70 |
71 | /**
72 | * 使用指定的ToolTip数据,创建默认的ToolTip类的实例,然后在舞台坐标中的指定位置显示此实例。
73 | * 保存此方法返回的对 ToolTip 的引用,以便将其传递给destroyToolTip()方法销毁实例。
74 | * @param toolTipData ToolTip数据
75 | * @param x 舞台坐标x
76 | * @param y 舞台坐标y
77 | * @return 创建的ToolTip实例引用
78 | */
79 | function createToolTip(toolTipData:String, x:Number, y:Number):IToolTip;
80 |
81 | /**
82 | * 销毁由createToolTip()方法创建的ToolTip实例。
83 | * @param toolTip 要销毁的ToolTip实例
84 | */
85 | function destroyToolTip(toolTip:IToolTip):void;
86 | }
87 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/managers/IToolTipManagerClient.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.managers
2 | {
3 | import flash.events.IEventDispatcher;
4 | import flash.geom.Point;
5 |
6 | /**
7 | * 包含工具提示功能的组件接口
8 | * @author dom
9 | */
10 | public interface IToolTipManagerClient extends IEventDispatcher
11 | {
12 | /**
13 | * 此组件的工具提示数据。
14 | * 此属性将赋值给工具提示显示对象的toolTipData属性。通常给此属性直接赋值一个String。
15 | * 当组件的toolTipClass为空时,ToolTipManager将采用注入的默认工具提示类创建显示对象。
16 | * 若toolTipClass不为空时,ToolTipManager将使用指定的toolTipClass创建显示对象。
17 | */
18 | function get toolTip():Object;
19 | function set toolTip(value:Object):void;
20 |
21 | /**
22 | * 创建工具提示显示对象要用到的类,要实现IToolTip接口。ToolTip默认会被禁用鼠标事件。
23 | * 若此属性为空,ToolTipManager将采用默认的工具提示类创建显示对象。
24 | */
25 | function get toolTipClass():Class;
26 | function set toolTipClass(value:Class):void;
27 |
28 | /**
29 | * toolTip弹出位置,请使用PopUpPosition定义的常量,若不设置或设置了非法的值,则弹出位置跟随鼠标。
30 | */
31 | function get toolTipPosition():String;
32 | function set toolTipPosition(value:String):void;
33 | /**
34 | * toolTip弹出位置的偏移量
35 | */
36 | function get toolTipOffset():Point;
37 | function set toolTipOffset(value:Point):void;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/AlertSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.text.TextFormatAlign;
4 |
5 | import org.flexlite.domUI.components.Button;
6 | import org.flexlite.domUI.components.Group;
7 | import org.flexlite.domUI.components.Label;
8 | import org.flexlite.domUI.layouts.HorizontalAlign;
9 | import org.flexlite.domUI.layouts.HorizontalLayout;
10 | import org.flexlite.domUI.layouts.VerticalAlign;
11 |
12 | /**
13 | * Alert默认皮肤
14 | * @author dom
15 | */
16 | public class AlertSkin extends TitleWindowSkin
17 | {
18 | /**
19 | * 构造函数
20 | */
21 | public function AlertSkin()
22 | {
23 | super();
24 | this.minHeight = 100;
25 | this.minWidth = 170;
26 | this.maxWidth = 310;
27 | }
28 |
29 | /**
30 | * [SkinPart]文本内容显示对象
31 | */
32 | public var contentDisplay:Label;
33 | /**
34 | * [SkinPart]第一个按钮,通常是"确定"。
35 | */
36 | public var firstButton:Button;
37 | /**
38 | * [SkinPart]第二个按钮,通常是"取消"。
39 | */
40 | public var secondButton:Button;
41 |
42 | /**
43 | * @inheritDoc
44 | */
45 | override protected function createChildren():void
46 | {
47 | super.createChildren();
48 | contentDisplay = new Label;
49 | contentDisplay.top = 30;
50 | contentDisplay.left = 1;
51 | contentDisplay.right = 1;
52 | contentDisplay.bottom = 36;
53 | contentDisplay.verticalAlign = VerticalAlign.MIDDLE;
54 | contentDisplay.textAlign = TextFormatAlign.CENTER;
55 | contentDisplay.padding = 10;
56 | contentDisplay.selectable = true;
57 | addElementAt(contentDisplay,0);
58 |
59 | var hGroup:Group = new Group;
60 | hGroup.bottom = 10;
61 | hGroup.horizontalCenter = 0;
62 | var layout:HorizontalLayout = new HorizontalLayout();
63 | layout.horizontalAlign = HorizontalAlign.CENTER;
64 | layout.gap = 10;
65 | layout.paddingLeft = layout.paddingRight = 20;
66 | hGroup.layout = layout;
67 | addElement(hGroup);
68 |
69 | firstButton = new Button();
70 | firstButton.label = "确定";
71 | hGroup.addElement(firstButton);
72 | secondButton = new Button();
73 | secondButton.label = "取消";
74 | hGroup.addElement(secondButton);
75 | }
76 | }
77 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 |
4 | import flash.text.TextFormatAlign;
5 |
6 | import org.flexlite.domCore.dx_internal;
7 | import org.flexlite.domUI.components.Label;
8 | import org.flexlite.domUI.layouts.VerticalAlign;
9 | import org.flexlite.domUI.skins.VectorSkin;
10 |
11 | use namespace dx_internal;
12 |
13 | /**
14 | * 按钮默认皮肤
15 | * @author dom
16 | */
17 | public class ButtonSkin extends VectorSkin
18 | {
19 | public function ButtonSkin()
20 | {
21 | super();
22 | states = ["up","over","down","disabled"];
23 | this.minHeight = 21;
24 | this.minWidth = 21;
25 | }
26 |
27 | public var labelDisplay:Label;
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override protected function createChildren():void
33 | {
34 | super.createChildren();
35 | labelDisplay = new Label();
36 | labelDisplay.textAlign = TextFormatAlign.CENTER;
37 | labelDisplay.verticalAlign = VerticalAlign.MIDDLE;
38 | labelDisplay.maxDisplayedLines = 1;
39 | labelDisplay.left = 5;
40 | labelDisplay.right = 5;
41 | labelDisplay.top = 3;
42 | labelDisplay.bottom = 3;
43 | addElement(labelDisplay);
44 | }
45 |
46 | /**
47 | * @inheritDoc
48 | */
49 | override protected function updateDisplayList(w:Number, h:Number):void
50 | {
51 | super.updateDisplayList(w, h);
52 |
53 | graphics.clear();
54 | var textColor:uint;
55 | switch (currentState)
56 | {
57 | case "up":
58 | case "disabled":
59 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
60 | [fillColors[0],fillColors[1]],cornerRadius);
61 | textColor = themeColors[0];
62 | break;
63 | case "over":
64 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
65 | [fillColors[2],fillColors[3]],cornerRadius);
66 | textColor = themeColors[1];
67 | break;
68 | case "down":
69 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
70 | [fillColors[4],fillColors[5]],cornerRadius);
71 | textColor = themeColors[1];
72 | break;
73 | }
74 | if(labelDisplay)
75 | {
76 | labelDisplay.textColor = textColor;
77 | labelDisplay.applyTextFormatNow();
78 | labelDisplay.filters = (currentState=="over"||currentState=="down")?textOverFilter:null;
79 | }
80 | this.alpha = currentState=="disabled"?0.5:1;
81 | }
82 | }
83 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ComboBoxButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 | /**
10 | * ComboBox的下拉按钮默认皮肤
11 | * @author dom
12 | */
13 | public class ComboBoxButtonSkin extends VectorSkin
14 | {
15 | public function ComboBoxButtonSkin()
16 | {
17 | super();
18 | states = ["up","over","down","disabled"];
19 | this.minHeight = 23;
20 | this.minWidth = 20;
21 | }
22 |
23 | /**
24 | * @inheritDoc
25 | */
26 | override protected function updateDisplayList(w:Number, h:Number):void
27 | {
28 | super.updateDisplayList(w, h);
29 |
30 | var g:Graphics = graphics;
31 | g.clear();
32 | var arrowColor:uint;
33 | var radius:Object = {tl:0,tr:cornerRadius,bl:0,br:cornerRadius};
34 | switch (currentState)
35 | {
36 | case "up":
37 | case "disabled":
38 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
39 | [fillColors[0],fillColors[1]],radius);
40 | arrowColor = themeColors[0];
41 | break;
42 | case "over":
43 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
44 | [fillColors[2],fillColors[3]],radius);
45 | arrowColor = themeColors[1];
46 | break;
47 | case "down":
48 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
49 | [fillColors[4],fillColors[5]],radius);
50 | arrowColor = themeColors[1];
51 | break;
52 | }
53 | this.alpha = currentState=="disabled"?0.5:1;
54 | g.lineStyle(0,0,0);
55 | g.beginFill(arrowColor);
56 | g.moveTo(w*0.5, h*0.5 + 3);
57 | g.lineTo(w*0.5-3.5, h*0.5 - 2);
58 | g.lineTo(w*0.5+3.5, h*0.5 - 2);
59 | g.lineTo(w*0.5, h*0.5 + 3);
60 | g.endFill();
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ComboBoxTextInputSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 |
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.components.EditableText;
7 | import org.flexlite.domUI.components.Label;
8 | import org.flexlite.domUI.skins.VectorSkin;
9 |
10 | use namespace dx_internal;
11 | /**
12 | * ComboBox的textInput部件默认皮肤
13 | * @author dom
14 | */
15 | public class ComboBoxTextInputSkin extends VectorSkin
16 | {
17 | public function ComboBoxTextInputSkin()
18 | {
19 | super();
20 | this.states = ["normal","disabled","normalWithPrompt","disabledWithPrompt"];
21 | }
22 |
23 | public var textDisplay:EditableText;
24 | /**
25 | * [SkinPart]当text属性为空字符串时要显示的文本。
26 | */
27 | public var promptDisplay:Label;
28 | /**
29 | * @inheritDoc
30 | */
31 | override protected function createChildren():void
32 | {
33 | super.createChildren();
34 | textDisplay = new EditableText();
35 | textDisplay.widthInChars = 10;
36 | textDisplay.heightInLines = 1;
37 | textDisplay.multiline = false;
38 | textDisplay.left = 1;
39 | textDisplay.right = 1;
40 | textDisplay.verticalCenter = 0;
41 | addElement(textDisplay);
42 | }
43 |
44 | override protected function commitCurrentState():void
45 | {
46 | this.alpha = currentState=="disabled"||
47 | currentState=="disabledWithPrompt"?0.5:1;
48 | if(currentState=="disabledWithPrompt"||currentState=="normalWithPrompt")
49 | {
50 | if(!promptDisplay)
51 | {
52 | createPromptDisplay();
53 | }
54 | if(!contains(promptDisplay))
55 | addElement(promptDisplay);
56 | }
57 | else if(promptDisplay&&contains(promptDisplay))
58 | {
59 | removeElement(promptDisplay);
60 | }
61 | }
62 |
63 | private function createPromptDisplay():void
64 | {
65 | promptDisplay = new Label();
66 | promptDisplay.maxDisplayedLines = 1;
67 | promptDisplay.verticalCenter = 0;
68 | promptDisplay.x = 1;
69 | promptDisplay.textColor = 0xa9a9a9;
70 | promptDisplay.mouseChildren = false;
71 | promptDisplay.mouseEnabled = false;
72 | if(hostComponent)
73 | hostComponent.findSkinParts();
74 | }
75 |
76 | /**
77 | * @inheritDoc
78 | */
79 | override protected function updateDisplayList(w:Number,h:Number):void
80 | {
81 | super.updateDisplayList(w, h);
82 |
83 | graphics.clear();
84 | var radius:Object = {tl:cornerRadius,tr:0,bl:cornerRadius,br:0};
85 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
86 | 0xFFFFFF,radius);
87 | }
88 | }
89 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/DropDownListButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 |
10 | /**
11 | * DropDownList下拉按钮默认皮肤
12 | * @author dom
13 | */
14 | public class DropDownListButtonSkin extends VectorSkin
15 | {
16 | public function DropDownListButtonSkin()
17 | {
18 | super();
19 | states = ["up","over","down","disabled"];
20 | this.minHeight = 25;
21 | this.minWidth = 22;
22 | }
23 |
24 | /**
25 | * @inheritDoc
26 | */
27 | override protected function updateDisplayList(w:Number, h:Number):void
28 | {
29 | super.updateDisplayList(w, h);
30 |
31 | var g:Graphics = graphics;
32 | g.clear();
33 | var arrowColor:uint;
34 | switch (currentState)
35 | {
36 | case "up":
37 | case "disabled":
38 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
39 | [fillColors[0],fillColors[1]],cornerRadius);
40 | if(w>21&&h>2)
41 | {
42 | drawLine(w-21,1,w-21,h-1,0xe4e4e4);
43 | drawLine(w-20,1,w-20,h-1,0xf9f9f9);
44 | }
45 | arrowColor = themeColors[0];
46 | break;
47 | case "over":
48 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
49 | [fillColors[2],fillColors[3]],cornerRadius);
50 | if(w>21&&h>2)
51 | {
52 | drawLine(w-21,1,w-21,h-1,0x3c74ab);
53 | drawLine(w-20,1,w-20,h-1,0x6a9fd3);
54 | }
55 | arrowColor = themeColors[1];
56 | break;
57 | case "down":
58 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
59 | [fillColors[4],fillColors[5]],cornerRadius);
60 | if(w>21&&h>2)
61 | {
62 | drawLine(w-21,1,w-21,h-1,0x787878);
63 | drawLine(w-20,1,w-20,h-1,0xa4a4a4);
64 | }
65 | arrowColor = themeColors[1];
66 | break;
67 | }
68 | if(w>21)
69 | {
70 | g.lineStyle(0,0,0);
71 | g.beginFill(arrowColor);
72 | g.moveTo(w-10, h*0.5 + 3);
73 | g.lineTo(w-13.5, h*0.5 - 2);
74 | g.lineTo(w-6.5, h*0.5 - 2);
75 | g.lineTo(w-10, h*0.5 + 3);
76 | g.endFill();
77 | }
78 | this.alpha = currentState=="disabled"?0.5:1;
79 | }
80 | }
81 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/HScrollBarSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domUI.components.Button;
4 | import org.flexlite.domCore.dx_internal;
5 | import org.flexlite.domUI.skins.VectorSkin;
6 |
7 | use namespace dx_internal;
8 | /**
9 | * 水平滚动条默认皮肤
10 | * @author dom
11 | */
12 | public class HScrollBarSkin extends VectorSkin
13 | {
14 | public function HScrollBarSkin()
15 | {
16 | super();
17 | this.minWidth = 50;
18 | this.minHeight = 15;
19 | }
20 |
21 | public var decrementButton:Button;
22 |
23 | public var incrementButton:Button;
24 |
25 | public var thumb:Button;
26 |
27 | public var track:Button;
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override protected function createChildren():void
33 | {
34 | super.createChildren();
35 | track = new Button();
36 | track.left = 16;
37 | track.right = 16;
38 | track.width = 54;
39 | track.skinName = HScrollBarTrackSkin;
40 | addElement(track);
41 |
42 | decrementButton = new Button();
43 | decrementButton.left = 0;
44 | decrementButton.skinName = ScrollBarLeftButtonSkin;
45 | addElement(decrementButton);
46 |
47 | incrementButton = new Button();
48 | incrementButton.right = 0;
49 | incrementButton.skinName = ScrollBarRightButtonSkin;
50 | addElement(incrementButton);
51 |
52 | thumb = new Button();
53 | thumb.skinName = HScrollBarThumbSkin;
54 | addElement(thumb);
55 | }
56 |
57 | /**
58 | * @inheritDoc
59 | */
60 | override protected function updateDisplayList(w:Number,h:Number):void
61 | {
62 | super.updateDisplayList(w,h);
63 | this.alpha = currentState=="disabled"?0.5:1;
64 | }
65 |
66 | }
67 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/HScrollBarThumbSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.skins.VectorSkin;
5 |
6 | use namespace dx_internal;
7 |
8 | /**
9 | * 水平滚动条thumb默认皮肤
10 | * @author dom
11 | */
12 | public class HScrollBarThumbSkin extends VectorSkin
13 | {
14 | public function HScrollBarThumbSkin()
15 | {
16 | super();
17 | states = ["up","over","down","disabled"];
18 | this.currentState = "up";
19 | this.minHeight = 15;
20 | this.minWidth = 15;
21 | }
22 |
23 | /**
24 | * @inheritDoc
25 | */
26 | override protected function updateDisplayList(w:Number, h:Number):void
27 | {
28 | super.updateDisplayList(w, h);
29 |
30 | graphics.clear();
31 | switch (currentState)
32 | {
33 | case "up":
34 | case "disabled":
35 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
36 | [fillColors[0],fillColors[1]],1);
37 | break;
38 | case "over":
39 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
40 | [fillColors[2],fillColors[3]],1);
41 | break;
42 | case "down":
43 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
44 | [fillColors[4],fillColors[5]],1);
45 | break;
46 | }
47 | this.alpha = currentState=="disabled"?0.5:1;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/HScrollBarTrackSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.GradientType;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 |
10 | /**
11 | * 水平滚动条track默认皮肤
12 | * @author dom
13 | */
14 | public class HScrollBarTrackSkin extends VectorSkin
15 | {
16 | public function HScrollBarTrackSkin()
17 | {
18 | super();
19 | states = ["up","over","down","disabled"];
20 | this.currentState = "up";
21 | this.minHeight = 15;
22 | this.minWidth = 15;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | override protected function updateDisplayList(w:Number, h:Number):void
29 | {
30 | super.updateDisplayList(w, h);
31 |
32 | graphics.clear();
33 | //绘制边框
34 | drawRoundRect(
35 | 0, 0, w, h, 0,
36 | borderColors[0], 1,
37 | verticalGradientMatrix(0, 0, w, h ),
38 | GradientType.LINEAR, null,
39 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
40 | //绘制填充
41 | drawRoundRect(
42 | 1, 1, w - 2, h - 2, 0,
43 | 0xdddbdb, 1,
44 | verticalGradientMatrix(1, 2, w - 2, h - 3));
45 | //绘制底线
46 | drawLine(1,1,w-1,1,0xbcbcbc);
47 | this.alpha = currentState=="disabled"?0.5:1;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/HSliderSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domUI.components.Button;
4 | import org.flexlite.domUI.components.UIAsset;
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 | /**
10 | * 水平滑块默认皮肤
11 | * @author dom
12 | */
13 | public class HSliderSkin extends VectorSkin
14 | {
15 | public function HSliderSkin()
16 | {
17 | super();
18 | this.minWidth = 50;
19 | this.minHeight = 11;
20 | }
21 |
22 | public var thumb:Button;
23 |
24 | public var track:Button;
25 |
26 | public var trackHighlight:UIAsset;
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | override protected function createChildren():void
32 | {
33 | super.createChildren();
34 | track = new Button;
35 | track.left = 0;
36 | track.right = 0;
37 | track.top = 0;
38 | track.bottom = 0;
39 | track.minWidth = 33;
40 | track.width = 100;
41 | track.tabEnabled = false;
42 | track.skinName = HSliderTrackSkin;
43 | addElement(track);
44 |
45 | trackHighlight = new UIAsset;
46 | trackHighlight.top = 0;
47 | trackHighlight.bottom = 0;
48 | trackHighlight.minWidth = 33;
49 | trackHighlight.width = 100;
50 | trackHighlight.tabEnabled = false;
51 | trackHighlight.skinName = HSliderTrackHighlightSkin;
52 | addElement(trackHighlight);
53 |
54 | thumb = new Button();
55 | thumb.top = 0;
56 | thumb.bottom = 0;
57 | thumb.width = 11;
58 | thumb.height = 11;
59 | thumb.tabEnabled = false;
60 | thumb.skinName = SliderThumbSkin;
61 | addElement(thumb);
62 | }
63 |
64 | /**
65 | * @inheritDoc
66 | */
67 | override protected function updateDisplayList(w:Number,h:Number):void
68 | {
69 | super.updateDisplayList(w,h);
70 | this.alpha = currentState=="disabled"?0.5:1;
71 | }
72 |
73 | }
74 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/HSliderTrackHighlightSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.skins.VectorSkin;
5 |
6 | use namespace dx_internal;
7 |
8 | /**
9 | * 水平滑块track默认皮肤
10 | * @author dom
11 | */
12 | public class HSliderTrackHighlightSkin extends VectorSkin
13 | {
14 | public function HSliderTrackHighlightSkin()
15 | {
16 | super();
17 | this.minHeight = 4;
18 | this.minWidth = 15;
19 | }
20 |
21 | /**
22 | * @inheritDoc
23 | */
24 | override protected function updateDisplayList(w:Number, h:Number):void
25 | {
26 | super.updateDisplayList(w, h);
27 | var offsetY:Number = Math.round(h*0.5-2);
28 |
29 | graphics.clear();
30 | graphics.beginFill(0xFFFFFF,0);
31 | graphics.drawRect(0,0,w,h);
32 | graphics.endFill();
33 | h=4;
34 | graphics.lineStyle();
35 | drawRoundRect(
36 | 0, offsetY, w, h, 1,
37 | fillColors[2], 1,
38 | verticalGradientMatrix(0, offsetY, w, h));
39 | if(w>5)
40 | drawLine(1,offsetY,w-1,offsetY,0x457cb2);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/HSliderTrackSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.skins.VectorSkin;
5 |
6 | use namespace dx_internal;
7 |
8 | /**
9 | * 水平滑块track默认皮肤
10 | * @author dom
11 | */
12 | public class HSliderTrackSkin extends VectorSkin
13 | {
14 | public function HSliderTrackSkin()
15 | {
16 | super();
17 | states = ["up","over","down","disabled"];
18 | this.currentState = "up";
19 | this.minHeight = 4;
20 | this.minWidth = 15;
21 | }
22 |
23 | /**
24 | * @inheritDoc
25 | */
26 | override protected function updateDisplayList(w:Number, h:Number):void
27 | {
28 | super.updateDisplayList(w, h);
29 | var offsetY:Number = Math.round(h*0.5-2);
30 |
31 | graphics.clear();
32 | graphics.beginFill(0xFFFFFF,0);
33 | graphics.drawRect(0,0,w,h);
34 | graphics.endFill();
35 | h=4;
36 | graphics.lineStyle();
37 | drawRoundRect(
38 | 0, offsetY, w, h, 1,
39 | 0xdddbdb, 1,
40 | verticalGradientMatrix(0, offsetY, w, h));
41 | if(w>4)
42 | drawLine(1,offsetY,w-1,offsetY,0xbcbcbc);
43 | this.alpha = currentState=="disabled"?0.5:1;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ItemRendererSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.GradientType;
4 | import flash.display.Graphics;
5 | import flash.text.TextFormatAlign;
6 |
7 | import org.flexlite.domCore.dx_internal;
8 | import org.flexlite.domUI.components.Label;
9 | import org.flexlite.domUI.layouts.VerticalAlign;
10 | import org.flexlite.domUI.skins.VectorSkin;
11 |
12 | use namespace dx_internal;
13 |
14 | /**
15 | * ItemRenderer默认皮肤
16 | * @author dom
17 | */
18 | public class ItemRendererSkin extends VectorSkin
19 | {
20 | public function ItemRendererSkin()
21 | {
22 | super();
23 | states = ["up","over","down"];
24 | this.minHeight = 21;
25 | this.minWidth = 21;
26 | }
27 |
28 | public var labelDisplay:Label;
29 |
30 | /**
31 | * @inheritDoc
32 | */
33 | override protected function createChildren():void
34 | {
35 | super.createChildren();
36 | labelDisplay = new Label();
37 | labelDisplay.textAlign = TextFormatAlign.CENTER;
38 | labelDisplay.verticalAlign = VerticalAlign.MIDDLE;
39 | labelDisplay.maxDisplayedLines = 1;
40 | labelDisplay.left = 5;
41 | labelDisplay.right = 5;
42 | labelDisplay.top = 3;
43 | labelDisplay.bottom = 3;
44 | addElement(labelDisplay);
45 | }
46 |
47 | /**
48 | * @inheritDoc
49 | */
50 | override protected function updateDisplayList(w:Number, h:Number):void
51 | {
52 | super.updateDisplayList(w, h);
53 |
54 | var g:Graphics = graphics;
55 | g.clear();
56 | var textColor:uint;
57 | switch (currentState)
58 | {
59 | case "up":
60 | case "disabled":
61 | drawRoundRect(
62 | 0, 0, w, h, 0,
63 | 0xFFFFFF, 1,
64 | verticalGradientMatrix(0, 0, w, h));
65 | textColor = themeColors[0];
66 | break;
67 | case "over":
68 | case "down":
69 | drawRoundRect(
70 | 0, 0, w, h, 0,
71 | borderColors[0], 1,
72 | verticalGradientMatrix(0, 0, w, h ),
73 | GradientType.LINEAR, null,
74 | { x: 0, y: 0, w: w, h: h - 1, r: 0});
75 | drawRoundRect(
76 | 0, 0, w, h - 1, 0,
77 | 0x4f83c4, 1,
78 | verticalGradientMatrix(0, 0, w, h - 1));
79 | textColor = themeColors[1];
80 | break;
81 | }
82 | if(labelDisplay)
83 | {
84 | labelDisplay.textColor = textColor;
85 | labelDisplay.applyTextFormatNow();
86 | labelDisplay.filters = (currentState=="over"||currentState=="down")?textOverFilter:null;
87 | }
88 | this.alpha = currentState=="disabled"?0.5:1;
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ListSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.GradientType;
4 |
5 | import org.flexlite.domUI.components.DataGroup;
6 | import org.flexlite.domUI.components.Scroller;
7 | import org.flexlite.domUI.components.supportClasses.ItemRenderer;
8 | import org.flexlite.domCore.dx_internal;
9 | import org.flexlite.domUI.layouts.HorizontalAlign;
10 | import org.flexlite.domUI.layouts.VerticalLayout;
11 | import org.flexlite.domUI.skins.VectorSkin;
12 |
13 | use namespace dx_internal;
14 | /**
15 | * List默认皮肤
16 | * @author dom
17 | */
18 | public class ListSkin extends VectorSkin
19 | {
20 | public function ListSkin()
21 | {
22 | super();
23 | minWidth = 70;
24 | minHeight = 70;
25 | }
26 |
27 | public var dataGroup:DataGroup;
28 |
29 | public var scroller:Scroller;
30 |
31 | /**
32 | * @inheritDoc
33 | */
34 | override protected function createChildren():void
35 | {
36 | super.createChildren();
37 | dataGroup = new DataGroup();
38 | dataGroup.itemRenderer = ItemRenderer;
39 | var layout:VerticalLayout = new VerticalLayout();
40 | layout.gap = 0;
41 | layout.horizontalAlign = HorizontalAlign.CONTENT_JUSTIFY;
42 | dataGroup.layout = layout;
43 |
44 | scroller = new Scroller();
45 | scroller.left = 0;
46 | scroller.top = 0;
47 | scroller.right = 0;
48 | scroller.bottom = 0;
49 | scroller.minViewportInset = 1;
50 | scroller.viewport = dataGroup;
51 | addElement(scroller);
52 | }
53 |
54 | /**
55 | * @inheritDoc
56 | */
57 | override protected function updateDisplayList(w:Number,h:Number):void
58 | {
59 | super.updateDisplayList(w,h);
60 | graphics.clear();
61 | drawRoundRect(
62 | x, y, w, h, 0,
63 | borderColors[0], 1,
64 | verticalGradientMatrix(x, y, w, h ),
65 | GradientType.LINEAR, null,
66 | { x: x+1, y: y+1, w: w - 2, h: h - 2, r: 0});
67 | this.alpha = currentState=="disabled"?0.5:1;
68 | }
69 |
70 | }
71 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ProgressBarSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 |
4 | import org.flexlite.domUI.components.Label;
5 | import org.flexlite.domUI.components.UIAsset;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 |
9 | /**
10 | * 进度条默认皮肤
11 | * @author dom
12 | */
13 | public class ProgressBarSkin extends VectorSkin
14 | {
15 | public function ProgressBarSkin()
16 | {
17 | super();
18 | this.minHeight = 24;
19 | this.minWidth = 30;
20 | }
21 |
22 | public var thumb:UIAsset;
23 | public var track:UIAsset;
24 | public var labelDisplay:Label;
25 |
26 | /**
27 | * @inheritDoc
28 | */
29 | override protected function createChildren():void
30 | {
31 | super.createChildren();
32 |
33 | track = new UIAsset();
34 | track.skinName = ProgressBarTrackSkin;
35 | track.left = 0;
36 | track.right = 0;
37 | addElement(track);
38 |
39 | thumb = new UIAsset();
40 | thumb.skinName = ProgressBarThumbSkin;
41 | addElement(thumb);
42 |
43 | labelDisplay = new Label();
44 | labelDisplay.y = 14;
45 | labelDisplay.horizontalCenter = 0;
46 | addElement(labelDisplay);
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ProgressBarThumbSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.skins.VectorSkin;
5 |
6 | use namespace dx_internal;
7 | /**
8 | *
9 | * @author dom
10 | */
11 | public class ProgressBarThumbSkin extends VectorSkin
12 | {
13 | public function ProgressBarThumbSkin()
14 | {
15 | super();
16 | this.minHeight = 10;
17 | this.minWidth = 5;
18 | }
19 |
20 | /**
21 | * @inheritDoc
22 | */
23 | override protected function updateDisplayList(w:Number, h:Number):void
24 | {
25 | super.updateDisplayList(w, h);
26 |
27 | graphics.clear();
28 | graphics.beginFill(0xFFFFFF,0);
29 | graphics.drawRect(0,0,w,h);
30 | graphics.endFill();
31 | graphics.lineStyle();
32 | drawRoundRect(
33 | 0, 0, w, h, 0,
34 | fillColors[2], 1,
35 | verticalGradientMatrix(0, 0, w, h));
36 | if(w>5)
37 | drawLine(1,0,w-1,0,0x457cb2);
38 | }
39 | }
40 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ProgressBarTrackSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.skins.VectorSkin;
5 |
6 | use namespace dx_internal;
7 |
8 | /**
9 | * 进度条轨道默认皮肤
10 | * @author dom
11 | */
12 | public class ProgressBarTrackSkin extends VectorSkin
13 | {
14 | public function ProgressBarTrackSkin()
15 | {
16 | super();
17 | this.minHeight = 10;
18 | this.minWidth = 30;
19 | }
20 |
21 | /**
22 | * @inheritDoc
23 | */
24 | override protected function updateDisplayList(w:Number, h:Number):void
25 | {
26 | super.updateDisplayList(w, h);
27 |
28 | graphics.clear();
29 | graphics.beginFill(0xFFFFFF,0);
30 | graphics.drawRect(0,0,w,h);
31 | graphics.endFill();
32 | graphics.lineStyle();
33 | drawRoundRect(
34 | 0, 0, w, h, 0,
35 | 0xdddbdb, 1,
36 | verticalGradientMatrix(0, 0, w, h));
37 | if(w>4)
38 | drawLine(1,0,w-1,0,0xbcbcbc);
39 | this.alpha = currentState=="disabled"?0.5:1;
40 | }
41 | }
42 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ScrollBarLeftButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 | /**
10 | * 滚动条向左滚动按钮默认皮肤
11 | * @author dom
12 | */
13 | public class ScrollBarLeftButtonSkin extends VectorSkin
14 | {
15 | public function ScrollBarLeftButtonSkin()
16 | {
17 | super();
18 | states = ["up","over","down","disabled"];
19 | this.currentState = "up";
20 | this.minHeight = 15;
21 | this.minWidth = 17;
22 | }
23 |
24 | /**
25 | * @inheritDoc
26 | */
27 | override protected function updateDisplayList(w:Number, h:Number):void
28 | {
29 | super.updateDisplayList(w, h);
30 |
31 | var g:Graphics = graphics;
32 | g.clear();
33 | var arrowColor:uint;
34 | var radius:Object = 0;
35 | switch (currentState)
36 | {
37 | case "up":
38 | case "disabled":
39 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
40 | [fillColors[0],fillColors[1]],radius);
41 | arrowColor = themeColors[0];
42 | break;
43 | case "over":
44 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
45 | [fillColors[2],fillColors[3]],radius);
46 | arrowColor = themeColors[1];
47 | break;
48 | case "down":
49 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
50 | [fillColors[4],fillColors[5]],radius);
51 | arrowColor = themeColors[1];
52 | break;
53 | }
54 | this.alpha = currentState=="disabled"?0.5:1;
55 | g.lineStyle(0,0,0);
56 | g.beginFill(arrowColor);
57 |
58 | g.moveTo(w*0.5-3, h*0.5);
59 | g.lineTo(w*0.5+2, h*0.5-3.5);
60 | g.lineTo(w*0.5+2, h*0.5+3.5);
61 | g.lineTo(w*0.5-3, h*0.5);
62 | g.endFill();
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ScrollBarRightButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 | /**
10 | * 滚动条向右滚动按钮默认皮肤
11 | * @author dom
12 | */
13 | public class ScrollBarRightButtonSkin extends VectorSkin
14 | {
15 | public function ScrollBarRightButtonSkin()
16 | {
17 | super();
18 | states = ["up","over","down","disabled"];
19 | this.currentState = "up";
20 | this.minHeight = 15;
21 | this.minWidth = 17;
22 | }
23 |
24 | /**
25 | * @inheritDoc
26 | */
27 | override protected function updateDisplayList(w:Number, h:Number):void
28 | {
29 | super.updateDisplayList(w, h);
30 |
31 | var g:Graphics = graphics;
32 | g.clear();
33 | var arrowColor:uint;
34 | var radius:Object = 0;
35 | switch (currentState)
36 | {
37 | case "up":
38 | case "disabled":
39 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
40 | [fillColors[0],fillColors[1]],radius);
41 | arrowColor = themeColors[0];
42 | break;
43 | case "over":
44 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
45 | [fillColors[2],fillColors[3]],radius);
46 | arrowColor = themeColors[1];
47 | break;
48 | case "down":
49 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
50 | [fillColors[4],fillColors[5]],radius);
51 | arrowColor = themeColors[1];
52 | break;
53 | }
54 | this.alpha = currentState=="disabled"?0.5:1;
55 | g.lineStyle(0,0,0);
56 | g.beginFill(arrowColor);
57 |
58 | g.moveTo(w*0.5+3, h*0.5);
59 | g.lineTo(w*0.5-2, h*0.5-3.5);
60 | g.lineTo(w*0.5-2, h*0.5+3.5);
61 | g.lineTo(w*0.5+3, h*0.5);
62 | g.endFill();
63 | }
64 | }
65 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ScrollBarUpButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.GradientType;
4 | import flash.display.Graphics;
5 |
6 | import org.flexlite.domCore.dx_internal;
7 | import org.flexlite.domUI.skins.VectorSkin;
8 |
9 | use namespace dx_internal;
10 | /**
11 | * 滚动条向上滚动按钮默认皮肤
12 | * @author dom
13 | */
14 | public class ScrollBarUpButtonSkin extends VectorSkin
15 | {
16 | public function ScrollBarUpButtonSkin()
17 | {
18 | super();
19 | states = ["up","over","down","disabled"];
20 | this.currentState = "up";
21 | this.minHeight = 17;
22 | this.minWidth = 15;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | override protected function updateDisplayList(w:Number, h:Number):void
29 | {
30 | super.updateDisplayList(w, h);
31 |
32 | var g:Graphics = graphics;
33 | g.clear();
34 | var arrowColor:uint;
35 | switch (currentState)
36 | {
37 | case "up":
38 | case "disabled":
39 | drawRoundRect(
40 | 0, 0, w, h, 0,
41 | borderColors[0], 1,
42 | horizontalGradientMatrix(0, 0, w, h ),
43 | GradientType.LINEAR, null,
44 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
45 | drawRoundRect(
46 | 1, 1, w - 2, h - 2, 0,
47 | [fillColors[0],fillColors[1]], 1,
48 | horizontalGradientMatrix(1, 1, w - 2, h - 2),GradientType.LINEAR);
49 | drawLine(w-1,0,w-1,h,bottomLineColors[0]);
50 | arrowColor = themeColors[0];
51 | break;
52 | case "over":
53 | drawRoundRect(
54 | 0, 0, w, h, 0,
55 | borderColors[1], 1,
56 | horizontalGradientMatrix(0, 0, w, h ),
57 | GradientType.LINEAR, null,
58 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
59 | drawRoundRect(
60 | 1, 1, w - 2, h - 2, 0,
61 | [fillColors[2],fillColors[3]], 1,
62 | horizontalGradientMatrix(1, 1, w - 2, h - 2),GradientType.LINEAR);
63 | drawLine(w-1,0,w-1,h,bottomLineColors[1]);
64 | arrowColor = themeColors[1];
65 | break;
66 | case "down":
67 | drawRoundRect(
68 | 0, 0, w, h, 0,
69 | borderColors[2], 1,
70 | horizontalGradientMatrix(0, 0, w, h ),
71 | GradientType.LINEAR, null,
72 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
73 | drawRoundRect(
74 | 1, 1, w - 2, h - 2, 0,
75 | [fillColors[4],fillColors[5]], 1,
76 | horizontalGradientMatrix(1, 1, w - 2, h - 2),GradientType.LINEAR);
77 | drawLine(w-1,0,w-1,h,bottomLineColors[2]);
78 | arrowColor = themeColors[1];
79 | break;
80 | }
81 | this.alpha = currentState=="disabled"?0.5:1;
82 | g.lineStyle(0,0,0);
83 | g.beginFill(arrowColor);
84 | g.moveTo(w*0.5, h*0.5 - 3);
85 | g.lineTo(w*0.5-3.5, h*0.5 + 2);
86 | g.lineTo(w*0.5+3.5, h*0.5 + 2);
87 | g.lineTo(w*0.5, h*0.5 -3);
88 | g.endFill();
89 | }
90 | }
91 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ScrollerSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domUI.components.HScrollBar;
4 | import org.flexlite.domUI.components.VScrollBar;
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 | /**
10 | * 垂直滚动条默认皮肤
11 | * @author dom
12 | */
13 | public class ScrollerSkin extends VectorSkin
14 | {
15 | public function ScrollerSkin()
16 | {
17 | super();
18 | }
19 |
20 | public var horizontalScrollBar:HScrollBar;
21 |
22 | public var verticalScrollBar:VScrollBar;
23 |
24 | /**
25 | * @inheritDoc
26 | */
27 | override protected function createChildren():void
28 | {
29 | super.createChildren();
30 | horizontalScrollBar = new HScrollBar();
31 | horizontalScrollBar.visible = false;
32 | addElement(horizontalScrollBar);
33 |
34 | verticalScrollBar = new VScrollBar();
35 | verticalScrollBar.visible = false;
36 | addElement(verticalScrollBar);
37 | }
38 |
39 | /**
40 | * @inheritDoc
41 | */
42 | override protected function updateDisplayList(w:Number,h:Number):void
43 | {
44 | super.updateDisplayList(w,h);
45 | this.alpha = currentState=="disabled"?0.5:1;
46 | }
47 |
48 | }
49 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/SliderThumbSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 |
10 | /**
11 | * 水平滑块thumb默认皮肤
12 | * @author dom
13 | */
14 | public class SliderThumbSkin extends VectorSkin
15 | {
16 | public function SliderThumbSkin()
17 | {
18 | super();
19 | states = ["up","over","down","disabled"];
20 | this.currentState = "up";
21 | this.minHeight = 12;
22 | this.minWidth = 12;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | override protected function updateDisplayList(w:Number, h:Number):void
29 | {
30 | super.updateDisplayList(w, h);
31 | w = 12;
32 | h = 12;
33 | var g:Graphics = graphics;
34 | g.clear();
35 | switch (currentState)
36 | {
37 | case "up":
38 | case "disabled":
39 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
40 | [fillColors[0],fillColors[1]],6);
41 | break;
42 | case "over":
43 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
44 | [fillColors[2],fillColors[3]],6);
45 | break;
46 | case "down":
47 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
48 | [fillColors[4],fillColors[5]],6);
49 | break;
50 | }
51 | this.alpha = currentState=="disabled"?0.5:1;
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/TabBarSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.components.DataGroup;
5 | import org.flexlite.domUI.components.TabBarButton;
6 | import org.flexlite.domUI.layouts.HorizontalAlign;
7 | import org.flexlite.domUI.layouts.HorizontalLayout;
8 | import org.flexlite.domUI.layouts.VerticalAlign;
9 | import org.flexlite.domUI.layouts.VerticalLayout;
10 | import org.flexlite.domUI.skins.VectorSkin;
11 |
12 | use namespace dx_internal;
13 | /**
14 | * TabBar默认皮肤
15 | * @author dom
16 | */
17 | public class TabBarSkin extends VectorSkin
18 | {
19 | public function TabBarSkin()
20 | {
21 | super();
22 | minWidth = 60;
23 | minHeight = 20;
24 | }
25 |
26 | public var dataGroup:DataGroup;
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | override protected function createChildren():void
32 | {
33 | super.createChildren();
34 | dataGroup = new DataGroup();
35 | dataGroup.percentWidth = 100;
36 | dataGroup.percentHeight = 100;
37 | dataGroup.itemRenderer = TabBarButton;
38 | var layout:HorizontalLayout = new HorizontalLayout();
39 | layout.gap = -1;
40 | layout.horizontalAlign = HorizontalAlign.JUSTIFY;
41 | layout.verticalAlign = VerticalAlign.CONTENT_JUSTIFY;
42 | dataGroup.layout = layout;
43 | addElement(dataGroup);
44 | }
45 |
46 | /**
47 | * @inheritDoc
48 | */
49 | override protected function updateDisplayList(w:Number,h:Number):void
50 | {
51 | super.updateDisplayList(w,h);
52 | this.alpha = currentState=="disabled"?0.5:1;
53 | }
54 |
55 | }
56 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/TabNavigatorSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.components.Group;
7 | import org.flexlite.domUI.components.TabBar;
8 | import org.flexlite.domUI.components.ViewStack;
9 | import org.flexlite.domUI.skins.VectorSkin;
10 |
11 | use namespace dx_internal;
12 | /**
13 | * 垂直滚动条默认皮肤
14 | * @author dom
15 | */
16 | public class TabNavigatorSkin extends VectorSkin
17 | {
18 | public function TabNavigatorSkin()
19 | {
20 | super();
21 | }
22 |
23 | public var contentGroup:Group;
24 | /**
25 | * [SkinPart]选项卡组件
26 | */
27 | public var tabBar:TabBar;
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override protected function createChildren():void
33 | {
34 | super.createChildren();
35 | contentGroup = new ViewStack();
36 | contentGroup.top = 25;
37 | contentGroup.left = 1;
38 | contentGroup.right = 1;
39 | contentGroup.bottom = 1;
40 | contentGroup.clipAndEnableScrolling = true;
41 | addElement(contentGroup);
42 |
43 | tabBar = new TabBar();
44 | tabBar.height = 25;
45 | addElement(tabBar);
46 | }
47 |
48 | /**
49 | * @inheritDoc
50 | */
51 | override protected function updateDisplayList(w:Number,h:Number):void
52 | {
53 | super.updateDisplayList(w,h);
54 | var g:Graphics = this.graphics;
55 | g.clear();
56 | g.beginFill(0xFFFFFF);
57 | g.lineStyle(1,borderColors[0]);
58 | g.drawRect(0,24,w,h-24);
59 | this.alpha = currentState=="disabled"?0.5:1;
60 | }
61 |
62 | }
63 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/TitleWindowCloseButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.CapsStyle;
4 | import flash.display.Graphics;
5 |
6 | import org.flexlite.domCore.dx_internal;
7 | import org.flexlite.domUI.skins.VectorSkin;
8 |
9 | use namespace dx_internal;
10 |
11 | /**
12 | * 按钮默认皮肤
13 | * @author dom
14 | */
15 | public class TitleWindowCloseButtonSkin extends VectorSkin
16 | {
17 | public function TitleWindowCloseButtonSkin()
18 | {
19 | super();
20 | states = ["up","over","down","disabled"];
21 | this.minHeight = 16;
22 | this.minWidth = 16;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | override protected function updateDisplayList(w:Number, h:Number):void
29 | {
30 | super.updateDisplayList(w, h);
31 |
32 | var g:Graphics = graphics;
33 | g.clear();
34 | g.beginFill(0xFFFFFF,0);
35 | g.drawRect(0,0,w,h);
36 | g.endFill();
37 | var offsetX:Number = Math.round(w*0.5-8);
38 | var offsetY:Number = Math.round(h*0.5-8);
39 | switch (currentState)
40 | {
41 | case "up":
42 | case "disabled":
43 | drawCloseIcon(0xcccccc,offsetX,offsetY);
44 | break;
45 | case "over":
46 | drawCloseIcon(0x555555,offsetX,offsetY);
47 | break;
48 | case "down":
49 | drawCloseIcon(0xcccccc,offsetX,offsetY+1);
50 | break;
51 | }
52 | this.alpha = currentState=="disabled"?0.5:1;
53 | }
54 | /**
55 | * 绘制关闭图标
56 | */
57 | private function drawCloseIcon(color:uint,offsetX:Number,offsetY:Number):void
58 | {
59 | var g:Graphics = graphics;
60 | g.lineStyle(2,color,1,false,"normal",CapsStyle.SQUARE);
61 | g.moveTo(offsetX+6,offsetY+6);
62 | g.lineTo(offsetX+10,offsetY+10);
63 | g.endFill();
64 | g.moveTo(offsetX+10,offsetY+6);
65 | g.lineTo(offsetX+6,offsetY+10);
66 | g.endFill();
67 | g.lineStyle();
68 | g.beginFill(color);
69 | g.drawEllipse(offsetX+0,offsetY+0,16,16);
70 | g.drawEllipse(offsetX+2,offsetY+2,12,12);
71 | g.endFill();
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/TitleWindowSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domUI.components.Button;
4 | import org.flexlite.domUI.components.Group;
5 | import org.flexlite.domCore.dx_internal;
6 |
7 | use namespace dx_internal;
8 |
9 | /**
10 | * TitleWindow默认皮肤
11 | * @author dom
12 | */
13 | public class TitleWindowSkin extends PanelSkin
14 | {
15 | /**
16 | * 构造函数
17 | */
18 | public function TitleWindowSkin()
19 | {
20 | super();
21 | }
22 |
23 | public var closeButton:Button;
24 |
25 | public var moveArea:Group;
26 |
27 | /**
28 | * @inheritDoc
29 | */
30 | override protected function createChildren():void
31 | {
32 | super.createChildren();
33 | moveArea = new Group();
34 | moveArea.left = 0;
35 | moveArea.right = 0;
36 | moveArea.top = 0;
37 | moveArea.height = 30;
38 | addElement(moveArea);
39 |
40 | closeButton = new Button();
41 | closeButton.skinName = TitleWindowCloseButtonSkin;
42 | closeButton.right = 7;
43 | closeButton.top = 7;
44 | addElement(closeButton);
45 | }
46 | }
47 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/ToggleButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 |
4 | import flash.text.TextFormatAlign;
5 |
6 | import org.flexlite.domCore.dx_internal;
7 | import org.flexlite.domUI.components.Label;
8 | import org.flexlite.domUI.layouts.VerticalAlign;
9 | import org.flexlite.domUI.skins.VectorSkin;
10 |
11 | use namespace dx_internal;
12 | /**
13 | * ToggleButton默认皮肤
14 | * @author dom
15 | */
16 | public class ToggleButtonSkin extends VectorSkin
17 | {
18 | public function ToggleButtonSkin()
19 | {
20 | super();
21 | states = ["up","over","down","disabled","upAndSelected","overAndSelected"
22 | ,"downAndSelected","disabledAndSelected"];
23 | this.currentState = "up";
24 | }
25 |
26 | public var labelDisplay:Label;
27 |
28 | /**
29 | * @inheritDoc
30 | */
31 | override protected function createChildren():void
32 | {
33 | super.createChildren();
34 | labelDisplay = new Label();
35 | labelDisplay.textAlign = TextFormatAlign.CENTER;
36 | labelDisplay.verticalAlign = VerticalAlign.MIDDLE;
37 | labelDisplay.maxDisplayedLines = 1;
38 | labelDisplay.left = 5;
39 | labelDisplay.right = 5;
40 | labelDisplay.top = 3;
41 | labelDisplay.bottom = 3;
42 | addElement(labelDisplay);
43 | }
44 |
45 | /**
46 | * @inheritDoc
47 | */
48 | override protected function updateDisplayList(w:Number, h:Number):void
49 | {
50 | super.updateDisplayList(w, h);
51 |
52 | graphics.clear();
53 | var textColor:uint;
54 | switch (currentState)
55 | {
56 | case "up":
57 | case "disabled":
58 | drawCurrentState(0,0,w,h,borderColors[0],bottomLineColors[0],
59 | [fillColors[0],fillColors[1]],cornerRadius);
60 | textColor = themeColors[0];
61 | break;
62 | case "over":
63 | drawCurrentState(0,0,w,h,borderColors[1],bottomLineColors[1],
64 | [fillColors[2],fillColors[3]],cornerRadius);
65 | textColor = themeColors[1];
66 | break;
67 | case "down":
68 | case "overAndSelected":
69 | case "upAndSelected":
70 | case "downAndSelected":
71 | case "disabledAndSelected":
72 | drawCurrentState(0,0,w,h,borderColors[2],bottomLineColors[2],
73 | [fillColors[4],fillColors[5]],cornerRadius);
74 | textColor = themeColors[1];
75 | break;
76 | }
77 | if(labelDisplay)
78 | {
79 | labelDisplay.textColor = textColor;
80 | labelDisplay.applyTextFormatNow();
81 | labelDisplay.filters = (currentState=="over"||currentState=="down")?textOverFilter:null;
82 | }
83 | this.alpha = currentState=="disabled"||currentState=="disabledAndSelected"?0.5:1;
84 | }
85 | }
86 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/TreeDisclosureButtonSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 | /**
10 | * ComboBox的下拉按钮默认皮肤
11 | * @author dom
12 | */
13 | public class TreeDisclosureButtonSkin extends VectorSkin
14 | {
15 | public function TreeDisclosureButtonSkin()
16 | {
17 | super();
18 | states = ["up","over","down","disabled"];
19 | this.height = 9;
20 | this.width = 9;
21 | }
22 |
23 | private var _overColor:uint = 0x666666;
24 | /**
25 | * 鼠标经过时的箭头颜色,默认0x666666。
26 | */
27 | public function get overColor():uint
28 | {
29 | return _overColor;
30 | }
31 | public function set overColor(value:uint):void
32 | {
33 | if(_overColor==value)
34 | return;
35 | _overColor = value;
36 | invalidateDisplayList();
37 | }
38 |
39 | private var _selectedColor:uint = 0x333333;
40 | /**
41 | * 节点开启时的箭头颜色,默认0x333333。
42 | */
43 | public function get selectedColor():uint
44 | {
45 | return _selectedColor;
46 | }
47 | public function set selectedColor(value:uint):void
48 | {
49 | if(_selectedColor==value)
50 | return;
51 | _selectedColor = value;
52 | invalidateDisplayList();
53 | }
54 |
55 |
56 | /**
57 | * @inheritDoc
58 | */
59 | override protected function updateDisplayList(w:Number, h:Number):void
60 | {
61 | super.updateDisplayList(w, h);
62 |
63 | var g:Graphics = graphics;
64 | g.clear();
65 | g.beginFill(0xFFFFFF,0);
66 | g.drawRect(0,0,9,9);
67 | g.endFill();
68 | var arrowColor:uint;
69 | var selected:Boolean = false;
70 | switch (currentState)
71 | {
72 | case "up":
73 | case "disabled":
74 | case "over":
75 | case "down":
76 | arrowColor = _overColor;
77 | break;
78 | case "overAndSelected":
79 | case "upAndSelected":
80 | case "downAndSelected":
81 | case "disabledAndSelected":
82 | selected = true;
83 | arrowColor = _selectedColor;
84 | break;
85 | }
86 | this.alpha = currentState=="disabled"||currentState=="disabledAndSelected"?0.5:1;
87 | g.beginFill(arrowColor);
88 | if(selected)
89 | {
90 | g.lineStyle(0,0,0);
91 | g.moveTo(1, 7);
92 | g.lineTo(7, 7);
93 | g.lineTo(7, 0);
94 | g.lineTo(1, 7);
95 | g.endFill();
96 | }
97 | else
98 | {
99 | g.moveTo(2, 0);
100 | g.lineTo(2, 9);
101 | g.lineTo(7, 5);
102 | g.lineTo(2, 0);
103 | g.endFill();
104 | }
105 |
106 | }
107 | }
108 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/TreeItemRendererSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.Graphics;
4 |
5 | import org.flexlite.domUI.components.Group;
6 | import org.flexlite.domUI.components.ToggleButton;
7 | import org.flexlite.domUI.components.UIAsset;
8 | import org.flexlite.domUI.layouts.HorizontalLayout;
9 | import org.flexlite.domUI.layouts.VerticalAlign;
10 |
11 | /**
12 | * TreeItemRenderer默认皮肤
13 | * @author dom
14 | */
15 | public class TreeItemRendererSkin extends ItemRendererSkin
16 | {
17 | /**
18 | * 构造函数
19 | */
20 | public function TreeItemRendererSkin()
21 | {
22 | super();
23 | this.minHeight = 22;
24 | }
25 |
26 | /**
27 | * [SkinPart]图标显示对象
28 | */
29 | public var iconDisplay:UIAsset;
30 | /**
31 | * [SkinPart]子节点开启按钮
32 | */
33 | public var disclosureButton:ToggleButton;
34 | /**
35 | * [SkinPart]用于调整缩进值的容器对象。
36 | */
37 | public var contentGroup:Group;
38 |
39 | /**
40 | * @inheritDoc
41 | */
42 | override protected function createChildren():void
43 | {
44 | super.createChildren();
45 | contentGroup = new Group();
46 | contentGroup.top = 0;
47 | contentGroup.bottom = 0;
48 | var layout:HorizontalLayout = new HorizontalLayout();
49 | layout.gap = 1;
50 | layout.verticalAlign = VerticalAlign.MIDDLE;
51 | contentGroup.layout = layout;
52 | addElement(contentGroup);
53 |
54 | disclosureButton = new ToggleButton();
55 | disclosureButton.skinName = TreeDisclosureButtonSkin;
56 | contentGroup.addElement(disclosureButton);
57 |
58 | iconDisplay = new UIAsset();
59 | contentGroup.addElement(iconDisplay);
60 | contentGroup.addElement(labelDisplay);
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/VScrollBarSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domUI.components.Button;
4 | import org.flexlite.domCore.dx_internal;
5 | import org.flexlite.domUI.skins.VectorSkin;
6 |
7 | use namespace dx_internal;
8 | /**
9 | * 垂直滚动条默认皮肤
10 | * @author dom
11 | */
12 | public class VScrollBarSkin extends VectorSkin
13 | {
14 | public function VScrollBarSkin()
15 | {
16 | super();
17 | this.minWidth = 15;
18 | this.minHeight = 50;
19 | }
20 |
21 | public var decrementButton:Button;
22 |
23 | public var incrementButton:Button;
24 |
25 | public var thumb:Button;
26 |
27 | public var track:Button;
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override protected function createChildren():void
33 | {
34 | super.createChildren();
35 | track = new Button();
36 | track.top = 16;
37 | track.bottom = 16;
38 | track.height = 54;
39 | track.skinName = VScrollBarTrackSkin;
40 | addElement(track);
41 |
42 | decrementButton = new Button();
43 | decrementButton.top = 0;
44 | decrementButton.skinName = ScrollBarUpButtonSkin;
45 | addElement(decrementButton);
46 |
47 | incrementButton = new Button();
48 | incrementButton.bottom = 0;
49 | incrementButton.skinName = ScrollBarDownButtonSkin;
50 | addElement(incrementButton);
51 |
52 | thumb = new Button();
53 | thumb.skinName = VScrollBarThumbSkin;
54 | addElement(thumb);
55 | }
56 |
57 | /**
58 | * @inheritDoc
59 | */
60 | override protected function updateDisplayList(w:Number,h:Number):void
61 | {
62 | super.updateDisplayList(w,h);
63 | this.alpha = currentState=="disabled"?0.5:1;
64 | }
65 |
66 | }
67 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/VScrollBarThumbSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.GradientType;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 |
10 | /**
11 | * 垂直滚动条thumb默认皮肤
12 | * @author dom
13 | */
14 | public class VScrollBarThumbSkin extends VectorSkin
15 | {
16 | public function VScrollBarThumbSkin()
17 | {
18 | super();
19 | states = ["up","over","down","disabled"];
20 | this.currentState = "up";
21 | this.minHeight = 15;
22 | this.minWidth = 15;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | override protected function updateDisplayList(w:Number, h:Number):void
29 | {
30 | super.updateDisplayList(w, h);
31 |
32 | graphics.clear();
33 | switch (currentState)
34 | {
35 | case "up":
36 | case "disabled":
37 | drawRoundRect(
38 | 0, 0, w, h, 0,
39 | borderColors[0], 1,
40 | horizontalGradientMatrix(0, 0, w, h ),
41 | GradientType.LINEAR, null,
42 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
43 | drawRoundRect(
44 | 1, 1, w - 2, h - 2, 0,
45 | [fillColors[0],fillColors[1]], 1,
46 | horizontalGradientMatrix(1, 1, w - 2, h - 2),GradientType.LINEAR);
47 | drawLine(w-1,0,w-1,h,bottomLineColors[0]);
48 | break;
49 | case "over":
50 | drawRoundRect(
51 | 0, 0, w, h, 0,
52 | borderColors[1], 1,
53 | horizontalGradientMatrix(0, 0, w, h ),
54 | GradientType.LINEAR, null,
55 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
56 | drawRoundRect(
57 | 1, 1, w - 2, h - 2, 0,
58 | [fillColors[2],fillColors[3]], 1,
59 | horizontalGradientMatrix(1, 1, w - 2, h - 2),GradientType.LINEAR);
60 | drawLine(w-1,0,w-1,h,bottomLineColors[1]);
61 | break;
62 | case "down":
63 | drawRoundRect(
64 | 0, 0, w, h, 0,
65 | borderColors[2], 1,
66 | horizontalGradientMatrix(0, 0, w, h ),
67 | GradientType.LINEAR, null,
68 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
69 | drawRoundRect(
70 | 1, 1, w - 2, h - 2, 0,
71 | [fillColors[4],fillColors[5]], 1,
72 | horizontalGradientMatrix(1, 1, w - 2, h - 2),GradientType.LINEAR);
73 | drawLine(w-1,0,w-1,h,bottomLineColors[2]);
74 | break;
75 | }
76 | this.alpha = currentState=="disabled"?0.5:1;
77 | }
78 | }
79 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/VScrollBarTrackSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import flash.display.GradientType;
4 |
5 | import org.flexlite.domCore.dx_internal;
6 | import org.flexlite.domUI.skins.VectorSkin;
7 |
8 | use namespace dx_internal;
9 |
10 | /**
11 | * 垂直滚动条track默认皮肤
12 | * @author dom
13 | */
14 | public class VScrollBarTrackSkin extends VectorSkin
15 | {
16 | public function VScrollBarTrackSkin()
17 | {
18 | super();
19 | states = ["up","over","down","disabled"];
20 | this.currentState = "up";
21 | this.minHeight = 15;
22 | this.minWidth = 15;
23 | }
24 |
25 | /**
26 | * @inheritDoc
27 | */
28 | override protected function updateDisplayList(w:Number, h:Number):void
29 | {
30 | super.updateDisplayList(w, h);
31 |
32 | graphics.clear();
33 | //绘制边框
34 | drawRoundRect(
35 | 0, 0, w, h, 0,
36 | borderColors[0], 1,
37 | horizontalGradientMatrix(0, 0, w, h ),
38 | GradientType.LINEAR, null,
39 | { x: 1, y: 1, w: w - 2, h: h - 2, r: 0});
40 | //绘制填充
41 | drawRoundRect(
42 | 1, 1, w - 2, h - 2, 0,
43 | 0xdddbdb, 1,
44 | horizontalGradientMatrix(1, 2, w - 2, h - 3));
45 | //绘制底线
46 | drawLine(1,1,1,h-1,0xbcbcbc);
47 | this.alpha = currentState=="disabled"?0.5:1;
48 | }
49 | }
50 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/VSliderSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domUI.components.Button;
4 |
5 | import org.flexlite.domUI.components.UIAsset;
6 | import org.flexlite.domCore.dx_internal;
7 | import org.flexlite.domUI.skins.VectorSkin;
8 |
9 | use namespace dx_internal;
10 | /**
11 | * 垂直滑块默认皮肤
12 | * @author dom
13 | */
14 | public class VSliderSkin extends VectorSkin
15 | {
16 | public function VSliderSkin()
17 | {
18 | super();
19 | this.minWidth = 11;
20 | this.minHeight = 50;
21 | }
22 |
23 | public var thumb:Button;
24 |
25 | public var track:Button;
26 |
27 | public var trackHighlight:UIAsset;
28 |
29 | /**
30 | * @inheritDoc
31 | */
32 | override protected function createChildren():void
33 | {
34 | super.createChildren();
35 | track = new Button;
36 | track.left = 0;
37 | track.right = 0;
38 | track.top = 0;
39 | track.bottom = 0;
40 | track.minHeight = 33;
41 | track.height = 100;
42 | track.tabEnabled = false;
43 | track.skinName = VSliderTrackSkin;
44 | addElement(track);
45 |
46 | trackHighlight = new UIAsset;
47 | trackHighlight.left = 0;
48 | trackHighlight.right = 0;
49 | trackHighlight.minHeight = 33;
50 | trackHighlight.height = 100;
51 | trackHighlight.tabEnabled = false;
52 | trackHighlight.skinName = VSliderTrackHighlightSkin;
53 | addElement(trackHighlight);
54 |
55 | thumb = new Button();
56 | thumb.left = 0;
57 | thumb.right = 0;
58 | thumb.width = 11;
59 | thumb.height = 11;
60 | thumb.tabEnabled = false;
61 | thumb.skinName = SliderThumbSkin;
62 | addElement(thumb);
63 | }
64 |
65 | /**
66 | * @inheritDoc
67 | */
68 | override protected function updateDisplayList(w:Number,h:Number):void
69 | {
70 | super.updateDisplayList(w,h);
71 | this.alpha = currentState=="disabled"?0.5:1;
72 | }
73 |
74 | }
75 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/VSliderTrackHighlightSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.skins.VectorSkin;
5 |
6 | use namespace dx_internal;
7 |
8 | /**
9 | * 水平滑块track默认皮肤
10 | * @author dom
11 | */
12 | public class VSliderTrackHighlightSkin extends VectorSkin
13 | {
14 | public function VSliderTrackHighlightSkin()
15 | {
16 | super();
17 | this.minHeight = 15;
18 | this.minWidth = 4;
19 | }
20 |
21 | /**
22 | * @inheritDoc
23 | */
24 | override protected function updateDisplayList(w:Number, h:Number):void
25 | {
26 | super.updateDisplayList(w, h);
27 | var offsetX:Number = Math.round(w*0.5-2);
28 |
29 | graphics.clear();
30 | graphics.beginFill(0xFFFFFF,0);
31 | graphics.drawRect(0,0,w,h);
32 | graphics.endFill();
33 | w=4;
34 | graphics.lineStyle();
35 | drawRoundRect(
36 | offsetX,0, w, h, 1,
37 | fillColors[2], 1,
38 | verticalGradientMatrix(offsetX,0, w, h));
39 | if(h>5)
40 | drawLine(offsetX,1,offsetX,h-1,0x457cb2);
41 | }
42 | }
43 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/skins/vector/VSliderTrackSkin.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.skins.vector
2 | {
3 | import org.flexlite.domCore.dx_internal;
4 | import org.flexlite.domUI.skins.VectorSkin;
5 |
6 | use namespace dx_internal;
7 |
8 | /**
9 | * 垂直滑块track默认皮肤
10 | * @author dom
11 | */
12 | public class VSliderTrackSkin extends VectorSkin
13 | {
14 | public function VSliderTrackSkin()
15 | {
16 | super();
17 | states = ["up","over","down","disabled"];
18 | this.currentState = "up";
19 | this.minHeight = 15;
20 | this.minWidth = 4;
21 | }
22 |
23 | /**
24 | * @inheritDoc
25 | */
26 | override protected function updateDisplayList(w:Number, h:Number):void
27 | {
28 | super.updateDisplayList(w, h);
29 | var offsetX:Number = Math.round(w*0.5-2);
30 |
31 | graphics.clear();
32 | graphics.beginFill(0xFFFFFF,0);
33 | graphics.drawRect(0,0,w,h);
34 | graphics.endFill();
35 | w=4;
36 | graphics.lineStyle();
37 | drawRoundRect(
38 | offsetX,0, w, h, 1,
39 | 0xdddbdb, 1,
40 | verticalGradientMatrix(offsetX,0,w,h));
41 | if(h>4)
42 | drawLine(offsetX,1,offsetX,h-1,0xbcbcbc);
43 | this.alpha = currentState=="disabled"?0.5:1;
44 | }
45 | }
46 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/states/IOverride.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.states
2 | {
3 | import org.flexlite.domUI.core.IContainer;
4 | import org.flexlite.domUI.core.IStateClient;
5 |
6 | /**
7 | * IOverride 接口用于视图状态覆盖。State 类 overrides 属性数组中的所有条目均必须实现此接口。
8 | * @author dom
9 | */
10 | public interface IOverride
11 | {
12 | /**
13 | * 初始化覆盖。在第一次调用 apply() 方法之前调用此方法,因此将覆盖的一次性初始化代码放在此方法中。
14 | */
15 | function initialize(parent:IStateClient):void;
16 | /**
17 | * 应用覆盖。将保留原始值,以便以后可以在 remove() 方法中恢复该值。
18 | */
19 | function apply(parent:IContainer):void;
20 | /**
21 | * 删除覆盖。在 apply() 方法中记住的值将被恢复。
22 | */
23 | function remove(parent:IContainer):void;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/states/OverrideBase.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.states
2 | {
3 | import org.flexlite.domUI.core.IContainer;
4 | import org.flexlite.domUI.core.IStateClient;
5 | import org.flexlite.domUI.utils.OnDemandEventDispatcher;
6 |
7 | /**
8 | * OverrideBase 类是视图状态所用的 override 类的基类。
9 | * @author dom
10 | */
11 | public class OverrideBase extends OnDemandEventDispatcher implements IOverride
12 | {
13 | public function OverrideBase() {}
14 |
15 | public function initialize(parent:IStateClient):void
16 | {
17 | }
18 |
19 | public function apply(parent:IContainer):void
20 | {
21 |
22 | }
23 |
24 | public function remove(parent:IContainer):void
25 | {
26 |
27 | }
28 | /**
29 | * 从对象初始化,这是一个便利方法
30 | */
31 | public function initializeFromObject(properties:Object):Object
32 | {
33 | for (var p:String in properties)
34 | {
35 | this[p] = properties[p];
36 | }
37 |
38 | return Object(this);
39 | }
40 |
41 | }
42 |
43 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/states/SetProperty.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.states
2 | {
3 | import org.flexlite.domUI.core.IContainer;
4 |
5 | /**
6 | * 设置属性
7 | * @author dom
8 | */
9 | public class SetProperty extends OverrideBase
10 | {
11 | /**
12 | * 构造函数
13 | */
14 | public function SetProperty()
15 | {
16 | super();
17 | }
18 |
19 | /**
20 | * 要修改的属性名
21 | */
22 | public var name:String;
23 |
24 | /**
25 | * 目标实例名
26 | */
27 | public var target:String;
28 |
29 | /**
30 | * 属性值
31 | */
32 | public var value:*;
33 |
34 | /**
35 | * 旧的属性值
36 | */
37 | private var oldValue:Object;
38 |
39 | override public function apply(parent:IContainer):void
40 | {
41 | var obj:Object = target==null||target==""?parent:parent[target];
42 | if(obj==null)
43 | return;
44 | oldValue = obj[name];
45 | setPropertyValue(obj, name, value, oldValue);
46 | }
47 |
48 | override public function remove(parent:IContainer):void
49 | {
50 | var obj:Object = target==null||target==""?parent:parent[target];
51 | if(obj==null)
52 | return;
53 | setPropertyValue(obj, name, oldValue, oldValue);
54 | oldValue = null;
55 | }
56 |
57 | /**
58 | * 设置属性值
59 | */
60 | private function setPropertyValue(obj:Object, name:String, value:*,
61 | valueForType:Object):void
62 | {
63 | if (value === undefined || value === null)
64 | obj[name] = value;
65 | else if (valueForType is Number)
66 | obj[name] = Number(value);
67 | else if (valueForType is Boolean)
68 | obj[name] = toBoolean(value);
69 | else
70 | obj[name] = value;
71 | }
72 | /**
73 | * 转成Boolean值
74 | */
75 | private function toBoolean(value:Object):Boolean
76 | {
77 | if (value is String)
78 | return value.toLowerCase() == "true";
79 |
80 | return value != false;
81 | }
82 | }
83 |
84 | }
85 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/states/State.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.states
2 | {
3 |
4 | import flash.events.Event;
5 | import flash.events.EventDispatcher;
6 |
7 | import org.flexlite.domCore.dx_internal;
8 | import org.flexlite.domUI.core.IContainer;
9 | import org.flexlite.domUI.core.IStateClient;
10 |
11 |
12 | use namespace dx_internal;
13 |
14 |
15 | [DXML(show="false")]
16 |
17 | [DefaultProperty(name="overrides",array="true")]
18 |
19 | /**
20 | * State 类定义视图状态,即组件的特定视图。
21 | * @author dom
22 | */
23 | public class State extends EventDispatcher
24 | {
25 | public function State(properties:Object=null)
26 | {
27 | super();
28 | for (var p:String in properties)
29 | {
30 | this[p] = properties[p];
31 | }
32 | }
33 | /**
34 | * 已经初始化标志
35 | */
36 | private var initialized:Boolean = false;
37 | /**
38 | * 该视图状态所基于的视图状态的名称;
39 | * 如果该视图状态不是基于已命名的视图状态,则为 null。
40 | * 如果该值为 null,则该视图状态基于根状态(包括不是使用 State 类为组件定义的属性、样式、事件处理函数和子项)。
41 | */
42 | public var basedOn:String;
43 |
44 | /**
45 | * 视图状态的名称。给定组件的状态名称必须唯一。必须设置此属性。
46 | */
47 | public var name:String;
48 |
49 | /**
50 | * 该视图状态的覆盖,表现为实现 IOverride 接口的对象的数组。
51 | * 这些覆盖在进入状态时按顺序应用,在退出状态时按相反的顺序删除。
52 | */
53 | public var overrides:Array = [];
54 | /**
55 | * 此视图状态作为 String 数组所属的状态组。
56 | */
57 | public var stateGroups:Array = [];
58 | /**
59 | * 初始化视图
60 | */
61 | dx_internal function initialize(parent:IStateClient):void
62 | {
63 | if (!initialized)
64 | {
65 | initialized = true;
66 | for (var i:int = 0; i < overrides.length; i++)
67 | {
68 | IOverride(overrides[i]).initialize(parent);
69 | }
70 | }
71 | }
72 | /**
73 | * 抛出进入视图状态事件
74 | */
75 | dx_internal function dispatchEnterState():void
76 | {
77 | if (hasEventListener("enterState"))
78 | dispatchEvent(new Event("enterState"));
79 | }
80 | /**
81 | * 抛出即将退出视图状态事件
82 | */
83 | dx_internal function dispatchExitState():void
84 | {
85 | if (hasEventListener("exitState"))
86 | dispatchEvent(new Event("exitState"));
87 | }
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/utils/GraphicsUtil.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.utils
2 | {
3 | import flash.display.Graphics;
4 |
5 | [ExcludeClass]
6 | /**
7 | * 绘图工具类
8 | * @author dom
9 | */
10 | public class GraphicsUtil
11 | {
12 | /**
13 | * 绘制四个角不同的圆角矩形
14 | * @param graphics 要绘制到的对象。
15 | * @param x 起始点x坐标
16 | * @param y 起始点y坐标
17 | * @param width 矩形宽度
18 | * @param height 矩形高度
19 | * @param topLeftRadius 左上圆角半径
20 | * @param topRightRadius 右上圆角半径
21 | * @param bottomLeftRadius 左下圆角半径
22 | * @param bottomRightRadius 右下圆角半径
23 | */
24 | public static function drawRoundRectComplex(graphics:Graphics, x:Number, y:Number,
25 | width:Number, height:Number,
26 | topLeftRadius:Number, topRightRadius:Number,
27 | bottomLeftRadius:Number, bottomRightRadius:Number):void
28 | {
29 | var xw:Number = x + width;
30 | var yh:Number = y + height;
31 |
32 | var minSize:Number = width < height ? width * 2 : height * 2;
33 | topLeftRadius = topLeftRadius < minSize ? topLeftRadius : minSize;
34 | topRightRadius = topRightRadius < minSize ? topRightRadius : minSize;
35 | bottomLeftRadius = bottomLeftRadius < minSize ? bottomLeftRadius : minSize;
36 | bottomRightRadius = bottomRightRadius < minSize ? bottomRightRadius : minSize;
37 |
38 | var a:Number = bottomRightRadius * 0.292893218813453;
39 | var s:Number = bottomRightRadius * 0.585786437626905;
40 | graphics.moveTo(xw, yh - bottomRightRadius);
41 | graphics.curveTo(xw, yh - s, xw - a, yh - a);
42 | graphics.curveTo(xw - s, yh, xw - bottomRightRadius, yh);
43 |
44 | a = bottomLeftRadius * 0.292893218813453;
45 | s = bottomLeftRadius * 0.585786437626905;
46 | graphics.lineTo(x + bottomLeftRadius, yh);
47 | graphics.curveTo(x + s, yh, x + a, yh - a);
48 | graphics.curveTo(x, yh - s, x, yh - bottomLeftRadius);
49 |
50 | a = topLeftRadius * 0.292893218813453;
51 | s = topLeftRadius * 0.585786437626905;
52 | graphics.lineTo(x, y + topLeftRadius);
53 | graphics.curveTo(x, y + s, x + a, y + a);
54 | graphics.curveTo(x + s, y, x + topLeftRadius, y);
55 |
56 | a = topRightRadius * 0.292893218813453;
57 | s = topRightRadius * 0.585786437626905;
58 | graphics.lineTo(xw - topRightRadius, y);
59 | graphics.curveTo(xw - s, y, xw - a, y + a);
60 | graphics.curveTo(xw, y + s, xw, y + topRightRadius);
61 | graphics.lineTo(xw, yh - bottomRightRadius);
62 | }
63 | }
64 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/utils/LayoutUtil.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.utils
2 | {
3 | import flash.display.DisplayObjectContainer;
4 |
5 | import org.flexlite.domUI.core.IVisualElement;
6 |
7 | /**
8 | * 布局工具类
9 | * @author dom
10 | */
11 | public class LayoutUtil
12 | {
13 | /**
14 | * 根据对象当前的xy坐标调整其相对位置属性,使其在下一次的父级布局中过程中保持当前位置不变。
15 | * @param element 要调整相对位置属性的对象
16 | * @param parent element的父级容器。若不设置,则取element.parent的值。若两者的值都为空,则放弃调整。
17 | */
18 | public static function adjustRelativeByXY(element:IVisualElement,parent:DisplayObjectContainer=null):void
19 | {
20 | if(!element)
21 | return;
22 | if(!parent)
23 | parent = element.parent;
24 | if(!parent)
25 | return;
26 | var x:Number = element.x;
27 | var y:Number = element.y;
28 | var h:Number = element.layoutBoundsHeight;
29 | var w:Number = element.layoutBoundsWidth;
30 | var parentW:Number = parent.width;
31 | var parentH:Number = parent.height;
32 | if(!isNaN(element.left))
33 | {
34 | element.left = x;
35 | }
36 | if(!isNaN(element.right))
37 | {
38 | element.right = parentW - x - w;
39 | }
40 | if(!isNaN(element.horizontalCenter))
41 | {
42 | element.horizontalCenter = x + w*0.5 - parentW*0.5;
43 | }
44 |
45 | if(!isNaN(element.top))
46 | {
47 | element.top = y;
48 | }
49 | if(!isNaN(element.bottom))
50 | {
51 | element.bottom = parentH - y - h;
52 | }
53 | if(!isNaN(element.verticalCenter))
54 | {
55 | element.verticalCenter = h*0.5-parentH*0.5+y;
56 | }
57 | }
58 | }
59 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/utils/OnDemandEventDispatcher.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.utils
2 | {
3 | import flash.events.Event;
4 | import flash.events.EventDispatcher;
5 | import flash.events.IEventDispatcher;
6 |
7 | /**
8 | * 对于分派事件但期望侦听器不常用的类,OnDemandEventDispatcher 用作其基类。
9 | * 只有在附加了监听器时才会初始化一个EventDispatcher实例,而不是每次都实例化一个。
10 | * @author dom
11 | */
12 | public class OnDemandEventDispatcher implements IEventDispatcher
13 | {
14 | private var _dispatcher:EventDispatcher;
15 | /**
16 | * 构造函数
17 | */
18 | public function OnDemandEventDispatcher()
19 | {
20 | }
21 | /**
22 | * @inheritDoc
23 | */
24 | public function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
25 | {
26 | if (_dispatcher == null)
27 | {
28 | _dispatcher = new EventDispatcher(this);
29 | }
30 | _dispatcher.addEventListener(type,listener,useCapture,priority,useWeakReference);
31 | }
32 | /**
33 | * @inheritDoc
34 | */
35 | public function dispatchEvent(event:Event):Boolean
36 | {
37 | if (_dispatcher != null)
38 | return _dispatcher.dispatchEvent(event);
39 | return true;
40 | }
41 | /**
42 | * @inheritDoc
43 | */
44 | public function hasEventListener(type:String):Boolean
45 | {
46 | if (_dispatcher != null)
47 | return _dispatcher.hasEventListener(type);
48 | return false;
49 | }
50 | /**
51 | * @inheritDoc
52 | */
53 | public function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
54 | {
55 | if (_dispatcher != null)
56 | _dispatcher.removeEventListener(type,listener,useCapture);
57 | }
58 | /**
59 | * @inheritDoc
60 | */
61 | public function willTrigger(type:String):Boolean
62 | {
63 | if (_dispatcher != null)
64 | return _dispatcher.willTrigger(type);
65 | return false;
66 | }
67 |
68 | }
69 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUI/utils/SkinPartUtil.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUI.utils
2 | {
3 | import flash.utils.Dictionary;
4 | import flash.utils.describeType;
5 | import flash.utils.getQualifiedClassName;
6 |
7 | import org.flexlite.domUI.components.SkinnableComponent;
8 |
9 | [ExcludeClass]
10 |
11 | /**
12 | * 获取皮肤定义的公开属性名工具类
13 | * @author dom
14 | */
15 | public class SkinPartUtil
16 | {
17 | /**
18 | * skinPart缓存字典
19 | */
20 | private static var skinPartCache:Dictionary = new Dictionary();
21 | /**
22 | * 基本数据类型列表
23 | */
24 | private static var basicTypes:Vector. =
25 | new ["Number","int","String","Boolean","uint","Object"];
26 |
27 | /**
28 | * 从一个Skin或其子类的实例里获取皮肤定义的公开属性名列表
29 | * @param skin 皮肤实例
30 | * @param superClass 皮肤基类,在遍历属性时过滤基类以上类定义的属性。
31 | */
32 | public static function getSkinParts(host:SkinnableComponent):Vector.
33 | {
34 | var key:String = getQualifiedClassName(host);
35 | if(skinPartCache[key])
36 | {
37 | return skinPartCache[key];
38 | }
39 |
40 | var info:XML = describeType(host);
41 | var node:XML;
42 | var skinParts:Vector. = new Vector.();
43 | var partName:String;
44 | for each(node in info.variable)
45 | {
46 | partName = node.@name.toString();
47 | if(basicTypes.indexOf(node.@type)==-1)
48 | {
49 | skinParts.push(partName);
50 | }
51 | }
52 | skinPartCache[key] = skinParts;
53 | return skinParts;
54 | }
55 |
56 | }
57 | }
--------------------------------------------------------------------------------
/src/org/flexlite/domUtils/CRC32Util.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUtils
2 | {
3 |
4 | import flash.utils.ByteArray;
5 |
6 | /**
7 | * CRC32工具类
8 | * @author dom
9 | */
10 | public class CRC32Util
11 | {
12 | /**
13 | * 计算时用到的CRC缓存数据表
14 | */
15 | private static var crcTable:Array = makeCrcTable();
16 |
17 | /**
18 | * 获取CRC缓存数据表
19 | */
20 | private static function makeCrcTable():Array
21 | {
22 | var crcTable:Array = new Array(256);
23 | for (var n:int = 0; n < 256; n++)
24 | {
25 | var c:uint = n;
26 | for (var k:int = 8; --k >= 0; )
27 | {
28 | if((c & 1) != 0)
29 | {
30 | c = 0xedb88320 ^ (c >>> 1);
31 | }
32 | else
33 | {
34 | c = c >>> 1;
35 | }
36 | }
37 | crcTable[n] = c;
38 | }
39 | return crcTable;
40 | }
41 |
42 | /**
43 | * 从字节流计算CRC32数据
44 | * @param buf 要计算的字节流
45 | */
46 | public static function getCRC32(buf:ByteArray):uint
47 | {
48 | var crc:uint = 0;
49 | var off:uint = 0;
50 | var len:uint = buf.length;
51 | var c:uint = ~crc;
52 | while(--len >= 0)
53 | {
54 | c = crcTable[(c ^ buf[off++]) & 0xff] ^ (c >>> 8);
55 | }
56 | crc = ~c;
57 | return crc & 0xffffffff;
58 | }
59 |
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/org/flexlite/domUtils/Recycler.as:
--------------------------------------------------------------------------------
1 | package org.flexlite.domUtils
2 | {
3 | import flash.utils.Dictionary;
4 |
5 | /**
6 | * 对象缓存复用工具类,可用于构建对象池。
7 | * 利用了Dictionary弱引用特性。一段时间后会自动回收对象。
8 | * @author dom
9 | */
10 | public class Recycler
11 | {
12 | /**
13 | * 构造函数
14 | */
15 | public function Recycler()
16 | {
17 | }
18 | /**
19 | * 缓存字典
20 | */
21 | private var cache:Dictionary = new Dictionary(true);
22 | /**
23 | * 缓存一个对象以复用
24 | * @param object
25 | */
26 | public function push(object:*):void
27 | {
28 | cache[object] = null;
29 | }
30 | /**
31 | * 获取一个缓存的对象
32 | */
33 | public function get():*
34 | {
35 | for(var object:* in cache)
36 | {
37 | delete cache[object];
38 | return object;
39 | }
40 | }
41 | /**
42 | * 立即清空所有缓存的对象。
43 | */
44 | public function reset():void
45 | {
46 | cache = new Dictionary(true);
47 | }
48 | }
49 | }
--------------------------------------------------------------------------------