diff --git a/README.md b/README.md index b18da00f69..34441a89cd 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ Egret Engine ================================================ -Current Version: v3.1.5 +Current Version: v3.1.6 Developed by Egret Technology, Egret Engine 3.0 includes a newly built 3D engine and a 2D engine created based on HTML5. With its robust cross-platform operability and commitment to solving the performance and fragmentation problems of HTML5 APP and games, Egret Engine 3.0 will perfectly meet developers’ needs. We appreciate every suggestion and please send it to Egret team if you have any. @@ -39,6 +39,8 @@ Document & API Release Notes -------------------- +[Egret 3.1.6 Release Notes 2016-8-8](/docs/en/3.1.6_ReleaseNotes.md) + [Egret 3.1.5 Release Notes 2016-7-25](/docs/en/3.1.5_ReleaseNotes.md) [Egret 3.1.4 Release Notes 2016-7-11](/docs/en/3.1.4_ReleaseNotes.md) @@ -151,6 +153,8 @@ Egret Engine 3.0 包含了白鹭时代研发的遵循HTML5标准的2D引擎及 发布说明 -------------------- +[Egret 3.1.6 Release Notes 2016-8-8](/docs/cn/3.1.6_ReleaseNotes.md) + [Egret 3.1.5 Release Notes 2016-7-25](/docs/cn/3.1.5_ReleaseNotes.md) [Egret 3.1.4 Release Notes 2016-7-11](/docs/cn/3.1.4_ReleaseNotes.md) diff --git a/build/dragonBones/dragonBones.d.ts b/build/dragonBones/dragonBones.d.ts index 18836f7135..3ec0b06fac 100644 --- a/build/dragonBones/dragonBones.d.ts +++ b/build/dragonBones/dragonBones.d.ts @@ -62,932 +62,888 @@ declare namespace dragonBones { } declare namespace dragonBones { /** - * @language zh_CN - * 动画混合时,使用的淡出方式。 - * @see dragonBones.Animation#fadeIn() - * @version DragonBones 4.5 + * @private */ - const enum AnimationFadeOutMode { - /** - * @language zh_CN - * 不淡出动画。 - * @version DragonBones 4.5 - */ - None = 0, - /** - * @language zh_CN - * 淡出同层的动画。 - * @version DragonBones 4.5 - */ - SameLayer = 1, - /** - * @language zh_CN - * 淡出同组的动画。 - * @version DragonBones 4.5 - */ - SameGroup = 2, - /** - * @language zh_CN - * 淡出同层并且同组的动画。 - * @version DragonBones 4.5 - */ - SameLayerAndGroup = 3, - /** - * @language zh_CN - * 淡出所有动画。 - * @version DragonBones 4.5 - */ - All = 4, + const enum ArmatureType { + Armature = 0, + MovieClip = 1, + Stage = 2, } /** - * @language zh_CN - * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口) - * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。 - * @see dragonBones.WorldClock - * @see dragonBones.Armature - * @version DragonBones 3.0 + * @private */ - interface IAnimateble { - /** - * @language zh_CN - * 更新一个指定的时间。 - * @param passedTime 前进的时间。 (以秒为单位) - * @version DragonBones 3.0 - */ - advanceTime(passedTime: number): void; + const enum DisplayType { + Image = 0, + Armature = 1, + Mesh = 2, } /** - * @language zh_CN - * 动画控制器,用来播放动画数据,管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * @private */ - class Animation extends BaseObject { + const enum ExtensionType { + FFD = 0, + AdjustColor = 10, + BevelFilter = 11, + BlurFilter = 12, + DropShadowFilter = 13, + GlowFilter = 14, + GradientBevelFilter = 15, + GradientGlowFilter = 16, + } + /** + * @private + */ + const enum EventType { + Frame = 0, + Sound = 1, + } + /** + * @private + */ + const enum ActionType { + Play = 0, + Stop = 1, + GotoAndPlay = 2, + GotoAndStop = 3, + FadeIn = 4, + FadeOut = 5, + } + /** + * @private + */ + const enum BlendMode { + Normal = 0, + Add = 1, + Alpha = 2, + Darken = 3, + Difference = 4, + Erase = 5, + HardLight = 6, + Invert = 7, + Layer = 8, + Lighten = 9, + Multiply = 10, + Overlay = 11, + Screen = 12, + Subtract = 13, + } + /** + * @private + */ + interface Map { + [key: string]: T; + } + /** + * DragonBones + */ + class DragonBones { /** * @private */ - protected static _sortAnimationState(a: AnimationState, b: AnimationState): number; + static PI_D: number; /** * @private */ - static toString(): string; - /** - * @language zh_CN - * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 - * @version DragonBones 3.0 - */ - timeScale: number; + static PI_H: number; /** - * @private Armature Slot + * @private */ - _animationStateDirty: boolean; + static PI_Q: number; /** - * @private Armature Slot + * @private */ - _timelineStateDirty: boolean; + static ANGLE_TO_RADIAN: number; /** - * @private Factory + * @private */ - _armature: Armature; + static RADIAN_TO_ANGLE: number; /** * @private */ - protected _isPlaying: boolean; + static SECOND_TO_MILLISECOND: number; /** * @private */ - protected _time: number; + static NO_TWEEN: number; + static VERSION: string; /** * @private */ - protected _lastAnimationState: AnimationState; + static DEBUG: boolean; /** * @private */ - protected _animations: Map; + static DEBUG_DRAW: boolean; /** * @private */ - protected _animationNames: Array; + static _armatures: Array; /** * @private */ - protected _animationStates: Array; + constructor(); /** * @private */ - constructor(); + static hasArmature(value: Armature): boolean; /** - * @inheritDoc + * @private */ - protected _onClear(): void; + static addArmature(value: Armature): void; /** * @private */ - protected _fadeOut(fadeOutTime: number, layer: number, group: string, fadeOutMode: AnimationFadeOutMode, pauseFadeOut: boolean): void; + static removeArmature(value: Armature): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + type EventStringType = string | 'start' | 'loopComplete' | 'complete' | 'fadeIn' | 'fadeInComplete' | 'fadeOut' | 'fadeOutComplete' | 'frameEvent' | 'soundEvent'; + /** + * @language zh_CN + * 事件接口。 + * @version DragonBones 4.5 + */ + interface IEventDispatcher { /** * @private */ - _updateFFDTimelineStates(): void; + _onClear(): void; /** * @private */ - _advanceTime(passedTime: number): void; + _dispatchEvent(eventObject: EventObject): void; /** * @language zh_CN - * 清除所有正在播放的动画状态。 + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @returns [true: 包含, false: 不包含] * @version DragonBones 4.5 */ - reset(): void; + hasEvent(type: EventStringType): boolean; /** * @language zh_CN - * 暂停播放动画。 - * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 */ - stop(animationName?: string): void; + addEvent(type: EventStringType, listener: Function, target: any): void; /** * @language zh_CN - * 播放动画。 - * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 - * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 4.5 */ - play(animationName?: string, playTimes?: number): AnimationState; + removeEvent(type: EventStringType, listener: Function, target: any): void; + } + /** + * @language zh_CN + * 事件数据。 + * @version DragonBones 4.5 + */ + class EventObject extends BaseObject { /** * @language zh_CN - * 淡入播放指定名称的动画。 - * @param animationName 动画数据的名称。 - * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位) - * @param layer 混合的图层,图层高会优先获取混合权重。 - * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。 - * @param fadeOutMode 淡出的模式。 - * @param additiveBlending 以叠加的形式混合。 - * @param displayControl 是否对显示对象属性可控。 - * @param pauseFadeOut 暂停需要淡出的动画。 - * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。 - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationFadeOutMode - * @see dragonBones.AnimationState + * 动画开始。 * @version DragonBones 4.5 */ - fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; + static START: string; /** * @language zh_CN - * 指定名称的动画从指定时间开始播放。 - * @param animationName 动画数据的名称。 - * @param time 时间。 (以秒为单位) - * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画循环播放一次完成。 * @version DragonBones 4.5 */ - gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState; + static LOOP_COMPLETE: string; /** * @language zh_CN - * 指定名称的动画从指定帧开始播放。 - * @param animationName 动画数据的名称。 - * @param frame 帧。 - * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画播放完成。 * @version DragonBones 4.5 */ - gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState; + static COMPLETE: string; /** * @language zh_CN - * 指定名称的动画从指定进度开始播放。 - * @param animationName 动画数据的名称。 - * @param progress 进度。 [0~1] - * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡入开始。 * @version DragonBones 4.5 */ - gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState; + static FADE_IN: string; /** * @language zh_CN - * 播放指定名称的动画到指定的时间并停止。 - * @param animationName 动画数据的名称。 - * @param time 时间。 (以秒为单位) - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡入完成。 * @version DragonBones 4.5 */ - gotoAndStopByTime(animationName: string, time?: number): AnimationState; + static FADE_IN_COMPLETE: string; /** * @language zh_CN - * 播放指定名称的动画到指定的帧并停止。 - * @param animationName 动画数据的名称。 - * @param frame 帧。 - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡出开始。 * @version DragonBones 4.5 */ - gotoAndStopByFrame(animationName: string, frame?: number): AnimationState; + static FADE_OUT: string; /** * @language zh_CN - * 播放指定名称的动画到指定的进度并停止。 - * @param animationName 动画数据的名称。 - * @param progress 进度。 [0~1] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡出完成。 * @version DragonBones 4.5 */ - gotoAndStopByProgress(animationName: string, progress?: number): AnimationState; + static FADE_OUT_COMPLETE: string; /** * @language zh_CN - * 获取指定名称的动画状态。 - * @param animationName 动画状态的名称。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * 动画帧事件。 + * @version DragonBones 4.5 */ - getState(animationName: string): AnimationState; + static FRAME_EVENT: string; /** * @language zh_CN - * 是否包含指定名称的动画数据。 - * @param animationName 动画数据的名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 + * 动画声音事件。 + * @version DragonBones 4.5 */ - hasAnimation(animationName: string): boolean; + static SOUND_EVENT: string; + /** + * @private + */ + static toString(): string; + /** + * @private + */ + static _soundEventManager: IEventDispatcher; /** * @language zh_CN - * 动画是否处于播放状态。 - * @version DragonBones 3.0 + * 事件类型。 + * @version DragonBones 4.5 */ - isPlaying: boolean; + type: EventStringType; /** * @language zh_CN - * 所有动画状态是否均已播放完毕。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * 事件名称。 (帧标签的名称或声音的名称) + * @version DragonBones 4.5 */ - isCompleted: boolean; + name: string; /** * @language zh_CN - * 上一个正在播放的动画状态的名称。 - * @see #lastAnimationState - * @version DragonBones 3.0 + * 扩展的数据。 + * @version DragonBones 4.5 */ - lastAnimationName: string; + data: any; /** * @language zh_CN - * 上一个正在播放的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * 发出事件的骨架。 + * @version DragonBones 4.5 */ - lastAnimationState: AnimationState; + armature: Armature; /** * @language zh_CN - * 所有动画数据名称。 - * @see #animations + * 发出事件的骨骼。 * @version DragonBones 4.5 */ - animationNames: Array; + bone: Bone; /** * @language zh_CN - * 所有的动画数据。 - * @see dragonBones.AnimationData + * 发出事件的插槽。 * @version DragonBones 4.5 */ - animations: Map; + slot: Slot; /** - * @deprecated - * @see #play() - * @see #fadeIn() - * @see #gotoAndPlayByTime() - * @see #gotoAndPlayByFrame() - * @see #gotoAndPlayByProgress() + * @language zh_CN + * 发出事件的动画状态。 + * @version DragonBones 4.5 */ - gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; + animationState: AnimationState; /** - * @deprecated - * @see #gotoAndStopByTime() - * @see #gotoAndStopByFrame() - * @see #gotoAndStopByProgress() + * @language zh_CN + * 用户数据。 + * @version DragonBones 4.5 */ - gotoAndStop(animationName: string, time?: number): AnimationState; + userData: any; /** - * @deprecated - * @see #animationNames - * @see #animations + * @private */ - animationList: Array; + constructor(); /** - * @language zh_CN - * @deprecated - * @see #animationNames - * @see #animations + * @inheritDoc */ - animationDataList: Array; + protected _onClear(): void; + /** + * @see #animationState + */ + animationName: string; + } +} +declare namespace dragonBones { + /** + * @private + */ + class Point { + x: number; + y: number; + constructor(x?: number, y?: number); + copyFrom(value: Point): void; + clear(): void; + } +} +declare namespace dragonBones { + /** + * @private + */ + class Rectangle { + x: number; + y: number; + width: number; + height: number; + constructor(x?: number, y?: number, width?: number, height?: number); + copyFrom(value: Rectangle): void; + clear(): void; } } declare namespace dragonBones { /** * @language zh_CN - * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData + * 2D 变换。 * @version DragonBones 3.0 */ - class AnimationState extends BaseObject { - /** - * @private - */ - static toString(): string; + class Transform { /** * @language zh_CN - * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。 - * @see dragonBones.Slot#displayController + * 水平位移。 * @version DragonBones 3.0 */ - displayControl: boolean; + x: number; /** * @language zh_CN - * 是否以叠加的方式混合动画。 + * 垂直位移。 * @version DragonBones 3.0 */ - additiveBlending: boolean; + y: number; /** * @language zh_CN - * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * 水平倾斜。 (以弧度为单位) * @version DragonBones 3.0 */ - playTimes: number; + skewX: number; /** * @language zh_CN - * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 + * 垂直倾斜。 (以弧度为单位) * @version DragonBones 3.0 */ - timeScale: number; + skewY: number; /** * @language zh_CN - * 进行动画混合时的权重。 - * @default 1 + * 水平缩放。 * @version DragonBones 3.0 */ - weight: number; + scaleX: number; /** * @language zh_CN - * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位) - * @default -1 + * 垂直缩放。 * @version DragonBones 3.0 */ - autoFadeOutTime: number; + scaleY: number; /** * @private */ - fadeTotalTime: number; + static normalizeRadian(value: number): number; /** - * @private Animation + * @private */ - _isFadeOutComplete: boolean; + constructor( + /** + * @language zh_CN + * 水平位移。 + * @version DragonBones 3.0 + */ + x?: number, + /** + * @language zh_CN + * 垂直位移。 + * @version DragonBones 3.0 + */ + y?: number, + /** + * @language zh_CN + * 水平倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewX?: number, + /** + * @language zh_CN + * 垂直倾斜。 (以弧度为单位) + * @version DragonBones 3.0 + */ + skewY?: number, + /** + * @language zh_CN + * 水平缩放。 + * @version DragonBones 3.0 + */ + scaleX?: number, + /** + * @language zh_CN + * 垂直缩放。 + * @version DragonBones 3.0 + */ + scaleY?: number); /** - * @private Animation + * @private */ - _layer: number; + toString(): string; /** - * @private TimelineState + * @private */ - _position: number; + copyFrom(value: Transform): Transform; /** - * @private TimelineState + * @private */ - _duration: number; + clone(): Transform; /** - * @private Animation, TimelineState + * @private */ - _weightResult: number; + identity(): Transform; /** - * @private Animation, TimelineState + * @private */ - _fadeProgress: number; + add(value: Transform): Transform; /** - * @private Animation TimelineState + * @private */ - _group: string; - /** - * @private TimelineState - */ - _timeline: AnimationTimelineState; - /** - * @private - */ - private _isPlaying; - /** - * @private - */ - private _isPausePlayhead; - /** - * @private - */ - private _isFadeOut; - /** - * @private - */ - private _currentPlayTimes; - /** - * @private - */ - private _fadeTime; - /** - * @private - */ - private _time; - /** - * @private - */ - private _name; - /** - * @private - */ - private _armature; - /** - * @private - */ - private _animationData; - /** - * @private - */ - private _boneMask; - /** - * @private - */ - private _boneTimelines; - /** - * @private - */ - private _slotTimelines; - /** - * @private - */ - private _ffdTimelines; - /** - * @private - */ - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - /** - * @private - */ - private _advanceFadeTime(passedTime); - /** - * @private - */ - _isDisabled(slot: Slot): boolean; - /** - * @private - */ - _fadeIn(armature: Armature, clip: AnimationData, animationName: string, playTimes: number, position: number, duration: number, time: number, timeScale: number, fadeInTime: number, pausePlayhead: boolean): void; - /** - * @private - */ - _updateTimelineStates(): void; - /** - * @private - */ - _updateFFDTimelineStates(): void; + minus(value: Transform): Transform; /** * @private */ - _advanceTime(passedTime: number, weightLeft: number, index: number): void; + fromMatrix(matrix: Matrix): Transform; /** * @language zh_CN - * 继续播放。 + * 转换为矩阵。 + * @param 矩阵。 * @version DragonBones 3.0 */ - play(): void; + toMatrix(matrix: Matrix): Transform; /** * @language zh_CN - * 暂停播放。 + * 旋转。 (以弧度为单位) * @version DragonBones 3.0 */ - stop(): void; + rotation: number; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ColorTransform { + alphaMultiplier: number; + redMultiplier: number; + greenMultiplier: number; + blueMultiplier: number; + alphaOffset: number; + redOffset: number; + greenOffset: number; + blueOffset: number; + constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); + copyFrom(value: ColorTransform): void; + identity(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 2D 矩阵。 + * @version DragonBones 3.0 + */ + class Matrix { + a: number; + b: number; + c: number; + d: number; + tx: number; + ty: number; + constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); /** * @language zh_CN - * 淡出动画。 - * @param fadeOutTime 淡出时间。 (以秒为单位) - * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停] + * 复制矩阵。 + * @param value 需要复制的矩阵。 * @version DragonBones 3.0 */ - fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; + copyFrom(value: Matrix): void; /** * @language zh_CN - * 是否包含指定的骨骼遮罩。 - * @param name 指定的骨骼名称。 + * 转换为恒等矩阵。 * @version DragonBones 3.0 */ - containsBoneMask(name: string): boolean; + identity(): void; /** * @language zh_CN - * 添加指定的骨骼遮罩。 - * @param boneName 指定的骨骼名称。 - * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 * @version DragonBones 3.0 */ - addBoneMask(name: string, recursive?: boolean): void; + concat(value: Matrix): void; /** * @language zh_CN - * 删除指定的骨骼遮罩。 - * @param boneName 指定的骨骼名称。 - * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * 转换为逆矩阵。 * @version DragonBones 3.0 */ - removeBoneMask(name: string, recursive?: boolean): void; + invert(): void; /** * @language zh_CN - * 删除所有骨骼遮罩。 + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 * @version DragonBones 3.0 */ - removeAllBoneMask(): void; + transformPoint(x: number, y: number, result: { + x: number; + y: number; + }, delta?: boolean): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 龙骨数据,包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + class DragonBonesData extends BaseObject { + /** + * @private + */ + static toString(): string; /** * @language zh_CN - * 动画图层。 - * @see dragonBones.Animation#fadeIn() - * @version DragonBones 3.0 + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * @default false + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 */ - layer: number; + autoSearch: boolean; /** * @language zh_CN - * 动画组。 - * @see dragonBones.Animation#fadeIn() + * 动画帧频。 * @version DragonBones 3.0 */ - group: string; + frameRate: number; /** * @language zh_CN - * 动画名称。 - * @see dragonBones.AnimationData#name + * 数据名称。 * @version DragonBones 3.0 */ name: string; /** - * @language zh_CN - * 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 + * @private */ - animationData: AnimationData; + userData: any; /** * @language zh_CN - * 是否播放完毕。 + * 所有的骨架数据。 + * @see dragonBones.ArmatureData * @version DragonBones 3.0 */ - isCompleted: Boolean; + armatures: Map; + private _armatureNames; /** - * @language zh_CN - * 是否正在播放。 - * @version DragonBones 3.0 + * @private */ - isPlaying: Boolean; + constructor(); /** - * @language zh_CN - * 当前动画的播放次数。 - * @version DragonBones 3.0 + * @inheritDoc */ - currentPlayTimes: number; + protected _onClear(): void; /** * @language zh_CN - * 当前动画的总时间。 (以秒为单位) + * 获取指定名称的骨架。 + * @param name 骨架数据骨架名称。 + * @see dragonBones.ArmatureData * @version DragonBones 3.0 */ - totalTime: number; + getArmature(name: string): ArmatureData; /** - * @language zh_CN - * 当前动画的播放时间。 (以秒为单位) - * @version DragonBones 3.0 + * @private */ - currentTime: number; + addArmature(value: ArmatureData): void; /** - * @deprecated + * @language zh_CN + * 所有的骨架数据名称。 + * @see #armatures + * @version DragonBones 3.0 */ - autoTween: boolean; + armatureNames: Array; /** * @deprecated - * @see #animationData - * @version DragonBones 3.0 + * @see dragonBones.BaseFactory#removeDragonBonesData() */ - clip: AnimationData; + dispose(): void; } } declare namespace dragonBones { /** * @private */ - const enum TweenType { - None = 0, - Once = 1, - Always = 2, - } - /** - * @private - */ - abstract class TimelineState, M extends TimelineData> extends BaseObject { - _isCompleted: boolean; - _currentPlayTimes: number; - _currentTime: number; - _timeline: M; - protected _isReverse: boolean; - protected _hasAsynchronyTimeline: boolean; - protected _frameRate: number; - protected _keyFrameCount: number; - protected _frameCount: number; - protected _position: number; - protected _duration: number; - protected _animationDutation: number; - protected _timeScale: number; - protected _timeOffset: number; - protected _currentFrame: T; - protected _armature: Armature; - protected _animationState: AnimationState; + class ActionData extends BaseObject { + static toString(): string; + type: ActionType; + data: Array; + bone: BoneData; + slot: SlotData; + constructor(); + protected _onClear(): void; + } + /** + * @private + */ + class EventData extends BaseObject { + static toString(): string; + type: EventType; + name: string; + data: any; + bone: BoneData; + slot: SlotData; + constructor(); + protected _onClear(): void; + } + /** + * @private + */ + abstract class FrameData extends BaseObject { + position: number; + duration: number; + prev: T; + next: T; constructor(); /** * @inheritDoc */ protected _onClear(): void; - protected _onFadeIn(): void; - protected _onUpdateFrame(isUpdate: boolean): void; - protected _onArriveAtFrame(isUpdate: boolean): void; - protected _onCrossFrame(frame: T): void; - protected _setCurrentTime(value: number): boolean; - setCurrentTime(value: number): void; - fadeIn(armature: Armature, animationState: AnimationState, timelineData: M, time: number): void; - fadeOut(): void; - update(time: number): void; } /** * @private */ - abstract class TweenTimelineState, M extends TimelineData> extends TimelineState { - static _getEasingValue(progress: number, easing: number): number; - static _getCurveEasingValue(progress: number, sampling: Array): number; - protected _tweenProgress: number; - protected _tweenEasing: number; - protected _curve: Array; + abstract class TweenFrameData extends FrameData { + static samplingCurve(curve: Array, frameCount: number): Array; + tweenEasing: number; + curve: Array; constructor(); /** * @inheritDoc */ protected _onClear(): void; - protected _onArriveAtFrame(isUpdate: boolean): void; - protected _onUpdateFrame(isUpdate: boolean): void; - protected _updateExtensionKeyFrame(current: ExtensionFrameData, next: ExtensionFrameData, result: ExtensionFrameData): number; } -} -declare namespace dragonBones { /** * @private */ - class AnimationTimelineState extends TimelineState { + class AnimationFrameData extends FrameData { static toString(): string; - private _isStarted; + actions: Array; + events: Array; constructor(); /** * @inheritDoc */ protected _onClear(): void; - protected _onCrossFrame(frame: AnimationFrameData): void; - update(time: number): void; } /** * @private */ - class BoneTimelineState extends TweenTimelineState { + class BoneFrameData extends TweenFrameData { static toString(): string; - bone: Bone; - private _tweenTransform; - private _tweenRotate; - private _tweenScale; - private _boneTransform; - private _originTransform; - private _transform; - private _currentTransform; - private _durationTransform; + tweenScale: boolean; + tweenRotate: number; + transform: Transform; constructor(); /** * @inheritDoc */ protected _onClear(): void; - protected _onFadeIn(): void; - protected _onArriveAtFrame(isUpdate: boolean): void; - protected _onUpdateFrame(isUpdate: boolean): void; - fadeOut(): void; - update(time: number): void; } /** * @private */ - class SlotTimelineState extends TweenTimelineState { + class SlotFrameData extends TweenFrameData { + static DEFAULT_COLOR: ColorTransform; + static generateColor(): ColorTransform; static toString(): string; - slot: Slot; - private _colorDirty; - private _tweenColor; - private _slotColor; - private _color; - private _durationColor; + displayIndex: number; + zOrder: number; + color: ColorTransform; constructor(); /** * @inheritDoc */ protected _onClear(): void; - protected _onFadeIn(): void; - protected _onArriveAtFrame(isUpdate: boolean): void; - protected _onUpdateFrame(isUpdate: boolean): void; - fadeOut(): void; - update(time: number): void; } /** * @private */ - class FFDTimelineState extends TweenTimelineState { + class ExtensionFrameData extends TweenFrameData { static toString(): string; - slot: Slot; - private _tweenFFD; - private _slotFFDVertices; - private _durationFFDFrame; - private _ffdVertices; + type: ExtensionType; + tweens: Array; + keys: Array; constructor(); /** * @inheritDoc */ protected _onClear(): void; - protected _onFadeIn(): void; - protected _onArriveAtFrame(isUpdate: boolean): void; - protected _onUpdateFrame(isUpdate: boolean): void; - update(time: number): void; } } declare namespace dragonBones { /** - * @language zh_CN - * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimatable - * @see dragonBones.Armature - * @version DragonBones 3.0 + * @private */ - class WorldClock implements IAnimateble { - private static _clock; - /** - * @language zh_CN - * 一个可以直接使用的全局静态 WorldClock 实例. - * @version DragonBones 3.0 - */ - static clock: WorldClock; + abstract class TimelineData> extends BaseObject { /** - * @language zh_CN - * 当前的时间。 (以秒为单位) - * @version DragonBones 3.0 + * @private */ - time: number; + scale: number; /** - * @language zh_CN - * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 - * @version DragonBones 3.0 + * @private */ - timeScale: number; - private _animatebles; + offset: number; /** - * @language zh_CN - * 创建一个新的 WorldClock 实例。 - * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。 - * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放) - * @version DragonBones 3.0 + * @private */ + frames: Array; constructor(); /** - * @language zh_CN - * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用) - * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) - * @version DragonBones 3.0 - */ - advanceTime(passedTime: number): void; - /** - * 是否包含指定的 IAnimatable 实例 - * @param value 指定的 IAnimatable 实例。 - * @returns [true: 包含,false: 不包含]。 - * @version DragonBones 3.0 + * @inheritDoc */ - contains(value: IAnimateble): boolean; + protected _onClear(): void; + } + /** + * @private + */ + class BoneTimelineData extends TimelineData { + static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; + static toString(): string; + bone: BoneData; + originTransform: Transform; + cachedFrames: Array; + constructor(); /** - * @language zh_CN - * 添加指定的 IAnimatable 实例。 - * @param value IAnimatable 实例。 - * @version DragonBones 3.0 + * @inheritDoc */ - add(value: IAnimateble): void; + protected _onClear(): void; + cacheFrames(cacheFrameCount: number): void; + } + /** + * @private + */ + class SlotTimelineData extends TimelineData { + static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; + static toString(): string; + slot: SlotData; + cachedFrames: Array; + constructor(); /** - * @language zh_CN - * 移除指定的 IAnimatable 实例。 - * @param value IAnimatable 实例。 - * @version DragonBones 3.0 + * @inheritDoc */ - remove(value: IAnimateble): void; + protected _onClear(): void; + cacheFrames(cacheFrameCount: number): void; + } + /** + * @private + */ + class FFDTimelineData extends TimelineData { + static toString(): string; + displayIndex: number; + skin: SkinData; + slot: SlotDisplayDataSet; + constructor(); /** - * @language zh_CN - * 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 + * @inheritDoc */ - clear(): void; + protected _onClear(): void; } } declare namespace dragonBones { /** * @language zh_CN - * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @see dragonBones.IArmatureDisplayContainer + * 骨架数据。 + * @see dragonBones.Armature * @version DragonBones 3.0 */ - class Armature extends BaseObject implements IAnimateble { - /** - * @private - */ - static _soundEventManager: IEventDispatcher; + class ArmatureData extends BaseObject { + private static _onSortSlots(a, b); /** * @private */ static toString(): string; /** * @language zh_CN - * 可以用于存储临时数据。 + * 动画帧率。 * @version DragonBones 3.0 */ - userData: any; + frameRate: number; /** * @private */ - _bonesDirty: boolean; + cacheFrameRate: number; /** - * @private + * @language zh_CN + * 骨架类型。 + * @see dragonBones.ArmatureType + * @version DragonBones 3.0 */ - _cacheFrameIndex: number; - /** - * @private - */ - _armatureData: ArmatureData; - /** - * @private - */ - _skinData: SkinData; - /** - * @private - */ - _animation: Animation; - /** - * @private - */ - _display: IArmatureDisplay; + type: ArmatureType; /** - * @private + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 */ - _parent: Slot; + name: string; /** * @private */ - _action: ActionData; + parent: DragonBonesData; /** * @private */ - _replacedTexture: any; + userData: any; /** * @private */ - private _delayDispose; + aabb: Rectangle; /** - * @private + * @language zh_CN + * 所有的骨骼数据。 + * @see dragonBones.BoneData + * @version DragonBones 3.0 */ - private _lockDispose; + bones: Map; /** - * @private + * @language zh_CN + * 所有的插槽数据。 + * @see dragonBones.SlotData + * @version DragonBones 3.0 */ - private _slotsDirty; + slots: Map; /** - * @private Store bones based on bones' hierarchy (From root to leaf) + * @language zh_CN + * 所有的皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 3.0 */ - private _bones; + skins: Map; /** - * @private Store slots based on slots' zOrder (From low to high) + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 */ - private _slots; + animations: Map; /** * @private */ - private _events; + actions: Array; + private _boneDirty; + private _slotDirty; + private _defaultSkin; + private _defaultAnimation; + private _sortedBones; + private _sortedSlots; + private _bonesChildren; /** * @private */ @@ -996,298 +952,236 @@ declare namespace dragonBones { * @inheritDoc */ protected _onClear(): void; - /** - * @private - */ private _sortBones(); - /** - * @private - */ private _sortSlots(); /** * @private */ - _addBoneToBoneList(value: Bone): void; + cacheFrames(value: number): void; /** * @private */ - _removeBoneFromBoneList(value: Bone): void; + addBone(value: BoneData, parentName: string): void; /** * @private */ - _addSlotToSlotList(value: Slot): void; + addSlot(value: SlotData): void; /** * @private */ - _removeSlotFromSlotList(value: Slot): void; + addSkin(value: SkinData): void; /** * @private */ - _bufferEvent(value: EventObject, type: string): void; + addAnimation(value: AnimationData): void; /** * @language zh_CN - * 释放骨架。 (会回收到内存池) + * 获取指定名称的骨骼数据。 + * @param name 骨骼数据名称。 + * @see dragonBones.BoneData * @version DragonBones 3.0 */ - dispose(): void; + getBone(name: string): BoneData; /** * @language zh_CN - * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新) - * @param passedTime 两帧之前的时间间隔。 (以秒为单位) - * @see dragonBones.IAnimateble - * @see dragonBones.WorldClock - * @see dragonBones.IArmatureDisplay + * 获取指定名称的插槽数据。 + * @param name 插槽数据名称。 + * @see dragonBones.SlotData * @version DragonBones 3.0 */ - advanceTime(passedTime: number): void; + getSlot(name: string): SlotData; /** * @language zh_CN - * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) - * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 - * @param updateSlotDisplay 是否更新插槽的显示对象。 - * @see dragonBones.Bone - * @see dragonBones.Slot + * 获取指定名称的皮肤数据。 + * @param name 皮肤数据名称。 + * @see dragonBones.SkinData * @version DragonBones 3.0 */ - invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void; + getSkin(name: string): SkinData; /** * @language zh_CN - * 获取指定名称的插槽。 - * @param name 插槽的名称。 - * @returns 插槽。 - * @see dragonBones.Slot + * 获取指定名称的动画数据。 + * @param name 动画数据名称。 + * @see dragonBones.AnimationData * @version DragonBones 3.0 */ - getSlot(name: string): Slot; + getAnimation(name: string): AnimationData; /** - * @language zh_CN - * 通过显示对象获取插槽。 - * @param display 显示对象。 - * @returns 包含这个显示对象的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @private */ - getSlotByDisplay(display: any): Slot; + sortedBones: Array; /** - * @language zh_CN - * 将一个指定的插槽添加到骨架中。 - * @param value 需要添加的插槽。 - * @param parentName 需要添加到的父骨骼名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @private */ - addSlot(value: Slot, parentName: string): void; + sortedSlots: Array; /** * @language zh_CN - * 将一个指定的插槽从骨架中移除。 - * @param value 需要移除的插槽 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * 获取默认的皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 */ - removeSlot(value: Slot): void; + defaultSkin: SkinData; /** * @language zh_CN - * 获取指定名称的骨骼。 - * @param name 骨骼的名称。 - * @returns 骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * 获取默认的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 */ - getBone(name: string): Bone; + defaultAnimation: AnimationData; + } + /** + * @language zh_CN + * 骨骼数据。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + class BoneData extends BaseObject { /** - * @language zh_CN - * 通过显示对象获取骨骼。 - * @param display 显示对象。 - * @returns 包含这个显示对象的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @private */ - getBoneByDisplay(display: any): Bone; + static toString(): string; /** - * @language zh_CN - * 将一个指定的骨骼添加到骨架中。 - * @param value 需要添加的骨骼。 - * @param parentName 需要添加到父骨骼的名称,如果未设置,则添加到骨架根部。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @private */ - addBone(value: Bone, parentName?: string): void; + inheritTranslation: boolean; /** - * @language zh_CN - * 将一个指定的骨骼从骨架中移除。 - * @param value 需要移除的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @private */ - removeBone(value: Bone): void; + inheritRotation: boolean; /** - * @language zh_CN - * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 - * @param texture 用来替换的贴图,根据渲染平台的不同,类型会有所不同,一般是 Texture 类型。 - * @version DragonBones 4.5 + * @private */ - replaceTexture(texture: any): void; + inheritScale: boolean; /** - * @language zh_CN - * 获取所有骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @private */ - getBones(): Array; + bendPositive: boolean; /** - * @language zh_CN - * 获取所有插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @private */ - getSlots(): Array; + chain: number; /** - * @language zh_CN - * 骨架名称。 - * @see dragonBones.ArmatureData#name - * @version DragonBones 3.0 + * @private */ - name: string; + chainIndex: number; /** - * @language zh_CN - * 获取骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 + * @private */ - armatureData: ArmatureData; + weight: number; + /** + * @private + */ + length: number; /** * @language zh_CN - * 获得动画控制器。 - * @see dragonBones.Animation + * 数据名称。 * @version DragonBones 3.0 */ - animation: Animation; + name: string; /** * @language zh_CN - * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * 所属的父骨骼数据。 * @version DragonBones 3.0 */ - display: IArmatureDisplay | any; + parent: BoneData; /** - * @language zh_CN - * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) - * @see dragonBones.Slot - * @version DragonBones 4.5 + * @private */ - parent: Slot; + ik: BoneData; /** - * @language zh_CN - * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 - * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 + * @private */ - cacheFrameRate: number; + transform: Transform; /** - * @language zh_CN - * 开启动画缓存。 - * @param frameRate 动画缓存的帧率 - * @see #cacheFrameRate - * @version DragonBones 4.5 + * @private */ - enableAnimationCache(frameRate: number): void; + constructor(); /** - * @language zh_CN - * 是否包含指定类型的事件。 - * @param type 事件类型。 - * @returns [true: 包含, false: 不包含] - * @version DragonBones 3.0 + * @inheritDoc */ - hasEventListener(type: EventStringType): void; + protected _onClear(): void; + } + /** + * @language zh_CN + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + class SlotData extends BaseObject { /** - * @language zh_CN - * 添加事件。 - * @param type 事件类型。 - * @param listener 事件回调。 - * @version DragonBones 3.0 + * @private */ - addEventListener(type: EventStringType, listener: Function, target: any): void; + static DEFAULT_COLOR: ColorTransform; /** - * @language zh_CN - * 移除事件。 - * @param type 事件类型。 - * @param listener 事件回调。 - * @version DragonBones 3.0 + * @private */ - removeEventListener(type: EventStringType, listener: Function, target: any): void; + static generateColor(): ColorTransform; /** - * @deprecated - * @see #display + * @private */ - getDisplay(): any; + static toString(): string; /** - * @deprecated - * @see #cacheFrameRate + * @private */ - enableCache: boolean; - } -} -declare namespace dragonBones { - /** - * @language zh_CN - * 基础变换对象。 - * @version DragonBones 4.5 - */ - abstract class TransformObject extends BaseObject { + displayIndex: number; /** - * @language zh_CN - * 可以用于存储临时数据。 - * @version DragonBones 3.0 + * @private */ - userData: any; + zOrder: number; /** - * @language zh_CN - * 对象的名称。 - * @version DragonBones 3.0 + * @private */ - name: string; + blendMode: BlendMode; /** * @language zh_CN - * 相对于骨架坐标系的矩阵。 + * 数据名称。 * @version DragonBones 3.0 */ - globalTransformMatrix: Matrix; + name: string; /** * @language zh_CN - * 相对于骨架坐标系的变换。 - * @see dragonBones.Transform + * 所属的父骨骼数据。 + * @see dragonBones.BoneData * @version DragonBones 3.0 */ - global: Transform; + parent: BoneData; /** - * @language zh_CN - * 相对于骨架或父骨骼坐标系的绑定变换。 - * @see dragonBones.Transform - * @version DragonBones 3.0 + * @private */ - origin: Transform; + color: ColorTransform; /** - * @language zh_CN - * 相对于骨架或父骨骼坐标系的偏移变换。 - * @see dragonBones.Transform - * @version DragonBones 3.0 + * @private */ - offset: Transform; + actions: Array; /** * @private */ - _armature: Armature; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } + /** + * @language zh_CN + * 皮肤数据。 + * @version DragonBones 3.0 + */ + class SkinData extends BaseObject { /** * @private */ - _parent: Bone; + static toString(): string; + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + name: string; /** * @private */ - protected _globalTransformMatrix: Matrix; + slots: Map; /** * @private */ @@ -1299,2587 +1193,2185 @@ declare namespace dragonBones { /** * @private */ - _setArmature(value: Armature): void; + addSlot(value: SlotDisplayDataSet): void; /** * @private */ - _setParent(value: Bone): void; + getSlot(name: string): SlotDisplayDataSet; + } + /** + * @private + */ + class SlotDisplayDataSet extends BaseObject { + static toString(): string; + slot: SlotData; + displays: Array; + constructor(); /** - * @language zh_CN - * 所属的骨架。 - * @see dragonBones.Armature - * @version DragonBones 3.0 + * @inheritDoc */ - armature: Armature; + protected _onClear(): void; + } + /** + * @private + */ + class DisplayData extends BaseObject { + static toString(): string; + isRelativePivot: boolean; + type: DisplayType; + name: string; + texture: TextureData; + armature: ArmatureData; + mesh: MeshData; + pivot: Point; + transform: Transform; + constructor(); /** - * @language zh_CN - * 所属的父骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @inheritDoc */ - parent: Bone; + protected _onClear(): void; } -} -declare namespace dragonBones { /** * @private */ - const enum BoneTransformDirty { - None = 0, - Self = 1, - All = 2, + class MeshData extends BaseObject { + static toString(): string; + skinned: boolean; + slotPose: Matrix; + uvs: Array; + vertices: Array; + vertexIndices: Array; + boneIndices: Array>; + weights: Array>; + boneVertices: Array>; + bones: Array; + inverseBindPose: Array; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; } +} +declare namespace dragonBones { /** * @language zh_CN - * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 - * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot + * 动画数据。 * @version DragonBones 3.0 */ - class Bone extends TransformObject { + class AnimationData extends TimelineData { /** * @private */ static toString(): string; /** - * @language zh_CN - * 是否继承父骨骼的平移。 [true: 继承, false: 不继承] - * @version DragonBones 3.0 + * @private */ - inheritTranslation: boolean; + hasAsynchronyTimeline: boolean; /** * @language zh_CN - * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承] + * 持续的帧数。 * @version DragonBones 3.0 */ - inheritRotation: boolean; + frameCount: number; /** * @language zh_CN - * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承] - * @version DragonBones 4.5 + * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 */ - inheritScale: boolean; + playTimes: number; /** * @language zh_CN - * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针] - * @version DragonBones 4.5 + * 开始的时间。 (以秒为单位) + * @version DragonBones 3.0 */ - ikBendPositive: boolean; + position: number; /** * @language zh_CN - * IK 约束的权重。 - * @version DragonBones 4.5 + * 持续的时间。 (以秒为单位) + * @version DragonBones 3.0 */ - ikWeight: number; + duration: number; /** * @language zh_CN - * 骨骼长度。 - * @version DragonBones 4.5 + * 淡入混合的时间。 (以秒为单位) + * @version DragonBones 3.0 */ - length: number; + fadeInTime: number; /** * @private */ - _transformDirty: BoneTransformDirty; + cacheTimeToFrameScale: number; /** - * @private + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 */ - _blendIndex: number; + name: string; /** * @private */ - _cacheFrames: Array; + animation: AnimationData; /** * @private */ - _animationPose: Transform; + boneTimelines: Map; /** * @private */ - private _visible; + slotTimelines: Map; /** * @private */ - private _ikChain; + ffdTimelines: Map>>; /** * @private */ - private _ikChainIndex; + cachedFrames: Array; /** * @private */ - private _ik; + constructor(); /** - * @private + * @inheritDoc */ - private _bones; + protected _onClear(): void; /** * @private */ - private _slots; + cacheFrames(value: number): void; /** * @private */ - constructor(); + addBoneTimeline(value: BoneTimelineData): void; /** - * @inheritDoc + * @private */ - protected _onClear(): void; + addSlotTimeline(value: SlotTimelineData): void; /** * @private */ - private _updateGlobalTransformMatrix(); + addFFDTimeline(value: FFDTimelineData): void; /** * @private */ - private _computeIKA(); - /** - * @private - */ - private _computeIKB(); - /** - * @inheritDoc - */ - _setArmature(value: Armature): void; - /** - * @private - */ - _setIK(value: Bone, chain: number, chainIndex: number): void; - /** - * @private - */ - _update(cacheFrameIndex: number): void; - /** - * @language zh_CN - * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) - * @version DragonBones 3.0 - */ - invalidUpdate(): void; - /** - * @language zh_CN - * 是否包含某个指定的骨骼或插槽。 - * @returns [true: 包含,false: 不包含] - * @see dragonBones.TransformObject - * @version DragonBones 3.0 - */ - contains(child: TransformObject): boolean; - /** - * @language zh_CN - * 所有的子骨骼。 - * @version DragonBones 3.0 - */ - getBones(): Array; - /** - * @language zh_CN - * 所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - */ - getSlots(): Array; + getBoneTimeline(name: string): BoneTimelineData; /** * @private */ - ikChain: number; + getSlotTimeline(name: string): SlotTimelineData; /** * @private */ - ikChainIndex: number; - /** - * @language zh_CN - * 当前的 IK 约束目标。 - * @version DragonBones 4.5 - */ - ik: Bone; - /** - * @language zh_CN - * 控制此骨骼所有插槽的显示。 - * @default true - * @see dragonBones.Slot - * @version DragonBones 3.0 - */ - visible: boolean; - /** - * @deprecated - * @see dragonBones.Armature#getSlot() - */ - slot: Slot; + getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData; } } declare namespace dragonBones { /** * @language zh_CN - * 骨架显示容器和事件的接口。 - * @see dragonBones.Armature#display + * 动画混合时,使用的淡出方式。 + * @see dragonBones.Animation#fadeIn() * @version DragonBones 4.5 */ - interface IArmatureDisplay extends IEventDispatcher { + const enum AnimationFadeOutMode { /** * @language zh_CN - * 由显示容器来更新骨架和动画。 - * @param on 开启或关闭显示容器对骨架与动画的更新。 + * 不淡出动画。 * @version DragonBones 4.5 */ - advanceTimeBySelf(on: boolean): void; + None = 0, + /** + * @language zh_CN + * 淡出同层的动画。 + * @version DragonBones 4.5 + */ + SameLayer = 1, /** * @language zh_CN - * 释放显示对象和骨架。 (骨架会回收到内存池) + * 淡出同组的动画。 * @version DragonBones 4.5 */ - dispose(): void; + SameGroup = 2, /** * @language zh_CN - * 获取使用这个显示容器的骨架。 - * @readOnly - * @see dragonBones.Armature + * 淡出同层并且同组的动画。 * @version DragonBones 4.5 */ - armature: Armature; + SameLayerAndGroup = 3, /** * @language zh_CN - * 获取使用骨架的动画控制器。 - * @readOnly - * @see dragonBones.Animation + * 淡出所有动画。 * @version DragonBones 4.5 */ - animation: Animation; + All = 4, } -} -declare namespace dragonBones { /** * @language zh_CN - * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * 播放动画组件接口。 (Armature 和 WordClock 都实现了该接口) + * 任何实现了此接口的实例都可以加到 WorldClock 时钟中,由时钟统一控制动画的播放。 + * @see dragonBones.WorldClock * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData * @version DragonBones 3.0 */ - abstract class Slot extends TransformObject { - /** - * @language zh_CN - * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承] - * @default true - * @version DragonBones 4.5 - */ - inheritAnimation: boolean; + interface IAnimateble { /** - * @language zh_CN - * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。 - * @default null - * @see dragonBones.AnimationState#displayControl - * @see dragonBones.AnimationState#name - * @see dragonBones.AnimationState#group - * @version DragonBones 4.5 - */ - displayController: string; + * @language zh_CN + * 更新一个指定的时间。 + * @param passedTime 前进的时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + advanceTime(passedTime: number): void; + } + /** + * @language zh_CN + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + class Animation extends BaseObject { /** * @private */ - _colorDirty: boolean; + protected static _sortAnimationState(a: AnimationState, b: AnimationState): number; /** * @private */ - _ffdDirty: boolean; + static toString(): string; /** - * @private + * @language zh_CN + * 动画的播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 */ - _blendIndex: number; + timeScale: number; /** - * @private + * @private Armature Slot */ - _zOrder: number; + _animationStateDirty: boolean; /** - * @private + * @private Armature Slot */ - _displayDataSet: SlotDisplayDataSet; + _timelineStateDirty: boolean; /** - * @private + * @private Factory */ - _meshData: MeshData; + _armature: Armature; /** * @private */ - _cacheFrames: Array; + protected _isPlaying: boolean; /** * @private */ - _rawDisplay: any; + protected _time: number; /** * @private */ - _meshDisplay: any; + protected _lastAnimationState: AnimationState; /** * @private */ - _colorTransform: ColorTransform; + protected _animations: Map; /** * @private */ - _ffdVertices: Array; + protected _animationNames: Array; /** * @private */ - _replacedDisplayDataSet: Array; + protected _animationStates: Array; /** * @private */ - protected _displayDirty: boolean; + constructor(); /** - * @private + * @inheritDoc */ - protected _blendModeDirty: boolean; + protected _onClear(): void; /** * @private */ - protected _originDirty: boolean; + protected _fadeOut(fadeOutTime: number, layer: number, group: string, fadeOutMode: AnimationFadeOutMode, pauseFadeOut: boolean): void; /** * @private */ - protected _transformDirty: boolean; + _updateFFDTimelineStates(): void; /** * @private */ - protected _displayIndex: number; + _advanceTime(passedTime: number): void; /** - * @private + * @language zh_CN + * 清除所有正在播放的动画状态。 + * @version DragonBones 4.5 */ - protected _blendMode: BlendMode; + reset(): void; /** - * @private + * @language zh_CN + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 */ - protected _display: any; + stop(animationName?: string): void; /** - * @private + * @language zh_CN + * 播放动画。 + * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 */ - protected _childArmature: Armature; + play(animationName?: string, playTimes?: number): AnimationState; /** - * @private + * @language zh_CN + * 淡入播放指定名称的动画。 + * @param animationName 动画数据的名称。 + * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位) + * @param layer 混合的图层,图层高会优先获取混合权重。 + * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。 + * @param fadeOutMode 淡出的模式。 + * @param additiveBlending 以叠加的形式混合。 + * @param displayControl 是否对显示对象属性可控。 + * @param pauseFadeOut 暂停需要淡出的动画。 + * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - protected _localMatrix: Matrix; + fadeIn(animationName: string, fadeInTime?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, additiveBlending?: boolean, displayControl?: boolean, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; /** - * @private + * @language zh_CN + * 指定名称的动画从指定时间开始播放。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - protected _displayList: Array; + gotoAndPlayByTime(animationName: string, time?: number, playTimes?: number): AnimationState; /** - * @private + * @language zh_CN + * 指定名称的动画从指定帧开始播放。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - protected _meshBones: Array; + gotoAndPlayByFrame(animationName: string, frame?: number, playTimes?: number): AnimationState; /** - * @private + * @language zh_CN + * 指定名称的动画从指定进度开始播放。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - constructor(); + gotoAndPlayByProgress(animationName: string, progress?: number, playTimes?: number): AnimationState; /** - * @inheritDoc + * @language zh_CN + * 播放指定名称的动画到指定的时间并停止。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - protected _onClear(): void; + gotoAndStopByTime(animationName: string, time?: number): AnimationState; /** - * @private + * @language zh_CN + * 播放指定名称的动画到指定的帧并停止。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - protected abstract _onUpdateDisplay(): void; + gotoAndStopByFrame(animationName: string, frame?: number): AnimationState; /** - * @private + * @language zh_CN + * 播放指定名称的动画到指定的进度并停止。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - protected abstract _initDisplay(value: any): void; + gotoAndStopByProgress(animationName: string, progress?: number): AnimationState; /** - * @private + * @language zh_CN + * 获取指定名称的动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 */ - protected abstract _addDisplay(): void; + getState(animationName: string): AnimationState; /** - * @private + * @language zh_CN + * 是否包含指定名称的动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 */ - protected abstract _replaceDisplay(value: any): void; + hasAnimation(animationName: string): boolean; /** - * @private + * @language zh_CN + * 动画是否处于播放状态。 + * @version DragonBones 3.0 */ - protected abstract _removeDisplay(): void; + isPlaying: boolean; /** - * @private + * @language zh_CN + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 */ - protected abstract _disposeDisplay(value: any): void; + isCompleted: boolean; /** - * @private Bone + * @language zh_CN + * 上一个正在播放的动画状态的名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 */ - abstract _updateVisible(): void; + lastAnimationName: string; /** - * @private + * @language zh_CN + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 */ - protected abstract _updateBlendMode(): void; + lastAnimationState: AnimationState; /** - * @private + * @language zh_CN + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 */ - protected abstract _updateColor(): void; + animationNames: Array; /** - * @private + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 */ - protected abstract _updateFilters(): void; + animations: Map; /** - * @private + * @deprecated + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() */ - protected abstract _updateFrame(): void; + gotoAndPlay(animationName: string, fadeInTime?: number, duration?: number, playTimes?: number, layer?: number, group?: string, fadeOutMode?: AnimationFadeOutMode, pauseFadeOut?: boolean, pauseFadeIn?: boolean): AnimationState; /** - * @private + * @deprecated + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() */ - protected abstract _updateMesh(): void; + gotoAndStop(animationName: string, time?: number): AnimationState; /** - * @private + * @deprecated + * @see #animationNames + * @see #animations */ - protected abstract _updateTransform(): void; + animationList: Array; /** - * @private + * @language zh_CN + * @deprecated + * @see #animationNames + * @see #animations */ - private _isMeshBonesUpdate(); + animationDataList: Array; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + class AnimationState extends BaseObject { /** * @private */ - protected _updateDisplay(): void; + static toString(): string; /** - * @private + * @language zh_CN + * 是否对插槽的颜色,显示序列索引,深度排序,行为等拥有控制的权限。 + * @see dragonBones.Slot#displayController + * @version DragonBones 3.0 */ - protected _updateLocalTransformMatrix(): void; + displayControl: boolean; + /** + * @language zh_CN + * 是否以叠加的方式混合动画。 + * @version DragonBones 3.0 + */ + additiveBlending: boolean; + /** + * @language zh_CN + * 需要播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] + * @version DragonBones 3.0 + */ + playTimes: number; + /** + * @language zh_CN + * 播放速度。 [(-N~0): 倒转播放, 0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 + */ + timeScale: number; + /** + * @language zh_CN + * 进行动画混合时的权重。 + * @default 1 + * @version DragonBones 3.0 + */ + weight: number; + /** + * @language zh_CN + * 自动淡出时需要的时间,当设置一个大于等于 0 的值,动画状态将会在播放完成后自动淡出。 (以秒为单位) + * @default -1 + * @version DragonBones 3.0 + */ + autoFadeOutTime: number; /** * @private */ - protected _updateGlobalTransformMatrix(): void; + fadeTotalTime: number; /** - * @inheritDoc + * @private Animation */ - _setArmature(value: Armature): void; + _isFadeOutComplete: boolean; /** - * @private Armature + * @private Animation */ - _updateMeshData(isTimelineUpdate: Boolean): void; + _layer: number; /** - * @private Armature + * @private TimelineState */ - _update(cacheFrameIndex: number): void; + _position: number; /** - * @private Factory + * @private TimelineState */ - _setDisplayList(value: Array): Boolean; + _duration: number; /** - * @private Factory + * @private Animation, TimelineState */ - _setDisplayIndex(value: number): boolean; + _weightResult: number; /** - * @private Factory + * @private Animation, TimelineState */ - _setBlendMode(value: BlendMode): boolean; + _fadeProgress: number; /** - * @private Factory + * @private Animation TimelineState */ - _setColor(value: ColorTransform): boolean; + _group: string; /** - * @language zh_CN - * 在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 + * @private TimelineState */ - invalidUpdate(): void; + _timeline: AnimationTimelineState; /** * @private */ - rawDisplay: any; + private _isPlaying; /** * @private */ - MeshDisplay: any; + private _isPausePlayhead; /** - * @language zh_CN - * 此时显示的显示对象在显示列表中的索引。 - * @version DragonBones 4.5 + * @private */ - displayIndex: number; + private _isFadeOut; /** - * @language zh_CN - * 包含显示对象或子骨架的显示列表。 - * @version DragonBones 3.0 + * @private */ - displayList: Array; + private _currentPlayTimes; /** - * @language zh_CN - * 此时显示的显示对象。 - * @version DragonBones 3.0 + * @private */ - display: any; + private _fadeTime; /** - * @language zh_CN - * 此时显示的子骨架。 - * @see dragonBones.Armature - * @version DragonBones 3.0 + * @private */ - childArmature: Armature; + private _time; /** - * @deprecated - * @see #display + * @private */ - getDisplay(): any; + private _name; /** - * @deprecated - * @see #display + * @private */ - setDisplay(value: any): void; - } -} -declare namespace dragonBones { - /** - * @private - */ - const enum ArmatureType { - Armature = 0, - MovieClip = 1, - Stage = 2, - } - /** - * @private - */ - const enum DisplayType { - Image = 0, - Armature = 1, - Mesh = 2, - } - /** - * @private - */ - const enum ExtensionType { - FFD = 0, - AdjustColor = 10, - BevelFilter = 11, - BlurFilter = 12, - DropShadowFilter = 13, - GlowFilter = 14, - GradientBevelFilter = 15, - GradientGlowFilter = 16, - } - /** - * @private - */ - const enum EventType { - Frame = 0, - Sound = 1, - } - /** - * @private - */ - const enum ActionType { - Play = 0, - Stop = 1, - GotoAndPlay = 2, - GotoAndStop = 3, - FadeIn = 4, - FadeOut = 5, - } - /** - * @private - */ - const enum BlendMode { - Normal = 0, - Add = 1, - Alpha = 2, - Darken = 3, - Difference = 4, - Erase = 5, - HardLight = 6, - Invert = 7, - Layer = 8, - Lighten = 9, - Multiply = 10, - Overlay = 11, - Screen = 12, - Subtract = 13, - } - /** - * @private - */ - interface Map { - [key: string]: T; - } - /** - * DragonBones - */ - class DragonBones { - /** - * @private - */ - static PI_D: number; - /** - * @private - */ - static PI_H: number; + private _armature; /** * @private */ - static PI_Q: number; + private _animationData; /** * @private */ - static ANGLE_TO_RADIAN: number; + private _boneMask; /** * @private */ - static RADIAN_TO_ANGLE: number; + private _boneTimelines; /** * @private */ - static SECOND_TO_MILLISECOND: number; + private _slotTimelines; /** * @private */ - static NO_TWEEN: number; - static VERSION: string; + private _ffdTimelines; /** * @private */ - static DEBUG: boolean; + constructor(); /** - * @private + * @inheritDoc */ - static _armatures: Array; + protected _onClear(): void; /** * @private */ - constructor(); + private _advanceFadeTime(passedTime); /** * @private */ - static hasArmature(value: Armature): boolean; + _isDisabled(slot: Slot): boolean; /** * @private */ - static addArmature(value: Armature): void; + _fadeIn(armature: Armature, clip: AnimationData, animationName: string, playTimes: number, position: number, duration: number, time: number, timeScale: number, fadeInTime: number, pausePlayhead: boolean): void; /** * @private */ - static removeArmature(value: Armature): void; - } -} -declare namespace dragonBones { - /** - * @private - */ - type EventStringType = string | 'start' | 'loopComplete' | 'complete' | 'fadeIn' | 'fadeInComplete' | 'fadeOut' | 'fadeOutComplete' | 'frameEvent' | 'soundEvent'; - /** - * @language zh_CN - * 事件接口。 - * @version DragonBones 4.5 - */ - interface IEventDispatcher { + _updateTimelineStates(): void; /** * @private */ - _onClear(): void; + _updateFFDTimelineStates(): void; /** * @private */ - _dispatchEvent(eventObject: EventObject): void; + _advanceTime(passedTime: number, weightLeft: number, index: number): void; /** * @language zh_CN - * 是否包含指定类型的事件。 - * @param type 事件类型。 - * @returns [true: 包含, false: 不包含] - * @version DragonBones 4.5 + * 继续播放。 + * @version DragonBones 3.0 */ - hasEvent(type: EventStringType): boolean; + play(): void; /** * @language zh_CN - * 添加事件。 - * @param type 事件类型。 - * @param listener 事件回调。 - * @version DragonBones 4.5 + * 暂停播放。 + * @version DragonBones 3.0 */ - addEvent(type: EventStringType, listener: Function, target: any): void; + stop(): void; /** * @language zh_CN - * 移除事件。 - * @param type 事件类型。 - * @param listener 事件回调。 - * @version DragonBones 4.5 + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停] + * @version DragonBones 3.0 */ - removeEvent(type: EventStringType, listener: Function, target: any): void; - } - /** - * @language zh_CN - * 事件数据。 - * @version DragonBones 4.5 - */ - class EventObject extends BaseObject { + fadeOut(fadeOutTime: number, pausePlayhead?: boolean): void; /** * @language zh_CN - * 动画开始。 - * @version DragonBones 4.5 + * 是否包含指定的骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 */ - static START: string; + containsBoneMask(name: string): boolean; /** * @language zh_CN - * 动画循环播放一次完成。 - * @version DragonBones 4.5 + * 添加指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 */ - static LOOP_COMPLETE: string; + addBoneMask(name: string, recursive?: boolean): void; /** * @language zh_CN - * 动画播放完成。 - * @version DragonBones 4.5 + * 删除指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 */ - static COMPLETE: string; + removeBoneMask(name: string, recursive?: boolean): void; /** * @language zh_CN - * 动画淡入开始。 - * @version DragonBones 4.5 + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 */ - static FADE_IN: string; + removeAllBoneMask(): void; /** * @language zh_CN - * 动画淡入完成。 - * @version DragonBones 4.5 + * 动画图层。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 */ - static FADE_IN_COMPLETE: string; + layer: number; /** * @language zh_CN - * 动画淡出开始。 - * @version DragonBones 4.5 + * 动画组。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 */ - static FADE_OUT: string; + group: string; /** * @language zh_CN - * 动画淡出完成。 - * @version DragonBones 4.5 + * 动画名称。 + * @see dragonBones.AnimationData#name + * @version DragonBones 3.0 */ - static FADE_OUT_COMPLETE: string; + name: string; /** * @language zh_CN - * 动画帧事件。 - * @version DragonBones 4.5 + * 动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 */ - static FRAME_EVENT: string; + animationData: AnimationData; /** * @language zh_CN - * 动画声音事件。 - * @version DragonBones 4.5 - */ - static SOUND_EVENT: string; - /** - * @private + * 是否播放完毕。 + * @version DragonBones 3.0 */ - static toString(): string; + isCompleted: Boolean; /** * @language zh_CN - * 事件类型。 - * @version DragonBones 4.5 + * 是否正在播放。 + * @version DragonBones 3.0 */ - type: EventStringType; + isPlaying: Boolean; /** * @language zh_CN - * 事件名称。 (帧标签的名称或声音的名称) - * @version DragonBones 4.5 + * 当前动画的播放次数。 + * @version DragonBones 3.0 */ - name: string; + currentPlayTimes: number; /** * @language zh_CN - * 扩展的数据。 - * @version DragonBones 4.5 + * 当前动画的总时间。 (以秒为单位) + * @version DragonBones 3.0 */ - data: any; + totalTime: number; /** * @language zh_CN - * 发出事件的骨架。 - * @version DragonBones 4.5 + * 当前动画的播放时间。 (以秒为单位) + * @version DragonBones 3.0 */ - armature: Armature; + currentTime: number; /** - * @language zh_CN - * 发出事件的骨骼。 - * @version DragonBones 4.5 + * @deprecated */ - bone: Bone; + autoTween: boolean; /** - * @language zh_CN - * 发出事件的插槽。 - * @version DragonBones 4.5 + * @deprecated + * @see #animationData */ - slot: Slot; + clip: AnimationData; + } +} +declare namespace dragonBones { + /** + * @private + */ + const enum TweenType { + None = 0, + Once = 1, + Always = 2, + } + /** + * @private + */ + abstract class TimelineState, M extends TimelineData> extends BaseObject { + _isCompleted: boolean; + _currentPlayTimes: number; + _currentTime: number; + _timeline: M; + protected _isReverse: boolean; + protected _hasAsynchronyTimeline: boolean; + protected _frameRate: number; + protected _keyFrameCount: number; + protected _frameCount: number; + protected _position: number; + protected _duration: number; + protected _animationDutation: number; + protected _timeScale: number; + protected _timeOffset: number; + protected _currentFrame: T; + protected _armature: Armature; + protected _animationState: AnimationState; + constructor(); /** - * @language zh_CN - * 发出事件的动画状态。 - * @version DragonBones 4.5 + * @inheritDoc */ - animationState: AnimationState; + protected _onClear(): void; + protected _onFadeIn(): void; + protected _onUpdateFrame(isUpdate: boolean): void; + protected _onArriveAtFrame(isUpdate: boolean): void; + protected _setCurrentTime(value: number): boolean; + setCurrentTime(value: number): void; + fadeIn(armature: Armature, animationState: AnimationState, timelineData: M, time: number): void; + fadeOut(): void; + update(time: number): void; + } + /** + * @private + */ + abstract class TweenTimelineState, M extends TimelineData> extends TimelineState { + static _getEasingValue(progress: number, easing: number): number; + static _getCurveEasingValue(progress: number, sampling: Array): number; + protected _tweenProgress: number; + protected _tweenEasing: number; + protected _curve: Array; + constructor(); /** - * @language zh_CN - * 用户数据。 - * @version DragonBones 4.5 + * @inheritDoc */ - userData: any; + protected _onClear(): void; + protected _onArriveAtFrame(isUpdate: boolean): void; + protected _onUpdateFrame(isUpdate: boolean): void; + protected _updateExtensionKeyFrame(current: ExtensionFrameData, next: ExtensionFrameData, result: ExtensionFrameData): number; + } +} +declare namespace dragonBones { + /** + * @private + */ + class AnimationTimelineState extends TimelineState { + static toString(): string; + private _isStarted; + constructor(); /** - * @private + * @inheritDoc */ + protected _onClear(): void; + protected _onCrossFrame(frame: AnimationFrameData): void; + update(time: number): void; + } + /** + * @private + */ + class BoneTimelineState extends TweenTimelineState { + static toString(): string; + bone: Bone; + private _tweenTransform; + private _tweenRotate; + private _tweenScale; + private _boneTransform; + private _originTransform; + private _transform; + private _currentTransform; + private _durationTransform; constructor(); /** * @inheritDoc */ protected _onClear(): void; + protected _onFadeIn(): void; + protected _onArriveAtFrame(isUpdate: boolean): void; + protected _onUpdateFrame(isUpdate: boolean): void; + fadeOut(): void; + update(time: number): void; + } + /** + * @private + */ + class SlotTimelineState extends TweenTimelineState { + static toString(): string; + slot: Slot; + private _colorDirty; + private _tweenColor; + private _slotColor; + private _color; + private _durationColor; + constructor(); /** - * @see #animationState + * @inheritDoc */ - animationName: string; + protected _onClear(): void; + protected _onFadeIn(): void; + protected _onArriveAtFrame(isUpdate: boolean): void; + protected _onUpdateFrame(isUpdate: boolean): void; + fadeOut(): void; + update(time: number): void; + } + /** + * @private + */ + class FFDTimelineState extends TweenTimelineState { + static toString(): string; + slot: Slot; + private _tweenFFD; + private _slotFFDVertices; + private _durationFFDFrame; + private _ffdVertices; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + protected _onFadeIn(): void; + protected _onArriveAtFrame(isUpdate: boolean): void; + protected _onUpdateFrame(isUpdate: boolean): void; + update(time: number): void; } } declare namespace dragonBones { /** * @language zh_CN - * 贴图集数据。 + * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimatable + * @see dragonBones.Armature * @version DragonBones 3.0 */ - abstract class TextureAtlasData extends BaseObject { + class WorldClock implements IAnimateble { + private static _clock; /** * @language zh_CN - * 是否开启共享搜索。 [true: 开启, false: 不开启] - * @default false - * @version DragonBones 4.5 + * 一个可以直接使用的全局静态 WorldClock 实例. + * @version DragonBones 3.0 */ - autoSearch: boolean; + static clock: WorldClock; /** * @language zh_CN - * 贴图集缩放系数。 + * 当前的时间。 (以秒为单位) * @version DragonBones 3.0 */ - scale: number; + time: number; /** * @language zh_CN - * 贴图集名称。 + * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 * @version DragonBones 3.0 */ - name: string; + timeScale: number; + private _animatebles; /** * @language zh_CN - * 贴图集图片路径。 + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放) * @version DragonBones 3.0 */ - imagePath: string; - /** - * @private - */ - textures: Map; - /** - * @private - */ constructor(); /** - * @inheritDoc - */ - protected _onClear(): void; - /** - * @deprecated - * @see dragonBones.BaseFactory#removeDragonBonesData() + * @language zh_CN + * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用) + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 */ - dispose(): void; + advanceTime(passedTime: number): void; /** - * @private + * 是否包含指定的 IAnimatable 实例 + * @param value 指定的 IAnimatable 实例。 + * @returns [true: 包含,false: 不包含]。 + * @version DragonBones 3.0 */ - abstract generateTextureData(): TextureData; + contains(value: IAnimateble): boolean; /** - * @private + * @language zh_CN + * 添加指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 */ - addTextureData(value: TextureData): void; + add(value: IAnimateble): void; /** - * @private + * @language zh_CN + * 移除指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 */ - getTextureData(name: string): TextureData; - } - /** - * @private - */ - abstract class TextureData extends BaseObject { - static generateRectangle(): Rectangle; - rotated: boolean; - name: string; - frame: Rectangle; - parent: TextureAtlasData; - region: Rectangle; - constructor(); + remove(value: IAnimateble): void; /** - * @inheritDoc + * @language zh_CN + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 */ - protected _onClear(): void; + clear(): void; } } declare namespace dragonBones { /** * @language zh_CN - * Egret 贴图集数据。 + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @see dragonBones.IArmatureDisplayContainer * @version DragonBones 3.0 */ - class EgretTextureAtlasData extends TextureAtlasData { + class Armature extends BaseObject implements IAnimateble { /** * @private */ static toString(): string; /** * @language zh_CN - * Egret 贴图。 + * 可以用于存储临时数据。 * @version DragonBones 3.0 */ - texture: egret.Texture; + userData: any; /** * @private */ - constructor(); + _bonesDirty: boolean; /** - * @inheritDoc + * @private */ - protected _onClear(): void; + _cacheFrameIndex: number; /** * @private */ - generateTextureData(): TextureData; - } - /** - * @private - */ - class EgretTextureData extends TextureData { - static toString(): string; - texture: egret.Texture; - constructor(); + _armatureData: ArmatureData; /** - * @inheritDoc + * @private */ - protected _onClear(): void; - } -} -declare namespace dragonBones { - /** - * @language zh_CN - * Egret 事件。 - * @version DragonBones 4.5 - */ - class EgretEvent extends egret.Event { + _skinData: SkinData; /** - * @language zh_CN - * 事件对象。 - * @version DragonBones 4.5 + * @private */ - eventObject: EventObject; + _animation: Animation; /** * @private */ - constructor(type: EventStringType, bubbles?: boolean, cancelable?: boolean, data?: any); + _display: IArmatureDisplay; /** - * @see dragonBones.EventObject#name + * @private */ - frameLabel: string; + _parent: Slot; /** - * @see dragonBones.EventObject#name + * @private */ - sound: string; + _replacedTexture: any; /** - * @see dragonBones.EventObject#animationName + * @private */ - animationName: string; + private _delayDispose; /** - * @see dragonBones.EventObject#armature + * @private */ - armature: Armature; + private _lockDispose; /** - * @see dragonBones.EventObject#bone + * @private */ - bone: Bone; + private _slotsDirty; /** - * @see dragonBones.EventObject#slot + * @private Store bones based on bones' hierarchy (From root to leaf) */ - slot: Slot; + private _bones; /** - * @see dragonBones.EventObject#animationState + * @private Store slots based on slots' zOrder (From low to high) */ - animationState: AnimationState; + private _slots; /** - * @deprecated - * @see #animationName + * @private */ - movementID: string; + private _actions; /** - * @see dragonBones.EventObject.START + * @private */ - static START: string; + private _events; /** - * @see dragonBones.EventObject.LOOP_COMPLETE + * @private */ - static LOOP_COMPLETE: string; + constructor(); /** - * @see dragonBones.EventObject.COMPLETE + * @inheritDoc */ - static COMPLETE: string; + protected _onClear(): void; /** - * @see dragonBones.EventObject.FADE_IN + * @private */ - static FADE_IN: string; + private _sortBones(); /** - * @see dragonBones.EventObject.FADE_IN_COMPLETE + * @private */ - static FADE_IN_COMPLETE: string; + private _sortSlots(); /** - * @see dragonBones.EventObject.FADE_OUT + * @private */ - static FADE_OUT: string; + private _doAction(value); /** - * @see dragonBones.EventObject.FADE_OUT_COMPLETE + * @private */ - static FADE_OUT_COMPLETE: string; + _addBoneToBoneList(value: Bone): void; /** - * @see dragonBones.EventObject.FRAME_EVENT + * @private */ - static FRAME_EVENT: string; + _removeBoneFromBoneList(value: Bone): void; /** - * @see dragonBones.EventObject.SOUND_EVENT + * @private */ - static SOUND_EVENT: string; + _addSlotToSlotList(value: Slot): void; /** - * @deprecated - * @see dragonBones.EventObject.FRAME_EVENT + * @private */ - static ANIMATION_FRAME_EVENT: string; + _removeSlotFromSlotList(value: Slot): void; /** - * @deprecated - * @see dragonBones.EventObject.FRAME_EVENT + * @private */ - static BONE_FRAME_EVENT: string; + _bufferAction(value: ActionData): void; /** - * @deprecated - * @see dragonBones.EventObject.FRAME_EVENT + * @private */ - static MOVEMENT_FRAME_EVENT: string; - } - /** - * @inheritDoc - */ - class EgretArmatureDisplay extends egret.DisplayObjectContainer implements IArmatureDisplay { - private static _clock; - private static _clockHandler(time); + _bufferEvent(value: EventObject, type: string): void; /** - * @private + * @language zh_CN + * 释放骨架。 (会回收到内存池) + * @version DragonBones 3.0 */ - _armature: Armature; + dispose(): void; /** - * @private + * @language zh_CN + * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新) + * @param passedTime 两帧之前的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @see dragonBones.IArmatureDisplay + * @version DragonBones 3.0 */ - constructor(); + advanceTime(passedTime: number): void; /** - * @inheritDoc + * @language zh_CN + * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - _onClear(): void; + invalidUpdate(boneName?: string, updateSlotDisplay?: boolean): void; /** - * @inheritDoc + * @language zh_CN + * 获取指定名称的插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - _dispatchEvent(eventObject: EventObject): void; + getSlot(name: string): Slot; /** - * @inheritDoc + * @language zh_CN + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - advanceTime(passedTime: number): void; + getSlotByDisplay(display: any): Slot; /** - * @inheritDoc + * @language zh_CN + * 将一个指定的插槽添加到骨架中。 + * @param value 需要添加的插槽。 + * @param parentName 需要添加到的父骨骼名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - hasEvent(type: EventStringType): boolean; + addSlot(value: Slot, parentName: string): void; /** - * @inheritDoc + * @language zh_CN + * 将一个指定的插槽从骨架中移除。 + * @param value 需要移除的插槽 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - addEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + removeSlot(value: Slot): void; /** - * @inheritDoc + * @language zh_CN + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + getBone(name: string): Bone; /** - * @inheritDoc + * @language zh_CN + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - advanceTimeBySelf(on: Boolean): void; + getBoneByDisplay(display: any): Bone; /** - * @inheritDoc + * @language zh_CN + * 将一个指定的骨骼添加到骨架中。 + * @param value 需要添加的骨骼。 + * @param parentName 需要添加到父骨骼的名称,如果未设置,则添加到骨架根部。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - dispose(): void; + addBone(value: Bone, parentName?: string): void; /** - * @inheritDoc + * @language zh_CN + * 将一个指定的骨骼从骨架中移除。 + * @param value 需要移除的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - armature: Armature; + removeBone(value: Bone): void; /** - * @inheritDoc + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @param texture 用来替换的贴图,根据渲染平台的不同,类型会有所不同,一般是 Texture 类型。 + * @version DragonBones 4.5 */ - animation: Animation; - } - /** - * @deprecated - * @see dragonBones.Armature - */ - type FastArmature = Armature; - /** - * @deprecated - * @see dragonBones.Bone - */ - type FastBone = Bone; - /** - * @deprecated - * @see dragonBones.Slot - */ - type FastSlot = Slot; - /** - * @deprecated - * @see dragonBones.Animation - */ - type FastAnimation = Animation; - /** - * @deprecated - * @see dragonBones.AnimationState - */ - type FastAnimationState = AnimationState; - /** - * @deprecated - * @see dragonBones.EgretEvent - */ - class AnimationEvent extends EgretEvent { - } - /** - * @deprecated - * @see dragonBones.EgretEvent - */ - class FrameEvent extends EgretEvent { - } - /** - * @deprecated - * @see dragonBones.EgretEvent - */ - class SoundEvent extends EgretEvent { - } - /** - * @deprecated - * @see dragonBones.EgretTextureAtlasData - */ - class EgretTextureAtlas extends EgretTextureAtlasData { - /** - * @private - */ - static toString(): string; - constructor(texture: egret.Texture, rawData: any, scale?: number); - } - /** - * @deprecated - * @see dragonBones.EgretTextureAtlasData - */ - class EgretSheetAtlas extends EgretTextureAtlas { - } - /** - * @deprecated - * @see dragonBones.EgretFactory#soundEventManater - */ - class SoundEventManager { + replaceTexture(texture: any): void; /** - * @deprecated - * @see dragonBones.EgretFactory#soundEventManater + * @language zh_CN + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - static getInstance(): EgretArmatureDisplay; - } - /** - * @deprecated - * @see dragonBones.Armature#cacheFrameRate - * @see dragonBones.Armature#enableAnimationCache() - */ - class AnimationCacheManager { - } -} -declare namespace dragonBones { - /** - * @private - */ - class ColorTransform { - alphaMultiplier: number; - redMultiplier: number; - greenMultiplier: number; - blueMultiplier: number; - alphaOffset: number; - redOffset: number; - greenOffset: number; - blueOffset: number; - constructor(alphaMultiplier?: number, redMultiplier?: number, greenMultiplier?: number, blueMultiplier?: number, alphaOffset?: number, redOffset?: number, greenOffset?: number, blueOffset?: number); - copyFrom(value: ColorTransform): void; - identity(): void; - } -} -declare namespace dragonBones { - /** - * @private - */ - type BuildArmaturePackage = { - dataName?: string; - data?: DragonBonesData; - armature?: ArmatureData; - skin?: SkinData; - }; - /** - * @language zh_CN - * 生成骨架的基础工厂。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - */ - abstract class BaseFactory { + getBones(): Array; /** * @language zh_CN - * 是否开启共享搜索。 [true: 开启, false: 不开启] - * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) - * @see dragonBones.DragonBonesData#autoSearch - * @see dragonBones.TextureAtlasData#autoSearch - * @version DragonBones 4.5 + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - autoSearch: boolean; + getSlots(): Array; /** - * @private + * @language zh_CN + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 */ - protected _objectDataParser: ObjectDataParser; + name: string; /** - * @private + * @language zh_CN + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 */ - protected _dragonBonesDataMap: Map; + armatureData: ArmatureData; /** - * @private + * @language zh_CN + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 */ - protected _textureAtlasDataMap: Map>; + animation: Animation; /** - * @private + * @language zh_CN + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 */ - constructor(); + display: IArmatureDisplay | any; /** - * @private + * @language zh_CN + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 */ - protected _getTextureData(dragonBonesName: string, textureName: string): TextureData; + parent: Slot; /** - * @private + * @language zh_CN + * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 */ - protected _fillBuildArmaturePackage(dragonBonesName: string, armatureName: string, skinName: string, dataPackage: BuildArmaturePackage): boolean; + cacheFrameRate: number; /** - * @private + * @language zh_CN + * 开启动画缓存。 + * @param frameRate 动画缓存的帧率 + * @see #cacheFrameRate + * @version DragonBones 4.5 */ - protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; + enableAnimationCache(frameRate: number): void; /** - * @private + * @language zh_CN + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @returns [true: 包含, false: 不包含] + * @version DragonBones 3.0 */ - protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; + hasEventListener(type: EventStringType): void; /** - * @private + * @language zh_CN + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 3.0 */ - protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void; + addEventListener(type: EventStringType, listener: Function, target: any): void; /** - * @private + * @language zh_CN + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 + * @version DragonBones 3.0 */ - protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData; + removeEventListener(type: EventStringType, listener: Function, target: any): void; /** - * @private + * @deprecated + * @see #display */ - protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature; + getDisplay(): any; /** - * @private + * @deprecated + * @see #cacheFrameRate */ - protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet): Slot; + enableCache: boolean; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 基础变换对象。 + * @version DragonBones 4.5 + */ + abstract class TransformObject extends BaseObject { /** * @language zh_CN - * 解析并添加龙骨数据。 - * @param rawData 需要解析的原始数据。 (JSON) - * @param dragonBonesName 为数据提供一个名称,以便可以通过这个名称来获取数据,状态,则使用数据中的名称。 - * @returns DragonBonesData - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 4.5 + * 可以用于存储临时数据。 + * @version DragonBones 3.0 */ - parseDragonBonesData(rawData: any, dragonBonesName?: string): DragonBonesData; + userData: any; /** * @language zh_CN - * 解析并添加贴图集数据。 - * @param rawData 需要解析的原始数据。 (JSON) - * @param textureAtlas 贴图集数据。 (JSON) - * @param name 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 - * @param scale 为贴图集设置一个缩放值。 - * @returns 贴图集数据 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 + * 对象的名称。 + * @version DragonBones 3.0 */ - parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData; + name: string; /** * @language zh_CN - * 获取指定名称的龙骨数据。 - * @param name 数据名称。 - * @returns DragonBonesData - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData + * 相对于骨架坐标系的矩阵。 * @version DragonBones 3.0 */ - getDragonBonesData(name: string): DragonBonesData; + globalTransformMatrix: Matrix; /** * @language zh_CN - * 添加龙骨数据。 - * @param data 龙骨数据。 - * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform * @version DragonBones 3.0 */ - addDragonBonesData(data: DragonBonesData, dragonBonesName?: string): void; + global: Transform; /** * @language zh_CN - * 移除龙骨数据。 - * @param dragonBonesName 数据名称。 - * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform * @version DragonBones 3.0 */ - removeDragonBonesData(dragonBonesName: string, disposeData?: boolean): void; + origin: Transform; /** * @language zh_CN - * 获取指定名称的贴图集数据列表。 - * @param dragonBonesName 数据名称。 - * @returns 贴图集数据列表。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.textures.TextureAtlasData + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform * @version DragonBones 3.0 */ - getTextureAtlasData(dragonBonesName: string): Array; + offset: Transform; /** - * @language zh_CN - * 添加贴图集数据。 - * @param data 贴图集数据。 - * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.textures.TextureAtlasData - * @version DragonBones 3.0 + * @private */ - addTextureAtlasData(data: TextureAtlasData, dragonBonesName?: string): void; + _armature: Armature; /** - * @language zh_CN - * 移除贴图集数据。 - * @param dragonBonesName 数据名称。 - * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.textures.TextureAtlasData - * @version DragonBones 3.0 + * @private */ - removeTextureAtlasData(dragonBonesName: string, disposeData?: boolean): void; + _parent: Bone; /** - * @language zh_CN - * 清除所有的数据。 - * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] - * @version DragonBones 4.5 + * @private */ - clear(disposeData?: Boolean): void; + protected _globalTransformMatrix: Matrix; /** - * @language zh_CN - * 创建一个指定名称的骨架。 - * @param armatureName 骨架数据名称。 - * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 - * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 - * @returns 骨架 - * @see dragonBones.Armature - * @version DragonBones 3.0 + * @private */ - buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string): Armature; + constructor(); /** - * @language zh_CN - * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) - * @param toArmature 指定的骨架。 - * @param fromArmatreName 其他骨架的名称。 - * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 - * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 - * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除] - * @returns 是否替换成功。 [true: 成功, false: 不成功] - * @see dragonBones.Armature - * @version DragonBones 4.5 + * @inheritDoc */ - copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean; + protected _onClear(): void; /** - * @language zh_CN - * 将指定插槽的显示对象替换为指定资源创造出的显示对象。 - * @param dragonBonesName 指定的龙骨数据名称。 - * @param armatureName 指定的骨架名称。 - * @param slotName 指定的插槽名称。 - * @param displayName 指定的显示对象名称。 - * @param slot 指定的插槽实例。 - * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 - * @version DragonBones 4.5 + * @private */ - replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; + _setArmature(value: Armature): void; + /** + * @private + */ + _setParent(value: Bone): void; /** * @language zh_CN - * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。 - * @param dragonBonesName 指定的 DragonBonesData 名称。 - * @param armatureName 指定的骨架名称。 - * @param slotName 指定的插槽名称。 - * @param slot 指定的插槽实例。 - * @version DragonBones 4.5 + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 */ - replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void; + armature: Armature; /** - * @deprecated - * @see #clear() + * @language zh_CN + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - dispose(): void; + parent: Bone; } } declare namespace dragonBones { + /** + * @private + */ + const enum BoneTransformDirty { + None = 0, + Self = 1, + All = 2, + } /** * @language zh_CN - * Egret 工厂。 + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot * @version DragonBones 3.0 */ - class EgretFactory extends BaseFactory { - /** - * @language zh_CN - * 创建一个工厂。 - * @version DragonBones 3.0 - */ - constructor(); - /** - * @private - */ - protected _generateTextureAtlasData(textureAtlasData: EgretTextureAtlasData, textureAtlas: egret.Texture): EgretTextureAtlasData; - /** - * @private - */ - protected _generateArmature(dataPackage: BuildArmaturePackage): Armature; + class Bone extends TransformObject { /** * @private */ - protected _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet): Slot; + static toString(): string; /** * @language zh_CN - * 创建一个指定名称的骨架,并使用骨架的显示容器来更新骨架动画。 - * @param armatureName 骨架数据名称。 - * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 - * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 - * @returns 骨架的显示容器。 - * @see dragonBones.IArmatureDisplayContainer - * @version DragonBones 4.5 + * 是否继承父骨骼的平移。 [true: 继承, false: 不继承] + * @version DragonBones 3.0 */ - buildArmatureDisplay(armatureName: string, dragonBonesName?: string, skinName?: string): EgretArmatureDisplay; + inheritTranslation: boolean; /** * @language zh_CN - * 获取带有指定贴图的显示对象。 - * @param textureName 指定的贴图名称。 - * @param dragonBonesName 指定的龙骨数据名称,如果未设置,将检索所有的龙骨数据。 + * 是否继承父骨骼的旋转。 [true: 继承, false: 不继承] * @version DragonBones 3.0 */ - getTextureDisplay(textureName: string, dragonBonesName?: string): egret.Bitmap; + inheritRotation: boolean; /** * @language zh_CN - * 获取全局声音事件管理器。 + * 是否继承父骨骼的缩放。 [true: 继承, false: 不继承] * @version DragonBones 4.5 */ - soundEventManater: EgretArmatureDisplay; - /** - * @deprecated - * @see dragonBones.BaseFactory#addDragonBonesData() - */ - addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName?: string): void; - /** - * @deprecated - * @see dragonBones.BaseFactory#getDragonBonesData() - */ - getSkeletonData(dragonBonesName: string): DragonBonesData; - /** - * @deprecated - * @see dragonBones.BaseFactory#removeSkeletonData() - */ - removeSkeletonData(dragonBonesName: string): void; - /** - * @deprecated - * @see dragonBones.BaseFactory#addTextureAtlasData() - */ - addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName?: string): void; + inheritScale: boolean; /** - * @deprecated - * @see dragonBones.BaseFactory#getTextureAtlasData() + * @language zh_CN + * IK 约束时骨骼方向是否为顺时针方向。 [true: 顺时针, false: 逆时针] + * @version DragonBones 4.5 */ - getTextureAtlas(dragonBonesName: string): TextureAtlasData[]; + ikBendPositive: boolean; /** - * @deprecated - * @see dragonBones.BaseFactory#removeTextureAtlasData() + * @language zh_CN + * IK 约束的权重。 + * @version DragonBones 4.5 */ - removeTextureAtlas(dragonBonesName: string): void; + ikWeight: number; /** - * @deprecated - * @see dragonBones.BaseFactory#buildArmature() + * @language zh_CN + * 骨骼长度。 + * @version DragonBones 4.5 */ - buildFastArmature(armatureName: string, dragonBonesName?: string, skinName?: string): FastArmature; - } -} -declare namespace dragonBones { - /** - * @language zh_CN - * Egret 插槽。 - * @version DragonBones 3.0 - */ - class EgretSlot extends Slot { + length: number; /** * @private */ - static toString(): string; + _transformDirty: BoneTransformDirty; /** - * @language zh_CN - * 是否更新显示对象的变换属性。 - * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 - * @default false - * @version DragonBones 3.0 + * @private */ - transformUpdateEnabled: boolean; - private _renderDisplay; - private _colorFilter; + _blendIndex: number; /** - * @language zh_CN - * 创建一个空的插槽。 - * @version DragonBones 3.0 + * @private */ - constructor(); + _cacheFrames: Array; /** - * @inheritDoc + * @private */ - protected _onClear(): void; + _animationPose: Transform; /** * @private */ - protected _onUpdateDisplay(): void; + private _visible; /** * @private */ - protected _initDisplay(value: Object): void; + private _ikChain; /** * @private */ - protected _addDisplay(): void; + private _ikChainIndex; /** * @private */ - protected _replaceDisplay(value: Object): void; + private _ik; /** * @private */ - protected _removeDisplay(): void; + private _bones; /** * @private */ - protected _disposeDisplay(value: Object): void; + private _slots; /** * @private */ - _updateVisible(): void; + constructor(); /** - * @private + * @inheritDoc */ - private static BLEND_MODE_LIST; + protected _onClear(): void; /** * @private */ - protected _updateBlendMode(): void; + private _updateGlobalTransformMatrix(); /** * @private */ - protected _updateColor(): void; + private _computeIKA(); /** * @private */ - protected _updateFilters(): void; + private _computeIKB(); /** - * @private + * @inheritDoc */ - protected _updateFrame(): void; + _setArmature(value: Armature): void; /** * @private */ - protected _updateMesh(): void; + _setIK(value: Bone, chain: number, chainIndex: number): void; /** * @private */ - protected _updateTransform(): void; - } -} -declare namespace dragonBones { - /** - * @language zh_CN - * 2D 矩阵。 - * @version DragonBones 3.0 - */ - class Matrix { - a: number; - b: number; - c: number; - d: number; - tx: number; - ty: number; - constructor(a?: number, b?: number, c?: number, d?: number, tx?: number, ty?: number); + _update(cacheFrameIndex: number): void; /** * @language zh_CN - * 复制矩阵。 - * @param value 需要复制的矩阵。 + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) * @version DragonBones 3.0 */ - copyFrom(value: Matrix): void; + invalidUpdate(): void; /** * @language zh_CN - * 转换为恒等矩阵。 + * 是否包含某个指定的骨骼或插槽。 + * @returns [true: 包含,false: 不包含] + * @see dragonBones.TransformObject * @version DragonBones 3.0 */ - identity(): void; + contains(child: TransformObject): boolean; /** * @language zh_CN - * 将当前矩阵与另一个矩阵相乘。 - * @param value 需要相乘的矩阵。 + * 所有的子骨骼。 * @version DragonBones 3.0 */ - concat(value: Matrix): void; + getBones(): Array; /** * @language zh_CN - * 转换为逆矩阵。 + * 所有的插槽。 + * @see dragonBones.Slot * @version DragonBones 3.0 */ - invert(): void; + getSlots(): Array; + /** + * @private + */ + ikChain: number; + /** + * @private + */ + ikChainIndex: number; /** * @language zh_CN - * 将矩阵转换应用于指定点。 - * @param x 横坐标。 - * @param y 纵坐标。 - * @param result 应用转换之后的坐标。 - * @params delta 是否忽略 tx,ty 对坐标的转换。 + * 当前的 IK 约束目标。 + * @version DragonBones 4.5 + */ + ik: Bone; + /** + * @language zh_CN + * 控制此骨骼所有插槽的显示。 + * @default true + * @see dragonBones.Slot * @version DragonBones 3.0 */ - transformPoint(x: number, y: number, result: { - x: number; - y: number; - }, delta?: boolean): void; - } -} -declare namespace dragonBones { - /** - * @private - */ - class Point { - x: number; - y: number; - constructor(x?: number, y?: number); - copyFrom(value: Point): void; - clear(): void; - } -} -declare namespace dragonBones { - /** - * @private - */ - class Rectangle { - x: number; - y: number; - width: number; - height: number; - constructor(x?: number, y?: number, width?: number, height?: number); - copyFrom(value: Rectangle): void; - clear(): void; + visible: boolean; + /** + * @deprecated + * @see dragonBones.Armature#getSlot() + */ + slot: Slot; } } declare namespace dragonBones { /** * @language zh_CN - * 2D 变换。 - * @version DragonBones 3.0 + * 骨架显示容器和事件的接口。 + * @see dragonBones.Armature#display + * @version DragonBones 4.5 */ - class Transform { + interface IArmatureDisplay extends IEventDispatcher { + /** + * @private + */ + _debugDraw(): void; /** * @language zh_CN - * 水平位移。 - * @version DragonBones 3.0 + * 由显示容器来更新骨架和动画。 + * @param on 开启或关闭显示容器对骨架与动画的更新。 + * @version DragonBones 4.5 */ - x: number; + advanceTimeBySelf(on: boolean): void; /** * @language zh_CN - * 垂直位移。 - * @version DragonBones 3.0 + * 释放显示对象和骨架。 (骨架会回收到内存池) + * @version DragonBones 4.5 */ - y: number; + dispose(): void; /** * @language zh_CN - * 水平倾斜。 (以弧度为单位) - * @version DragonBones 3.0 + * 获取使用这个显示容器的骨架。 + * @readOnly + * @see dragonBones.Armature + * @version DragonBones 4.5 */ - skewX: number; + armature: Armature; /** * @language zh_CN - * 垂直倾斜。 (以弧度为单位) - * @version DragonBones 3.0 + * 获取使用骨架的动画控制器。 + * @readOnly + * @see dragonBones.Animation + * @version DragonBones 4.5 */ - skewY: number; + animation: Animation; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData + * @version DragonBones 3.0 + */ + abstract class Slot extends TransformObject { /** * @language zh_CN - * 水平缩放。 - * @version DragonBones 3.0 + * 子骨架是否继承父骨架的动画。 [true: 继承, false: 不继承] + * @default true + * @version DragonBones 4.5 */ - scaleX: number; + inheritAnimation: boolean; /** * @language zh_CN - * 垂直缩放。 - * @version DragonBones 3.0 + * 显示对象受到控制的对象,应设置为动画状态的名称或组名称,设置为 null 则表示受所有的动画状态控制。 + * @default null + * @see dragonBones.AnimationState#displayControl + * @see dragonBones.AnimationState#name + * @see dragonBones.AnimationState#group + * @version DragonBones 4.5 */ - scaleY: number; + displayController: string; /** * @private */ - static normalizeRadian(value: number): number; + _colorDirty: boolean; /** * @private */ - constructor( - /** - * @language zh_CN - * 水平位移。 - * @version DragonBones 3.0 - */ - x?: number, - /** - * @language zh_CN - * 垂直位移。 - * @version DragonBones 3.0 - */ - y?: number, - /** - * @language zh_CN - * 水平倾斜。 (以弧度为单位) - * @version DragonBones 3.0 - */ - skewX?: number, - /** - * @language zh_CN - * 垂直倾斜。 (以弧度为单位) - * @version DragonBones 3.0 - */ - skewY?: number, - /** - * @language zh_CN - * 水平缩放。 - * @version DragonBones 3.0 - */ - scaleX?: number, - /** - * @language zh_CN - * 垂直缩放。 - * @version DragonBones 3.0 - */ - scaleY?: number); + _ffdDirty: boolean; /** * @private */ - toString(): string; + _blendIndex: number; /** * @private */ - copyFrom(value: Transform): Transform; + _zOrder: number; /** * @private */ - clone(): Transform; + _displayDataSet: SlotDisplayDataSet; /** * @private */ - identity(): Transform; + _meshData: MeshData; /** * @private */ - add(value: Transform): Transform; + _childArmature: Armature; /** * @private */ - minus(value: Transform): Transform; + _rawDisplay: any; /** * @private */ - fromMatrix(matrix: Matrix): Transform; + _meshDisplay: any; /** - * @language zh_CN - * 转换为矩阵。 - * @param 矩阵。 - * @version DragonBones 3.0 + * @private */ - toMatrix(matrix: Matrix): void; + _cacheFrames: Array; /** - * @language zh_CN - * 旋转。 (以弧度为单位) - * @version DragonBones 3.0 + * @private */ - rotation: number; - } -} -declare namespace dragonBones { - /** - * @private - */ - abstract class TimelineData> extends BaseObject { + _colorTransform: ColorTransform; /** * @private */ - scale: number; + _ffdVertices: Array; /** * @private */ - offset: number; + _replacedDisplayDataSet: Array; /** * @private */ - frames: Array; - constructor(); + protected _displayDirty: boolean; /** - * @inheritDoc + * @private */ - protected _onClear(): void; - } - /** - * @private - */ - class BoneTimelineData extends TimelineData { - static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; - static toString(): string; - bone: BoneData; - originTransform: Transform; - cachedFrames: Array; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - cacheFrames(cacheFrameCount: number): void; - } - /** - * @private - */ - class SlotTimelineData extends TimelineData { - static cacheFrame(cacheFrames: Array, cacheFrameIndex: number, globalTransformMatrix: Matrix): Matrix; - static toString(): string; - slot: SlotData; - cachedFrames: Array; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - cacheFrames(cacheFrameCount: number): void; - } - /** - * @private - */ - class FFDTimelineData extends TimelineData { - static toString(): string; - displayIndex: number; - skin: SkinData; - slot: SlotDisplayDataSet; - constructor(); + protected _blendModeDirty: boolean; /** - * @inheritDoc + * @private */ - protected _onClear(): void; - } -} -declare namespace dragonBones { - /** - * @language zh_CN - * 动画数据。 - * @version DragonBones 3.0 - */ - class AnimationData extends TimelineData { + protected _originDirty: boolean; /** * @private */ - static toString(): string; + protected _transformDirty: boolean; /** * @private */ - hasAsynchronyTimeline: boolean; + protected _displayIndex: number; /** - * @language zh_CN - * 持续的帧数。 - * @version DragonBones 3.0 + * @private */ - frameCount: number; + protected _blendMode: BlendMode; /** - * @language zh_CN - * 循环播放的次数。 [0: 无限循环播放, [1~N]: 循环播放 N 次] - * @version DragonBones 3.0 + * @private */ - playTimes: number; + protected _display: any; /** - * @language zh_CN - * 开始的时间。 (以秒为单位) - * @version DragonBones 3.0 + * @private */ - position: number; + protected _localMatrix: Matrix; /** - * @language zh_CN - * 持续的时间。 (以秒为单位) - * @version DragonBones 3.0 + * @private */ - duration: number; + protected _displayList: Array; /** - * @language zh_CN - * 淡入混合的时间。 (以秒为单位) - * @version DragonBones 3.0 + * @private */ - fadeInTime: number; + protected _meshBones: Array; /** * @private */ - cacheTimeToFrameScale: number; + constructor(); /** - * @language zh_CN - * 数据名称。 - * @version DragonBones 3.0 + * @inheritDoc */ - name: string; + protected _onClear(): void; /** * @private */ - animation: AnimationData; + protected abstract _onUpdateDisplay(): void; /** * @private */ - boneTimelines: Map; + protected abstract _initDisplay(value: any): void; /** * @private */ - slotTimelines: Map; + protected abstract _addDisplay(): void; /** * @private */ - ffdTimelines: Map>>; + protected abstract _replaceDisplay(value: any): void; /** * @private */ - cachedFrames: Array; + protected abstract _removeDisplay(): void; /** * @private */ - constructor(); + protected abstract _disposeDisplay(value: any): void; /** - * @inheritDoc + * @private Bone */ - protected _onClear(): void; + abstract _updateVisible(): void; /** * @private */ - cacheFrames(value: number): void; + protected abstract _updateBlendMode(): void; /** * @private */ - addBoneTimeline(value: BoneTimelineData): void; + protected abstract _updateColor(): void; /** * @private */ - addSlotTimeline(value: SlotTimelineData): void; + protected abstract _updateFilters(): void; /** * @private */ - addFFDTimeline(value: FFDTimelineData): void; + protected abstract _updateFrame(): void; /** * @private */ - getBoneTimeline(name: string): BoneTimelineData; + protected abstract _updateMesh(): void; /** * @private */ - getSlotTimeline(name: string): SlotTimelineData; + protected abstract _updateTransform(): void; /** * @private */ - getFFDTimeline(skinName: string, slotName: string, displayIndex: number): FFDTimelineData; - } -} -declare namespace dragonBones { - /** - * @language zh_CN - * 骨架数据。 - * @see dragonBones.Armature - * @version DragonBones 3.0 - */ - class ArmatureData extends BaseObject { - private static _onSortSlots(a, b); + private _isMeshBonesUpdate(); /** * @private */ - static toString(): string; - /** - * @language zh_CN - * 动画帧率。 - * @version DragonBones 3.0 - */ - frameRate: number; + protected _updateDisplay(): void; /** * @private */ - cacheFrameRate: number; - /** - * @language zh_CN - * 骨架类型。 - * @see dragonBones.ArmatureType - * @version DragonBones 3.0 - */ - type: ArmatureType; - /** - * @language zh_CN - * 数据名称。 - * @version DragonBones 3.0 - */ - name: string; + protected _updateLocalTransformMatrix(): void; /** * @private */ - parent: DragonBonesData; - /** - * @language zh_CN - * 所有的骨骼数据。 - * @see dragonBones.BoneData - * @version DragonBones 3.0 - */ - bones: Map; - /** - * @language zh_CN - * 所有的插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 3.0 - */ - slots: Map; + protected _updateGlobalTransformMatrix(): void; /** - * @language zh_CN - * 所有的皮肤数据。 - * @see dragonBones.SkinData - * @version DragonBones 3.0 + * @inheritDoc */ - skins: Map; + _setArmature(value: Armature): void; /** - * @language zh_CN - * 所有的动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 + * @private Armature */ - animations: Map; + _updateMeshData(isTimelineUpdate: Boolean): void; /** - * @private + * @private Armature */ - actions: Array; - private _boneDirty; - private _slotDirty; - private _defaultSkin; - private _defaultAnimation; - private _sortedBones; - private _sortedSlots; - private _bonesChildren; + _update(cacheFrameIndex: number): void; /** - * @private + * @private Factory */ - constructor(); + _setDisplayList(value: Array): Boolean; /** - * @inheritDoc + * @private Factory */ - protected _onClear(): void; - private _sortBones(); - private _sortSlots(); + _setDisplayIndex(value: number): boolean; /** - * @private + * @private Factory */ - cacheFrames(value: number): void; + _setBlendMode(value: BlendMode): boolean; /** - * @private + * @private Factory */ - addBone(value: BoneData, parentName: string): void; + _setColor(value: ColorTransform): boolean; /** - * @private + * @language zh_CN + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 */ - addSlot(value: SlotData): void; + invalidUpdate(): void; /** * @private */ - addSkin(value: SkinData): void; + rawDisplay: any; /** * @private */ - addAnimation(value: AnimationData): void; + MeshDisplay: any; /** * @language zh_CN - * 获取指定名称的骨骼数据。 - * @param name 骨骼数据名称。 - * @see dragonBones.BoneData - * @version DragonBones 3.0 + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 */ - getBone(name: string): BoneData; + displayIndex: number; /** * @language zh_CN - * 获取指定名称的插槽数据。 - * @param name 插槽数据名称。 - * @see dragonBones.SlotData + * 包含显示对象或子骨架的显示列表。 * @version DragonBones 3.0 */ - getSlot(name: string): SlotData; + displayList: Array; /** * @language zh_CN - * 获取指定名称的皮肤数据。 - * @param name 皮肤数据名称。 - * @see dragonBones.SkinData + * 此时显示的显示对象。 * @version DragonBones 3.0 */ - getSkin(name: string): SkinData; + display: any; /** * @language zh_CN - * 获取指定名称的动画数据。 - * @param name 动画数据名称。 - * @see dragonBones.AnimationData + * 此时显示的子骨架。 + * @see dragonBones.Armature * @version DragonBones 3.0 */ - getAnimation(name: string): AnimationData; + childArmature: Armature; /** - * @private + * @deprecated + * @see #display */ - sortedBones: Array; + getDisplay(): any; /** - * @private - */ - sortedSlots: Array; - /** - * @language zh_CN - * 获取默认的皮肤数据。 - * @see dragonBones.SkinData - * @version DragonBones 4.5 - */ - defaultSkin: SkinData; - /** - * @language zh_CN - * 获取默认的动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 4.5 + * @deprecated + * @see #display */ - defaultAnimation: AnimationData; + setDisplay(value: any): void; } +} +declare namespace dragonBones { + /** + * @private + */ + type BuildArmaturePackage = { + dataName?: string; + data?: DragonBonesData; + armature?: ArmatureData; + skin?: SkinData; + }; /** * @language zh_CN - * 骨骼数据。 - * @see dragonBones.Bone + * 生成骨架的基础工厂。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature * @version DragonBones 3.0 */ - class BoneData extends BaseObject { - /** - * @private - */ - static toString(): string; + abstract class BaseFactory { /** - * @private + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 */ - inheritTranslation: boolean; + autoSearch: boolean; /** * @private */ - inheritRotation: boolean; + protected _dataParser: DataParser; /** * @private */ - inheritScale: boolean; + protected _dragonBonesDataMap: Map; /** * @private */ - bendPositive: boolean; + protected _textureAtlasDataMap: Map>; /** * @private */ - chain: number; + constructor(dataParser?: DataParser); /** * @private */ - chainIndex: number; + protected _getTextureData(dragonBonesName: string, textureName: string): TextureData; /** * @private */ - weight: number; + protected _fillBuildArmaturePackage(dragonBonesName: string, armatureName: string, skinName: string, dataPackage: BuildArmaturePackage): boolean; /** * @private */ - length: number; - /** - * @language zh_CN - * 数据名称。 - * @version DragonBones 3.0 - */ - name: string; - /** - * @language zh_CN - * 所属的父骨骼数据。 - * @version DragonBones 3.0 - */ - parent: BoneData; + protected _buildBones(dataPackage: BuildArmaturePackage, armature: Armature): void; /** * @private */ - ik: BoneData; + protected _buildSlots(dataPackage: BuildArmaturePackage, armature: Armature): void; /** * @private */ - transform: Transform; + protected _replaceSlotDisplay(dataPackage: BuildArmaturePackage, displayData: DisplayData, slot: Slot, displayIndex: number): void; /** * @private */ - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @language zh_CN - * 插槽数据。 - * @see dragonBones.Slot - * @version DragonBones 3.0 - */ - class SlotData extends BaseObject { + protected abstract _generateTextureAtlasData(textureAtlasData: TextureAtlasData, textureAtlas: any): TextureAtlasData; /** * @private */ - static DEFAULT_COLOR: ColorTransform; + protected abstract _generateArmature(dataPackage: BuildArmaturePackage): Armature; /** * @private */ - static generateColor(): ColorTransform; + protected abstract _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet): Slot; /** - * @private + * @language zh_CN + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param dragonBonesName 为数据提供一个名称,以便可以通过这个名称来获取数据,状态,则使用数据中的名称。 + * @returns DragonBonesData + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 */ - static toString(): string; + parseDragonBonesData(rawData: any, dragonBonesName?: string): DragonBonesData; /** - * @private + * @language zh_CN + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图集数据。 (JSON) + * @param name 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 */ - displayIndex: number; + parseTextureAtlasData(rawData: any, textureAtlas: Object, name?: string, scale?: number): TextureAtlasData; /** - * @private + * @language zh_CN + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 */ - zOrder: number; + getDragonBonesData(name: string): DragonBonesData; /** - * @private + * @language zh_CN + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 */ - blendMode: BlendMode; + addDragonBonesData(data: DragonBonesData, dragonBonesName?: string): void; /** * @language zh_CN - * 数据名称。 + * 移除龙骨数据。 + * @param dragonBonesName 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData * @version DragonBones 3.0 */ - name: string; + removeDragonBonesData(dragonBonesName: string, disposeData?: boolean): void; /** * @language zh_CN - * 所属的父骨骼数据。 - * @see dragonBones.BoneData + * 获取指定名称的贴图集数据列表。 + * @param dragonBonesName 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData * @version DragonBones 3.0 */ - parent: BoneData; + getTextureAtlasData(dragonBonesName: string): Array; /** - * @private + * @language zh_CN + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 */ - color: ColorTransform; + addTextureAtlasData(data: TextureAtlasData, dragonBonesName?: string): void; /** - * @private + * @language zh_CN + * 移除贴图集数据。 + * @param dragonBonesName 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 */ - actions: Array; + removeTextureAtlasData(dragonBonesName: string, disposeData?: boolean): void; /** - * @private + * @language zh_CN + * 清除所有的数据。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @version DragonBones 4.5 */ - constructor(); + clear(disposeData?: Boolean): void; /** - * @inheritDoc + * @language zh_CN + * 创建一个指定名称的骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @returns 骨架 + * @see dragonBones.Armature + * @version DragonBones 3.0 */ - protected _onClear(): void; - } - /** - * @language zh_CN - * 皮肤数据。 - * @version DragonBones 3.0 - */ - class SkinData extends BaseObject { + buildArmature(armatureName: string, dragonBonesName?: string, skinName?: string): Armature; /** - * @private + * @language zh_CN + * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除] + * @returns 是否替换成功。 [true: 成功, false: 不成功] + * @see dragonBones.Armature + * @version DragonBones 4.5 */ - static toString(): string; + copyAnimationsToArmature(toArmature: Armature, fromArmatreName: string, fromSkinName?: string, fromDragonBonesDataName?: string, ifRemoveOriginalAnimationList?: boolean): boolean; /** * @language zh_CN - * 数据名称。 - * @version DragonBones 3.0 + * 将指定插槽的显示对象替换为指定资源创造出的显示对象。 + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 */ - name: string; + replaceSlotDisplay(dragonBonesName: string, armatureName: string, slotName: string, displayName: string, slot: Slot, displayIndex?: number): void; /** - * @private + * @language zh_CN + * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 */ - slots: Map; + replaceSlotDisplayList(dragonBonesName: string, armatureName: string, slotName: string, slot: Slot): void; /** - * @private - */ - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - /** - * @private - */ - addSlot(value: SlotDisplayDataSet): void; - /** - * @private - */ - getSlot(name: string): SlotDisplayDataSet; - } - /** - * @private - */ - class SlotDisplayDataSet extends BaseObject { - static toString(): string; - slot: SlotData; - displays: Array; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @private - */ - class DisplayData extends BaseObject { - static toString(): string; - isRelativePivot: boolean; - type: DisplayType; - name: string; - textureData: TextureData; - armatureData: ArmatureData; - meshData: MeshData; - pivot: Point; - transform: Transform; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @private - */ - class MeshData extends BaseObject { - static toString(): string; - skinned: boolean; - slotPose: Matrix; - uvs: Array; - vertices: Array; - vertexIndices: Array; - boneIndices: Array>; - weights: Array>; - boneVertices: Array>; - bones: Array; - inverseBindPose: Array; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } -} -declare namespace dragonBones { - /** - * @language zh_CN - * 龙骨数据,包含多个骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - */ - class DragonBonesData extends BaseObject { - /** - * @private - */ - static toString(): string; - /** - * @language zh_CN - * 是否开启共享搜索。 [true: 开启, false: 不开启] - * @default false - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - */ - autoSearch: boolean; - /** - * @language zh_CN - * 动画帧频。 - * @version DragonBones 3.0 - */ - frameRate: number; - /** - * @language zh_CN - * 数据名称。 - * @version DragonBones 3.0 - */ - name: string; - /** - * @language zh_CN - * 所有的骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - */ - armatures: Map; - private _armatureNames; - /** - * @private - */ - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - /** - * @language zh_CN - * 获取指定名称的骨架。 - * @param name 骨架数据骨架名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - */ - getArmature(name: string): ArmatureData; - /** - * @private - */ - addArmature(value: ArmatureData): void; - /** - * @language zh_CN - * 所有的骨架数据名称。 - * @see #armatures - * @version DragonBones 3.0 - */ - armatureNames: Array; - /** - * @deprecated - * @see dragonBones.BaseFactory#removeDragonBonesData() + * @deprecated + * @see #clear() */ dispose(): void; } } -declare namespace dragonBones { - /** - * @private - */ - class ActionData extends BaseObject { - static toString(): string; - type: ActionType; - data: Array; - bone: BoneData; - slot: SlotData; - constructor(); - protected _onClear(): void; - } - /** - * @private - */ - class EventData extends BaseObject { - static toString(): string; - type: EventType; - name: string; - data: any; - bone: BoneData; - slot: SlotData; - constructor(); - protected _onClear(): void; - } - /** - * @private - */ - abstract class FrameData extends BaseObject { - position: number; - duration: number; - prev: T; - next: T; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @private - */ - abstract class TweenFrameData extends FrameData { - static samplingCurve(curve: Array, frameCount: number): Array; - tweenEasing: number; - curve: Array; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @private - */ - class AnimationFrameData extends FrameData { - static toString(): string; - actions: Array; - events: Array; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @private - */ - class BoneFrameData extends TweenFrameData { - static toString(): string; - tweenScale: boolean; - tweenRotate: number; - transform: Transform; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @private - */ - class SlotFrameData extends TweenFrameData { - static DEFAULT_COLOR: ColorTransform; - static generateColor(): ColorTransform; - static toString(): string; - displayIndex: number; - zOrder: number; - color: ColorTransform; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } - /** - * @private - */ - class ExtensionFrameData extends TweenFrameData { - static toString(): string; - type: ExtensionType; - tweens: Array; - keys: Array; - constructor(); - /** - * @inheritDoc - */ - protected _onClear(): void; - } -} declare namespace dragonBones { /** * @private @@ -3912,6 +3404,7 @@ declare namespace dragonBones { protected static FRAME: string; protected static PIVOT: string; protected static TRANSFORM: string; + protected static AABB: string; protected static COLOR: string; protected static FILTER: string; protected static VERSION: string; @@ -3989,171 +3482,716 @@ declare namespace dragonBones { protected _mesh: MeshData; protected _animation: AnimationData; protected _timeline: any; - protected _isParentCooriinate: boolean; + protected _isOldData: boolean; + protected _isGlobalTransform: boolean; protected _isAutoTween: boolean; protected _animationTweenEasing: number; + protected _timelinePivot: Point; protected _armatureScale: number; protected _helpPoint: Point; - protected _helpTransform: Transform; + protected _helpTransformA: Transform; + protected _helpTransformB: Transform; protected _helpMatrix: Matrix; protected _rawBones: Array; constructor(); /** - * @private + * @private + */ + abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData; + /** + * @private + */ + abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void; + private _getTimelineFrameMatrix(animation, timeline, position, transform); + protected _globalToLocal(armature: ArmatureData): void; + protected _mergeFrameToAnimationTimeline>(frame: T, actions: Array, events: Array): void; + /** + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static parseDragonBonesData(rawData: any): DragonBonesData; + /** + * @deprecated + * @see dragonBones.BaseFactory#parsetTextureAtlasData() + */ + static parseTextureAtlasData(rawData: any, scale?: number): any; + } +} +declare namespace dragonBones { + /** + * @private + */ + class ObjectDataParser extends DataParser { + /** + * @private + */ + protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + /** + * @private + */ + protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + /** + * @private + */ + protected static _getString(rawData: any, key: string, defaultValue: string): string; + /** + * @private + */ + protected static _getParameter(rawData: Array, index: number, defaultValue: any): any; + /** + * @private + */ + constructor(); + /** + * @private + */ + protected _parseArmature(rawData: any): ArmatureData; + /** + * @private + */ + protected _parseBone(rawData: any): BoneData; + /** + * @private + */ + protected _parseIK(rawData: any): void; + /** + * @private + */ + protected _parseSlot(rawData: any): SlotData; + /** + * @private + */ + protected _parseSkin(rawData: any): SkinData; + /** + * @private + */ + protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet; + /** + * @private + */ + protected _parseDisplay(rawData: any): DisplayData; + /** + * @private + */ + protected _parseMesh(rawData: any): MeshData; + /** + * @private + */ + protected _parseAnimation(rawData: any): AnimationData; + /** + * @private + */ + protected _parseBoneTimeline(rawData: any): BoneTimelineData; + /** + * @private + */ + protected _parseSlotTimeline(rawData: any): SlotTimelineData; + /** + * @private + */ + protected _parseFFDTimeline(rawData: any): FFDTimelineData; + /** + * @private + */ + protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData; + /** + * @private + */ + protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData; + /** + * @private + */ + protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData; + /** + * @private + */ + protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData; + /** + * @private + */ + protected _parseTweenFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + /** + * @private + */ + protected _parseFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + /** + * @private + */ + protected _parseTimeline>(rawData: Object, timeline: TimelineData, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void; + /** + * @private + */ + protected _parseActionData(rawData: any, actions: Array, bone: BoneData, slot: SlotData): void; + /** + * @private + */ + protected _parseEventData(rawData: any, events: Array, bone: BoneData, slot: SlotData): void; + /** + * @private + */ + protected _parseTransform(rawData: Object, transform: Transform): void; + /** + * @private + */ + protected _parseColorTransform(rawData: Object, color: ColorTransform): void; + /** + * @inheritDoc + */ + parseDragonBonesData(rawData: any, scale?: number): DragonBonesData; + /** + * @inheritDoc + */ + parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): TextureAtlasData; + /** + * @private + */ + private static _instance; + /** + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + static getInstance(): ObjectDataParser; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * 贴图集数据。 + * @version DragonBones 3.0 + */ + abstract class TextureAtlasData extends BaseObject { + /** + * @language zh_CN + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * @default false + * @version DragonBones 4.5 + */ + autoSearch: boolean; + /** + * @language zh_CN + * 贴图集缩放系数。 + * @version DragonBones 3.0 + */ + scale: number; + /** + * @language zh_CN + * 贴图集名称。 + * @version DragonBones 3.0 + */ + name: string; + /** + * @language zh_CN + * 贴图集图片路径。 + * @version DragonBones 3.0 + */ + imagePath: string; + /** + * @private + */ + textures: Map; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @deprecated + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + dispose(): void; + /** + * @private + */ + abstract generateTextureData(): TextureData; + /** + * @private + */ + addTextureData(value: TextureData): void; + /** + * @private + */ + getTextureData(name: string): TextureData; + } + /** + * @private + */ + abstract class TextureData extends BaseObject { + static generateRectangle(): Rectangle; + rotated: boolean; + name: string; + frame: Rectangle; + parent: TextureAtlasData; + region: Rectangle; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * Egret 贴图集数据。 + * @version DragonBones 3.0 + */ + class EgretTextureAtlasData extends TextureAtlasData { + /** + * @private + */ + static toString(): string; + /** + * @language zh_CN + * Egret 贴图。 + * @version DragonBones 3.0 + */ + texture: egret.Texture; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + /** + * @private + */ + generateTextureData(): TextureData; + } + /** + * @private + */ + class EgretTextureData extends TextureData { + static toString(): string; + texture: egret.Texture; + constructor(); + /** + * @inheritDoc + */ + protected _onClear(): void; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * Egret 事件。 + * @version DragonBones 4.5 + */ + class EgretEvent extends egret.Event { + /** + * @language zh_CN + * 事件对象。 + * @version DragonBones 4.5 + */ + eventObject: EventObject; + /** + * @private + */ + constructor(type: EventStringType, bubbles?: boolean, cancelable?: boolean, data?: any); + /** + * @see dragonBones.EventObject#name + */ + frameLabel: string; + /** + * @see dragonBones.EventObject#name + */ + sound: string; + /** + * @see dragonBones.EventObject#animationName + */ + animationName: string; + /** + * @see dragonBones.EventObject#armature + */ + armature: Armature; + /** + * @see dragonBones.EventObject#bone + */ + bone: Bone; + /** + * @see dragonBones.EventObject#slot + */ + slot: Slot; + /** + * @see dragonBones.EventObject#animationState + */ + animationState: AnimationState; + /** + * @deprecated + * @see #animationName + */ + movementID: string; + /** + * @see dragonBones.EventObject.START + */ + static START: string; + /** + * @see dragonBones.EventObject.LOOP_COMPLETE + */ + static LOOP_COMPLETE: string; + /** + * @see dragonBones.EventObject.COMPLETE + */ + static COMPLETE: string; + /** + * @see dragonBones.EventObject.FADE_IN + */ + static FADE_IN: string; + /** + * @see dragonBones.EventObject.FADE_IN_COMPLETE + */ + static FADE_IN_COMPLETE: string; + /** + * @see dragonBones.EventObject.FADE_OUT + */ + static FADE_OUT: string; + /** + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + static FADE_OUT_COMPLETE: string; + /** + * @see dragonBones.EventObject.FRAME_EVENT + */ + static FRAME_EVENT: string; + /** + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND_EVENT: string; + /** + * @deprecated + * @see dragonBones.EventObject.FRAME_EVENT + */ + static ANIMATION_FRAME_EVENT: string; + /** + * @deprecated + * @see dragonBones.EventObject.FRAME_EVENT + */ + static BONE_FRAME_EVENT: string; + /** + * @deprecated + * @see dragonBones.EventObject.FRAME_EVENT + */ + static MOVEMENT_FRAME_EVENT: string; + /** + * @deprecated + * @see dragonBones.EventObject.SOUND_EVENT + */ + static SOUND: string; + } + /** + * @inheritDoc + */ + class EgretArmatureDisplay extends egret.DisplayObjectContainer implements IArmatureDisplay { + static passTime: number; + private static _clock; + private static _clockHandler(time); + /** + * @private + */ + _armature: Armature; + private _debugDrawer; + /** + * @private + */ + constructor(); + /** + * @inheritDoc + */ + _onClear(): void; + /** + * @inheritDoc + */ + _dispatchEvent(eventObject: EventObject): void; + /** + * @inheritDoc + */ + _debugDraw(): void; + /** + * @inheritDoc */ - abstract parseDragonBonesData(rawData: any, scale: number): DragonBonesData; + hasEvent(type: EventStringType): boolean; /** - * @private + * @inheritDoc */ - abstract parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale: number): void; - private _getTimelineFrameMatrix(animation, timeline, position, transform); - protected _mergeFrameToAnimationTimeline>(frame: T, actions: Array, events: Array): void; - protected _globalToLocal(armature: ArmatureData): void; + addEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; /** - * @deprecated - * @see dragonBones.BaseFactory#parseDragonBonesData() + * @inheritDoc */ - static parseDragonBonesData(rawData: any): DragonBonesData; + removeEvent(type: EventStringType, listener: (event: EgretEvent) => void, target: any): void; + /** + * @inheritDoc + */ + advanceTimeBySelf(on: Boolean): void; + /** + * @inheritDoc + */ + dispose(): void; + /** + * @inheritDoc + */ + armature: Armature; + /** + * @inheritDoc + */ + animation: Animation; + } + /** + * @deprecated + * @see dragonBones.Armature + */ + type FastArmature = Armature; + /** + * @deprecated + * @see dragonBones.Bone + */ + type FastBone = Bone; + /** + * @deprecated + * @see dragonBones.Slot + */ + type FastSlot = Slot; + /** + * @deprecated + * @see dragonBones.Animation + */ + type FastAnimation = Animation; + /** + * @deprecated + * @see dragonBones.AnimationState + */ + type FastAnimationState = AnimationState; + /** + * @deprecated + * @see dragonBones.EgretEvent + */ + class AnimationEvent extends EgretEvent { + } + /** + * @deprecated + * @see dragonBones.EgretEvent + */ + class FrameEvent extends EgretEvent { + } + /** + * @deprecated + * @see dragonBones.EgretEvent + */ + class SoundEvent extends EgretEvent { + } + /** + * @deprecated + * @see dragonBones.EgretTextureAtlasData + */ + class EgretTextureAtlas extends EgretTextureAtlasData { + /** + * @private + */ + static toString(): string; + constructor(texture: egret.Texture, rawData: any, scale?: number); + } + /** + * @deprecated + * @see dragonBones.EgretTextureAtlasData + */ + class EgretSheetAtlas extends EgretTextureAtlas { + } + /** + * @deprecated + * @see dragonBones.EgretFactory#soundEventManater + */ + class SoundEventManager { /** * @deprecated - * @see dragonBones.BaseFactory#parsetTextureAtlasData() + * @see dragonBones.EgretFactory#soundEventManater */ - static parseTextureAtlasData(rawData: any, scale?: number): any; + static getInstance(): EgretArmatureDisplay; + } + /** + * @deprecated + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + class AnimationCacheManager { } } declare namespace dragonBones { /** - * @private + * @language zh_CN + * Egret 工厂。 + * @version DragonBones 3.0 */ - class ObjectDataParser extends DataParser { + class EgretFactory extends BaseFactory { /** - * @private + * @language zh_CN + * 创建一个工厂。 + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 */ - protected static _getBoolean(rawData: any, key: string, defaultValue: boolean): boolean; + constructor(dataParser?: DataParser); /** * @private */ - protected static _getNumber(rawData: any, key: string, defaultValue: number): number; + protected _generateTextureAtlasData(textureAtlasData: EgretTextureAtlasData, textureAtlas: egret.Texture): EgretTextureAtlasData; /** * @private */ - protected static _getString(rawData: any, key: string, defaultValue: string): string; + protected _generateArmature(dataPackage: BuildArmaturePackage): Armature; /** * @private */ - protected static _getParameter(rawData: Array, index: number, defaultValue: any): any; + protected _generateSlot(dataPackage: BuildArmaturePackage, slotDisplayDataSet: SlotDisplayDataSet): Slot; /** - * @private + * @language zh_CN + * 创建一个指定名称的骨架,并使用骨架的显示容器来更新骨架动画。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @returns 骨架的显示容器。 + * @see dragonBones.IArmatureDisplayContainer + * @version DragonBones 4.5 */ - constructor(); + buildArmatureDisplay(armatureName: string, dragonBonesName?: string, skinName?: string): EgretArmatureDisplay; /** - * @private + * @language zh_CN + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param dragonBonesName 指定的龙骨数据名称,如果未设置,将检索所有的龙骨数据。 + * @version DragonBones 3.0 */ - protected _parseArmature(rawData: any): ArmatureData; + getTextureDisplay(textureName: string, dragonBonesName?: string): egret.Bitmap; /** - * @private + * @language zh_CN + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 */ - protected _parseBone(rawData: any): BoneData; + soundEventManater: EgretArmatureDisplay; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#addDragonBonesData() */ - protected _parseIK(rawData: any): void; + addSkeletonData(dragonBonesData: DragonBonesData, dragonBonesName?: string): void; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#getDragonBonesData() */ - protected _parseSlot(rawData: any): SlotData; + getSkeletonData(dragonBonesName: string): DragonBonesData; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#removeSkeletonData() */ - protected _parseSkin(rawData: any): SkinData; + removeSkeletonData(dragonBonesName: string): void; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#addTextureAtlasData() */ - protected _parseSlotDisplaySet(rawData: any): SlotDisplayDataSet; + addTextureAtlas(textureAtlasData: TextureAtlasData, dragonBonesName?: string): void; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#getTextureAtlasData() */ - protected _parseDisplay(rawData: any): DisplayData; + getTextureAtlas(dragonBonesName: string): TextureAtlasData[]; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#removeTextureAtlasData() */ - protected _parseMesh(rawData: any): MeshData; + removeTextureAtlas(dragonBonesName: string): void; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#buildArmature() */ - protected _parseAnimation(rawData: any): AnimationData; + buildFastArmature(armatureName: string, dragonBonesName?: string, skinName?: string): FastArmature; + } +} +declare namespace dragonBones { + /** + * @language zh_CN + * Egret 插槽。 + * @version DragonBones 3.0 + */ + class EgretSlot extends Slot { /** * @private */ - protected _parseBoneTimeline(rawData: any): BoneTimelineData; + static toString(): string; /** - * @private + * @language zh_CN + * 是否更新显示对象的变换属性。 + * 为了更好的性能, 并不会更新 display 的变换属性 (x, y, rotation, scaleX, scaleX), 如果需要正确访问这些属性, 则需要设置为 true 。 + * @default false + * @version DragonBones 3.0 */ - protected _parseSlotTimeline(rawData: any): SlotTimelineData; + transformUpdateEnabled: boolean; + private _renderDisplay; + private _colorFilter; /** - * @private + * @language zh_CN + * 创建一个空的插槽。 + * @version DragonBones 3.0 */ - protected _parseFFDTimeline(rawData: any): FFDTimelineData; + constructor(); /** - * @private + * @inheritDoc */ - protected _parseAnimationFrame(rawData: any, frameStart: number, frameCount: number): AnimationFrameData; + protected _onClear(): void; /** * @private */ - protected _parseBoneFrame(rawData: Object, frameStart: number, frameCount: number): BoneFrameData; + protected _onUpdateDisplay(): void; /** * @private */ - protected _parseSlotFrame(rawData: any, frameStart: number, frameCount: number): SlotFrameData; + protected _initDisplay(value: Object): void; /** * @private */ - protected _parseFFDFrame(rawData: any, frameStart: number, frameCount: number): ExtensionFrameData; + protected _addDisplay(): void; /** * @private */ - protected _parseTweenFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + protected _replaceDisplay(value: Object): void; /** * @private */ - protected _parseFrame>(rawData: any, frame: T, frameStart: number, frameCount: number): void; + protected _removeDisplay(): void; /** * @private */ - protected _parseTimeline>(rawData: Object, timeline: TimelineData, frameParser: (rawData: any, frameStart: number, frameCount: number) => T): void; + protected _disposeDisplay(value: Object): void; /** * @private */ - protected _parseActionData(rawData: any, actions: Array, bone: BoneData, slot: SlotData): void; + _updateVisible(): void; /** * @private */ - protected _parseEventData(rawData: any, events: Array, bone: BoneData, slot: SlotData): void; + private static BLEND_MODE_LIST; /** * @private */ - protected _parseTransform(rawData: Object, transform: Transform): void; + protected _updateBlendMode(): void; /** * @private */ - protected _parseColorTransform(rawData: Object, color: ColorTransform): void; + protected _updateColor(): void; /** - * @inheritDoc + * @private */ - parseDragonBonesData(rawData: any, scale?: number): DragonBonesData; + protected _updateFilters(): void; /** - * @inheritDoc + * @private */ - parseTextureAtlasData(rawData: any, textureAtlasData: TextureAtlasData, scale?: number): TextureAtlasData; + protected _updateFrame(): void; /** - * @deprecated + * @private */ - private static _instance; + protected _updateMesh(): void; /** - * @deprecated - * @see dragonBones.BaseFactory#parseDragonBonesData() + * @private */ - static getInstance(): ObjectDataParser; + protected _updateTransform(): void; } } diff --git a/build/dragonBones/dragonBones.js b/build/dragonBones/dragonBones.js index 43dfbfcfc2..10fc594830 100644 --- a/build/dragonBones/dragonBones.js +++ b/build/dragonBones/dragonBones.js @@ -1,3 +1,8 @@ +var __extends = (this && this.__extends) || function (d, b) { + for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; + function __() { this.constructor = d; } + d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); +}; var dragonBones; (function (dragonBones) { /** @@ -17,7 +22,6 @@ var dragonBones; */ this.hashCode = BaseObject._hashCode++; } - var d = __define,c=BaseObject,p=c.prototype; BaseObject._returnObject = function (object) { var objectConstructor = object.constructor; var classType = String(objectConstructor); @@ -113,7 +117,7 @@ var dragonBones; * 清除数据并返还对象池。 * @version DragonBones 4.5 */ - p.returnToPool = function () { + BaseObject.prototype.returnToPool = function () { this._onClear(); BaseObject._returnObject(this); }; @@ -124,3623 +128,2590 @@ var dragonBones; return BaseObject; }()); dragonBones.BaseObject = BaseObject; - egret.registerClass(BaseObject,'dragonBones.BaseObject'); })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** - * @language zh_CN - * 动画控制器,用来播放动画数据,管理动画状态。 - * @see dragonBones.AnimationData - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * DragonBones */ - var Animation = (function (_super) { - __extends(Animation, _super); + var DragonBones = (function () { /** * @private */ - function Animation() { - _super.call(this); - /** - * @private - */ - this._animations = {}; - /** - * @private - */ - this._animationNames = []; - /** - * @private - */ - this._animationStates = []; + function DragonBones() { } - var d = __define,c=Animation,p=c.prototype; /** * @private */ - Animation._sortAnimationState = function (a, b) { - return a.layer > b.layer ? 1 : -1; + DragonBones.hasArmature = function (value) { + return DragonBones._armatures.indexOf(value) >= 0; }; /** * @private */ - Animation.toString = function () { - return "[Class dragonBones.Animation]"; + DragonBones.addArmature = function (value) { + if (value && DragonBones._armatures.indexOf(value) < 0) { + DragonBones._armatures.push(value); + } }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - self.timeScale = 1; - self._animationStateDirty = false; - self._timelineStateDirty = false; - self._armature = null; - self._isPlaying = false; - self._time = 0; - self._lastAnimationState = null; - for (var i in self._animations) { - delete self._animations[i]; - } - if (self._animationNames.length) { - self._animationNames.length = 0; - } - for (var i = 0, l = self._animationStates.length; i < l; ++i) { - self._animationStates[i].returnToPool(); + DragonBones.removeArmature = function (value) { + if (value) { + var index = DragonBones._armatures.indexOf(value); + if (index >= 0) { + DragonBones._armatures.splice(index, 1); + } } - self._animationStates.length = 0; }; /** * @private */ - p._fadeOut = function (fadeOutTime, layer, group, fadeOutMode, pauseFadeOut) { - var self = this; - var i = 0, l = self._animationStates.length; - var animationState = null; - switch (fadeOutMode) { - case 0 /* None */: - break; - case 1 /* SameLayer */: - for (; i < l; ++i) { - animationState = self._animationStates[i]; - if (animationState.layer == layer) { - animationState.fadeOut(fadeOutTime, pauseFadeOut); - } - } - break; - case 2 /* SameGroup */: - for (; i < l; ++i) { - animationState = self._animationStates[i]; - if (animationState.group == group) { - animationState.fadeOut(fadeOutTime, pauseFadeOut); - } - } - break; - case 4 /* All */: - for (; i < l; ++i) { - animationState = self._animationStates[i]; - animationState.fadeOut(fadeOutTime, pauseFadeOut); - } - break; - case 3 /* SameLayerAndGroup */: - for (; i < l; ++i) { - animationState = self._animationStates[i]; - if (animationState.layer == layer && animationState.group == group) { - animationState.fadeOut(fadeOutTime, pauseFadeOut); - } - } - break; - } - }; + DragonBones.PI_D = Math.PI * 2; /** * @private */ - p._updateFFDTimelineStates = function () { - var self = this; - for (var i = 0, l = self._animationStates.length; i < l; ++i) { - self._animationStates[i]._updateFFDTimelineStates(); - } - }; + DragonBones.PI_H = Math.PI / 2; /** * @private */ - p._advanceTime = function (passedTime) { - var self = this; - if (!self._isPlaying) { - return; - } - if (passedTime < 0) { - passedTime = -passedTime; - } - var animationStateCount = self._animationStates.length; - if (animationStateCount == 1) { - var animationState = self._animationStates[0]; - if (animationState._isFadeOutComplete) { - animationState.returnToPool(); - self._animationStates.length = 0; - self._animationStateDirty = true; - self._lastAnimationState = null; - } - else { - if (self._timelineStateDirty) { - animationState._updateTimelineStates(); - } - animationState._advanceTime(passedTime, 1, 0); - } - } - else if (animationStateCount > 1) { - var prevLayer = self._animationStates[0]._layer; - var weightLeft = 1; - var layerTotalWeight = 0; - var layerIndex = 1; - for (var i = 0, r = 0; i < animationStateCount; ++i) { - var animationState = self._animationStates[i]; - if (animationState._isFadeOutComplete) { - r++; - animationState.returnToPool(); - if (self._lastAnimationState == animationState) { - if (i - r >= 0) { - self._lastAnimationState = self._animationStates[i - r]; - } - else { - self._lastAnimationState = null; - } - } - } - else { - if (r > 0) { - self._animationStates[i - r] = animationState; - } - if (prevLayer != animationState._layer) { - prevLayer = animationState._layer; - if (layerTotalWeight >= weightLeft) { - weightLeft = 0; - } - else { - weightLeft -= layerTotalWeight; - } - layerTotalWeight = 0; - } - if (self._timelineStateDirty) { - animationState._updateTimelineStates(); - } - animationState._advanceTime(passedTime, weightLeft, layerIndex); - if (animationState._weightResult != 0) { - layerTotalWeight += animationState._weightResult; - layerIndex++; - } - } - if (i == animationStateCount - 1 && r > 0) { - self._animationStates.length -= r; - } - } - } - self._timelineStateDirty = false; - }; + DragonBones.PI_Q = Math.PI / 4; /** - * @language zh_CN - * 清除所有正在播放的动画状态。 - * @version DragonBones 4.5 + * @private */ - p.reset = function () { - var self = this; - self._isPlaying = false; - self._lastAnimationState = null; - for (var i = 0, l = self._animationStates.length; i < l; ++i) { - self._animationStates[i].returnToPool(); - } - self._animationStates.length = 0; + DragonBones.ANGLE_TO_RADIAN = Math.PI / 180; + /** + * @private + */ + DragonBones.RADIAN_TO_ANGLE = 180 / Math.PI; + /** + * @private + */ + DragonBones.SECOND_TO_MILLISECOND = 1000; + /** + * @private + */ + DragonBones.NO_TWEEN = 100; + DragonBones.VERSION = "4.7.2"; + /** + * @private + */ + DragonBones.DEBUG = false; + /** + * @private + */ + DragonBones.DEBUG_DRAW = false; + /** + * @private + */ + DragonBones._armatures = []; + return DragonBones; + }()); + dragonBones.DragonBones = DragonBones; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 事件数据。 + * @version DragonBones 4.5 + */ + var EventObject = (function (_super) { + __extends(EventObject, _super); + /** + * @private + */ + function EventObject() { + _super.call(this); + } + /** + * @private + */ + EventObject.toString = function () { + return "[class dragonBones.EventObject]"; }; /** - * @language zh_CN - * 暂停播放动画。 - * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * @inheritDoc */ - p.stop = function (animationName) { - if (animationName === void 0) { animationName = null; } - if (animationName) { - var animationState = this.getState(animationName); - if (animationState) { - animationState.stop(); - } - } - else { - this._isPlaying = false; - } + EventObject.prototype._onClear = function () { + this.type = null; + this.name = null; + this.data = null; + this.armature = null; + this.bone = null; + this.slot = null; + this.animationState = null; + this.userData = null; }; + Object.defineProperty(EventObject.prototype, "animationName", { + /** + * @see #animationState + */ + get: function () { + return this.animationState.name; + }, + enumerable: true, + configurable: true + }); /** * @language zh_CN - * 播放动画。 - * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 - * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * 动画开始。 + * @version DragonBones 4.5 */ - p.play = function (animationName, playTimes) { - if (animationName === void 0) { animationName = null; } - if (playTimes === void 0) { playTimes = -1; } - var self = this; - var animationState = null; - if (animationName) { - animationState = self.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); - } - else if (!self._lastAnimationState) { - var defaultAnimation = self._armature.armatureData.defaultAnimation; - if (defaultAnimation) { - animationState = self.fadeIn(defaultAnimation.name, 0, playTimes, 0, null, 4 /* All */); - } - } - else if (!self._isPlaying) { - self._isPlaying = true; - } - else { - animationState = self.fadeIn(self._lastAnimationState.name, 0, playTimes, 0, null, 4 /* All */); - } - return animationState; - }; + EventObject.START = "start"; /** * @language zh_CN - * 淡入播放指定名称的动画。 - * @param animationName 动画数据的名称。 - * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位) - * @param layer 混合的图层,图层高会优先获取混合权重。 - * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。 - * @param fadeOutMode 淡出的模式。 - * @param additiveBlending 以叠加的形式混合。 - * @param displayControl 是否对显示对象属性可控。 - * @param pauseFadeOut 暂停需要淡出的动画。 - * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。 - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationFadeOutMode - * @see dragonBones.AnimationState + * 动画循环播放一次完成。 * @version DragonBones 4.5 */ - p.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode, additiveBlending, displayControl, pauseFadeOut, pauseFadeIn) { - if (fadeInTime === void 0) { fadeInTime = -1; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - if (additiveBlending === void 0) { additiveBlending = false; } - if (displayControl === void 0) { displayControl = true; } - if (pauseFadeOut === void 0) { pauseFadeOut = true; } - if (pauseFadeIn === void 0) { pauseFadeIn = true; } - var self = this; - var clipData = self._animations[animationName]; - if (!clipData) { - self._time = 0; - console.warn("No animation.", " Armature: " + self._armature.name, " Animation: " + animationName); - return null; - } - self._isPlaying = true; - if (fadeInTime != fadeInTime || fadeInTime < 0) { - if (self._lastAnimationState) { - fadeInTime = clipData.fadeInTime; - } - else { - fadeInTime = 0; - } - } - if (playTimes < 0) { - playTimes = clipData.playTimes; - } - self._fadeOut(fadeInTime, layer, group, fadeOutMode, pauseFadeOut); - self._lastAnimationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); - self._lastAnimationState._layer = layer; - self._lastAnimationState._group = group; - self._lastAnimationState.additiveBlending = additiveBlending; - self._lastAnimationState.displayControl = displayControl; - self._lastAnimationState._fadeIn(self._armature, clipData.animation || clipData, animationName, playTimes, clipData.position, clipData.duration, self._time, 1 / clipData.scale, fadeInTime, pauseFadeIn); - self._animationStates.push(self._lastAnimationState); - self._animationStateDirty = true; - self._time = 0; - if (self._animationStates.length > 1) { - self._animationStates.sort(Animation._sortAnimationState); - } - var slots = self._armature.getSlots(); - for (var i = 0, l = slots.length; i < l; ++i) { - var slot = slots[i]; - if (slot.inheritAnimation) { - var childArmature = slot.childArmature; - if (childArmature && - childArmature.animation.hasAnimation(animationName) && - !childArmature.animation.getState(animationName)) { - childArmature.animation.fadeIn(animationName); - } - } - } - self._armature.advanceTime(0); - return self._lastAnimationState; - }; + EventObject.LOOP_COMPLETE = "loopComplete"; /** * @language zh_CN - * 指定名称的动画从指定时间开始播放。 - * @param animationName 动画数据的名称。 - * @param time 时间。 (以秒为单位) - * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画播放完成。 * @version DragonBones 4.5 */ - p.gotoAndPlayByTime = function (animationName, time, playTimes) { - if (time === void 0) { time = 0; } - if (playTimes === void 0) { playTimes = -1; } - this._time = time; - return this.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); - }; + EventObject.COMPLETE = "complete"; /** * @language zh_CN - * 指定名称的动画从指定帧开始播放。 - * @param animationName 动画数据的名称。 - * @param frame 帧。 - * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡入开始。 * @version DragonBones 4.5 */ - p.gotoAndPlayByFrame = function (animationName, frame, playTimes) { - if (frame === void 0) { frame = 0; } - if (playTimes === void 0) { playTimes = -1; } - var clipData = this._animations[animationName]; - if (clipData) { - this._time = clipData.duration * frame / clipData.frameCount; - } - return this.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); - }; + EventObject.FADE_IN = "fadeIn"; /** * @language zh_CN - * 指定名称的动画从指定进度开始播放。 - * @param animationName 动画数据的名称。 - * @param progress 进度。 [0~1] - * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡入完成。 * @version DragonBones 4.5 */ - p.gotoAndPlayByProgress = function (animationName, progress, playTimes) { - if (progress === void 0) { progress = 0; } - if (playTimes === void 0) { playTimes = -1; } - var clipData = this._animations[animationName]; - if (clipData) { - this._time = clipData.duration * Math.max(progress, 0); - } - return this.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); - }; + EventObject.FADE_IN_COMPLETE = "fadeInComplete"; /** * @language zh_CN - * 播放指定名称的动画到指定的时间并停止。 - * @param animationName 动画数据的名称。 - * @param time 时间。 (以秒为单位) - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡出开始。 * @version DragonBones 4.5 */ - p.gotoAndStopByTime = function (animationName, time) { - if (time === void 0) { time = 0; } - var animationState = this.gotoAndPlayByTime(animationName, time, 1); - if (animationState) { - this._isPlaying = false; - animationState.stop(); - } - return animationState; - }; + EventObject.FADE_OUT = "fadeOut"; /** * @language zh_CN - * 播放指定名称的动画到指定的帧并停止。 - * @param animationName 动画数据的名称。 - * @param frame 帧。 - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画淡出完成。 * @version DragonBones 4.5 */ - p.gotoAndStopByFrame = function (animationName, frame) { - if (frame === void 0) { frame = 0; } - var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); - if (animationState) { - this._isPlaying = false; - animationState.stop(); - } - return animationState; - }; + EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; /** * @language zh_CN - * 播放指定名称的动画到指定的进度并停止。 - * @param animationName 动画数据的名称。 - * @param progress 进度。 [0~1] - * @returns 返回控制这个动画数据的动画状态。 - * @see dragonBones.AnimationState + * 动画帧事件。 * @version DragonBones 4.5 */ - p.gotoAndStopByProgress = function (animationName, progress) { - if (progress === void 0) { progress = 0; } - var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); - if (animationState) { - this._isPlaying = false; - animationState.stop(); - } - return animationState; - }; + EventObject.FRAME_EVENT = "frameEvent"; /** * @language zh_CN - * 获取指定名称的动画状态。 - * @param animationName 动画状态的名称。 - * @see dragonBones.AnimationState - * @version DragonBones 3.0 + * 动画声音事件。 + * @version DragonBones 4.5 */ - p.getState = function (animationName) { - for (var i = 0, l = this._animationStates.length; i < l; ++i) { - var animationState = this._animationStates[i]; - if (animationState.name == animationName) { - return animationState; - } - } - return null; - }; + EventObject.SOUND_EVENT = "soundEvent"; /** - * @language zh_CN - * 是否包含指定名称的动画数据。 - * @param animationName 动画数据的名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 + * @private */ - p.hasAnimation = function (animationName) { - return this._animations[animationName] != null; + EventObject._soundEventManager = null; + return EventObject; + }(dragonBones.BaseObject)); + dragonBones.EventObject = EventObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var Point = (function () { + function Point(x, y) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + this.x = x; + this.y = y; + } + Point.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + }; + Point.prototype.clear = function () { + this.x = this.y = 0; + }; + return Point; + }()); + dragonBones.Point = Point; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var Rectangle = (function () { + function Rectangle(x, y, width, height) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + if (width === void 0) { width = 0; } + if (height === void 0) { height = 0; } + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + Rectangle.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + this.width = value.width; + this.height = value.height; + }; + Rectangle.prototype.clear = function () { + this.x = this.y = 0; + this.width = this.height = 0; }; - d(p, "isPlaying" + return Rectangle; + }()); + dragonBones.Rectangle = Rectangle; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 2D 变换。 + * @version DragonBones 3.0 + */ + var Transform = (function () { + /** + * @private + */ + function Transform( /** * @language zh_CN - * 动画是否处于播放状态。 + * 水平位移。 * @version DragonBones 3.0 */ - ,function () { - return this._isPlaying; - } - ); - d(p, "isCompleted" + x, /** * @language zh_CN - * 所有动画状态是否均已播放完毕。 - * @see dragonBones.AnimationState + * 垂直位移。 * @version DragonBones 3.0 */ - ,function () { - var self = this; - if (self._lastAnimationState) { - if (!self._lastAnimationState.isCompleted) { - return false; - } - for (var i = 0, l = self._animationStates.length; i < l; ++i) { - if (!self._animationStates[i].isCompleted) { - return false; - } - } - } - return true; - } - ); - d(p, "lastAnimationName" + y, /** * @language zh_CN - * 上一个正在播放的动画状态的名称。 - * @see #lastAnimationState + * 水平倾斜。 (以弧度为单位) * @version DragonBones 3.0 */ - ,function () { - return this._lastAnimationState ? this._lastAnimationState.name : null; - } - ); - d(p, "lastAnimationState" + skewX, /** * @language zh_CN - * 上一个正在播放的动画状态。 - * @see dragonBones.AnimationState + * 垂直倾斜。 (以弧度为单位) * @version DragonBones 3.0 */ - ,function () { - return this._lastAnimationState; - } - ); - d(p, "animationNames" + skewY, /** * @language zh_CN - * 所有动画数据名称。 - * @see #animations - * @version DragonBones 4.5 + * 水平缩放。 + * @version DragonBones 3.0 */ - ,function () { - return this._animationNames; - } - ); - d(p, "animations" + scaleX, /** * @language zh_CN - * 所有的动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 4.5 + * 垂直缩放。 + * @version DragonBones 3.0 */ - ,function () { - return this._animations; - } - ,function (value) { - var self = this; - if (self._animations == value) { - return; - } - for (var i in self._animations) { - delete self._animations[i]; - } - self._animationNames.length = 0; - if (value) { - for (var i in value) { - self._animations[i] = value[i]; - self._animationNames.push(i); - } - } - } - ); + scaleY) { + if (x === void 0) { x = 0; } + if (y === void 0) { y = 0; } + if (skewX === void 0) { skewX = 0; } + if (skewY === void 0) { skewY = 0; } + if (scaleX === void 0) { scaleX = 1; } + if (scaleY === void 0) { scaleY = 1; } + this.x = x; + this.y = y; + this.skewX = skewX; + this.skewY = skewY; + this.scaleX = scaleX; + this.scaleY = scaleY; + } /** - * @deprecated - * @see #play() - * @see #fadeIn() - * @see #gotoAndPlayByTime() - * @see #gotoAndPlayByFrame() - * @see #gotoAndPlayByProgress() + * @private */ - p.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { - if (fadeInTime === void 0) { fadeInTime = -1; } - if (duration === void 0) { duration = -1; } - if (playTimes === void 0) { playTimes = -1; } - if (layer === void 0) { layer = 0; } - if (group === void 0) { group = null; } - if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } - if (pauseFadeOut === void 0) { pauseFadeOut = true; } - if (pauseFadeIn === void 0) { pauseFadeIn = true; } - var animationState = this.fadeIn(animationName, fadeInTime, playTimes, layer, group, fadeOutMode, false, true, pauseFadeOut, pauseFadeIn); - if (animationState && duration && duration > 0) { - animationState.timeScale = animationState.totalTime / duration; - } - return animationState; + Transform.normalizeRadian = function (value) { + value = (value + Math.PI) % (Math.PI * 2); + value += value > 0 ? -Math.PI : Math.PI; + return value; }; /** - * @deprecated - * @see #gotoAndStopByTime() - * @see #gotoAndStopByFrame() - * @see #gotoAndStopByProgress() + * @private */ - p.gotoAndStop = function (animationName, time) { - if (time === void 0) { time = 0; } - return this.gotoAndStopByTime(animationName, time); + Transform.prototype.toString = function () { + return "[object dragonBones.Transform] x:" + this.x + " y:" + this.y + " skewX:" + this.skewX * 180 / Math.PI + " skewY:" + this.skewY * 180 / Math.PI + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY; }; - d(p, "animationList" - /** - * @deprecated - * @see #animationNames - * @see #animations - */ - ,function () { - return this._animationNames; - } - ); - d(p, "animationDataList" - /** - * @language zh_CN - * @deprecated - * @see #animationNames - * @see #animations - */ - ,function () { - var list = []; - for (var i = 0, l = this._animationNames.length; i < l; ++i) { - list.push(this._animations[this._animationNames[i]]); - } - return list; - } - ); - return Animation; - }(dragonBones.BaseObject)); - dragonBones.Animation = Animation; - egret.registerClass(Animation,'dragonBones.Animation'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。 - * @see dragonBones.Animation - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - */ - var AnimationState = (function (_super) { - __extends(AnimationState, _super); /** * @private */ - function AnimationState() { - _super.call(this); - /** - * @private - */ - this._boneMask = []; - /** - * @private - */ - this._boneTimelines = []; - /** - * @private - */ - this._slotTimelines = []; - /** - * @private - */ - this._ffdTimelines = []; - /** - * @deprecated - */ - this.autoTween = false; - } - var d = __define,c=AnimationState,p=c.prototype; + Transform.prototype.copyFrom = function (value) { + this.x = value.x; + this.y = value.y; + this.skewX = value.skewX; + this.skewY = value.skewY; + this.scaleX = value.scaleX; + this.scaleY = value.scaleY; + return this; + }; /** * @private */ - AnimationState.toString = function () { - return "[Class dragonBones.AnimationState]"; + Transform.prototype.clone = function () { + var value = new Transform(); + value.copyFrom(this); + return value; }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - self.displayControl = true; - self.additiveBlending = false; - self.playTimes = 1; - self.timeScale = 1; - self.weight = 1; - self.autoFadeOutTime = -1; - self.fadeTotalTime = 0; - self._isFadeOutComplete = false; - self._layer = 0; - self._position = 0; - self._duration = 0; - self._weightResult = 0; - self._fadeProgress = 0; - self._group = null; - if (self._timeline) { - self._timeline.returnToPool(); - self._timeline = null; - } - self._isPlaying = true; - self._isPausePlayhead = false; - self._isFadeOut = false; - self._currentPlayTimes = 0; - self._fadeTime = 0; - self._time = 0; - self._name = null; - self._armature = null; - self._animationData = null; - if (self._boneMask.length) { - self._boneMask.length = 0; - } - for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { - self._boneTimelines[i].returnToPool(); - } - for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { - self._slotTimelines[i].returnToPool(); - } - for (var i = 0, l = self._ffdTimelines.length; i < l; ++i) { - self._ffdTimelines[i].returnToPool(); - } - self._boneTimelines.length = 0; - self._slotTimelines.length = 0; - self._ffdTimelines.length = 0; - }; - /** - * @private - */ - p._advanceFadeTime = function (passedTime) { - var self = this; - if (passedTime < 0) { - passedTime = -passedTime; - } - self._fadeTime += passedTime; - var fadeProgress = 0; - if (self._fadeTime >= self.fadeTotalTime) { - fadeProgress = self._isFadeOut ? 0 : 1; - } - else if (self._fadeTime > 0) { - fadeProgress = self._isFadeOut ? (1 - self._fadeTime / self.fadeTotalTime) : (self._fadeTime / self.fadeTotalTime); - } - else { - fadeProgress = self._isFadeOut ? 1 : 0; - } - if (self._fadeProgress != fadeProgress) { - self._fadeProgress = fadeProgress; - var eventDispatcher = self._armature._display; - if (self._fadeTime <= passedTime) { - if (self._isFadeOut) { - if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_OUT)) { - var event_1 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - event_1.animationState = this; - self._armature._bufferEvent(event_1, dragonBones.EventObject.FADE_OUT); - } - } - else { - if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_IN)) { - var event_2 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - event_2.animationState = this; - self._armature._bufferEvent(event_2, dragonBones.EventObject.FADE_IN); - } - } - } - if (self._fadeTime >= self.fadeTotalTime) { - if (self._isFadeOut) { - self._isFadeOutComplete = true; - if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_OUT_COMPLETE)) { - var event_3 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - event_3.animationState = this; - self._armature._bufferEvent(event_3, dragonBones.EventObject.FADE_OUT_COMPLETE); - } - } - else { - self._isPausePlayhead = false; - if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_IN_COMPLETE)) { - var event_4 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - event_4.animationState = this; - self._armature._bufferEvent(event_4, dragonBones.EventObject.FADE_IN_COMPLETE); - } - } - } - } + Transform.prototype.identity = function () { + this.x = this.y = this.skewX = this.skewY = 0; + this.scaleX = this.scaleY = 1; + return this; }; /** * @private */ - p._isDisabled = function (slot) { - if (this.displayControl && - (!slot.displayController || - slot.displayController == this._name || - slot.displayController == this._group)) { - return false; - } - return true; + Transform.prototype.add = function (value) { + this.x += value.x; + this.y += value.y; + this.skewX += value.skewX; + this.skewY += value.skewY; + this.scaleX *= value.scaleX; + this.scaleY *= value.scaleY; + return this; }; /** * @private */ - p._fadeIn = function (armature, clip, animationName, playTimes, position, duration, time, timeScale, fadeInTime, pausePlayhead) { - var self = this; - self._armature = armature; - self._animationData = clip; - self._name = animationName; - self.playTimes = playTimes; - self.timeScale = timeScale; - self.fadeTotalTime = fadeInTime; - self._position = position; - self._duration = duration; - self._time = time; - self._isPausePlayhead = pausePlayhead; - if (self.fadeTotalTime == 0) { - self._fadeProgress = 0.999999; - } - self._timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineState); - self._timeline.fadeIn(self._armature, self, self._animationData, self._time); - self._updateTimelineStates(); + Transform.prototype.minus = function (value) { + this.x -= value.x; + this.y -= value.y; + this.skewX = Transform.normalizeRadian(this.skewX - value.skewX); + this.skewY = Transform.normalizeRadian(this.skewY - value.skewY); + this.scaleX /= value.scaleX; + this.scaleY /= value.scaleY; + return this; }; /** * @private */ - p._updateTimelineStates = function () { - var self = this; - var time = self._time; - if (!self._animationData.hasAsynchronyTimeline) { - time = self._timeline._currentTime; - } - var boneTimelineStates = {}; - var slotTimelineStates = {}; - for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { - var boneTimelineState = self._boneTimelines[i]; - boneTimelineStates[boneTimelineState.bone.name] = boneTimelineState; - } - var bones = self._armature.getBones(); - for (var i = 0, l = bones.length; i < l; ++i) { - var bone = bones[i]; - var boneTimelineName = bone.name; - var boneTimelineData = self._animationData.getBoneTimeline(boneTimelineName); - if (boneTimelineData && self.containsBoneMask(boneTimelineName)) { - var boneTimelineState = boneTimelineStates[boneTimelineName]; - if (boneTimelineState) { - delete boneTimelineStates[boneTimelineName]; - } - else { - boneTimelineState = dragonBones.BaseObject.borrowObject(dragonBones.BoneTimelineState); - boneTimelineState.bone = bone; - boneTimelineState.fadeIn(self._armature, this, boneTimelineData, time); - self._boneTimelines.push(boneTimelineState); - } - } - } - for (var i in boneTimelineStates) { - var boneTimelineState = boneTimelineStates[i]; - boneTimelineState.bone.invalidUpdate(); - self._boneTimelines.splice(self._boneTimelines.indexOf(boneTimelineState), 1); - boneTimelineState.returnToPool(); - } - // - for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { - var slotTimelineState = self._slotTimelines[i]; - slotTimelineStates[slotTimelineState.slot.name] = slotTimelineState; - } - var slots = self._armature.getSlots(); - for (var i = 0, l = slots.length; i < l; ++i) { - var slot = slots[i]; - var slotTimelineName = slot.name; - var parentTimelineName = slot.parent.name; - var slotTimelineData = self._animationData.getSlotTimeline(slotTimelineName); - if (slotTimelineData && self.containsBoneMask(parentTimelineName) && !self._isFadeOut) { - var slotTimelineState = slotTimelineStates[slotTimelineName]; - if (slotTimelineState) { - delete slotTimelineStates[slotTimelineName]; - } - else { - slotTimelineState = dragonBones.BaseObject.borrowObject(dragonBones.SlotTimelineState); - slotTimelineState.slot = slot; - slotTimelineState.fadeIn(self._armature, this, slotTimelineData, time); - self._slotTimelines.push(slotTimelineState); - } - } - } - for (var i in slotTimelineStates) { - var slotTimelineState = slotTimelineStates[i]; - self._slotTimelines.splice(self._slotTimelines.indexOf(slotTimelineState), 1); - slotTimelineState.returnToPool(); + Transform.prototype.fromMatrix = function (matrix) { + var PI_Q = Math.PI * 0.25; + var backupScaleX = this.scaleX, backupScaleY = this.scaleY; + this.x = matrix.tx; + this.y = matrix.ty; + this.skewX = Math.atan(-matrix.c / matrix.d); + this.skewY = Math.atan(matrix.b / matrix.a); + if (this.skewX != this.skewX) + this.skewX = 0; + if (this.skewY != this.skewY) + this.skewY = 0; + this.scaleY = (this.skewX > -PI_Q && this.skewX < PI_Q) ? matrix.d / Math.cos(this.skewX) : -matrix.c / Math.sin(this.skewX); + this.scaleX = (this.skewY > -PI_Q && this.skewY < PI_Q) ? matrix.a / Math.cos(this.skewY) : matrix.b / Math.sin(this.skewY); + if (backupScaleX >= 0 && this.scaleX < 0) { + this.scaleX = -this.scaleX; + this.skewY = this.skewY - Math.PI; + } + if (backupScaleY >= 0 && this.scaleY < 0) { + this.scaleY = -this.scaleY; + this.skewX = this.skewX - Math.PI; } - self._updateFFDTimelineStates(); + return this; }; /** - * @private + * @language zh_CN + * 转换为矩阵。 + * @param 矩阵。 + * @version DragonBones 3.0 */ - p._updateFFDTimelineStates = function () { - var self = this; - var time = self._time; - if (!self._animationData.hasAsynchronyTimeline) { - time = self._timeline._currentTime; - } - var ffdTimelineStates = {}; - for (var i = 0, l = self._ffdTimelines.length; i < l; ++i) { - var ffdTimelineState = self._ffdTimelines[i]; - ffdTimelineStates[ffdTimelineState.slot.name] = ffdTimelineState; - } - var slots = self._armature.getSlots(); - for (var i = 0, l = slots.length; i < l; ++i) { - var slot = slots[i]; - var slotTimelineName = slot.name; - var parentTimelineName = slot.parent.name; - if (slot._meshData) { - var ffdTimelineData = self._animationData.getFFDTimeline(self._armature._skinData.name, slotTimelineName, slot.displayIndex); - if (ffdTimelineData && self.containsBoneMask(parentTimelineName)) { - var ffdTimelineState = ffdTimelineStates[slotTimelineName]; - if (ffdTimelineState) { - delete ffdTimelineStates[slotTimelineName]; - } - else { - ffdTimelineState = dragonBones.BaseObject.borrowObject(dragonBones.FFDTimelineState); - ffdTimelineState.slot = slot; - ffdTimelineState.fadeIn(self._armature, this, ffdTimelineData, time); - self._ffdTimelines.push(ffdTimelineState); - } - } - else { - for (var iF = 0, lF = slot._ffdVertices.length; iF < lF; ++iF) { - slot._ffdVertices[iF] = 0; - } - slot._ffdDirty = true; - } - } - } - for (var i in ffdTimelineStates) { - var ffdTimelineState = ffdTimelineStates[i]; - ffdTimelineState.slot._ffdDirty = true; - self._ffdTimelines.splice(self._ffdTimelines.indexOf(ffdTimelineState), 1); - ffdTimelineState.returnToPool(); - } + Transform.prototype.toMatrix = function (matrix) { + matrix.a = this.scaleX * Math.cos(this.skewY); + matrix.b = this.scaleX * Math.sin(this.skewY); + matrix.c = -this.scaleY * Math.sin(this.skewX); + matrix.d = this.scaleY * Math.cos(this.skewX); + matrix.tx = this.x; + matrix.ty = this.y; + return this; }; - /** - * @private - */ - p._advanceTime = function (passedTime, weightLeft, index) { - var self = this; - if (passedTime != 0) { - self._advanceFadeTime(passedTime); - } - // Update time. - passedTime *= self.timeScale; - if (passedTime != 0 && self._isPlaying && !self._isPausePlayhead) { - self._time += passedTime; - } - // Blend weight. - self._weightResult = self.weight * self._fadeProgress * weightLeft; - if (self._weightResult != 0) { - var isCacheEnabled = self._fadeProgress >= 1 && index == 0 && self._armature.cacheFrameRate > 0; - var cacheTimeToFrameScale = self._animationData.cacheTimeToFrameScale; - var isUpdatesTimeline = true; - var isUpdatesBoneTimeline = true; - var time = isCacheEnabled ? (Math.floor(self._time * cacheTimeToFrameScale) / cacheTimeToFrameScale) : self._time; // Cache time internval. - // Update main timeline. - self._timeline.update(time); - if (!self._animationData.hasAsynchronyTimeline) { - time = self._timeline._currentTime; - } - if (isCacheEnabled) { - var cacheFrameIndex = Math.floor(self._timeline._currentTime * cacheTimeToFrameScale); - if (self._armature._cacheFrameIndex == cacheFrameIndex) { - isUpdatesTimeline = false; - isUpdatesBoneTimeline = false; - } - else { - self._armature._cacheFrameIndex = cacheFrameIndex; - if (self._armature._animation._animationStateDirty) { - self._armature._animation._animationStateDirty = false; - for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { - var boneTimeline = self._boneTimelines[i]; - boneTimeline.bone._cacheFrames = boneTimeline._timeline.cachedFrames; - } - for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { - var slotTimeline = self._slotTimelines[i]; - slotTimeline.slot._cacheFrames = slotTimeline._timeline.cachedFrames; - } - } - if (self._animationData.cachedFrames[cacheFrameIndex]) { - isUpdatesBoneTimeline = false; - } - else { - self._animationData.cachedFrames[cacheFrameIndex] = true; - } - } - } - else { - self._armature._cacheFrameIndex = -1; - } - if (isUpdatesTimeline) { - if (isUpdatesBoneTimeline) { - for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { - self._boneTimelines[i].update(time); - } - } - for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { - self._slotTimelines[i].update(time); - } - for (var i = 0, l = self._ffdTimelines.length; i < l; ++i) { - self._ffdTimelines[i].update(time); - } - } - } - if (self.autoFadeOutTime >= 0 && self._fadeProgress >= 1 && self._timeline._isCompleted) { - self.fadeOut(self.autoFadeOutTime); - } + Object.defineProperty(Transform.prototype, "rotation", { + /** + * @language zh_CN + * 旋转。 (以弧度为单位) + * @version DragonBones 3.0 + */ + get: function () { + return this.skewY; + }, + set: function (value) { + var dValue = value - this.skewY; + this.skewX += dValue; + this.skewY += dValue; + }, + enumerable: true, + configurable: true + }); + return Transform; + }()); + dragonBones.Transform = Transform; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var ColorTransform = (function () { + function ColorTransform(alphaMultiplier, redMultiplier, greenMultiplier, blueMultiplier, alphaOffset, redOffset, greenOffset, blueOffset) { + if (alphaMultiplier === void 0) { alphaMultiplier = 1; } + if (redMultiplier === void 0) { redMultiplier = 1; } + if (greenMultiplier === void 0) { greenMultiplier = 1; } + if (blueMultiplier === void 0) { blueMultiplier = 1; } + if (alphaOffset === void 0) { alphaOffset = 0; } + if (redOffset === void 0) { redOffset = 0; } + if (greenOffset === void 0) { greenOffset = 0; } + if (blueOffset === void 0) { blueOffset = 0; } + this.alphaMultiplier = alphaMultiplier; + this.redMultiplier = redMultiplier; + this.greenMultiplier = greenMultiplier; + this.blueMultiplier = blueMultiplier; + this.alphaOffset = alphaOffset; + this.redOffset = redOffset; + this.greenOffset = greenOffset; + this.blueOffset = blueOffset; + } + ColorTransform.prototype.copyFrom = function (value) { + this.alphaMultiplier = value.alphaMultiplier; + this.redMultiplier = value.redMultiplier; + this.greenMultiplier = value.greenMultiplier; + this.blueMultiplier = value.blueMultiplier; + this.alphaOffset = value.alphaOffset; + this.redOffset = value.redOffset; + this.redOffset = value.redOffset; + this.greenOffset = value.blueOffset; + }; + ColorTransform.prototype.identity = function () { + this.alphaMultiplier = this.redMultiplier = this.greenMultiplier = this.blueMultiplier = 1; + this.alphaOffset = this.redOffset = this.greenOffset = this.blueOffset = 0; }; + return ColorTransform; + }()); + dragonBones.ColorTransform = ColorTransform; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 2D 矩阵。 + * @version DragonBones 3.0 + */ + var Matrix = (function () { + function Matrix(a, b, c, d, tx, ty) { + if (a === void 0) { a = 1; } + if (b === void 0) { b = 0; } + if (c === void 0) { c = 0; } + if (d === void 0) { d = 1; } + if (tx === void 0) { tx = 0; } + if (ty === void 0) { ty = 0; } + this.a = a; + this.b = b; + this.c = c; + this.d = d; + this.tx = tx; + this.ty = ty; + } /** * @language zh_CN - * 继续播放。 + * 复制矩阵。 + * @param value 需要复制的矩阵。 * @version DragonBones 3.0 */ - p.play = function () { - this._isPlaying = true; + Matrix.prototype.copyFrom = function (value) { + this.a = value.a; + this.b = value.b; + this.c = value.c; + this.d = value.d; + this.tx = value.tx; + this.ty = value.ty; }; /** * @language zh_CN - * 暂停播放。 + * 转换为恒等矩阵。 * @version DragonBones 3.0 */ - p.stop = function () { - this._isPlaying = false; + Matrix.prototype.identity = function () { + this.a = this.d = 1; + this.b = this.c = 0; + this.tx = this.ty = 0; }; /** * @language zh_CN - * 淡出动画。 - * @param fadeOutTime 淡出时间。 (以秒为单位) - * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停] + * 将当前矩阵与另一个矩阵相乘。 + * @param value 需要相乘的矩阵。 * @version DragonBones 3.0 */ - p.fadeOut = function (fadeOutTime, pausePlayhead) { - if (pausePlayhead === void 0) { pausePlayhead = true; } - var self = this; - if (fadeOutTime < 0 || fadeOutTime != fadeOutTime) { - fadeOutTime = 0; - } - self._isPausePlayhead = pausePlayhead; - if (self._isFadeOut) { - if (fadeOutTime > fadeOutTime - self._fadeTime) { - // If the animation is already in fade out, the new fade out will be ignored. - return; - } - } - else { - self._isFadeOut = true; - if (fadeOutTime == 0 || self._fadeProgress <= 0) { - self._fadeProgress = 0.000001; - } - for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { - self._boneTimelines[i].fadeOut(); - } - for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { - self._slotTimelines[i].fadeOut(); - } - } - self.displayControl = false; - self.fadeTotalTime = self._fadeProgress > 0.000001 ? fadeOutTime / self._fadeProgress : 0; - self._fadeTime = self.fadeTotalTime * (1 - self._fadeProgress); + Matrix.prototype.concat = function (value) { + var aA = this.a; + var bA = this.b; + var cA = this.c; + var dA = this.d; + var txA = this.tx; + var tyA = this.ty; + var aB = value.a; + var bB = value.b; + var cB = value.c; + var dB = value.d; + var txB = value.tx; + var tyB = value.ty; + this.a = aA * aB + bA * cB; + this.b = aA * bB + bA * dB; + this.c = cA * aB + dA * cB; + this.d = cA * bB + dA * dB; + this.tx = aB * txA + cB * tyA + txB; + this.ty = dB * tyA + bB * txA + tyB; + /* + [ + this.a, + this.b, + this.c, + this.d, + this.tx, + this.ty + ] = [ + this.a * value.a + this.b * value.c, + this.a * value.b + this.b * value.d, + this.c * value.a + this.d * value.c, + this.c * value.b + this.d * value.d, + value.a * this.tx + value.c * this.tx + value.tx, + value.d * this.ty + value.b * this.ty + value.ty + ]; + */ }; /** * @language zh_CN - * 是否包含指定的骨骼遮罩。 - * @param name 指定的骨骼名称。 + * 转换为逆矩阵。 * @version DragonBones 3.0 */ - p.containsBoneMask = function (name) { - return !this._boneMask.length || this._boneMask.indexOf(name) >= 0; + Matrix.prototype.invert = function () { + var aA = this.a; + var bA = this.b; + var cA = this.c; + var dA = this.d; + var txA = this.tx; + var tyA = this.ty; + var n = aA * dA - bA * cA; + this.a = dA / n; + this.b = -bA / n; + this.c = -cA / n; + this.d = aA / n; + this.tx = (cA * tyA - dA * txA) / n; + this.ty = -(aA * tyA - bA * txA) / n; }; /** * @language zh_CN - * 添加指定的骨骼遮罩。 - * @param boneName 指定的骨骼名称。 - * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * 将矩阵转换应用于指定点。 + * @param x 横坐标。 + * @param y 纵坐标。 + * @param result 应用转换之后的坐标。 + * @params delta 是否忽略 tx,ty 对坐标的转换。 * @version DragonBones 3.0 */ - p.addBoneMask = function (name, recursive) { - if (recursive === void 0) { recursive = true; } - var self = this; - var currentBone = self._armature.getBone(name); - if (!currentBone) { - return; - } - if (self._boneMask.indexOf(name) < 0 && - self._animationData.getBoneTimeline(name)) { - self._boneMask.push(name); - } - if (recursive) { - var bones = self._armature.getBones(); - for (var i = 0, l = bones.length; i < l; ++i) { - var bone = bones[i]; - var boneName = bone.name; - if (self._boneMask.indexOf(boneName) < 0 && - self._animationData.getBoneTimeline(boneName) && - currentBone.contains(bone)) { - self._boneMask.push(boneName); - } - } + Matrix.prototype.transformPoint = function (x, y, result, delta) { + if (delta === void 0) { delta = false; } + result.x = this.a * x + this.c * y; + result.y = this.b * x + this.d * y; + if (!delta) { + result.x += this.tx; + result.y += this.ty; } - self._updateTimelineStates(); }; + return Matrix; + }()); + dragonBones.Matrix = Matrix; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 龙骨数据,包含多个骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + var DragonBonesData = (function (_super) { + __extends(DragonBonesData, _super); /** - * @language zh_CN - * 删除指定的骨骼遮罩。 - * @param boneName 指定的骨骼名称。 - * @param recursive 是否删除该骨骼的子骨骼遮罩。 - * @version DragonBones 3.0 + * @private */ - p.removeBoneMask = function (name, recursive) { - if (recursive === void 0) { recursive = true; } - var self = this; - var index = self._boneMask.indexOf(name); - if (index >= 0) { - self._boneMask.splice(index, 1); - } - if (recursive) { - var currentBone = self._armature.getBone(name); - if (currentBone) { - var bones = self._armature.getBones(); - for (var i = 0, l = bones.length; i < l; ++i) { - var bone = bones[i]; - var boneName = bone.name; - var index_1 = self._boneMask.indexOf(boneName); - if (index_1 >= 0 && - currentBone.contains(bone)) { - self._boneMask.splice(index_1, 1); - } - } - } - } - self._updateTimelineStates(); - }; - /** - * @language zh_CN - * 删除所有骨骼遮罩。 - * @version DragonBones 3.0 - */ - p.removeAllBoneMask = function () { - this._boneMask.length = 0; - this._updateTimelineStates(); - }; - d(p, "layer" - /** - * @language zh_CN - * 动画图层。 - * @see dragonBones.Animation#fadeIn() - * @version DragonBones 3.0 - */ - ,function () { - return this._layer; - } - ); - d(p, "group" - /** - * @language zh_CN - * 动画组。 - * @see dragonBones.Animation#fadeIn() - * @version DragonBones 3.0 - */ - ,function () { - return this._group; - } - ); - d(p, "name" - /** - * @language zh_CN - * 动画名称。 - * @see dragonBones.AnimationData#name - * @version DragonBones 3.0 - */ - ,function () { - return this._name; - } - ); - d(p, "animationData" - /** - * @language zh_CN - * 动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - */ - ,function () { - return this._animationData; - } - ); - d(p, "isCompleted" + function DragonBonesData() { + _super.call(this); /** * @language zh_CN - * 是否播放完毕。 + * 所有的骨架数据。 + * @see dragonBones.ArmatureData * @version DragonBones 3.0 */ - ,function () { - return this._timeline._isCompleted; + this.armatures = {}; + this._armatureNames = []; + } + /** + * @private + */ + DragonBonesData.toString = function () { + return "[class dragonBones.DragonBonesData]"; + }; + /** + * @inheritDoc + */ + DragonBonesData.prototype._onClear = function () { + this.autoSearch = false; + this.frameRate = 0; + this.name = null; + this.userData = null; + for (var i in this.armatures) { + this.armatures[i].returnToPool(); + delete this.armatures[i]; } - ); - d(p, "isPlaying" - /** - * @language zh_CN - * 是否正在播放。 - * @version DragonBones 3.0 - */ - ,function () { - return (this._isPlaying && !this._timeline._isCompleted); + if (this._armatureNames.length) { + this._armatureNames.length = 0; } - ); - d(p, "currentPlayTimes" - /** - * @language zh_CN - * 当前动画的播放次数。 - * @version DragonBones 3.0 - */ - ,function () { - return this._currentPlayTimes; + }; + /** + * @language zh_CN + * 获取指定名称的骨架。 + * @param name 骨架数据骨架名称。 + * @see dragonBones.ArmatureData + * @version DragonBones 3.0 + */ + DragonBonesData.prototype.getArmature = function (name) { + return this.armatures[name]; + }; + /** + * @private + */ + DragonBonesData.prototype.addArmature = function (value) { + if (value && value.name && !this.armatures[value.name]) { + this.armatures[value.name] = value; + this._armatureNames.push(value.name); + value.parent = this; } - ); - d(p, "totalTime" - /** - * @language zh_CN - * 当前动画的总时间。 (以秒为单位) - * @version DragonBones 3.0 - */ - ,function () { - return this._duration; + else { + throw new Error(); } - ); - d(p, "currentTime" + }; + Object.defineProperty(DragonBonesData.prototype, "armatureNames", { /** * @language zh_CN - * 当前动画的播放时间。 (以秒为单位) - * @version DragonBones 3.0 - */ - ,function () { - return this._timeline._currentTime; - } - ,function (value) { - var self = this; - if (value < 0 || value != value) { - value = 0; - } - self._time = value; - self._timeline.setCurrentTime(self._time); - if (self._weightResult != 0) { - var time = self._time; - if (!self._animationData.hasAsynchronyTimeline) { - time = self._timeline._currentTime; - } - for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { - self._boneTimelines[i].setCurrentTime(time); - } - for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { - self._slotTimelines[i].setCurrentTime(time); - } - for (var i = 0, l = self._ffdTimelines.length; i < l; ++i) { - self._ffdTimelines[i].setCurrentTime(time); - } - } - } - ); - d(p, "clip" - /** - * @deprecated - * @see #animationData + * 所有的骨架数据名称。 + * @see #armatures * @version DragonBones 3.0 */ - ,function () { - return this._animationData; - } - ); - return AnimationState; + get: function () { + return this._armatureNames; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * @see dragonBones.BaseFactory#removeDragonBonesData() + */ + DragonBonesData.prototype.dispose = function () { + this.returnToPool(); + }; + return DragonBonesData; }(dragonBones.BaseObject)); - dragonBones.AnimationState = AnimationState; - egret.registerClass(AnimationState,'dragonBones.AnimationState'); + dragonBones.DragonBonesData = DragonBonesData; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** * @private */ - var TimelineState = (function (_super) { - __extends(TimelineState, _super); - function TimelineState() { + var ActionData = (function (_super) { + __extends(ActionData, _super); + function ActionData() { _super.call(this); } - var d = __define,c=TimelineState,p=c.prototype; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self._isCompleted = false; - self._currentPlayTimes = 0; - self._currentTime = 0; - self._timeline = null; - self._isReverse = false; - self._hasAsynchronyTimeline = false; - self._frameRate = 0; - self._keyFrameCount = 0; - self._frameCount = 0; - self._position = 0; - self._duration = 0; - self._animationDutation = 0; - self._timeScale = 1; - self._timeOffset = 0; - self._currentFrame = null; - self._armature = null; - self._animationState = null; - }; - p._onFadeIn = function () { }; - p._onUpdateFrame = function (isUpdate) { }; - p._onArriveAtFrame = function (isUpdate) { }; - p._onCrossFrame = function (frame) { }; - p._setCurrentTime = function (value) { - var self = this; - var currentPlayTimes = 0; - if (self._hasAsynchronyTimeline) { - var playTimes = self._animationState.playTimes; - var totalTimes = playTimes * self._duration; - value *= self._timeScale; - if (self._timeOffset != 0) { - value += self._timeOffset * self._animationDutation; - } - if (playTimes > 0 && (value >= totalTimes || value <= -totalTimes)) { - self._isCompleted = true; - currentPlayTimes = playTimes; - if (value < 0) { - value = 0; - } - else { - value = self._duration; - } - } - else { - self._isCompleted = false; - if (value < 0) { - currentPlayTimes = Math.floor(-value / self._duration); - value = self._duration - (-value % self._duration); - } - else { - currentPlayTimes = Math.floor(value / self._duration); - value %= self._duration; - } - if (playTimes > 0 && currentPlayTimes > playTimes) { - currentPlayTimes = playTimes; - } - } - value += self._position; - } - else { - self._isCompleted = self._animationState._timeline._isCompleted; - currentPlayTimes = self._animationState._timeline._currentPlayTimes; - } - if (self._currentTime == value) { - return false; - } - if (self._keyFrameCount == 1 && value > self._position && this != self._animationState._timeline) { - self._isCompleted = true; - } - self._isReverse = self._currentTime > value && self._currentPlayTimes == currentPlayTimes; - self._currentTime = value; - self._currentPlayTimes = currentPlayTimes; - return true; + ActionData.toString = function () { + return "[class dragonBones.ActionData]"; }; - p.setCurrentTime = function (value) { - var self = this; - self._setCurrentTime(value); - switch (self._keyFrameCount) { - case 0: - break; - case 1: - self._currentFrame = self._timeline.frames[0]; - self._onArriveAtFrame(false); - self._onUpdateFrame(false); - break; - default: - self._currentFrame = self._timeline.frames[Math.floor(self._currentTime * self._frameRate)]; - self._onArriveAtFrame(false); - self._onUpdateFrame(false); - break; - } - self._currentFrame = null; + ActionData.prototype._onClear = function () { + this.type = 0 /* Play */; + this.data = null; + this.bone = null; + this.slot = null; }; - p.fadeIn = function (armature, animationState, timelineData, time) { - var self = this; - self._armature = armature; - self._animationState = animationState; - self._timeline = timelineData; - var isMainTimeline = this == self._animationState._timeline; - self._hasAsynchronyTimeline = isMainTimeline || self._animationState.animationData.hasAsynchronyTimeline; - self._frameRate = self._armature.armatureData.frameRate; - self._keyFrameCount = self._timeline.frames.length; - self._frameCount = self._animationState.animationData.frameCount; - self._position = self._animationState._position; - self._duration = self._animationState._duration; - self._animationDutation = self._animationState.animationData.duration; - self._timeScale = isMainTimeline ? 1 : (1 / self._timeline.scale); - self._timeOffset = isMainTimeline ? 0 : self._timeline.offset; - self._onFadeIn(); - self.setCurrentTime(time); - }; - p.fadeOut = function () { }; - p.update = function (time) { - var self = this; - var prevTime = self._currentTime; - if (!self._isCompleted && self._setCurrentTime(time) && self._keyFrameCount) { - var currentFrameIndex = self._keyFrameCount > 1 ? Math.floor(self._currentTime * self._frameRate) : 0; - var currentFrame = self._timeline.frames[currentFrameIndex]; - if (self._currentFrame != currentFrame) { - if (self._keyFrameCount > 1) { - var crossedFrame = self._currentFrame; - self._currentFrame = currentFrame; - if (!crossedFrame) { - var prevFrameIndex = Math.floor(prevTime * self._frameRate); - crossedFrame = self._timeline.frames[prevFrameIndex]; - if (!self._isReverse && prevTime <= crossedFrame.position) { - crossedFrame = crossedFrame.prev; - } - } - if (self._isReverse) { - while (crossedFrame != currentFrame) { - self._onCrossFrame(crossedFrame); - crossedFrame = crossedFrame.prev; - } - } - else { - while (crossedFrame != currentFrame) { - crossedFrame = crossedFrame.next; - self._onCrossFrame(crossedFrame); - } - } - self._onArriveAtFrame(true); - } - else { - self._currentFrame = currentFrame; - self._onCrossFrame(self._currentFrame); - self._onArriveAtFrame(true); - } - } - self._onUpdateFrame(true); - } + return ActionData; + }(dragonBones.BaseObject)); + dragonBones.ActionData = ActionData; + /** + * @private + */ + var EventData = (function (_super) { + __extends(EventData, _super); + function EventData() { + _super.call(this); + } + EventData.toString = function () { + return "[class dragonBones.EventData]"; }; - return TimelineState; + EventData.prototype._onClear = function () { + this.type = 0 /* Frame */; + this.name = null; + this.data = null; + this.bone = null; + this.slot = null; + }; + return EventData; }(dragonBones.BaseObject)); - dragonBones.TimelineState = TimelineState; - egret.registerClass(TimelineState,'dragonBones.TimelineState'); + dragonBones.EventData = EventData; /** * @private */ - var TweenTimelineState = (function (_super) { - __extends(TweenTimelineState, _super); - function TweenTimelineState() { + var FrameData = (function (_super) { + __extends(FrameData, _super); + function FrameData() { _super.call(this); } - var d = __define,c=TweenTimelineState,p=c.prototype; - TweenTimelineState._getEasingValue = function (progress, easing) { - var value = 1; - if (easing > 2) { - return progress; - } - else if (easing > 1) { - value = 0.5 * (1 - Math.cos(progress * Math.PI)); - easing -= 1; - } - else if (easing > 0) { - value = 1 - Math.pow(1 - progress, 2); - } - else if (easing >= -1) { - easing *= -1; - value = Math.pow(progress, 2); - } - else if (easing >= -2) { - easing *= -1; - value = Math.acos(1 - progress * 2) / Math.PI; - easing -= 1; - } - else { - return progress; - } - return (value - progress) * easing + progress; + /** + * @inheritDoc + */ + FrameData.prototype._onClear = function () { + this.position = 0; + this.duration = 0; + this.prev = null; + this.next = null; }; - TweenTimelineState._getCurveEasingValue = function (progress, sampling) { - var x = 0; - var y = 0; - for (var i = 0, l = sampling.length; i < l; i += 2) { - x = sampling[i]; - y = sampling[i + 1]; - if (x >= progress) { - if (i == 0) { - return y * progress / x; - } - else { - var xP = sampling[i - 2]; - var yP = sampling[i - 1]; // i - 2 + 1 - return yP + (y - yP) * (progress - xP) / (x - xP); - } + return FrameData; + }(dragonBones.BaseObject)); + dragonBones.FrameData = FrameData; + /** + * @private + */ + var TweenFrameData = (function (_super) { + __extends(TweenFrameData, _super); + function TweenFrameData() { + _super.call(this); + } + TweenFrameData.samplingCurve = function (curve, frameCount) { + if (curve.length == 0 || frameCount == 0) { + return null; + } + var samplingTimes = frameCount + 2; + var samplingStep = 1 / samplingTimes; + var sampling = new Array((samplingTimes - 1) * 2); + // + curve.unshift(0, 0); + curve.push(1, 1); + var stepIndex = 0; + for (var i = 0; i < samplingTimes - 1; ++i) { + var step = samplingStep * (i + 1); + while (curve[stepIndex + 6] < step) { + stepIndex += 6; // stepIndex += 3 * 2 } + var x1 = curve[stepIndex]; + var x4 = curve[stepIndex + 6]; + var t = (step - x1) / (x4 - x1); + var l_t = 1 - t; + var powA = l_t * l_t; + var powB = t * t; + var kA = l_t * powA; + var kB = 3 * t * powA; + var kC = 3 * l_t * powB; + var kD = t * powB; + sampling[i * 2] = kA * x1 + kB * curve[stepIndex + 2] + kC * curve[stepIndex + 4] + kD * x4; + sampling[i * 2 + 1] = kA * curve[stepIndex + 1] + kB * curve[stepIndex + 3] + kC * curve[stepIndex + 5] + kD * curve[stepIndex + 7]; } - return y + (1 - y) * (progress - x) / (1 - x); + return sampling; }; /** * @inheritDoc */ - p._onClear = function () { + TweenFrameData.prototype._onClear = function () { _super.prototype._onClear.call(this); - this._tweenProgress = 0; - this._tweenEasing = dragonBones.DragonBones.NO_TWEEN; - this._curve = null; - }; - p._onArriveAtFrame = function (isUpdate) { - var self = this; - self._tweenEasing = self._currentFrame.tweenEasing; - self._curve = self._currentFrame.curve; - if (self._keyFrameCount == 1 || - (self._currentFrame.next == self._timeline.frames[0] && - (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve) && - self._animationState.playTimes > 0 && - self._animationState.currentPlayTimes == self._animationState.playTimes - 1)) { - self._tweenEasing = dragonBones.DragonBones.NO_TWEEN; - self._curve = null; - } + this.tweenEasing = 0; + this.curve = null; }; - p._onUpdateFrame = function (isUpdate) { - var self = this; - if (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN && self._currentFrame.duration > 0) { - self._tweenProgress = (self._currentTime - self._currentFrame.position + self._position) / self._currentFrame.duration; - if (self._tweenEasing != 0) { - self._tweenProgress = TweenTimelineState._getEasingValue(self._tweenProgress, self._tweenEasing); - } - } - else if (self._curve) { - self._tweenProgress = (self._currentTime - self._currentFrame.position + self._position) / self._currentFrame.duration; - self._tweenProgress = TweenTimelineState._getCurveEasingValue(self._tweenProgress, self._curve); - } - else { - self._tweenProgress = 0; - } + return TweenFrameData; + }(FrameData)); + dragonBones.TweenFrameData = TweenFrameData; + /** + * @private + */ + var AnimationFrameData = (function (_super) { + __extends(AnimationFrameData, _super); + function AnimationFrameData() { + _super.call(this); + this.actions = []; + this.events = []; + } + AnimationFrameData.toString = function () { + return "[class dragonBones.AnimationFrameData]"; }; - p._updateExtensionKeyFrame = function (current, next, result) { - var tweenType = 0 /* None */; - if (current.type == next.type) { - for (var i = 0, l = current.tweens.length; i < l; ++i) { - var tweenDuration = next.tweens[i] - current.tweens[i]; - result.tweens[i] = tweenDuration; - if (tweenDuration != 0) { - tweenType = 2 /* Always */; - } + /** + * @inheritDoc + */ + AnimationFrameData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.actions.length) { + for (var i = 0, l = this.actions.length; i < l; ++i) { + this.actions[i].returnToPool(); } + this.actions.length = 0; } - if (tweenType == 0 /* None */) { - if (result.type != current.type) { - tweenType = 1 /* Once */; - result.type = current.type; - } - if (result.tweens.length != current.tweens.length) { - tweenType = 1 /* Once */; - result.tweens.length = current.tweens.length; - } - if (result.keys.length != current.keys.length) { - tweenType = 1 /* Once */; - result.keys.length = current.keys.length; - } - for (var i = 0, l = current.keys.length; i < l; ++i) { - var key = current.keys[i]; - if (result.keys[i] != key) { - tweenType = 1 /* Once */; - result.keys[i] = key; - } + if (this.events.length) { + for (var i = 0, l = this.events.length; i < l; ++i) { + this.events[i].returnToPool(); } + this.events.length = 0; } - return tweenType; }; - return TweenTimelineState; - }(TimelineState)); - dragonBones.TweenTimelineState = TweenTimelineState; - egret.registerClass(TweenTimelineState,'dragonBones.TweenTimelineState'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { + return AnimationFrameData; + }(FrameData)); + dragonBones.AnimationFrameData = AnimationFrameData; /** * @private */ - var AnimationTimelineState = (function (_super) { - __extends(AnimationTimelineState, _super); - function AnimationTimelineState() { + var BoneFrameData = (function (_super) { + __extends(BoneFrameData, _super); + function BoneFrameData() { _super.call(this); + this.transform = new dragonBones.Transform(); } - var d = __define,c=AnimationTimelineState,p=c.prototype; - AnimationTimelineState.toString = function () { - return "[Class dragonBones.AnimationTimelineState]"; + BoneFrameData.toString = function () { + return "[class dragonBones.BoneFrameData]"; }; /** * @inheritDoc */ - p._onClear = function () { + BoneFrameData.prototype._onClear = function () { _super.prototype._onClear.call(this); - this._isStarted = false; - }; - p._onCrossFrame = function (frame) { - var self = this; - var actions = frame.actions; - for (var i = 0, l = actions.length; i < l; ++i) { - var actionData = actions[i]; - if (actionData.slot) { - var slot = self._armature.getSlot(actionData.slot.name); - if (slot) { - var childArmature = slot.childArmature; - if (childArmature) { - childArmature._action = actionData; - } - } - } - else if (actionData.bone) { - var slots = self._armature.getSlots(); - for (var i_1 = 0, l_1 = slots.length; i_1 < l_1; ++i_1) { - var eachChildArmature = slots[i_1].childArmature; - if (eachChildArmature) { - eachChildArmature._action = actionData; - } - } - } - else { - self._armature._action = actionData; - } - } - var eventDispatcher = self._armature._display; - var events = frame.events; - for (var i = 0, l = events.length; i < l; ++i) { - var eventData = events[i]; - var eventType = ""; - switch (eventData.type) { - case 0 /* Frame */: - eventType = dragonBones.EventObject.FRAME_EVENT; - break; - case 1 /* Sound */: - eventType = dragonBones.EventObject.SOUND_EVENT; - break; - } - if (eventDispatcher.hasEvent(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.animationState = self._animationState; - if (eventData.bone) { - eventObject.bone = self._armature.getBone(eventData.bone.name); - } - if (eventData.slot) { - eventObject.slot = self._armature.getSlot(eventData.slot.name); - } - eventObject.name = eventData.name; - eventObject.data = eventData.data; - self._armature._bufferEvent(eventObject, eventType); - } - } - }; - p.update = function (time) { - var self = this; - var prevPlayTimes = self._currentPlayTimes; - var eventDispatcher = self._armature._display; - if (!self._isStarted && time != 0) { - self._isStarted = true; - if (eventDispatcher.hasEvent(dragonBones.EventObject.START)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.animationState = self._animationState; - self._armature._bufferEvent(eventObject, dragonBones.EventObject.START); - } - } - _super.prototype.update.call(this, time); - if (prevPlayTimes != self._currentPlayTimes) { - var eventType = self._isCompleted ? dragonBones.EventObject.COMPLETE : dragonBones.EventObject.LOOP_COMPLETE; - if (eventDispatcher.hasEvent(eventType)) { - var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); - eventObject.animationState = self._animationState; - self._armature._bufferEvent(eventObject, eventType); - } - } + this.tweenScale = false; + this.tweenRotate = 0; + this.transform.identity(); }; - return AnimationTimelineState; - }(dragonBones.TimelineState)); - dragonBones.AnimationTimelineState = AnimationTimelineState; - egret.registerClass(AnimationTimelineState,'dragonBones.AnimationTimelineState'); + return BoneFrameData; + }(TweenFrameData)); + dragonBones.BoneFrameData = BoneFrameData; /** * @private */ - var BoneTimelineState = (function (_super) { - __extends(BoneTimelineState, _super); - function BoneTimelineState() { + var SlotFrameData = (function (_super) { + __extends(SlotFrameData, _super); + function SlotFrameData() { _super.call(this); - this._transform = new dragonBones.Transform(); - this._currentTransform = new dragonBones.Transform(); - this._durationTransform = new dragonBones.Transform(); } - var d = __define,c=BoneTimelineState,p=c.prototype; - BoneTimelineState.toString = function () { - return "[Class dragonBones.BoneTimelineState]"; + SlotFrameData.generateColor = function () { + return new dragonBones.ColorTransform(); + }; + SlotFrameData.toString = function () { + return "[class dragonBones.SlotFrameData]"; }; /** * @inheritDoc */ - p._onClear = function () { - var self = this; + SlotFrameData.prototype._onClear = function () { _super.prototype._onClear.call(this); - self.bone = null; - self._tweenTransform = 0 /* None */; - self._tweenRotate = 0 /* None */; - self._tweenScale = 0 /* None */; - self._boneTransform = null; - self._originTransform = null; - self._transform.identity(); - self._currentTransform.identity(); - self._durationTransform.identity(); - }; - p._onFadeIn = function () { - var self = this; - self._originTransform = self._timeline.originTransform; - self._boneTransform = self.bone._animationPose; + this.displayIndex = 0; + this.zOrder = 0; + this.color = null; }; - p._onArriveAtFrame = function (isUpdate) { - var self = this; - _super.prototype._onArriveAtFrame.call(this, isUpdate); - self._currentTransform.copyFrom(self._currentFrame.transform); - self._tweenTransform = 1 /* Once */; - self._tweenRotate = 1 /* Once */; - self._tweenScale = 1 /* Once */; - if (self._keyFrameCount > 1 && (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve)) { - var nextFrame = self._currentFrame.next; - var nextTransform = nextFrame.transform; - // Transform. - self._durationTransform.x = nextTransform.x - self._currentTransform.x; - self._durationTransform.y = nextTransform.y - self._currentTransform.y; - if (self._durationTransform.x != 0 || self._durationTransform.y != 0) { - self._tweenTransform = 2 /* Always */; - } - // Rotate. - var tweenRotate = self._currentFrame.tweenRotate; - if (tweenRotate == tweenRotate) { - if (tweenRotate) { - if (tweenRotate > 0 ? nextTransform.skewY >= self._currentTransform.skewY : nextTransform.skewY <= self._currentTransform.skewY) { - var rotate = tweenRotate > 0 ? tweenRotate - 1 : tweenRotate + 1; - self._durationTransform.skewX = nextTransform.skewX - self._currentTransform.skewX + dragonBones.DragonBones.PI_D * rotate; - self._durationTransform.skewY = nextTransform.skewY - self._currentTransform.skewY + dragonBones.DragonBones.PI_D * rotate; - } - else { - self._durationTransform.skewX = nextTransform.skewX - self._currentTransform.skewX + dragonBones.DragonBones.PI_D * tweenRotate; - self._durationTransform.skewY = nextTransform.skewY - self._currentTransform.skewY + dragonBones.DragonBones.PI_D * tweenRotate; - } - } - else { - self._durationTransform.skewX = dragonBones.Transform.normalizeRadian(nextTransform.skewX - self._currentTransform.skewX); - self._durationTransform.skewY = dragonBones.Transform.normalizeRadian(nextTransform.skewY - self._currentTransform.skewY); - } - if (self._durationTransform.skewX != 0 || self._durationTransform.skewY != 0) { - self._tweenRotate = 2 /* Always */; - } - } - else { - self._durationTransform.skewX = 0; - self._durationTransform.skewY = 0; - } - // Scale. - if (self._currentFrame.tweenScale) { - self._durationTransform.scaleX = nextTransform.scaleX - self._currentTransform.scaleX; - self._durationTransform.scaleY = nextTransform.scaleY - self._currentTransform.scaleY; - if (self._durationTransform.scaleX != 0 || self._durationTransform.scaleY != 0) { - self._tweenScale = 2 /* Always */; - } - } - else { - self._durationTransform.scaleX = 0; - self._durationTransform.scaleY = 0; - } + SlotFrameData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotFrameData; + }(TweenFrameData)); + dragonBones.SlotFrameData = SlotFrameData; + /** + * @private + */ + var ExtensionFrameData = (function (_super) { + __extends(ExtensionFrameData, _super); + function ExtensionFrameData() { + _super.call(this); + this.tweens = []; + this.keys = []; + } + ExtensionFrameData.toString = function () { + return "[class dragonBones.ExtensionFrameData]"; + }; + /** + * @inheritDoc + */ + ExtensionFrameData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.type = 0 /* FFD */; + if (this.tweens.length) { + this.tweens.length = 0; } - else { - self._durationTransform.x = 0; - self._durationTransform.y = 0; - self._durationTransform.skewX = 0; - self._durationTransform.skewY = 0; - self._durationTransform.scaleX = 0; - self._durationTransform.scaleY = 0; + if (this.keys.length) { + this.keys.length = 0; } }; - p._onUpdateFrame = function (isUpdate) { - var self = this; - if (self._tweenTransform || self._tweenRotate || self._tweenScale) { - _super.prototype._onUpdateFrame.call(this, isUpdate); - if (self._tweenTransform) { - if (self._tweenTransform == 1 /* Once */) { - self._tweenTransform = 0 /* None */; - } - if (self._animationState.additiveBlending) { - self._transform.x = self._currentTransform.x + self._durationTransform.x * self._tweenProgress; - self._transform.y = self._currentTransform.y + self._durationTransform.y * self._tweenProgress; - } - else { - self._transform.x = self._originTransform.x + self._currentTransform.x + self._durationTransform.x * self._tweenProgress; - self._transform.y = self._originTransform.y + self._currentTransform.y + self._durationTransform.y * self._tweenProgress; - } - } - if (self._tweenRotate) { - if (self._tweenRotate == 1 /* Once */) { - self._tweenRotate = 0 /* None */; - } - if (self._animationState.additiveBlending) { - self._transform.skewX = self._currentTransform.skewX + self._durationTransform.skewX * self._tweenProgress; - self._transform.skewY = self._currentTransform.skewY + self._durationTransform.skewY * self._tweenProgress; - } - else { - self._transform.skewX = self._originTransform.skewX + self._currentTransform.skewX + self._durationTransform.skewX * self._tweenProgress; - self._transform.skewY = self._originTransform.skewY + self._currentTransform.skewY + self._durationTransform.skewY * self._tweenProgress; - } - } - if (self._tweenScale) { - if (self._tweenScale == 1 /* Once */) { - self._tweenScale = 0 /* None */; - } - if (self._animationState.additiveBlending) { - self._transform.scaleX = self._currentTransform.scaleX + self._durationTransform.scaleX * self._tweenProgress; - self._transform.scaleY = self._currentTransform.scaleY + self._durationTransform.scaleY * self._tweenProgress; - } - else { - self._transform.scaleX = self._originTransform.scaleX * (self._currentTransform.scaleX + self._durationTransform.scaleX * self._tweenProgress); - self._transform.scaleY = self._originTransform.scaleY * (self._currentTransform.scaleY + self._durationTransform.scaleY * self._tweenProgress); + return ExtensionFrameData; + }(TweenFrameData)); + dragonBones.ExtensionFrameData = ExtensionFrameData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @private + */ + var TimelineData = (function (_super) { + __extends(TimelineData, _super); + function TimelineData() { + _super.call(this); + /** + * @private + */ + this.frames = []; + } + /** + * @inheritDoc + */ + TimelineData.prototype._onClear = function () { + this.scale = 1; + this.offset = 0; + if (this.frames.length) { + var prevFrame = null; + for (var i = 0, l = this.frames.length; i < l; ++i) { + var frame = this.frames[i]; + if (prevFrame && frame != prevFrame) { + prevFrame.returnToPool(); } + prevFrame = frame; } - self.bone.invalidUpdate(); + this.frames.length = 0; } }; - p.fadeOut = function () { - var self = this; - self._transform.skewX = dragonBones.Transform.normalizeRadian(self._transform.skewX); - self._transform.skewY = dragonBones.Transform.normalizeRadian(self._transform.skewY); + return TimelineData; + }(dragonBones.BaseObject)); + dragonBones.TimelineData = TimelineData; + /** + * @private + */ + var BoneTimelineData = (function (_super) { + __extends(BoneTimelineData, _super); + function BoneTimelineData() { + _super.call(this); + this.bone = null; + this.originTransform = new dragonBones.Transform(); + this.cachedFrames = []; + } + BoneTimelineData.cacheFrame = function (cacheFrames, cacheFrameIndex, globalTransformMatrix) { + var cacheMatrix = cacheFrames[cacheFrameIndex] = new dragonBones.Matrix(); + cacheMatrix.copyFrom(globalTransformMatrix); + return cacheMatrix; }; - p.update = function (time) { - var self = this; - _super.prototype.update.call(this, time); - // Blend animation state. - var weight = self._animationState._weightResult; - if (weight > 0) { - if (self.bone._blendIndex == 0) { - self._boneTransform.x = self._transform.x * weight; - self._boneTransform.y = self._transform.y * weight; - self._boneTransform.skewX = self._transform.skewX * weight; - self._boneTransform.skewY = self._transform.skewY * weight; - self._boneTransform.scaleX = (self._transform.scaleX - 1) * weight + 1; - self._boneTransform.scaleY = (self._transform.scaleY - 1) * weight + 1; - } - else { - self._boneTransform.x += self._transform.x * weight; - self._boneTransform.y += self._transform.y * weight; - self._boneTransform.skewX += self._transform.skewX * weight; - self._boneTransform.skewY += self._transform.skewY * weight; - self._boneTransform.scaleX += (self._transform.scaleX - 1) * weight; - self._boneTransform.scaleY += (self._transform.scaleY - 1) * weight; - } - self.bone._blendIndex++; - var fadeProgress = self._animationState._fadeProgress; - if (fadeProgress < 1) { - self.bone.invalidUpdate(); - } + BoneTimelineData.toString = function () { + return "[class dragonBones.BoneTimelineData]"; + }; + /** + * @inheritDoc + */ + BoneTimelineData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.bone = null; + this.originTransform.identity(); + if (this.cachedFrames.length) { + this.cachedFrames.length = 0; } }; - return BoneTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.BoneTimelineState = BoneTimelineState; - egret.registerClass(BoneTimelineState,'dragonBones.BoneTimelineState'); + BoneTimelineData.prototype.cacheFrames = function (cacheFrameCount) { + this.cachedFrames.length = 0; + this.cachedFrames.length = cacheFrameCount; + }; + return BoneTimelineData; + }(TimelineData)); + dragonBones.BoneTimelineData = BoneTimelineData; /** * @private */ - var SlotTimelineState = (function (_super) { - __extends(SlotTimelineState, _super); - function SlotTimelineState() { + var SlotTimelineData = (function (_super) { + __extends(SlotTimelineData, _super); + function SlotTimelineData() { _super.call(this); - this._color = new dragonBones.ColorTransform(); - this._durationColor = new dragonBones.ColorTransform(); + this.slot = null; + this.cachedFrames = []; } - var d = __define,c=SlotTimelineState,p=c.prototype; - SlotTimelineState.toString = function () { - return "[Class dragonBones.SlotTimelineState]"; + SlotTimelineData.cacheFrame = function (cacheFrames, cacheFrameIndex, globalTransformMatrix) { + var cacheMatrix = cacheFrames[cacheFrameIndex] = new dragonBones.Matrix(); + cacheMatrix.copyFrom(globalTransformMatrix); + return cacheMatrix; + }; + SlotTimelineData.toString = function () { + return "[class dragonBones.SlotTimelineData]"; }; /** * @inheritDoc */ - p._onClear = function () { - var self = this; + SlotTimelineData.prototype._onClear = function () { _super.prototype._onClear.call(this); - self.slot = null; - self._colorDirty = false; - self._tweenColor = 0 /* None */; - self._slotColor = null; - self._color.identity(); - self._durationColor.identity(); - }; - p._onFadeIn = function () { - this._slotColor = this.slot._colorTransform; - }; - p._onArriveAtFrame = function (isUpdate) { - var self = this; - _super.prototype._onArriveAtFrame.call(this, isUpdate); - if (self._animationState._isDisabled(self.slot)) { - self._tweenEasing = dragonBones.DragonBones.NO_TWEEN; - self._curve = null; - self._tweenColor = 0 /* None */; - return; - } - if (self.slot._displayDataSet) { - var displayIndex = self._currentFrame.displayIndex; - if (self.slot.displayIndex >= 0 && displayIndex >= 0) { - if (self.slot._displayDataSet.displays.length > 1) { - self.slot._setDisplayIndex(displayIndex); - } - } - else { - self.slot._setDisplayIndex(displayIndex); - } - self.slot._updateMeshData(true); + this.slot = null; + if (this.cachedFrames.length) { + this.cachedFrames.length = 0; } - if (self._currentFrame.displayIndex >= 0) { - self._tweenColor = 0 /* None */; - var currentColor = self._currentFrame.color; - if (self._keyFrameCount > 1 && (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve)) { - var nextFrame = self._currentFrame.next; - var nextColor = nextFrame.color; - if (currentColor != nextColor && nextFrame.displayIndex >= 0) { - self._durationColor.alphaMultiplier = nextColor.alphaMultiplier - currentColor.alphaMultiplier; - self._durationColor.redMultiplier = nextColor.redMultiplier - currentColor.redMultiplier; - self._durationColor.greenMultiplier = nextColor.greenMultiplier - currentColor.greenMultiplier; - self._durationColor.blueMultiplier = nextColor.blueMultiplier - currentColor.blueMultiplier; - self._durationColor.alphaOffset = nextColor.alphaOffset - currentColor.alphaOffset; - self._durationColor.redOffset = nextColor.redOffset - currentColor.redOffset; - self._durationColor.greenOffset = nextColor.greenOffset - currentColor.greenOffset; - self._durationColor.blueOffset = nextColor.blueOffset - currentColor.blueOffset; - if (self._durationColor.alphaMultiplier != 0 || - self._durationColor.redMultiplier != 0 || - self._durationColor.greenMultiplier != 0 || - self._durationColor.blueMultiplier != 0 || - self._durationColor.alphaOffset != 0 || - self._durationColor.redOffset != 0 || - self._durationColor.greenOffset != 0 || - self._durationColor.blueOffset != 0) { - self._tweenColor = 2 /* Always */; - } - } - } - if (self._tweenColor == 0 /* None */) { - self._durationColor.alphaMultiplier = currentColor.alphaMultiplier - self._slotColor.alphaMultiplier; - self._durationColor.redMultiplier = currentColor.redMultiplier - self._slotColor.redMultiplier; - self._durationColor.greenMultiplier = currentColor.greenMultiplier - self._slotColor.greenMultiplier; - self._durationColor.blueMultiplier = currentColor.blueMultiplier - self._slotColor.blueMultiplier; - self._durationColor.alphaOffset = currentColor.alphaOffset - self._slotColor.alphaOffset; - self._durationColor.redOffset = currentColor.redOffset - self._slotColor.redOffset; - self._durationColor.greenOffset = currentColor.greenOffset - self._slotColor.greenOffset; - self._durationColor.blueOffset = currentColor.blueOffset - self._slotColor.blueOffset; - if (self._durationColor.alphaMultiplier != 0 || - self._durationColor.redMultiplier != 0 || - self._durationColor.greenMultiplier != 0 || - self._durationColor.blueMultiplier != 0 || - self._durationColor.alphaOffset != 0 || - self._durationColor.redOffset != 0 || - self._durationColor.greenOffset != 0 || - self._durationColor.blueOffset != 0) { - self._tweenColor = 1 /* Once */; - } - } - } - else { - self._tweenEasing = dragonBones.DragonBones.NO_TWEEN; - self._curve = null; - self._tweenColor = 0 /* None */; - } - }; - p._onUpdateFrame = function (isUpdate) { - var self = this; - _super.prototype._onUpdateFrame.call(this, isUpdate); - if (self._tweenColor) { - if (self._tweenColor == 1 /* Once */) { - self._tweenColor = 0 /* None */; - } - var currentColor = self._currentFrame.color; - self._color.alphaMultiplier = currentColor.alphaMultiplier + self._durationColor.alphaMultiplier * self._tweenProgress; - self._color.redMultiplier = currentColor.redMultiplier + self._durationColor.redMultiplier * self._tweenProgress; - self._color.greenMultiplier = currentColor.greenMultiplier + self._durationColor.greenMultiplier * self._tweenProgress; - self._color.blueMultiplier = currentColor.blueMultiplier + self._durationColor.blueMultiplier * self._tweenProgress; - self._color.alphaOffset = currentColor.alphaOffset + self._durationColor.alphaOffset * self._tweenProgress; - self._color.redOffset = currentColor.redOffset + self._durationColor.redOffset * self._tweenProgress; - self._color.greenOffset = currentColor.greenOffset + self._durationColor.greenOffset * self._tweenProgress; - self._color.blueOffset = currentColor.blueOffset + self._durationColor.blueOffset * self._tweenProgress; - self._colorDirty = true; - } - }; - p.fadeOut = function () { - this._tweenColor = 0 /* None */; }; - p.update = function (time) { - var self = this; - _super.prototype.update.call(this, time); - // Fade animation. - if (self._tweenColor != 0 /* None */ || self._colorDirty) { - var weight = self._animationState._weightResult; - if (weight > 0) { - var fadeProgress = self._animationState._fadeProgress; - if (fadeProgress < 1) { - self._slotColor.alphaMultiplier += (self._color.alphaMultiplier - self._slotColor.alphaMultiplier) * fadeProgress; - self._slotColor.redMultiplier += (self._color.redMultiplier - self._slotColor.redMultiplier) * fadeProgress; - self._slotColor.greenMultiplier += (self._color.greenMultiplier - self._slotColor.greenMultiplier) * fadeProgress; - self._slotColor.blueMultiplier += (self._color.blueMultiplier - self._slotColor.blueMultiplier) * fadeProgress; - self._slotColor.alphaOffset += (self._color.alphaOffset - self._slotColor.alphaOffset) * fadeProgress; - self._slotColor.redOffset += (self._color.redOffset - self._slotColor.redOffset) * fadeProgress; - self._slotColor.greenOffset += (self._color.greenOffset - self._slotColor.greenOffset) * fadeProgress; - self._slotColor.blueOffset += (self._color.blueOffset - self._slotColor.blueOffset) * fadeProgress; - self.slot._colorDirty = true; - } - else if (self._colorDirty) { - self._colorDirty = false; - self._slotColor.alphaMultiplier = self._color.alphaMultiplier; - self._slotColor.redMultiplier = self._color.redMultiplier; - self._slotColor.greenMultiplier = self._color.greenMultiplier; - self._slotColor.blueMultiplier = self._color.blueMultiplier; - self._slotColor.alphaOffset = self._color.alphaOffset; - self._slotColor.redOffset = self._color.redOffset; - self._slotColor.greenOffset = self._color.greenOffset; - self._slotColor.blueOffset = self._color.blueOffset; - self.slot._colorDirty = true; - } - } - } + SlotTimelineData.prototype.cacheFrames = function (cacheFrameCount) { + this.cachedFrames.length = 0; + this.cachedFrames.length = cacheFrameCount; }; - return SlotTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.SlotTimelineState = SlotTimelineState; - egret.registerClass(SlotTimelineState,'dragonBones.SlotTimelineState'); + return SlotTimelineData; + }(TimelineData)); + dragonBones.SlotTimelineData = SlotTimelineData; /** * @private */ - var FFDTimelineState = (function (_super) { - __extends(FFDTimelineState, _super); - function FFDTimelineState() { + var FFDTimelineData = (function (_super) { + __extends(FFDTimelineData, _super); + function FFDTimelineData() { _super.call(this); - this._ffdVertices = []; + this.displayIndex = 0; + this.skin = null; + this.slot = null; } - var d = __define,c=FFDTimelineState,p=c.prototype; - FFDTimelineState.toString = function () { - return "[Class dragonBones.FFDTimelineState]"; + FFDTimelineData.toString = function () { + return "[class dragonBones.FFDTimelineData]"; }; /** * @inheritDoc */ - p._onClear = function () { - var self = this; + FFDTimelineData.prototype._onClear = function () { _super.prototype._onClear.call(this); - self.slot = null; - self._tweenFFD = 0 /* None */; - self._slotFFDVertices = null; - if (self._durationFFDFrame) { - self._durationFFDFrame.returnToPool(); - self._durationFFDFrame = null; - } - if (self._ffdVertices.length) { - self._ffdVertices.length = 0; - } - }; - p._onFadeIn = function () { - var self = this; - self._slotFFDVertices = self.slot._ffdVertices; - self._durationFFDFrame = dragonBones.BaseObject.borrowObject(dragonBones.ExtensionFrameData); - self._durationFFDFrame.tweens.length = self._slotFFDVertices.length; - self._ffdVertices.length = self._slotFFDVertices.length; - for (var i = 0, l = self._durationFFDFrame.tweens.length; i < l; ++i) { - self._durationFFDFrame.tweens[i] = 0; - } - for (var i = 0, l = self._ffdVertices.length; i < l; ++i) { - self._ffdVertices[i] = 0; - } - }; - p._onArriveAtFrame = function (isUpdate) { - var self = this; - _super.prototype._onArriveAtFrame.call(this, isUpdate); - self._tweenFFD = 0 /* None */; - if (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve) { - self._tweenFFD = self._updateExtensionKeyFrame(self._currentFrame, self._currentFrame.next, self._durationFFDFrame); - } - if (self._tweenFFD == 0 /* None */) { - var currentFFDVertices = self._currentFrame.tweens; - for (var i = 0, l = currentFFDVertices.length; i < l; ++i) { - if (self._slotFFDVertices[i] != currentFFDVertices[i]) { - self._tweenFFD = 1 /* Once */; - break; - } - } - } - }; - p._onUpdateFrame = function (isUpdate) { - var self = this; - _super.prototype._onUpdateFrame.call(this, isUpdate); - if (self._tweenFFD != 0 /* None */) { - if (self._tweenFFD == 1 /* Once */) { - self._tweenFFD = 0 /* None */; - } - var currentFFDVertices = self._currentFrame.tweens; - var nextFFDVertices = self._durationFFDFrame.tweens; - for (var i = 0, l = currentFFDVertices.length; i < l; ++i) { - self._ffdVertices[i] = currentFFDVertices[i] + nextFFDVertices[i] * self._tweenProgress; - } - self.slot._ffdDirty = true; - } - }; - p.update = function (time) { - var self = this; - _super.prototype.update.call(this, time); - // Blend animation. - var weight = self._animationState._weightResult; - if (weight > 0) { - if (self.slot._blendIndex == 0) { - for (var i = 0, l = self._ffdVertices.length; i < l; ++i) { - self._slotFFDVertices[i] = self._ffdVertices[i] * weight; - } - } - else { - for (var i = 0, l = self._ffdVertices.length; i < l; ++i) { - self._slotFFDVertices[i] += self._ffdVertices[i] * weight; - } - } - self.slot._blendIndex++; - var fadeProgress = self._animationState._fadeProgress; - if (fadeProgress < 1) { - self.slot._ffdDirty = true; - } - } + this.displayIndex = 0; + this.skin = null; + this.slot = null; }; - return FFDTimelineState; - }(dragonBones.TweenTimelineState)); - dragonBones.FFDTimelineState = FFDTimelineState; - egret.registerClass(FFDTimelineState,'dragonBones.FFDTimelineState'); + return FFDTimelineData; + }(TimelineData)); + dragonBones.FFDTimelineData = FFDTimelineData; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** * @language zh_CN - * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。 - * @see dragonBones.IAnimatable + * 骨架数据。 * @see dragonBones.Armature * @version DragonBones 3.0 */ - var WorldClock = (function () { + var ArmatureData = (function (_super) { + __extends(ArmatureData, _super); /** - * @language zh_CN - * 创建一个新的 WorldClock 实例。 - * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。 - * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放) - * @version DragonBones 3.0 + * @private */ - function WorldClock() { + function ArmatureData() { + _super.call(this); + /** + * @private + */ + this.aabb = new dragonBones.Rectangle(); /** * @language zh_CN - * 当前的时间。 (以秒为单位) + * 所有的骨骼数据。 + * @see dragonBones.BoneData * @version DragonBones 3.0 */ - this.time = new Date().getTime() / dragonBones.DragonBones.SECOND_TO_MILLISECOND; + this.bones = {}; /** * @language zh_CN - * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] - * @default 1 + * 所有的插槽数据。 + * @see dragonBones.SlotData * @version DragonBones 3.0 */ - this.timeScale = 1; - this._animatebles = []; - } - var d = __define,c=WorldClock,p=c.prototype; - d(WorldClock, "clock" + this.slots = {}; /** * @language zh_CN - * 一个可以直接使用的全局静态 WorldClock 实例. + * 所有的皮肤数据。 + * @see dragonBones.SkinData * @version DragonBones 3.0 */ - ,function () { - if (!WorldClock._clock) { - WorldClock._clock = new WorldClock(); - } - return WorldClock._clock; - } - ); + this.skins = {}; + /** + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + this.animations = {}; + /** + * @private + */ + this.actions = []; + this._sortedBones = []; + this._sortedSlots = []; + this._bonesChildren = {}; + } + ArmatureData._onSortSlots = function (a, b) { + return a.zOrder > b.zOrder ? 1 : -1; + }; /** - * @language zh_CN - * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用) - * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) - * @version DragonBones 3.0 + * @private */ - p.advanceTime = function (passedTime) { - var self = this; - if (passedTime != passedTime) { - passedTime = 0; + ArmatureData.toString = function () { + return "[class dragonBones.ArmatureData]"; + }; + /** + * @inheritDoc + */ + ArmatureData.prototype._onClear = function () { + this.frameRate = 0; + this.cacheFrameRate = 0; + this.type = 0 /* Armature */; + this.name = null; + this.parent = null; + this.userData = null; + this.aabb.clear(); + for (var i in this.bones) { + this.bones[i].returnToPool(); + delete this.bones[i]; } - if (passedTime < 0) { - passedTime = new Date().getTime() / dragonBones.DragonBones.SECOND_TO_MILLISECOND - self.time; + for (var i in this.slots) { + this.slots[i].returnToPool(); + delete this.slots[i]; } - passedTime *= self.timeScale; - if (passedTime < 0) { - self.time -= passedTime; + for (var i in this.skins) { + this.skins[i].returnToPool(); + delete this.skins[i]; } - else { - self.time += passedTime; + for (var i in this.animations) { + this.animations[i].returnToPool(); + delete this.animations[i]; } - if (passedTime) { - var i = 0, r = 0, l = self._animatebles.length; - for (; i < l; ++i) { - var animateble = self._animatebles[i]; - if (animateble) { - animateble.advanceTime(passedTime); - } - else { - r++; - } - } - if (r > 0) { - r = 0; - l = self._animatebles.length; - for (; i < l; ++i) { - var animateble = self._animatebles[i]; - if (animateble) { - self._animatebles[i - r] = animateble; - } - else { - r++; - } - } - self._animatebles.length -= r; + if (this.actions.length) { + for (var i = 0, l = this.actions.length; i < l; ++i) { + this.actions[i].returnToPool(); } + this.actions.length = 0; + } + this._boneDirty = false; + this._slotDirty = false; + this._defaultSkin = null; + this._defaultAnimation = null; + if (this._sortedBones.length) { + this._sortedBones.length = 0; + } + if (this._sortedSlots.length) { + this._sortedSlots.length = 0; + } + for (var i in this._bonesChildren) { + delete this._bonesChildren[i]; } }; - /** - * 是否包含指定的 IAnimatable 实例 - * @param value 指定的 IAnimatable 实例。 - * @returns [true: 包含,false: 不包含]。 - * @version DragonBones 3.0 - */ - p.contains = function (value) { - return this._animatebles.indexOf(value) >= 0; - }; - /** - * @language zh_CN - * 添加指定的 IAnimatable 实例。 - * @param value IAnimatable 实例。 - * @version DragonBones 3.0 - */ - p.add = function (value) { - if (value && this._animatebles.indexOf(value) < 0) { - this._animatebles.push(value); - if (dragonBones.DragonBones.DEBUG && value instanceof dragonBones.Armature) { - dragonBones.DragonBones.addArmature(value); - } - } - }; - /** - * @language zh_CN - * 移除指定的 IAnimatable 实例。 - * @param value IAnimatable 实例。 - * @version DragonBones 3.0 - */ - p.remove = function (value) { - var index = this._animatebles.indexOf(value); - if (index >= 0) { - this._animatebles[index] = null; - if (dragonBones.DragonBones.DEBUG && value instanceof dragonBones.Armature) { - dragonBones.DragonBones.removeArmature(value); - } - } - }; - /** - * @language zh_CN - * 清除所有的 IAnimatable 实例。 - * @version DragonBones 3.0 - */ - p.clear = function () { - for (var i = 0, l = this._animatebles.length; i < l; ++i) { - this._animatebles[i] = null; - } - }; - WorldClock._clock = null; - return WorldClock; - }()); - dragonBones.WorldClock = WorldClock; - egret.registerClass(WorldClock,'dragonBones.WorldClock',["dragonBones.IAnimateble"]); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 - * @see dragonBones.ArmatureData - * @see dragonBones.Bone - * @see dragonBones.Slot - * @see dragonBones.Animation - * @see dragonBones.IArmatureDisplayContainer - * @version DragonBones 3.0 - */ - var Armature = (function (_super) { - __extends(Armature, _super); - /** - * @private - */ - function Armature() { - _super.call(this); - /** - * @private Store bones based on bones' hierarchy (From root to leaf) - */ - this._bones = []; - /** - * @private Store slots based on slots' zOrder (From low to high) - */ - this._slots = []; - /** - * @private - */ - this._events = []; - /** - * @deprecated - * @see #cacheFrameRate - */ - this.enableCache = false; - } - var d = __define,c=Armature,p=c.prototype; - /** - * @private - */ - Armature.toString = function () { - return "[Class dragonBones.Armature]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.userData = null; - self._bonesDirty = false; - self._cacheFrameIndex = -1; - self._armatureData = null; - self._skinData = null; - if (self._animation) { - self._animation.returnToPool(); - self._animation = null; - } - if (self._display) { - self._display._onClear(); - self._display = null; - } - self._parent = null; - self._action = null; - self._replacedTexture = null; - self._delayDispose = false; - self._lockDispose = false; - self._slotsDirty = false; - if (self._bones.length) { - for (var i = 0, l = self._bones.length; i < l; ++i) { - self._bones[i].returnToPool(); - } - self._bones.length = 0; - } - if (self._slots.length) { - for (var i = 0, l = self._slots.length; i < l; ++i) { - self._slots[i].returnToPool(); - } - self._slots.length = 0; - } - if (self._events.length) { - for (var i = 0, l = self._events.length; i < l; ++i) { - self._events[i].returnToPool(); - } - self._events.length = 0; - } - }; - /** - * @private - */ - p._sortBones = function () { - var total = this._bones.length; + ArmatureData.prototype._sortBones = function () { + var total = this._sortedBones.length; if (!total) { return; } - var sortHelper = this._bones.concat(); + var sortHelper = this._sortedBones.concat(); var index = 0; var count = 0; - this._bones.length = 0; + this._sortedBones.length = 0; while (count < total) { var bone = sortHelper[index++]; if (index >= total) { index = 0; } - if (this._bones.indexOf(bone) >= 0) { + if (this._sortedBones.indexOf(bone) >= 0) { continue; } - if (bone.parent && this._bones.indexOf(bone.parent) < 0) { + if (bone.parent && this._sortedBones.indexOf(bone.parent) < 0) { continue; } - if (bone.ik && this._bones.indexOf(bone.ik) < 0) { + if (bone.ik && this._sortedBones.indexOf(bone.ik) < 0) { continue; } - if (bone.ik && bone.ikChain > 0 && bone.ikChainIndex == bone.ikChain) { - this._bones.splice(this._bones.indexOf(bone.parent) + 1, 0, bone); // ik, parent, bone, children + if (bone.ik && bone.chain > 0 && bone.chainIndex == bone.chain) { + this._sortedBones.splice(this._sortedBones.indexOf(bone.parent) + 1, 0, bone); } else { - this._bones.push(bone); + this._sortedBones.push(bone); } count++; } }; - /** - * @private - */ - p._sortSlots = function () { + ArmatureData.prototype._sortSlots = function () { + this._sortedSlots.sort(ArmatureData._onSortSlots); }; /** * @private */ - p._addBoneToBoneList = function (value) { - if (this._bones.indexOf(value) < 0) { - this._bonesDirty = true; - this._bones[this._bones.length] = value; - this._animation._timelineStateDirty = true; + ArmatureData.prototype.cacheFrames = function (value) { + if (this.cacheFrameRate == value) { + return; + } + this.cacheFrameRate = value; + var frameScale = this.cacheFrameRate / this.frameRate; + for (var i in this.animations) { + this.animations[i].cacheFrames(frameScale); } }; /** * @private */ - p._removeBoneFromBoneList = function (value) { - var index = this._bones.indexOf(value); - if (index >= 0) { - this._bones.splice(index, 1); - this._animation._timelineStateDirty = true; + ArmatureData.prototype.addBone = function (value, parentName) { + if (value && value.name && !this.bones[value.name]) { + if (parentName) { + var parent_1 = this.getBone(parentName); + if (parent_1) { + value.parent = parent_1; + } + else { + (this._bonesChildren[parentName] = this._bonesChildren[parentName] || []).push(value); + } + } + var children = this._bonesChildren[value.name]; + if (children) { + for (var i = 0, l = children.length; i < l; ++i) { + children[i].parent = value; + } + delete this._bonesChildren[value.name]; + } + this.bones[value.name] = value; + this._sortedBones.push(value); + this._boneDirty = true; + } + else { + throw new Error(); } }; /** * @private */ - p._addSlotToSlotList = function (value) { - if (this._slots.indexOf(value) < 0) { - this._slotsDirty = true; - this._slots[this._slots.length] = value; - this._animation._timelineStateDirty = true; + ArmatureData.prototype.addSlot = function (value) { + if (value && value.name && !this.slots[value.name]) { + this.slots[value.name] = value; + this._sortedSlots.push(value); + this._slotDirty = true; + } + else { + throw new Error(); } }; /** * @private */ - p._removeSlotFromSlotList = function (value) { - var index = this._slots.indexOf(value); - if (index >= 0) { - this._slots.splice(index, 1); - this._animation._timelineStateDirty = true; + ArmatureData.prototype.addSkin = function (value) { + if (value && value.name && !this.skins[value.name]) { + this.skins[value.name] = value; + if (!this._defaultSkin) { + this._defaultSkin = value; + } + } + else { + throw new Error(); } }; /** * @private */ - p._bufferEvent = function (value, type) { - value.type = type; - value.armature = this; - this._events.push(value); + ArmatureData.prototype.addAnimation = function (value) { + if (value && value.name && !this.animations[value.name]) { + this.animations[value.name] = value; + if (!this._defaultAnimation) { + this._defaultAnimation = value; + } + } + else { + throw new Error(); + } }; /** * @language zh_CN - * 释放骨架。 (会回收到内存池) + * 获取指定名称的骨骼数据。 + * @param name 骨骼数据名称。 + * @see dragonBones.BoneData * @version DragonBones 3.0 */ - p.dispose = function () { - this._delayDispose = true; - if (!this._lockDispose) { - this.returnToPool(); - } + ArmatureData.prototype.getBone = function (name) { + return this.bones[name]; }; /** * @language zh_CN - * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新) - * @param passedTime 两帧之前的时间间隔。 (以秒为单位) - * @see dragonBones.IAnimateble - * @see dragonBones.WorldClock - * @see dragonBones.IArmatureDisplay + * 获取指定名称的插槽数据。 + * @param name 插槽数据名称。 + * @see dragonBones.SlotData * @version DragonBones 3.0 */ - p.advanceTime = function (passedTime) { - var self = this; - if (!self._lockDispose) { - self._lockDispose = true; - var scaledPassedTime = passedTime * self._animation.timeScale; - // Animations. - self._animation._advanceTime(scaledPassedTime); - // Bones and slots. - if (self._bonesDirty) { - self._bonesDirty = false; - self._sortBones(); - } - if (self._slotsDirty) { - self._slotsDirty = false; - self._sortSlots(); - } - for (var i = 0, l = self._bones.length; i < l; ++i) { - self._bones[i]._update(self._cacheFrameIndex); - } - for (var i = 0, l = self._slots.length; i < l; ++i) { - var slot = self._slots[i]; - slot._update(self._cacheFrameIndex); - var childArmature = slot.childArmature; - if (childArmature) { - if (slot.inheritAnimation) { - childArmature.advanceTime(scaledPassedTime); - } - else { - childArmature.advanceTime(passedTime); - } - } - } - // Actions and events. - if (self._action) { - switch (self._action.type) { - case 0 /* Play */: - self._animation.play(self._action.data[0], self._action.data[1]); - break; - case 1 /* Stop */: - self._animation.stop(self._action.data[0]); - break; - case 2 /* GotoAndPlay */: - self._animation.gotoAndPlayByTime(self._action.data[0], self._action.data[1], self._action.data[2]); - break; - case 3 /* GotoAndStop */: - self._animation.gotoAndStopByTime(self._action.data[0], self._action.data[1]); - break; - case 4 /* FadeIn */: - self._animation.fadeIn(self._action.data[0], self._action.data[1], self._action.data[2]); - break; - case 5 /* FadeOut */: - // TODO fade out - break; - } - self._action = null; - } - if (self._events.length > 0) { - for (var i = 0, l = self._events.length; i < l; ++i) { - var event_5 = self._events[i]; - if (Armature._soundEventManager && event_5.type == dragonBones.EventObject.SOUND_EVENT) { - Armature._soundEventManager._dispatchEvent(event_5); - } - else { - self._display._dispatchEvent(event_5); - } - event_5.returnToPool(); - } - self._events.length = 0; - } - self._lockDispose = false; - } - if (self._delayDispose) { - self.returnToPool(); - } + ArmatureData.prototype.getSlot = function (name) { + return this.slots[name]; }; /** * @language zh_CN - * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) - * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 - * @param updateSlotDisplay 是否更新插槽的显示对象。 - * @see dragonBones.Bone - * @see dragonBones.Slot + * 获取指定名称的皮肤数据。 + * @param name 皮肤数据名称。 + * @see dragonBones.SkinData * @version DragonBones 3.0 */ - p.invalidUpdate = function (boneName, updateSlotDisplay) { - if (boneName === void 0) { boneName = null; } - if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } - if (boneName) { - var bone = this.getBone(boneName); - if (bone) { - bone.invalidUpdate(); - if (updateSlotDisplay) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - if (slot.parent == bone) { - slot.invalidUpdate(); - } - } - } - } - } - else { - for (var i = 0, l = this._bones.length; i < l; ++i) { - this._bones[i].invalidUpdate(); - } - if (updateSlotDisplay) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].invalidUpdate(); - } - } - } + ArmatureData.prototype.getSkin = function (name) { + return name ? this.skins[name] : this._defaultSkin; }; /** * @language zh_CN - * 获取指定名称的插槽。 - * @param name 插槽的名称。 - * @returns 插槽。 - * @see dragonBones.Slot + * 获取指定名称的动画数据。 + * @param name 动画数据名称。 + * @see dragonBones.AnimationData * @version DragonBones 3.0 */ - p.getSlot = function (name) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - if (slot.name == name) { - return slot; + ArmatureData.prototype.getAnimation = function (name) { + return name ? this.animations[name] : this._defaultAnimation; + }; + Object.defineProperty(ArmatureData.prototype, "sortedBones", { + /** + * @private + */ + get: function () { + if (this._boneDirty) { + this._boneDirty = false; + this._sortBones(); } - } - return null; + return this._sortedBones; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ArmatureData.prototype, "sortedSlots", { + /** + * @private + */ + get: function () { + if (this._slotDirty) { + this._slotDirty = false; + this._sortSlots(); + } + return this._sortedSlots; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ArmatureData.prototype, "defaultSkin", { + /** + * @language zh_CN + * 获取默认的皮肤数据。 + * @see dragonBones.SkinData + * @version DragonBones 4.5 + */ + get: function () { + return this._defaultSkin; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(ArmatureData.prototype, "defaultAnimation", { + /** + * @language zh_CN + * 获取默认的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + */ + get: function () { + return this._defaultAnimation; + }, + enumerable: true, + configurable: true + }); + return ArmatureData; + }(dragonBones.BaseObject)); + dragonBones.ArmatureData = ArmatureData; + /** + * @language zh_CN + * 骨骼数据。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + var BoneData = (function (_super) { + __extends(BoneData, _super); + /** + * @private + */ + function BoneData() { + _super.call(this); + /** + * @private + */ + this.transform = new dragonBones.Transform(); + } + /** + * @private + */ + BoneData.toString = function () { + return "[class dragonBones.BoneData]"; }; /** - * @language zh_CN - * 通过显示对象获取插槽。 - * @param display 显示对象。 - * @returns 包含这个显示对象的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @inheritDoc */ - p.getSlotByDisplay = function (display) { - if (display) { - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - if (slot.display == display) { - return slot; - } - } - } - return null; + BoneData.prototype._onClear = function () { + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.bendPositive = false; + this.chain = 0; + this.chainIndex = 0; + this.weight = 0; + this.length = 0; + this.name = null; + this.parent = null; + this.ik = null; + this.transform.identity(); }; + return BoneData; + }(dragonBones.BaseObject)); + dragonBones.BoneData = BoneData; + /** + * @language zh_CN + * 插槽数据。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + var SlotData = (function (_super) { + __extends(SlotData, _super); /** - * @language zh_CN - * 将一个指定的插槽添加到骨架中。 - * @param value 需要添加的插槽。 - * @param parentName 需要添加到的父骨骼名称。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @private */ - p.addSlot = function (value, parentName) { - var bone = this.getBone(parentName); - if (bone) { - value._setArmature(this); - value._setParent(bone); - } - else { - throw new Error(); - } + function SlotData() { + _super.call(this); + /** + * @private + */ + this.actions = []; + } + /** + * @private + */ + SlotData.generateColor = function () { + return new dragonBones.ColorTransform(); }; /** - * @language zh_CN - * 将一个指定的插槽从骨架中移除。 - * @param value 需要移除的插槽 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @private */ - p.removeSlot = function (value) { - if (value && value.armature == this) { - value._setParent(null); - value._setArmature(null); - } - else { - throw new Error(); - } + SlotData.toString = function () { + return "[class dragonBones.SlotData]"; }; /** - * @language zh_CN - * 获取指定名称的骨骼。 - * @param name 骨骼的名称。 - * @returns 骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @inheritDoc */ - p.getBone = function (name) { - for (var i = 0, l = this._bones.length; i < l; ++i) { - var bone = this._bones[i]; - if (bone.name == name) { - return bone; + SlotData.prototype._onClear = function () { + this.displayIndex = 0; + this.zOrder = 0; + this.blendMode = 0 /* Normal */; + this.name = null; + this.parent = null; + this.color = null; + if (this.actions.length) { + for (var i = 0, l = this.actions.length; i < l; ++i) { + this.actions[i].returnToPool(); } + this.actions.length = 0; } - return null; }; /** - * @language zh_CN - * 通过显示对象获取骨骼。 - * @param display 显示对象。 - * @returns 包含这个显示对象的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @private */ - p.getBoneByDisplay = function (display) { - var slot = this.getSlotByDisplay(display); - return slot ? slot.parent : null; + SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); + return SlotData; + }(dragonBones.BaseObject)); + dragonBones.SlotData = SlotData; + /** + * @language zh_CN + * 皮肤数据。 + * @version DragonBones 3.0 + */ + var SkinData = (function (_super) { + __extends(SkinData, _super); + /** + * @private + */ + function SkinData() { + _super.call(this); + /** + * @language zh_CN + * 数据名称。 + * @version DragonBones 3.0 + */ + this.name = null; + /** + * @private + */ + this.slots = {}; + } + /** + * @private + */ + SkinData.toString = function () { + return "[class dragonBones.SkinData]"; }; /** - * @language zh_CN - * 将一个指定的骨骼添加到骨架中。 - * @param value 需要添加的骨骼。 - * @param parentName 需要添加到父骨骼的名称,如果未设置,则添加到骨架根部。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @inheritDoc */ - p.addBone = function (value, parentName) { - if (parentName === void 0) { parentName = null; } - if (value) { - value._setArmature(this); - value._setParent(parentName ? this.getBone(parentName) : null); - } - else { - throw new Error(); + SkinData.prototype._onClear = function () { + this.name = null; + for (var i in this.slots) { + this.slots[i].returnToPool(); + delete this.slots[i]; } }; /** - * @language zh_CN - * 将一个指定的骨骼从骨架中移除。 - * @param value 需要移除的骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 + * @private */ - p.removeBone = function (value) { - if (value && value.armature == this) { - value._setParent(null); - value._setArmature(null); + SkinData.prototype.addSlot = function (value) { + if (value && value.slot && !this.slots[value.slot.name]) { + this.slots[value.slot.name] = value; } else { throw new Error(); } }; /** - * @language zh_CN - * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 - * @param texture 用来替换的贴图,根据渲染平台的不同,类型会有所不同,一般是 Texture 类型。 - * @version DragonBones 4.5 + * @private */ - p.replaceTexture = function (texture) { - this._replacedTexture = texture; - for (var i = 0, l = this._slots.length; i < l; ++i) { - this._slots[i].invalidUpdate(); - } + SkinData.prototype.getSlot = function (name) { + return this.slots[name]; }; - /** - * @language zh_CN - * 获取所有骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - */ - p.getBones = function () { - return this._bones; + return SkinData; + }(dragonBones.BaseObject)); + dragonBones.SkinData = SkinData; + /** + * @private + */ + var SlotDisplayDataSet = (function (_super) { + __extends(SlotDisplayDataSet, _super); + function SlotDisplayDataSet() { + _super.call(this); + this.displays = []; + } + SlotDisplayDataSet.toString = function () { + return "[class dragonBones.SlotDisplayDataSet]"; }; /** - * @language zh_CN - * 获取所有插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @inheritDoc */ - p.getSlots = function () { - return this._slots; - }; - d(p, "name" - /** - * @language zh_CN - * 骨架名称。 - * @see dragonBones.ArmatureData#name - * @version DragonBones 3.0 - */ - ,function () { - return this._armatureData ? this._armatureData.name : null; - } - ); - d(p, "armatureData" - /** - * @language zh_CN - * 获取骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 4.5 - */ - ,function () { - return this._armatureData; - } - ); - d(p, "animation" - /** - * @language zh_CN - * 获得动画控制器。 - * @see dragonBones.Animation - * @version DragonBones 3.0 - */ - ,function () { - return this._animation; - } - ); - d(p, "display" - /** - * @language zh_CN - * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 - * @version DragonBones 3.0 - */ - ,function () { - return this._display; - } - ); - d(p, "parent" - /** - * @language zh_CN - * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) - * @see dragonBones.Slot - * @version DragonBones 4.5 - */ - ,function () { - return this._parent; - } - ); - d(p, "cacheFrameRate" - /** - * @language zh_CN - * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。 - * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 - * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 - * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 - * @see dragonBones.DragonBonesData#frameRate - * @see dragonBones.ArmatureData#frameRate - * @version DragonBones 4.5 - */ - ,function () { - return this._armatureData.cacheFrameRate; - } - ,function (value) { - if (this._armatureData.cacheFrameRate != value) { - this._armatureData.cacheFrames(value); - // Set child armature frameRate. - for (var i = 0, l = this._slots.length; i < l; ++i) { - var slot = this._slots[i]; - var childArmature = slot.childArmature; - if (childArmature) { - childArmature.cacheFrameRate = value; - } - } + SlotDisplayDataSet.prototype._onClear = function () { + this.slot = null; + if (this.displays.length) { + for (var i = 0, l = this.displays.length; i < l; ++i) { + this.displays[i].returnToPool(); } + this.displays.length = 0; } - ); - /** - * @language zh_CN - * 开启动画缓存。 - * @param frameRate 动画缓存的帧率 - * @see #cacheFrameRate - * @version DragonBones 4.5 - */ - p.enableAnimationCache = function (frameRate) { - this.cacheFrameRate = frameRate; }; - /** - * @language zh_CN - * 是否包含指定类型的事件。 - * @param type 事件类型。 - * @returns [true: 包含, false: 不包含] - * @version DragonBones 3.0 - */ - p.hasEventListener = function (type) { - this._display.hasEvent(type); + return SlotDisplayDataSet; + }(dragonBones.BaseObject)); + dragonBones.SlotDisplayDataSet = SlotDisplayDataSet; + /** + * @private + */ + var DisplayData = (function (_super) { + __extends(DisplayData, _super); + function DisplayData() { + _super.call(this); + this.pivot = new dragonBones.Point(); + this.transform = new dragonBones.Transform(); + } + DisplayData.toString = function () { + return "[class dragonBones.DisplayData]"; }; /** - * @language zh_CN - * 添加事件。 - * @param type 事件类型。 - * @param listener 事件回调。 - * @version DragonBones 3.0 + * @inheritDoc */ - p.addEventListener = function (type, listener, target) { - this._display.addEvent(type, listener, target); + DisplayData.prototype._onClear = function () { + this.isRelativePivot = false; + this.type = 0 /* Image */; + this.name = null; + this.texture = null; + this.armature = null; + if (this.mesh) { + this.mesh.returnToPool(); + this.mesh = null; + } + this.pivot.clear(); + this.transform.identity(); }; - /** - * @language zh_CN - * 移除事件。 - * @param type 事件类型。 - * @param listener 事件回调。 - * @version DragonBones 3.0 - */ - p.removeEventListener = function (type, listener, target) { - this._display.removeEvent(type, listener, target); + return DisplayData; + }(dragonBones.BaseObject)); + dragonBones.DisplayData = DisplayData; + /** + * @private + */ + var MeshData = (function (_super) { + __extends(MeshData, _super); + function MeshData() { + _super.call(this); + this.slotPose = new dragonBones.Matrix(); + this.uvs = []; // vertices * 2 + this.vertices = []; // vertices * 2 + this.vertexIndices = []; // triangles * 3 + this.boneIndices = []; // vertices bones + this.weights = []; // vertices bones + this.boneVertices = []; // vertices bones * 2 + this.bones = []; // bones + this.inverseBindPose = []; // bones + } + MeshData.toString = function () { + return "[class dragonBones.MeshData]"; }; /** - * @deprecated - * @see #display + * @inheritDoc */ - p.getDisplay = function () { - return this._display; + MeshData.prototype._onClear = function () { + this.skinned = false; + this.slotPose.identity(); + if (this.uvs.length) { + this.uvs.length = 0; + } + if (this.vertices.length) { + this.vertices.length = 0; + } + if (this.vertexIndices.length) { + this.vertexIndices.length = 0; + } + if (this.boneIndices.length) { + this.boneIndices.length = 0; + } + if (this.weights.length) { + this.weights.length = 0; + } + if (this.boneVertices.length) { + this.boneVertices.length = 0; + } + if (this.bones.length) { + this.bones.length = 0; + } + if (this.inverseBindPose.length) { + this.inverseBindPose.length = 0; + } }; - /** - * @private - */ - Armature._soundEventManager = null; - return Armature; + return MeshData; }(dragonBones.BaseObject)); - dragonBones.Armature = Armature; - egret.registerClass(Armature,'dragonBones.Armature',["dragonBones.IAnimateble"]); + dragonBones.MeshData = MeshData; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** * @language zh_CN - * 基础变换对象。 - * @version DragonBones 4.5 + * 动画数据。 + * @version DragonBones 3.0 */ - var TransformObject = (function (_super) { - __extends(TransformObject, _super); + var AnimationData = (function (_super) { + __extends(AnimationData, _super); /** * @private */ - function TransformObject() { + function AnimationData() { _super.call(this); /** - * @language zh_CN - * 相对于骨架坐标系的变换。 - * @see dragonBones.Transform - * @version DragonBones 3.0 + * @private */ - this.global = new dragonBones.Transform(); + this.boneTimelines = {}; /** - * @language zh_CN - * 相对于骨架或父骨骼坐标系的绑定变换。 - * @see dragonBones.Transform - * @version DragonBones 3.0 + * @private */ - this.origin = new dragonBones.Transform(); + this.slotTimelines = {}; /** - * @language zh_CN - * 相对于骨架或父骨骼坐标系的偏移变换。 - * @see dragonBones.Transform - * @version DragonBones 3.0 + * @private */ - this.offset = new dragonBones.Transform(); + this.ffdTimelines = {}; // skin slot displayIndex /** * @private */ - this._globalTransformMatrix = new dragonBones.Matrix(); + this.cachedFrames = []; } - var d = __define,c=TransformObject,p=c.prototype; + /** + * @private + */ + AnimationData.toString = function () { + return "[class dragonBones.AnimationData]"; + }; /** * @inheritDoc */ - p._onClear = function () { - var self = this; - self.userData = null; - self.name = null; - self.globalTransformMatrix = self._globalTransformMatrix; - self.global.identity(); - self.origin.identity(); - self.offset.identity(); - self._armature = null; - self._parent = null; - self._globalTransformMatrix.identity(); + AnimationData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.hasAsynchronyTimeline = false; + this.cacheTimeToFrameScale = 0; + this.position = 0; + this.duration = 0; + this.playTimes = 0; + this.fadeInTime = 0; + this.name = null; + this.animation = null; + for (var i in this.boneTimelines) { + this.boneTimelines[i].returnToPool(); + delete this.boneTimelines[i]; + } + for (var i in this.slotTimelines) { + this.slotTimelines[i].returnToPool(); + delete this.slotTimelines[i]; + } + for (var i in this.ffdTimelines) { + for (var j in this.ffdTimelines[i]) { + for (var k in this.ffdTimelines[i][j]) { + this.ffdTimelines[i][j][k].returnToPool(); + } + } + delete this.ffdTimelines[i]; + } + if (this.cachedFrames.length) { + this.cachedFrames.length = 0; + } }; /** * @private */ - p._setArmature = function (value) { - this._armature = value; + AnimationData.prototype.cacheFrames = function (value) { + if (this.animation) { + return; + } + var cacheFrameCount = Math.max(Math.floor(this.frameCount * this.scale * value), 1); + this.cacheTimeToFrameScale = cacheFrameCount / (this.duration + 0.000001); // + this.cachedFrames.length = 0; + this.cachedFrames.length = cacheFrameCount; + for (var i in this.boneTimelines) { + this.boneTimelines[i].cacheFrames(cacheFrameCount); + } + for (var i in this.slotTimelines) { + this.slotTimelines[i].cacheFrames(cacheFrameCount); + } }; /** * @private */ - p._setParent = function (value) { - this._parent = value; - }; - d(p, "armature" - /** - * @language zh_CN - * 所属的骨架。 - * @see dragonBones.Armature - * @version DragonBones 3.0 - */ - ,function () { - return this._armature; + AnimationData.prototype.addBoneTimeline = function (value) { + if (value && value.bone && !this.boneTimelines[value.bone.name]) { + this.boneTimelines[value.bone.name] = value; } - ); - d(p, "parent" - /** - * @language zh_CN - * 所属的父骨骼。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - */ - ,function () { - return this._parent; + else { + throw new Error(); } - ); - return TransformObject; - }(dragonBones.BaseObject)); - dragonBones.TransformObject = TransformObject; - egret.registerClass(TransformObject,'dragonBones.TransformObject'); + }; + /** + * @private + */ + AnimationData.prototype.addSlotTimeline = function (value) { + if (value && value.slot && !this.slotTimelines[value.slot.name]) { + this.slotTimelines[value.slot.name] = value; + } + else { + throw new Error(); + } + }; + /** + * @private + */ + AnimationData.prototype.addFFDTimeline = function (value) { + if (value && value.skin && value.slot) { + var skin = this.ffdTimelines[value.skin.name] = this.ffdTimelines[value.skin.name] || {}; + var slot = skin[value.slot.slot.name] = skin[value.slot.slot.name] || {}; + if (!slot[value.displayIndex]) { + slot[value.displayIndex] = value; + } + else { + throw new Error(); + } + } + else { + throw new Error(); + } + }; + /** + * @private + */ + AnimationData.prototype.getBoneTimeline = function (name) { + return this.boneTimelines[name]; + }; + /** + * @private + */ + AnimationData.prototype.getSlotTimeline = function (name) { + return this.slotTimelines[name]; + }; + /** + * @private + */ + AnimationData.prototype.getFFDTimeline = function (skinName, slotName, displayIndex) { + var skin = this.ffdTimelines[skinName]; + if (skin) { + var slot = skin[slotName]; + if (slot) { + return slot[displayIndex]; + } + } + return null; + }; + return AnimationData; + }(dragonBones.TimelineData)); + dragonBones.AnimationData = AnimationData; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** * @language zh_CN - * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 - * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 - * @see dragonBones.BoneData - * @see dragonBones.Armature - * @see dragonBones.Slot + * 动画控制器,用来播放动画数据,管理动画状态。 + * @see dragonBones.AnimationData + * @see dragonBones.AnimationState * @version DragonBones 3.0 */ - var Bone = (function (_super) { - __extends(Bone, _super); + var Animation = (function (_super) { + __extends(Animation, _super); /** * @private */ - function Bone() { + function Animation() { _super.call(this); /** * @private */ - this._animationPose = new dragonBones.Transform(); + this._animations = {}; /** * @private */ - this._bones = []; + this._animationNames = []; /** * @private */ - this._slots = []; + this._animationStates = []; } - var d = __define,c=Bone,p=c.prototype; /** * @private */ - Bone.toString = function () { - return "[Class dragonBones.Bone]"; + Animation._sortAnimationState = function (a, b) { + return a.layer > b.layer ? 1 : -1; + }; + /** + * @private + */ + Animation.toString = function () { + return "[class dragonBones.Animation]"; }; /** * @inheritDoc */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.inheritTranslation = false; - self.inheritRotation = false; - self.inheritScale = false; - self.ikBendPositive = false; - self.ikWeight = 0; - self.length = 0; - self._transformDirty = 2 /* All */; // Update - self._blendIndex = 0; - self._cacheFrames = null; - self._animationPose.identity(); - self._visible = true; - self._ikChain = 0; - self._ikChainIndex = 0; - self._ik = null; - if (self._bones.length) { - self._bones.length = 0; + Animation.prototype._onClear = function () { + this.timeScale = 1; + this._animationStateDirty = false; + this._timelineStateDirty = false; + this._armature = null; + this._isPlaying = false; + this._time = 0; + this._lastAnimationState = null; + for (var i in this._animations) { + delete this._animations[i]; } - if (self._slots.length) { - self._slots.length = 0; + if (this._animationNames.length) { + this._animationNames.length = 0; } + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + this._animationStates[i].returnToPool(); + } + this._animationStates.length = 0; }; /** * @private */ - p._updateGlobalTransformMatrix = function () { - var self = this; - if (self._parent) { - var parentRotation = self._parent.global.skewY; // Only inherit skew y. - var parentMatrix = self._parent.globalTransformMatrix; - if (self.inheritScale) { - if (!self.inheritRotation) { - self.global.skewX -= parentRotation; - self.global.skewY -= parentRotation; - } - self.global.toMatrix(self.globalTransformMatrix); - self.globalTransformMatrix.concat(parentMatrix); - if (!self.inheritTranslation) { - self.globalTransformMatrix.tx = self.global.x; - self.globalTransformMatrix.ty = self.global.y; - } - self.global.fromMatrix(self.globalTransformMatrix); - } - else { - if (self.inheritTranslation) { - var x = self.global.x; - var y = self.global.y; - self.global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; - self.global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + Animation.prototype._fadeOut = function (fadeOutTime, layer, group, fadeOutMode, pauseFadeOut) { + var i = 0, l = this._animationStates.length; + var animationState = null; + switch (fadeOutMode) { + case 0 /* None */: + break; + case 1 /* SameLayer */: + for (; i < l; ++i) { + animationState = this._animationStates[i]; + if (animationState.layer == layer) { + animationState.fadeOut(fadeOutTime, pauseFadeOut); + } } - if (self.inheritRotation) { - self.global.skewX += parentRotation; - self.global.skewY += parentRotation; + break; + case 2 /* SameGroup */: + for (; i < l; ++i) { + animationState = this._animationStates[i]; + if (animationState.group == group) { + animationState.fadeOut(fadeOutTime, pauseFadeOut); + } } - self.global.toMatrix(self.globalTransformMatrix); - } - } - else { - self.global.toMatrix(self.globalTransformMatrix); + break; + case 4 /* All */: + for (; i < l; ++i) { + animationState = this._animationStates[i]; + animationState.fadeOut(fadeOutTime, pauseFadeOut); + } + break; + case 3 /* SameLayerAndGroup */: + for (; i < l; ++i) { + animationState = this._animationStates[i]; + if (animationState.layer == layer && animationState.group == group) { + animationState.fadeOut(fadeOutTime, pauseFadeOut); + } + } + break; } }; /** * @private */ - p._computeIKA = function () { - var self = this; - var ikGlobal = self._ik.global; - var x = self.globalTransformMatrix.a * self.length; - var y = self.globalTransformMatrix.b * self.length; - var ikRadian = (Math.atan2(ikGlobal.y - self.global.y, ikGlobal.x - self.global.x) + - self.offset.skewY - - self.global.skewY * 2 + - Math.atan2(y, x)) * self.ikWeight; // Support offset. - self.global.skewX += ikRadian; - self.global.skewY += ikRadian; - self.global.toMatrix(self.globalTransformMatrix); - }; - /** - * @private - */ - p._computeIKB = function () { - var self = this; - var parentGlobal = self._parent.global; - var ikGlobal = self._ik.global; - var x = self.globalTransformMatrix.a * self.length; - var y = self.globalTransformMatrix.b * self.length; - var lLL = x * x + y * y; - var lL = Math.sqrt(lLL); - var dX = self.global.x - parentGlobal.x; - var dY = self.global.y - parentGlobal.y; - var lPP = dX * dX + dY * dY; - var lP = Math.sqrt(lPP); - dX = ikGlobal.x - parentGlobal.x; - dY = ikGlobal.y - parentGlobal.y; - var lTT = dX * dX + dY * dY; - var lT = Math.sqrt(lTT); - var ikRadianA = 0; - if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { - ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x) + self._parent.offset.skewY; // Support offset. - if (lL + lP <= lT) { - } - else if (lP < lL) { - ikRadianA += Math.PI; - } - } - else { - var h = (lPP - lLL + lTT) / (2 * lTT); - var r = Math.sqrt(lPP - h * h * lTT) / lT; - var hX = parentGlobal.x + (dX * h); - var hY = parentGlobal.y + (dY * h); - var rX = -dY * r; - var rY = dX * r; - if (self.ikBendPositive) { - self.global.x = hX - rX; - self.global.y = hY - rY; - } - else { - self.global.x = hX + rX; - self.global.y = hY + rY; - } - ikRadianA = Math.atan2(self.global.y - parentGlobal.y, self.global.x - parentGlobal.x) + self._parent.offset.skewY; // Support offset. + Animation.prototype._updateFFDTimelineStates = function () { + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + this._animationStates[i]._updateFFDTimelineStates(); } - ikRadianA = (ikRadianA - parentGlobal.skewY) * self.ikWeight; - parentGlobal.skewX += ikRadianA; - parentGlobal.skewY += ikRadianA; - parentGlobal.toMatrix(self._parent.globalTransformMatrix); - self._parent._transformDirty = 1 /* Self */; - self.global.x = parentGlobal.x + Math.cos(parentGlobal.skewY) * lP; - self.global.y = parentGlobal.y + Math.sin(parentGlobal.skewY) * lP; - var ikRadianB = (Math.atan2(ikGlobal.y - self.global.y, ikGlobal.x - self.global.x) + self.offset.skewY - - self.global.skewY * 2 + Math.atan2(y, x)) * self.ikWeight; // Support offset. - self.global.skewX += ikRadianB; - self.global.skewY += ikRadianB; - self.global.toMatrix(self.globalTransformMatrix); }; /** - * @inheritDoc + * @private */ - p._setArmature = function (value) { + Animation.prototype._advanceTime = function (passedTime) { var self = this; - if (self._armature == value) { + if (!self._isPlaying) { return; } - self._ik = null; - var oldSlots = null; - var oldBones = null; - if (self._armature) { - oldSlots = self.getSlots(); - oldBones = self.getBones(); - self._armature._removeBoneFromBoneList(this); - } - self._armature = value; - if (self._armature) { - self._armature._addBoneToBoneList(this); + if (passedTime < 0) { + passedTime = -passedTime; } - if (oldSlots) { - for (var i = 0, l = oldSlots.length; i < l; ++i) { - var slot = oldSlots[i]; - if (slot.parent == this) { - slot._setArmature(self._armature); - } + var animationStateCount = self._animationStates.length; + if (animationStateCount == 1) { + var animationState = self._animationStates[0]; + if (animationState._isFadeOutComplete) { + animationState.returnToPool(); + self._animationStates.length = 0; + self._animationStateDirty = true; + self._lastAnimationState = null; } - } - if (oldBones) { - for (var i = 0, l = oldBones.length; i < l; ++i) { - var bone = oldBones[i]; - if (bone.parent == this) { - bone._setArmature(self._armature); + else { + if (self._timelineStateDirty) { + animationState._updateTimelineStates(); } + animationState._advanceTime(passedTime, 1, 0); } } - }; - /** - * @private - */ - p._setIK = function (value, chain, chainIndex) { - var self = this; - if (value) { - if (chain == chainIndex) { - var chainEnd = self._parent; - if (chain && chainEnd) { - chain = 1; - } - else { - chain = 0; - chainIndex = 0; - chainEnd = this; - } - if (chainEnd == value || chainEnd.contains(value)) { - value = null; - chain = 0; - chainIndex = 0; + else if (animationStateCount > 1) { + var prevLayer = self._animationStates[0]._layer; + var weightLeft = 1; + var layerTotalWeight = 0; + var animationIndex = 1; // If has multiply animation state, first index is 1. + for (var i = 0, r = 0; i < animationStateCount; ++i) { + var animationState = self._animationStates[i]; + if (animationState._isFadeOutComplete) { + r++; + animationState.returnToPool(); + self._animationStateDirty = true; + if (self._lastAnimationState == animationState) { + if (i - r >= 0) { + self._lastAnimationState = self._animationStates[i - r]; + } + else { + self._lastAnimationState = null; + } + } } else { - var ancestor = value; - while (ancestor.ik && ancestor.ikChain) { - if (chainEnd.contains(ancestor.ik)) { - value = null; - chain = 0; - chainIndex = 0; - break; + if (r > 0) { + self._animationStates[i - r] = animationState; + } + if (prevLayer != animationState._layer) { + prevLayer = animationState._layer; + if (layerTotalWeight >= weightLeft) { + weightLeft = 0; } - ancestor = ancestor.parent; + else { + weightLeft -= layerTotalWeight; + } + layerTotalWeight = 0; + } + if (self._timelineStateDirty) { + animationState._updateTimelineStates(); + } + animationState._advanceTime(passedTime, weightLeft, animationIndex); + if (animationState._weightResult != 0) { + layerTotalWeight += animationState._weightResult; + animationIndex++; } } + if (i == animationStateCount - 1 && r > 0) { + self._animationStates.length -= r; + } } } - else { - chain = 0; - chainIndex = 0; - } - self._ik = value; - self._ikChain = chain; - self._ikChainIndex = chainIndex; - if (self._armature) { - self._armature._bonesDirty = true; + self._timelineStateDirty = false; + }; + /** + * @language zh_CN + * 清除所有正在播放的动画状态。 + * @version DragonBones 4.5 + */ + Animation.prototype.reset = function () { + this._isPlaying = false; + this._lastAnimationState = null; + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + this._animationStates[i].returnToPool(); } + this._animationStates.length = 0; }; /** - * @private + * @language zh_CN + * 暂停播放动画。 + * @param animationName 动画状态的名称,如果未设置,则暂停所有动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 */ - p._update = function (cacheFrameIndex) { - var self = this; - self._blendIndex = 0; - if (cacheFrameIndex >= 0) { - var cacheFrame = self._cacheFrames[cacheFrameIndex]; - if (self.globalTransformMatrix == cacheFrame) { - self._transformDirty = 0 /* None */; - } - else if (cacheFrame) { - self._transformDirty = 2 /* All */; // For update children and ik children. - self.globalTransformMatrix = cacheFrame; - } - else if (self._transformDirty == 2 /* All */ || - (self._parent && self._parent._transformDirty != 0 /* None */) || - (self._ik && self.ikWeight > 0 && self._ik._transformDirty != 0 /* None */)) { - self._transformDirty = 2 /* All */; // For update children and ik children. - self.globalTransformMatrix = self._globalTransformMatrix; - } - else if (self.globalTransformMatrix != self._globalTransformMatrix) { - self._transformDirty = 0 /* None */; - self._cacheFrames[cacheFrameIndex] = self.globalTransformMatrix; + Animation.prototype.stop = function (animationName) { + if (animationName === void 0) { animationName = null; } + if (animationName) { + var animationState = this.getState(animationName); + if (animationState) { + animationState.stop(); } - else { - self._transformDirty = 1 /* Self */; - self.globalTransformMatrix = self._globalTransformMatrix; + } + else { + this._isPlaying = false; + } + }; + /** + * @language zh_CN + * 播放动画。 + * @param animationName 动画数据的名称,如果未设置,则播放默认动画,或将暂停状态切换为播放状态,或重新播放上一个正在播放的动画。 + * @param playTimes 动画需要播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + Animation.prototype.play = function (animationName, playTimes) { + if (animationName === void 0) { animationName = null; } + if (playTimes === void 0) { playTimes = -1; } + var animationState = null; + if (animationName) { + animationState = this.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); + } + else if (!this._lastAnimationState) { + var defaultAnimation = this._armature.armatureData.defaultAnimation; + if (defaultAnimation) { + animationState = this.fadeIn(defaultAnimation.name, 0, playTimes, 0, null, 4 /* All */); } } - else if (self._transformDirty == 2 /* All */ || - (self._parent && self._parent._transformDirty != 0 /* None */) || - (self._ik && self.ikWeight > 0 && self._ik._transformDirty != 0 /* None */)) { - self._transformDirty = 2 /* All */; // For update children and ik children. - self.globalTransformMatrix = self._globalTransformMatrix; + else if (!this._isPlaying) { + this._isPlaying = true; } - if (self._transformDirty != 0 /* None */) { - if (self._transformDirty == 2 /* All */) { - self._transformDirty = 1 /* Self */; + else { + animationState = this.fadeIn(this._lastAnimationState.name, 0, playTimes, 0, null, 4 /* All */); + } + return animationState; + }; + /** + * @language zh_CN + * 淡入播放指定名称的动画。 + * @param animationName 动画数据的名称。 + * @param playTimes 循环播放的次数。 [-1: 使用数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @param fadeInTime 淡入的时间。 [-1: 使用数据默认值, [0~N]: N 秒淡入完毕] (以秒为单位) + * @param layer 混合的图层,图层高会优先获取混合权重。 + * @param group 混合的组,用于给动画状态编组,方便混合淡出控制。 + * @param fadeOutMode 淡出的模式。 + * @param additiveBlending 以叠加的形式混合。 + * @param displayControl 是否对显示对象属性可控。 + * @param pauseFadeOut 暂停需要淡出的动画。 + * @param pauseFadeIn 暂停需要淡入的动画,直到淡入结束才开始播放。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationFadeOutMode + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + Animation.prototype.fadeIn = function (animationName, fadeInTime, playTimes, layer, group, fadeOutMode, additiveBlending, displayControl, pauseFadeOut, pauseFadeIn) { + if (fadeInTime === void 0) { fadeInTime = -1; } + if (playTimes === void 0) { playTimes = -1; } + if (layer === void 0) { layer = 0; } + if (group === void 0) { group = null; } + if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } + if (additiveBlending === void 0) { additiveBlending = false; } + if (displayControl === void 0) { displayControl = true; } + if (pauseFadeOut === void 0) { pauseFadeOut = true; } + if (pauseFadeIn === void 0) { pauseFadeIn = true; } + var animationData = this._animations[animationName]; + if (!animationData) { + this._time = 0; + console.warn("No animation.", " Armature: " + this._armature.name, " Animation: " + animationName); + return null; + } + this._isPlaying = true; + if (fadeInTime != fadeInTime || fadeInTime < 0) { + if (this._lastAnimationState) { + fadeInTime = animationData.fadeInTime; } else { - self._transformDirty = 0 /* None */; + fadeInTime = 0; } - if (self.globalTransformMatrix == self._globalTransformMatrix) { - /*self.global.copyFrom(self.origin).add(self.offset).add(self._animationPose);*/ - self.global.x = self.origin.x + self.offset.x + self._animationPose.x; - self.global.y = self.origin.y + self.offset.y + self._animationPose.y; - self.global.skewX = self.origin.skewX + self.offset.skewX + self._animationPose.skewX; - self.global.skewY = self.origin.skewY + self.offset.skewY + self._animationPose.skewY; - self.global.scaleX = self.origin.scaleX * self.offset.scaleX * self._animationPose.scaleX; - self.global.scaleY = self.origin.scaleY * self.offset.scaleY * self._animationPose.scaleY; - self._updateGlobalTransformMatrix(); - if (self._ik && self._ikChainIndex == self._ikChain && self.ikWeight > 0) { - if (self.inheritTranslation && self._ikChain > 0 && self._parent) { - self._computeIKB(); - } - else { - self._computeIKA(); - } - } - if (cacheFrameIndex >= 0) { - self.globalTransformMatrix = dragonBones.BoneTimelineData.cacheFrame(self._cacheFrames, cacheFrameIndex, self._globalTransformMatrix); + } + if (playTimes < 0) { + playTimes = animationData.playTimes; + } + this._fadeOut(fadeInTime, layer, group, fadeOutMode, pauseFadeOut); + this._lastAnimationState = dragonBones.BaseObject.borrowObject(dragonBones.AnimationState); + this._lastAnimationState._layer = layer; + this._lastAnimationState._group = group; + this._lastAnimationState.additiveBlending = additiveBlending; + this._lastAnimationState.displayControl = displayControl; + this._lastAnimationState._fadeIn(this._armature, animationData.animation || animationData, animationName, playTimes, animationData.position, animationData.duration, this._time, 1 / animationData.scale, fadeInTime, pauseFadeIn); + this._animationStates.push(this._lastAnimationState); + this._animationStateDirty = true; + this._time = 0; + if (this._animationStates.length > 1) { + this._animationStates.sort(Animation._sortAnimationState); + } + var slots = this._armature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var slot = slots[i]; + if (slot.inheritAnimation) { + var childArmature = slot.childArmature; + if (childArmature && + childArmature.animation.hasAnimation(animationName) && + !childArmature.animation.getState(animationName)) { + childArmature.animation.fadeIn(animationName); } } } + this._armature.advanceTime(0); + return this._lastAnimationState; }; /** * @language zh_CN - * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) - * @version DragonBones 3.0 + * 指定名称的动画从指定时间开始播放。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @param playTimes 动画循环播放的次数。 [-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - p.invalidUpdate = function () { - this._transformDirty = 2 /* All */; + Animation.prototype.gotoAndPlayByTime = function (animationName, time, playTimes) { + if (time === void 0) { time = 0; } + if (playTimes === void 0) { playTimes = -1; } + this._time = time; + return this.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); }; /** * @language zh_CN - * 是否包含某个指定的骨骼或插槽。 - * @returns [true: 包含,false: 不包含] - * @see dragonBones.TransformObject - * @version DragonBones 3.0 + * 指定名称的动画从指定帧开始播放。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - p.contains = function (child) { - if (child) { - if (child == this) { - return false; - } - var ancestor = child; - while (ancestor != this && ancestor) { - ancestor = ancestor.parent; - } - return ancestor == this; + Animation.prototype.gotoAndPlayByFrame = function (animationName, frame, playTimes) { + if (frame === void 0) { frame = 0; } + if (playTimes === void 0) { playTimes = -1; } + var animationData = this._animations[animationName]; + if (animationData) { + this._time = animationData.duration * frame / animationData.frameCount; } - return false; + return this.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); }; /** * @language zh_CN - * 所有的子骨骼。 - * @version DragonBones 3.0 + * 指定名称的动画从指定进度开始播放。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @param playTimes 动画循环播放的次数。[-1: 使用动画数据默认值, 0: 无限循环播放, [1~N]: 循环播放 N 次] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - p.getBones = function () { - this._bones.length = 0; - var bones = this._armature.getBones(); - for (var i = 0, l = bones.length; i < l; ++i) { - var bone = bones[i]; - if (bone.parent == this) { - this._bones.push(bone); - } + Animation.prototype.gotoAndPlayByProgress = function (animationName, progress, playTimes) { + if (progress === void 0) { progress = 0; } + if (playTimes === void 0) { playTimes = -1; } + var animationData = this._animations[animationName]; + if (animationData) { + this._time = animationData.duration * Math.max(progress, 0); } - return this._bones; + return this.fadeIn(animationName, 0, playTimes, 0, null, 4 /* All */); }; /** * @language zh_CN - * 所有的插槽。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * 播放指定名称的动画到指定的时间并停止。 + * @param animationName 动画数据的名称。 + * @param time 时间。 (以秒为单位) + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 */ - p.getSlots = function () { - this._slots.length = 0; - var slots = this._armature.getSlots(); - for (var i = 0, l = slots.length; i < l; ++i) { - var slot = slots[i]; - if (slot.parent == this) { - this._slots.push(slot); - } + Animation.prototype.gotoAndStopByTime = function (animationName, time) { + if (time === void 0) { time = 0; } + var animationState = this.gotoAndPlayByTime(animationName, time, 1); + if (animationState) { + this._isPlaying = false; + animationState.stop(); } - return this._slots; + return animationState; }; - d(p, "ikChain" - /** - * @private - */ - ,function () { - return this._ikChain; - } - ); - d(p, "ikChainIndex" - /** - * @private - */ - ,function () { - return this._ikChainIndex; + /** + * @language zh_CN + * 播放指定名称的动画到指定的帧并停止。 + * @param animationName 动画数据的名称。 + * @param frame 帧。 + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + Animation.prototype.gotoAndStopByFrame = function (animationName, frame) { + if (frame === void 0) { frame = 0; } + var animationState = this.gotoAndPlayByFrame(animationName, frame, 1); + if (animationState) { + this._isPlaying = false; + animationState.stop(); } - ); - d(p, "ik" - /** - * @language zh_CN - * 当前的 IK 约束目标。 - * @version DragonBones 4.5 - */ - ,function () { - return this._ik; + return animationState; + }; + /** + * @language zh_CN + * 播放指定名称的动画到指定的进度并停止。 + * @param animationName 动画数据的名称。 + * @param progress 进度。 [0~1] + * @returns 返回控制这个动画数据的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 4.5 + */ + Animation.prototype.gotoAndStopByProgress = function (animationName, progress) { + if (progress === void 0) { progress = 0; } + var animationState = this.gotoAndPlayByProgress(animationName, progress, 1); + if (animationState) { + this._isPlaying = false; + animationState.stop(); } - ); - d(p, "visible" - /** - * @language zh_CN - * 控制此骨骼所有插槽的显示。 - * @default true - * @see dragonBones.Slot + return animationState; + }; + /** + * @language zh_CN + * 获取指定名称的动画状态。 + * @param animationName 动画状态的名称。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + Animation.prototype.getState = function (animationName) { + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + var animationState = this._animationStates[i]; + if (animationState.name == animationName) { + return animationState; + } + } + return null; + }; + /** + * @language zh_CN + * 是否包含指定名称的动画数据。 + * @param animationName 动画数据的名称。 + * @see dragonBones.AnimationData + * @version DragonBones 3.0 + */ + Animation.prototype.hasAnimation = function (animationName) { + return this._animations[animationName] != null; + }; + Object.defineProperty(Animation.prototype, "isPlaying", { + /** + * @language zh_CN + * 动画是否处于播放状态。 * @version DragonBones 3.0 */ - ,function () { - return this._visible; - } - ,function (value) { - if (this._visible == value) { + get: function () { + return this._isPlaying; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "isCompleted", { + /** + * @language zh_CN + * 所有动画状态是否均已播放完毕。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + get: function () { + var self = this; + if (this._lastAnimationState) { + if (!this._lastAnimationState.isCompleted) { + return false; + } + for (var i = 0, l = this._animationStates.length; i < l; ++i) { + if (!this._animationStates[i].isCompleted) { + return false; + } + } + } + return true; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationName", { + /** + * @language zh_CN + * 上一个正在播放的动画状态的名称。 + * @see #lastAnimationState + * @version DragonBones 3.0 + */ + get: function () { + return this._lastAnimationState ? this._lastAnimationState.name : null; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "lastAnimationState", { + /** + * @language zh_CN + * 上一个正在播放的动画状态。 + * @see dragonBones.AnimationState + * @version DragonBones 3.0 + */ + get: function () { + return this._lastAnimationState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationNames", { + /** + * @language zh_CN + * 所有动画数据名称。 + * @see #animations + * @version DragonBones 4.5 + */ + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animations", { + /** + * @language zh_CN + * 所有的动画数据。 + * @see dragonBones.AnimationData + * @version DragonBones 4.5 + */ + get: function () { + return this._animations; + }, + set: function (value) { + var self = this; + if (this._animations == value) { return; } - this._visible = value; - var slots = this._armature.getSlots(); - for (var i = 0, l = slots.length; i < l; ++i) { - var slot = slots[i]; - if (slot._parent == this) { - slot._updateVisible(); + for (var i in this._animations) { + delete this._animations[i]; + } + this._animationNames.length = 0; + if (value) { + for (var i in value) { + this._animations[i] = value[i]; + this._animationNames.push(i); } } + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * @see #play() + * @see #fadeIn() + * @see #gotoAndPlayByTime() + * @see #gotoAndPlayByFrame() + * @see #gotoAndPlayByProgress() + */ + Animation.prototype.gotoAndPlay = function (animationName, fadeInTime, duration, playTimes, layer, group, fadeOutMode, pauseFadeOut, pauseFadeIn) { + if (fadeInTime === void 0) { fadeInTime = -1; } + if (duration === void 0) { duration = -1; } + if (playTimes === void 0) { playTimes = -1; } + if (layer === void 0) { layer = 0; } + if (group === void 0) { group = null; } + if (fadeOutMode === void 0) { fadeOutMode = 3 /* SameLayerAndGroup */; } + if (pauseFadeOut === void 0) { pauseFadeOut = true; } + if (pauseFadeIn === void 0) { pauseFadeIn = true; } + var animationState = this.fadeIn(animationName, fadeInTime, playTimes, layer, group, fadeOutMode, false, true, pauseFadeOut, pauseFadeIn); + if (animationState && duration && duration > 0) { + animationState.timeScale = animationState.totalTime / duration; } - ); - d(p, "slot" + return animationState; + }; + /** + * @deprecated + * @see #gotoAndStopByTime() + * @see #gotoAndStopByFrame() + * @see #gotoAndStopByProgress() + */ + Animation.prototype.gotoAndStop = function (animationName, time) { + if (time === void 0) { time = 0; } + return this.gotoAndStopByTime(animationName, time); + }; + Object.defineProperty(Animation.prototype, "animationList", { /** * @deprecated - * @see dragonBones.Armature#getSlot() + * @see #animationNames + * @see #animations */ - ,function () { - var slots = this._armature.getSlots(); - for (var i = 0, l = slots.length; i < l; ++i) { - var slot = slots[i]; - if (slot.parent == this) { - return slot; - } + get: function () { + return this._animationNames; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Animation.prototype, "animationDataList", { + /** + * @language zh_CN + * @deprecated + * @see #animationNames + * @see #animations + */ + get: function () { + var list = []; + for (var i = 0, l = this._animationNames.length; i < l; ++i) { + list.push(this._animations[this._animationNames[i]]); } - return null; - } - ); - return Bone; - }(dragonBones.TransformObject)); - dragonBones.Bone = Bone; - egret.registerClass(Bone,'dragonBones.Bone'); + return list; + }, + enumerable: true, + configurable: true + }); + return Animation; + }(dragonBones.BaseObject)); + dragonBones.Animation = Animation; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** * @language zh_CN - * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 - * 一个骨骼上可以包含多个插槽。 - * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 - * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 - * @see dragonBones.Armature - * @see dragonBones.Bone - * @see dragonBones.SlotData + * 动画状态,播放动画时产生,可以对单个动画的播放进行更细致的控制和调节。 + * @see dragonBones.Animation + * @see dragonBones.AnimationData * @version DragonBones 3.0 */ - var Slot = (function (_super) { - __extends(Slot, _super); + var AnimationState = (function (_super) { + __extends(AnimationState, _super); /** * @private */ - function Slot() { + function AnimationState() { _super.call(this); /** * @private */ - this._colorTransform = new dragonBones.ColorTransform(); - /** - * @private - */ - this._ffdVertices = []; + this._boneMask = []; /** * @private */ - this._replacedDisplayDataSet = []; + this._boneTimelines = []; /** * @private */ - this._localMatrix = new dragonBones.Matrix(); + this._slotTimelines = []; /** * @private */ - this._displayList = []; + this._ffdTimelines = []; /** - * @private + * @deprecated */ - this._meshBones = []; + this.autoTween = false; } - var d = __define,c=Slot,p=c.prototype; + /** + * @private + */ + AnimationState.toString = function () { + return "[class dragonBones.AnimationState]"; + }; /** * @inheritDoc */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - var disposeDisplayList = []; - for (var i = 0, l = self._displayList.length; i < l; ++i) { - var eachDisplay = self._displayList[i]; - if (eachDisplay != self._rawDisplay && eachDisplay != self._meshDisplay && - disposeDisplayList.indexOf(eachDisplay) < 0) { - disposeDisplayList.push(eachDisplay); - } - } - for (var i = 0, l = disposeDisplayList.length; i < l; ++i) { - var eachDisplay = disposeDisplayList[i]; - if (eachDisplay instanceof dragonBones.Armature) { - eachDisplay.returnToPool(); - } - else { - self._disposeDisplay(eachDisplay); - } - } - if (self._meshDisplay && self._meshDisplay != self._rawDisplay) { - self._disposeDisplay(self._meshDisplay); - } - if (self._rawDisplay) { - self._disposeDisplay(self._rawDisplay); - } - self.inheritAnimation = true; - self.displayController = null; - self._colorDirty = false; - self._ffdDirty = false; - self._blendIndex = 0; - self._zOrder = 0; - self._displayDataSet = null; - self._meshData = null; - self._cacheFrames = null; - self._rawDisplay = null; - self._meshDisplay = null; - self._colorTransform.identity(); - if (self._ffdVertices.length) { - self._ffdVertices.length = 0; + AnimationState.prototype._onClear = function () { + this.displayControl = true; + this.additiveBlending = false; + this.playTimes = 1; + this.timeScale = 1; + this.weight = 1; + this.autoFadeOutTime = -1; + this.fadeTotalTime = 0; + this._isFadeOutComplete = false; + this._layer = 0; + this._position = 0; + this._duration = 0; + this._weightResult = 0; + this._fadeProgress = 0; + this._group = null; + if (this._timeline) { + this._timeline.returnToPool(); + this._timeline = null; } - if (self._replacedDisplayDataSet.length) { - self._replacedDisplayDataSet.length = 0; + this._isPlaying = true; + this._isPausePlayhead = false; + this._isFadeOut = false; + this._currentPlayTimes = 0; + this._fadeTime = 0; + this._time = 0; + this._name = null; + this._armature = null; + this._animationData = null; + if (this._boneMask.length) { + this._boneMask.length = 0; } - self._displayDirty = false; - self._blendModeDirty = false; - self._originDirty = false; - self._transformDirty = false; - self._displayIndex = 0; - self._blendMode = 0 /* Normal */; - self._display = null; - self._childArmature = null; - self._localMatrix.identity(); - if (self._displayList.length) { - self._displayList.length = 0; + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + this._boneTimelines[i].returnToPool(); } - if (self._meshBones.length) { - self._meshBones.length = 0; + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + this._slotTimelines[i].returnToPool(); } - }; - /** - * @private - */ - p._isMeshBonesUpdate = function () { - for (var i = 0, l = this._meshBones.length; i < l; ++i) { - if (this._meshBones[i]._transformDirty != 0 /* None */) { - return true; - } + for (var i = 0, l = this._ffdTimelines.length; i < l; ++i) { + this._ffdTimelines[i].returnToPool(); } - return false; + this._boneTimelines.length = 0; + this._slotTimelines.length = 0; + this._ffdTimelines.length = 0; }; /** * @private */ - p._updateDisplay = function () { + AnimationState.prototype._advanceFadeTime = function (passedTime) { var self = this; - var prevDisplay = self._display || self._rawDisplay; - var prevChildArmature = self._childArmature; - if (self._displayIndex >= 0 && self._displayIndex < self._displayList.length) { - self._display = self._displayList[self._displayIndex]; - if (self._display instanceof dragonBones.Armature) { - self._childArmature = self._display; - self._display = self._childArmature._display; - } - else { - self._childArmature = null; - } - } - else { - self._display = null; - self._childArmature = null; + if (passedTime < 0) { + passedTime = -passedTime; } - var currentDisplay = self._display || self._rawDisplay; - if (currentDisplay != prevDisplay) { - self._onUpdateDisplay(); - if (prevDisplay) { - self._replaceDisplay(prevDisplay); - } - else { - self._addDisplay(); - } - self._blendModeDirty = true; - self._colorDirty = true; + self._fadeTime += passedTime; + var fadeProgress = 0; + if (self._fadeTime >= self.fadeTotalTime) { + fadeProgress = self._isFadeOut ? 0 : 1; } - // Update origin. - if (self._displayDataSet && self._displayIndex >= 0 && self._displayIndex < self._displayDataSet.displays.length) { - self.origin.copyFrom(self._displayDataSet.displays[self._displayIndex].transform); - self._originDirty = true; + else if (self._fadeTime > 0) { + fadeProgress = self._isFadeOut ? (1 - self._fadeTime / self.fadeTotalTime) : (self._fadeTime / self.fadeTotalTime); } - // Update meshData. - self._updateMeshData(false); - // Update frame. - if (currentDisplay == self._rawDisplay || currentDisplay == self._meshDisplay) { - self._updateFrame(); + else { + fadeProgress = self._isFadeOut ? 1 : 0; } - // Update child armature. - if (self._childArmature != prevChildArmature) { - if (prevChildArmature) { - prevChildArmature._parent = null; // Update child armature parent. - if (self.inheritAnimation) { - prevChildArmature.animation.reset(); - } - } - if (self._childArmature) { - self._childArmature._parent = this; // Update child armature parent. - if (self.inheritAnimation) { - // Set child armature frameRate. - var cacheFrameRate = self._armature.cacheFrameRate; - if (cacheFrameRate) { - self._childArmature.cacheFrameRate = cacheFrameRate; - } - var slotData = self._armature.armatureData.getSlot(self.name); - if (slotData.actions.length > 0) { - self._childArmature._action = slotData.actions[slotData.actions.length - 1]; + if (self._fadeProgress != fadeProgress) { + self._fadeProgress = fadeProgress; + var eventDispatcher = self._armature._display; + if (self._fadeTime <= passedTime) { + if (self._isFadeOut) { + if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_OUT)) { + var event_1 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + event_1.animationState = this; + self._armature._bufferEvent(event_1, dragonBones.EventObject.FADE_OUT); } - else { - self._childArmature.animation.play(); + } + else { + if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_IN)) { + var event_2 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + event_2.animationState = this; + self._armature._bufferEvent(event_2, dragonBones.EventObject.FADE_IN); + } + } + } + if (self._fadeTime >= self.fadeTotalTime) { + if (self._isFadeOut) { + self._isFadeOutComplete = true; + if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_OUT_COMPLETE)) { + var event_3 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + event_3.animationState = this; + self._armature._bufferEvent(event_3, dragonBones.EventObject.FADE_OUT_COMPLETE); + } + } + else { + self._isPausePlayhead = false; + if (eventDispatcher.hasEvent(dragonBones.EventObject.FADE_IN_COMPLETE)) { + var event_4 = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + event_4.animationState = this; + self._armature._bufferEvent(event_4, dragonBones.EventObject.FADE_IN_COMPLETE); } } } @@ -3749,5125 +2720,6215 @@ var dragonBones; /** * @private */ - p._updateLocalTransformMatrix = function () { - var self = this; - self.global.copyFrom(self.origin).add(self.offset).toMatrix(self._localMatrix); + AnimationState.prototype._isDisabled = function (slot) { + if (this.displayControl && + (!slot.displayController || + slot.displayController == this._name || + slot.displayController == this._group)) { + return false; + } + return true; }; /** * @private */ - p._updateGlobalTransformMatrix = function () { - var self = this; - self.globalTransformMatrix.copyFrom(self._localMatrix); - self.globalTransformMatrix.concat(self._parent.globalTransformMatrix); - self.global.fromMatrix(self.globalTransformMatrix); + AnimationState.prototype._fadeIn = function (armature, clip, animationName, playTimes, position, duration, time, timeScale, fadeInTime, pausePlayhead) { + this._armature = armature; + this._animationData = clip; + this._name = animationName; + this.playTimes = playTimes; + this.timeScale = timeScale; + this.fadeTotalTime = fadeInTime; + this._position = position; + this._duration = duration; + this._time = time; + this._isPausePlayhead = pausePlayhead; + if (this.fadeTotalTime == 0) { + this._fadeProgress = 0.999999; + } + this._timeline = dragonBones.BaseObject.borrowObject(dragonBones.AnimationTimelineState); + this._timeline.fadeIn(this._armature, this, this._animationData, this._time); + this._updateTimelineStates(); }; /** - * @inheritDoc + * @private */ - p._setArmature = function (value) { - var self = this; - if (self._armature == value) { - return; + AnimationState.prototype._updateTimelineStates = function () { + var time = this._time; + if (!this._animationData.hasAsynchronyTimeline) { + time = this._timeline._currentTime; + } + var boneTimelineStates = {}; + var slotTimelineStates = {}; + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + var boneTimelineState = this._boneTimelines[i]; + boneTimelineStates[boneTimelineState.bone.name] = boneTimelineState; } - if (self._armature) { - self._armature._removeSlotFromSlotList(this); + var bones = this._armature.getBones(); + for (var i = 0, l = bones.length; i < l; ++i) { + var bone = bones[i]; + var boneTimelineName = bone.name; + var boneTimelineData = this._animationData.getBoneTimeline(boneTimelineName); + if (boneTimelineData && this.containsBoneMask(boneTimelineName)) { + var boneTimelineState = boneTimelineStates[boneTimelineName]; + if (boneTimelineState) { + delete boneTimelineStates[boneTimelineName]; + } + else { + boneTimelineState = dragonBones.BaseObject.borrowObject(dragonBones.BoneTimelineState); + boneTimelineState.bone = bone; + boneTimelineState.fadeIn(this._armature, this, boneTimelineData, time); + this._boneTimelines.push(boneTimelineState); + } + } } - self._armature = value; - self._onUpdateDisplay(); - if (self._armature) { - self._armature._addSlotToSlotList(this); - self._addDisplay(); + for (var i in boneTimelineStates) { + var boneTimelineState = boneTimelineStates[i]; + boneTimelineState.bone.invalidUpdate(); + this._boneTimelines.splice(this._boneTimelines.indexOf(boneTimelineState), 1); + boneTimelineState.returnToPool(); } - else { - self._removeDisplay(); + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + var slotTimelineState = this._slotTimelines[i]; + slotTimelineStates[slotTimelineState.slot.name] = slotTimelineState; } + var slots = this._armature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var slot = slots[i]; + var slotTimelineName = slot.name; + var parentTimelineName = slot.parent.name; + var slotTimelineData = this._animationData.getSlotTimeline(slotTimelineName); + if (slotTimelineData && this.containsBoneMask(parentTimelineName) && !this._isFadeOut) { + var slotTimelineState = slotTimelineStates[slotTimelineName]; + if (slotTimelineState) { + delete slotTimelineStates[slotTimelineName]; + } + else { + slotTimelineState = dragonBones.BaseObject.borrowObject(dragonBones.SlotTimelineState); + slotTimelineState.slot = slot; + slotTimelineState.fadeIn(this._armature, this, slotTimelineData, time); + this._slotTimelines.push(slotTimelineState); + } + } + } + for (var i in slotTimelineStates) { + var slotTimelineState = slotTimelineStates[i]; + this._slotTimelines.splice(this._slotTimelines.indexOf(slotTimelineState), 1); + slotTimelineState.returnToPool(); + } + this._updateFFDTimelineStates(); }; /** - * @private Armature + * @private */ - p._updateMeshData = function (isTimelineUpdate) { - var self = this; - var prevMeshData = self._meshData; - if (self._display == self._meshDisplay && self._displayDataSet && self._displayIndex >= 0 && self._displayIndex < self._displayDataSet.displays.length) { - self._meshData = self._displayDataSet.displays[self._displayIndex].meshData; + AnimationState.prototype._updateFFDTimelineStates = function () { + var time = this._time; + if (!this._animationData.hasAsynchronyTimeline) { + time = this._timeline._currentTime; } - else { - self._meshData = null; - } - if (self._meshData != prevMeshData) { - if (self._meshData) { - if (self._meshData.skinned) { - self._meshBones.length = self._meshData.bones.length; - for (var i = 0, l = self._meshBones.length; i < l; ++i) { - self._meshBones[i] = self._armature.getBone(self._meshData.bones[i].name); + var ffdTimelineStates = {}; + for (var i = 0, l = this._ffdTimelines.length; i < l; ++i) { + var ffdTimelineState = this._ffdTimelines[i]; + ffdTimelineStates[ffdTimelineState.slot.name] = ffdTimelineState; + } + var slots = this._armature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var slot = slots[i]; + var slotTimelineName = slot.name; + var parentTimelineName = slot.parent.name; + if (slot._meshData) { + var ffdTimelineData = this._animationData.getFFDTimeline(this._armature._skinData.name, slotTimelineName, slot.displayIndex); + if (ffdTimelineData && this.containsBoneMask(parentTimelineName)) { + var ffdTimelineState = ffdTimelineStates[slotTimelineName]; + if (ffdTimelineState) { + delete ffdTimelineStates[slotTimelineName]; } - var ffdVerticesCount = 0; - for (var i = 0, l = self._meshData.boneIndices.length; i < l; ++i) { - ffdVerticesCount += self._meshData.boneIndices[i].length; + else { + ffdTimelineState = dragonBones.BaseObject.borrowObject(dragonBones.FFDTimelineState); + ffdTimelineState.slot = slot; + ffdTimelineState.fadeIn(this._armature, this, ffdTimelineData, time); + this._ffdTimelines.push(ffdTimelineState); } - self._ffdVertices.length = ffdVerticesCount * 2; } else { - self._meshBones.length = 0; - self._ffdVertices.length = self._meshData.vertices.length; - } - for (var i = 0, l = self._ffdVertices.length; i < l; ++i) { - self._ffdVertices[i] = 0; + for (var iF = 0, lF = slot._ffdVertices.length; iF < lF; ++iF) { + slot._ffdVertices[iF] = 0; + } + slot._ffdDirty = true; } - self._ffdDirty = true; - } - else { - self._meshBones.length = 0; - self._ffdVertices.length = 0; - } - if (isTimelineUpdate) { - self._armature.animation._updateFFDTimelineStates(); } } + for (var i in ffdTimelineStates) { + var ffdTimelineState = ffdTimelineStates[i]; + ffdTimelineState.slot._ffdDirty = true; + this._ffdTimelines.splice(this._ffdTimelines.indexOf(ffdTimelineState), 1); + ffdTimelineState.returnToPool(); + } }; /** - * @private Armature + * @private */ - p._update = function (cacheFrameIndex) { + AnimationState.prototype._advanceTime = function (passedTime, weightLeft, index) { var self = this; - self._blendIndex = 0; - if (self._displayDirty) { - self._displayDirty = false; - self._updateDisplay(); - } - if (!self._display) { - return; - } - if (self._blendModeDirty) { - self._blendModeDirty = false; - self._updateBlendMode(); - } - if (self._colorDirty) { - self._colorDirty = false; - self._updateColor(); - } - if (self._meshData) { - if (self._ffdDirty || (self._meshData.skinned && self._isMeshBonesUpdate())) { - self._ffdDirty = false; - self._updateMesh(); - } - if (self._meshData.skinned) { - return; - } + if (passedTime != 0) { + self._advanceFadeTime(passedTime); } - if (self._originDirty) { - self._originDirty = false; - self._transformDirty = true; - self._updateLocalTransformMatrix(); + // Update time. + passedTime *= self.timeScale; + if (passedTime != 0 && self._isPlaying && !self._isPausePlayhead) { + self._time += passedTime; } - if (cacheFrameIndex >= 0) { - var cacheFrame = self._cacheFrames[cacheFrameIndex]; - if (self.globalTransformMatrix == cacheFrame) { - self._transformDirty = false; - } - else if (cacheFrame) { - self._transformDirty = true; - self.globalTransformMatrix = cacheFrame; - } - else if (self._transformDirty || self._parent._transformDirty != 0 /* None */) { - self._transformDirty = true; - self.globalTransformMatrix = self._globalTransformMatrix; + // Blend weight. + self._weightResult = self.weight * self._fadeProgress * weightLeft; + if (self._weightResult != 0) { + var isCacheEnabled = self._fadeProgress >= 1 && index == 0 && self._armature.cacheFrameRate > 0; + var cacheTimeToFrameScale = self._animationData.cacheTimeToFrameScale; + var isUpdatesTimeline = true; + var isUpdatesBoneTimeline = true; + var time = isCacheEnabled ? (Math.floor(self._time * cacheTimeToFrameScale) / cacheTimeToFrameScale) : self._time; // Cache time internval. + // Update main timeline. + self._timeline.update(time); + if (!self._animationData.hasAsynchronyTimeline) { + time = self._timeline._currentTime; } - else if (self.globalTransformMatrix != self._globalTransformMatrix) { - self._transformDirty = false; - self._cacheFrames[cacheFrameIndex] = self.globalTransformMatrix; + if (isCacheEnabled) { + var cacheFrameIndex = Math.floor(self._timeline._currentTime * cacheTimeToFrameScale); // uint + if (self._armature._cacheFrameIndex == cacheFrameIndex) { + isUpdatesTimeline = false; + isUpdatesBoneTimeline = false; + } + else { + self._armature._cacheFrameIndex = cacheFrameIndex; + if (self._armature._animation._animationStateDirty) { + self._armature._animation._animationStateDirty = false; + for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { + var boneTimeline = self._boneTimelines[i]; + boneTimeline.bone._cacheFrames = boneTimeline._timeline.cachedFrames; + } + for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { + var slotTimeline = self._slotTimelines[i]; + slotTimeline.slot._cacheFrames = slotTimeline._timeline.cachedFrames; + } + } + if (self._animationData.cachedFrames[cacheFrameIndex]) { + isUpdatesBoneTimeline = false; + } + else { + self._animationData.cachedFrames[cacheFrameIndex] = true; + } + } } else { - self._transformDirty = true; - self.globalTransformMatrix = self._globalTransformMatrix; + self._armature._cacheFrameIndex = -1; } - } - else if (self._transformDirty || self._parent._transformDirty != 0 /* None */) { - self._transformDirty = true; - self.globalTransformMatrix = self._globalTransformMatrix; - } - if (self._transformDirty) { - self._transformDirty = false; - if (self.globalTransformMatrix == self._globalTransformMatrix) { - self._updateGlobalTransformMatrix(); - if (cacheFrameIndex >= 0) { - self.globalTransformMatrix = dragonBones.SlotTimelineData.cacheFrame(self._cacheFrames, cacheFrameIndex, self._globalTransformMatrix); + if (isUpdatesTimeline) { + if (isUpdatesBoneTimeline) { + for (var i = 0, l = self._boneTimelines.length; i < l; ++i) { + self._boneTimelines[i].update(time); + } + } + for (var i = 0, l = self._slotTimelines.length; i < l; ++i) { + self._slotTimelines[i].update(time); + } + for (var i = 0, l = self._ffdTimelines.length; i < l; ++i) { + self._ffdTimelines[i].update(time); } } - self._updateTransform(); + } + if (self.autoFadeOutTime >= 0 && self._fadeProgress >= 1 && self._timeline._isCompleted) { + self.fadeOut(self.autoFadeOutTime); } }; /** - * @private Factory + * @language zh_CN + * 继续播放。 + * @version DragonBones 3.0 */ - p._setDisplayList = function (value) { - var self = this; - if (value && value.length) { - if (self._displayList.length != value.length) { - self._displayList.length = value.length; - } - for (var i = 0, l = self._displayList.length; i < l; ++i) { - var eachDisplay = value[i]; - if (eachDisplay && eachDisplay != self._rawDisplay && eachDisplay != self._meshDisplay && !(eachDisplay instanceof dragonBones.Armature) && - self._displayList.indexOf(eachDisplay) < 0) { - self._initDisplay(eachDisplay); - } - self._displayList[i] = eachDisplay; - } - } - else if (self._displayList.length) { - self._displayList.length = 0; - } - if (self._displayIndex >= 0 && self._displayIndex < self._displayList.length) { - self._displayDirty = self._display != self._displayList[self._displayIndex]; - } - else { - self._displayDirty = self._display != null; - } - return self._displayDirty; + AnimationState.prototype.play = function () { + this._isPlaying = true; }; /** - * @private Factory + * @language zh_CN + * 暂停播放。 + * @version DragonBones 3.0 */ - p._setDisplayIndex = function (value) { - if (this._displayIndex == value) { - return false; + AnimationState.prototype.stop = function () { + this._isPlaying = false; + }; + /** + * @language zh_CN + * 淡出动画。 + * @param fadeOutTime 淡出时间。 (以秒为单位) + * @param pausePlayhead 淡出时是否暂停动画。 [true: 暂停, false: 不暂停] + * @version DragonBones 3.0 + */ + AnimationState.prototype.fadeOut = function (fadeOutTime, pausePlayhead) { + if (pausePlayhead === void 0) { pausePlayhead = true; } + if (fadeOutTime < 0 || fadeOutTime != fadeOutTime) { + fadeOutTime = 0; } - this._displayIndex = value; - this._displayDirty = true; - return this._displayDirty; + this._isPausePlayhead = pausePlayhead; + if (this._isFadeOut) { + if (fadeOutTime > fadeOutTime - this._fadeTime) { + // If the animation is already in fade out, the new fade out will be ignored. + return; + } + } + else { + this._isFadeOut = true; + if (fadeOutTime == 0 || this._fadeProgress <= 0) { + this._fadeProgress = 0.000001; + } + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + this._boneTimelines[i].fadeOut(); + } + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + this._slotTimelines[i].fadeOut(); + } + } + this.displayControl = false; + this.fadeTotalTime = this._fadeProgress > 0.000001 ? fadeOutTime / this._fadeProgress : 0; + this._fadeTime = this.fadeTotalTime * (1 - this._fadeProgress); }; /** - * @private Factory + * @language zh_CN + * 是否包含指定的骨骼遮罩。 + * @param name 指定的骨骼名称。 + * @version DragonBones 3.0 */ - p._setBlendMode = function (value) { - if (this._blendMode == value) { - return false; + AnimationState.prototype.containsBoneMask = function (name) { + return !this._boneMask.length || this._boneMask.indexOf(name) >= 0; + }; + /** + * @language zh_CN + * 添加指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否为该骨骼的子骨骼添加遮罩。 + * @version DragonBones 3.0 + */ + AnimationState.prototype.addBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var currentBone = this._armature.getBone(name); + if (!currentBone) { + return; } - this._blendMode = value; - this._blendModeDirty = true; - return true; + if (this._boneMask.indexOf(name) < 0 && + this._animationData.getBoneTimeline(name)) { + this._boneMask.push(name); + } + if (recursive) { + var bones = this._armature.getBones(); + for (var i = 0, l = bones.length; i < l; ++i) { + var bone = bones[i]; + var boneName = bone.name; + if (this._boneMask.indexOf(boneName) < 0 && + this._animationData.getBoneTimeline(boneName) && + currentBone.contains(bone)) { + this._boneMask.push(boneName); + } + } + } + this._updateTimelineStates(); }; /** - * @private Factory + * @language zh_CN + * 删除指定的骨骼遮罩。 + * @param boneName 指定的骨骼名称。 + * @param recursive 是否删除该骨骼的子骨骼遮罩。 + * @version DragonBones 3.0 */ - p._setColor = function (value) { - this._colorTransform.copyFrom(value); - this._colorDirty = true; - return true; + AnimationState.prototype.removeBoneMask = function (name, recursive) { + if (recursive === void 0) { recursive = true; } + var index = this._boneMask.indexOf(name); + if (index >= 0) { + this._boneMask.splice(index, 1); + } + if (recursive) { + var currentBone = this._armature.getBone(name); + if (currentBone) { + var bones = this._armature.getBones(); + for (var i = 0, l = bones.length; i < l; ++i) { + var bone = bones[i]; + var boneName = bone.name; + var index_1 = this._boneMask.indexOf(boneName); + if (index_1 >= 0 && + currentBone.contains(bone)) { + this._boneMask.splice(index_1, 1); + } + } + } + } + this._updateTimelineStates(); }; /** * @language zh_CN - * 在下一帧更新显示对象的状态。 - * @version DragonBones 4.5 + * 删除所有骨骼遮罩。 + * @version DragonBones 3.0 */ - p.invalidUpdate = function () { - this._displayDirty = true; + AnimationState.prototype.removeAllBoneMask = function () { + this._boneMask.length = 0; + this._updateTimelineStates(); }; - d(p, "rawDisplay" + Object.defineProperty(AnimationState.prototype, "layer", { /** - * @private + * @language zh_CN + * 动画图层。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 */ - ,function () { - return this._rawDisplay; - } - ); - d(p, "MeshDisplay" + get: function () { + return this._layer; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "group", { /** - * @private + * @language zh_CN + * 动画组。 + * @see dragonBones.Animation#fadeIn() + * @version DragonBones 3.0 */ - ,function () { - return this._meshDisplay; - } - ); - d(p, "displayIndex" + get: function () { + return this._group; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "name", { /** * @language zh_CN - * 此时显示的显示对象在显示列表中的索引。 - * @version DragonBones 4.5 + * 动画名称。 + * @see dragonBones.AnimationData#name + * @version DragonBones 3.0 */ - ,function () { - return this._displayIndex; - } - ,function (value) { - if (this._setDisplayIndex(value)) { - this._update(-1); - } - } - ); - d(p, "displayList" + get: function () { + return this._name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "animationData", { /** * @language zh_CN - * 包含显示对象或子骨架的显示列表。 + * 动画数据。 + * @see dragonBones.AnimationData * @version DragonBones 3.0 */ - ,function () { - return this._displayList.concat(); - } - ,function (value) { - var self = this; - var backupDisplayList = self._displayList.concat(); // Copy. - var disposeDisplayList = []; - if (self._setDisplayList(value)) { - self._update(-1); - } - // Release replaced render displays. - for (var i = 0, l = backupDisplayList.length; i < l; ++i) { - var eachDisplay = backupDisplayList[i]; - if (eachDisplay != self._rawDisplay && eachDisplay != self._meshDisplay && - self._displayList.indexOf(eachDisplay) < 0 && - disposeDisplayList.indexOf(eachDisplay) < 0) { - disposeDisplayList.push(eachDisplay); - } - } - for (var i = 0, l = disposeDisplayList.length; i < l; ++i) { - var eachDisplay = disposeDisplayList[i]; - if (eachDisplay instanceof dragonBones.Armature) { - (eachDisplay).returnToPool(); - } - else { - self._disposeDisplay(eachDisplay); - } - } - } - ); - d(p, "display" + get: function () { + return this._animationData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isCompleted", { /** * @language zh_CN - * 此时显示的显示对象。 + * 是否播放完毕。 * @version DragonBones 3.0 */ - ,function () { - return this._display; - } - ,function (value) { - var self = this; - if (self._display == value) { - return; - } - var displayListLength = self._displayList.length; - if (self._displayIndex < 0 && displayListLength == 0) { - self._displayIndex = 0; - } - if (self._displayIndex < 0) { - return; - } - else { - var replaceDisplayList = self.displayList; // Copy. - if (displayListLength <= self._displayIndex) { - replaceDisplayList.length = self._displayIndex + 1; - } - replaceDisplayList[self._displayIndex] = value; - self.displayList = replaceDisplayList; - } - } - ); - d(p, "childArmature" + get: function () { + return this._timeline._isCompleted; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "isPlaying", { /** * @language zh_CN - * 此时显示的子骨架。 - * @see dragonBones.Armature + * 是否正在播放。 * @version DragonBones 3.0 */ - ,function () { - return this._childArmature; - } - ,function (value) { - if (this._childArmature == value) { - return; + get: function () { + return (this._isPlaying && !this._timeline._isCompleted); + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentPlayTimes", { + /** + * @language zh_CN + * 当前动画的播放次数。 + * @version DragonBones 3.0 + */ + get: function () { + return this._currentPlayTimes; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "totalTime", { + /** + * @language zh_CN + * 当前动画的总时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + get: function () { + return this._duration; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "currentTime", { + /** + * @language zh_CN + * 当前动画的播放时间。 (以秒为单位) + * @version DragonBones 3.0 + */ + get: function () { + return this._timeline._currentTime; + }, + set: function (value) { + if (value < 0 || value != value) { + value = 0; } - this.display = value; - } - ); - /** - * @deprecated - * @see #display - */ - p.getDisplay = function () { - return this._display; - }; - /** - * @deprecated - * @see #display - */ - p.setDisplay = function (value) { - this.display = value; - }; - return Slot; - }(dragonBones.TransformObject)); - dragonBones.Slot = Slot; - egret.registerClass(Slot,'dragonBones.Slot'); + this._time = value; + this._timeline.setCurrentTime(this._time); + if (this._weightResult != 0) { + var time = this._time; + if (!this._animationData.hasAsynchronyTimeline) { + time = this._timeline._currentTime; + } + for (var i = 0, l = this._boneTimelines.length; i < l; ++i) { + this._boneTimelines[i].setCurrentTime(time); + } + for (var i = 0, l = this._slotTimelines.length; i < l; ++i) { + this._slotTimelines[i].setCurrentTime(time); + } + for (var i = 0, l = this._ffdTimelines.length; i < l; ++i) { + this._ffdTimelines[i].setCurrentTime(time); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(AnimationState.prototype, "clip", { + /** + * @deprecated + * @see #animationData + */ + get: function () { + return this._animationData; + }, + enumerable: true, + configurable: true + }); + return AnimationState; + }(dragonBones.BaseObject)); + dragonBones.AnimationState = AnimationState; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** - * DragonBones + * @private */ - var DragonBones = (function () { - /** - * @private - */ - function DragonBones() { + var TimelineState = (function (_super) { + __extends(TimelineState, _super); + function TimelineState() { + _super.call(this); } - var d = __define,c=DragonBones,p=c.prototype; /** - * @private - */ - DragonBones.hasArmature = function (value) { - return DragonBones._armatures.indexOf(value) >= 0; - }; - /** - * @private + * @inheritDoc */ - DragonBones.addArmature = function (value) { - if (value && DragonBones._armatures.indexOf(value) < 0) { - DragonBones._armatures.push(value); - } + TimelineState.prototype._onClear = function () { + this._isCompleted = false; + this._currentPlayTimes = 0; + this._currentTime = 0; + this._timeline = null; + this._isReverse = false; + this._hasAsynchronyTimeline = false; + this._frameRate = 0; + this._keyFrameCount = 0; + this._frameCount = 0; + this._position = 0; + this._duration = 0; + this._animationDutation = 0; + this._timeScale = 1; + this._timeOffset = 0; + this._currentFrame = null; + this._armature = null; + this._animationState = null; }; - /** - * @private - */ - DragonBones.removeArmature = function (value) { - if (value) { - var index = DragonBones._armatures.indexOf(value); - if (index >= 0) { - DragonBones._armatures.splice(index, 1); + TimelineState.prototype._onFadeIn = function () { }; + TimelineState.prototype._onUpdateFrame = function (isUpdate) { }; + TimelineState.prototype._onArriveAtFrame = function (isUpdate) { }; + TimelineState.prototype._setCurrentTime = function (value) { + var self = this; + var currentPlayTimes = 0; + if (self._hasAsynchronyTimeline) { + var playTimes = self._animationState.playTimes; + var totalTimes = playTimes * self._duration; + value *= self._timeScale; + if (self._timeOffset != 0) { + value += self._timeOffset * self._animationDutation; } - } - }; - /** - * @private - */ - DragonBones.PI_D = Math.PI * 2; - /** - * @private - */ - DragonBones.PI_H = Math.PI / 2; - /** - * @private - */ - DragonBones.PI_Q = Math.PI / 4; - /** - * @private - */ - DragonBones.ANGLE_TO_RADIAN = Math.PI / 180; - /** - * @private - */ - DragonBones.RADIAN_TO_ANGLE = 180 / Math.PI; - /** - * @private - */ - DragonBones.SECOND_TO_MILLISECOND = 1000; - /** - * @private - */ - DragonBones.NO_TWEEN = 100; - DragonBones.VERSION = "4.7.1"; - /** - * @private - */ - DragonBones.DEBUG = true; + if (playTimes > 0 && (value >= totalTimes || value <= -totalTimes)) { + self._isCompleted = true; + currentPlayTimes = playTimes; + if (value < 0) { + value = 0; + } + else { + value = self._duration; + } + } + else { + self._isCompleted = false; + if (value < 0) { + currentPlayTimes = Math.floor(-value / self._duration); + value = self._duration - (-value % self._duration); + } + else { + currentPlayTimes = Math.floor(value / self._duration); + value %= self._duration; + } + if (playTimes > 0 && currentPlayTimes > playTimes) { + currentPlayTimes = playTimes; + } + } + value += self._position; + } + else { + self._isCompleted = self._animationState._timeline._isCompleted; + currentPlayTimes = self._animationState._timeline._currentPlayTimes; + } + if (self._currentTime == value) { + return false; + } + if (self._keyFrameCount == 1 && value > self._position && this != self._animationState._timeline) { + self._isCompleted = true; + } + self._isReverse = self._currentTime > value && self._currentPlayTimes == currentPlayTimes; + self._currentTime = value; + self._currentPlayTimes = currentPlayTimes; + return true; + }; + TimelineState.prototype.setCurrentTime = function (value) { + this._setCurrentTime(value); + switch (this._keyFrameCount) { + case 0: + break; + case 1: + this._currentFrame = this._timeline.frames[0]; + this._onArriveAtFrame(false); + this._onUpdateFrame(false); + break; + default: + this._currentFrame = this._timeline.frames[Math.floor(this._currentTime * this._frameRate)]; + this._onArriveAtFrame(false); + this._onUpdateFrame(false); + break; + } + this._currentFrame = null; + }; + TimelineState.prototype.fadeIn = function (armature, animationState, timelineData, time) { + this._armature = armature; + this._animationState = animationState; + this._timeline = timelineData; + var isMainTimeline = this == this._animationState._timeline; + this._hasAsynchronyTimeline = isMainTimeline || this._animationState.animationData.hasAsynchronyTimeline; + this._frameRate = this._armature.armatureData.frameRate; + this._keyFrameCount = this._timeline.frames.length; + this._frameCount = this._animationState.animationData.frameCount; + this._position = this._animationState._position; + this._duration = this._animationState._duration; + this._animationDutation = this._animationState.animationData.duration; + this._timeScale = isMainTimeline ? 1 : (1 / this._timeline.scale); + this._timeOffset = isMainTimeline ? 0 : this._timeline.offset; + this._onFadeIn(); + this.setCurrentTime(time); + }; + TimelineState.prototype.fadeOut = function () { }; + TimelineState.prototype.update = function (time) { + var self = this; + if (!self._isCompleted && self._setCurrentTime(time) && self._keyFrameCount) { + var currentFrameIndex = self._keyFrameCount > 1 ? Math.floor(self._currentTime * self._frameRate) : 0; + var currentFrame = self._timeline.frames[currentFrameIndex]; + if (self._currentFrame != currentFrame) { + self._currentFrame = currentFrame; + self._onArriveAtFrame(true); + } + self._onUpdateFrame(true); + } + }; + return TimelineState; + }(dragonBones.BaseObject)); + dragonBones.TimelineState = TimelineState; + /** + * @private + */ + var TweenTimelineState = (function (_super) { + __extends(TweenTimelineState, _super); + function TweenTimelineState() { + _super.call(this); + } + TweenTimelineState._getEasingValue = function (progress, easing) { + var value = 1; + if (easing > 2) { + return progress; + } + else if (easing > 1) { + value = 0.5 * (1 - Math.cos(progress * Math.PI)); + easing -= 1; + } + else if (easing > 0) { + value = 1 - Math.pow(1 - progress, 2); + } + else if (easing >= -1) { + easing *= -1; + value = Math.pow(progress, 2); + } + else if (easing >= -2) { + easing *= -1; + value = Math.acos(1 - progress * 2) / Math.PI; + easing -= 1; + } + else { + return progress; + } + return (value - progress) * easing + progress; + }; + TweenTimelineState._getCurveEasingValue = function (progress, sampling) { + var x = 0; + var y = 0; + /*const total = sampling.length * 0.5; + const count = Math.floor((total + 2) * progress); + if (count == 0) { + return sampling[1] * progress / sampling[0]; + }*/ + for (var i = 0, l = sampling.length; i < l; i += 2) { + x = sampling[i]; + y = sampling[i + 1]; + if (x >= progress) { + if (i == 0) { + return y * progress / x; + } + else { + var xP = sampling[i - 2]; + var yP = sampling[i - 1]; // i - 2 + 1 + return yP + (y - yP) * (progress - xP) / (x - xP); + } + } + } + return y + (1 - y) * (progress - x) / (1 - x); + }; /** - * @private + * @inheritDoc */ - DragonBones._armatures = []; - return DragonBones; - }()); - dragonBones.DragonBones = DragonBones; - egret.registerClass(DragonBones,'dragonBones.DragonBones'); + TweenTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._tweenProgress = 0; + this._tweenEasing = dragonBones.DragonBones.NO_TWEEN; + this._curve = null; + }; + TweenTimelineState.prototype._onArriveAtFrame = function (isUpdate) { + var self = this; + self._tweenEasing = self._currentFrame.tweenEasing; + self._curve = self._currentFrame.curve; + if (self._keyFrameCount <= 1 || + (self._currentFrame.next == self._timeline.frames[0] && + (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve) && + self._animationState.playTimes > 0 && + self._animationState.currentPlayTimes == self._animationState.playTimes - 1)) { + self._tweenEasing = dragonBones.DragonBones.NO_TWEEN; + self._curve = null; + } + }; + TweenTimelineState.prototype._onUpdateFrame = function (isUpdate) { + var self = this; + if (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN) { + self._tweenProgress = (self._currentTime - self._currentFrame.position + self._position) / self._currentFrame.duration; + if (self._tweenEasing != 0) { + self._tweenProgress = TweenTimelineState._getEasingValue(self._tweenProgress, self._tweenEasing); + } + } + else if (self._curve) { + self._tweenProgress = (self._currentTime - self._currentFrame.position + self._position) / self._currentFrame.duration; + self._tweenProgress = TweenTimelineState._getCurveEasingValue(self._tweenProgress, self._curve); + } + else { + self._tweenProgress = 0; + } + }; + TweenTimelineState.prototype._updateExtensionKeyFrame = function (current, next, result) { + var tweenType = 0 /* None */; + if (current.type == next.type) { + for (var i = 0, l = current.tweens.length; i < l; ++i) { + var tweenDuration = next.tweens[i] - current.tweens[i]; + result.tweens[i] = tweenDuration; + if (tweenDuration != 0) { + tweenType = 2 /* Always */; + } + } + } + if (tweenType == 0 /* None */) { + if (result.type != current.type) { + tweenType = 1 /* Once */; + result.type = current.type; + } + if (result.tweens.length != current.tweens.length) { + tweenType = 1 /* Once */; + result.tweens.length = current.tweens.length; + } + if (result.keys.length != current.keys.length) { + tweenType = 1 /* Once */; + result.keys.length = current.keys.length; + } + for (var i = 0, l = current.keys.length; i < l; ++i) { + var key = current.keys[i]; + if (result.keys[i] != key) { + tweenType = 1 /* Once */; + result.keys[i] = key; + } + } + } + return tweenType; + }; + return TweenTimelineState; + }(TimelineState)); + dragonBones.TweenTimelineState = TweenTimelineState; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** - * @language zh_CN - * 事件数据。 - * @version DragonBones 4.5 + * @private */ - var EventObject = (function (_super) { - __extends(EventObject, _super); - /** - * @private - */ - function EventObject() { + var AnimationTimelineState = (function (_super) { + __extends(AnimationTimelineState, _super); + function AnimationTimelineState() { _super.call(this); } - var d = __define,c=EventObject,p=c.prototype; - /** - * @private - */ - EventObject.toString = function () { - return "[Class dragonBones.EventObject]"; + AnimationTimelineState.toString = function () { + return "[class dragonBones.AnimationTimelineState]"; }; /** * @inheritDoc */ - p._onClear = function () { - this.type = null; - this.name = null; - this.data = null; - this.armature = null; - this.bone = null; - this.slot = null; - this.animationState = null; - this.userData = null; + AnimationTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this._isStarted = false; }; - d(p, "animationName" - /** - * @see #animationState - */ - ,function () { - return this.animationState.name; + AnimationTimelineState.prototype._onCrossFrame = function (frame) { + var self = this; + var actions = frame.actions; + for (var i = 0, l = actions.length; i < l; ++i) { + self._armature._bufferAction(actions[i]); } - ); - /** - * @language zh_CN - * 动画开始。 - * @version DragonBones 4.5 - */ - EventObject.START = "start"; - /** - * @language zh_CN - * 动画循环播放一次完成。 - * @version DragonBones 4.5 - */ - EventObject.LOOP_COMPLETE = "loopComplete"; - /** - * @language zh_CN - * 动画播放完成。 - * @version DragonBones 4.5 - */ - EventObject.COMPLETE = "complete"; - /** - * @language zh_CN - * 动画淡入开始。 - * @version DragonBones 4.5 - */ - EventObject.FADE_IN = "fadeIn"; - /** - * @language zh_CN - * 动画淡入完成。 - * @version DragonBones 4.5 - */ - EventObject.FADE_IN_COMPLETE = "fadeInComplete"; - /** - * @language zh_CN - * 动画淡出开始。 - * @version DragonBones 4.5 - */ - EventObject.FADE_OUT = "fadeOut"; - /** - * @language zh_CN - * 动画淡出完成。 - * @version DragonBones 4.5 - */ - EventObject.FADE_OUT_COMPLETE = "fadeOutComplete"; - /** - * @language zh_CN - * 动画帧事件。 - * @version DragonBones 4.5 - */ - EventObject.FRAME_EVENT = "frameEvent"; - /** - * @language zh_CN - * 动画声音事件。 - * @version DragonBones 4.5 - */ - EventObject.SOUND_EVENT = "soundEvent"; - return EventObject; - }(dragonBones.BaseObject)); - dragonBones.EventObject = EventObject; - egret.registerClass(EventObject,'dragonBones.EventObject'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * 贴图集数据。 - * @version DragonBones 3.0 - */ - var TextureAtlasData = (function (_super) { - __extends(TextureAtlasData, _super); - /** - * @private - */ - function TextureAtlasData() { - _super.call(this); - /** - * @private - */ - this.textures = {}; - } - var d = __define,c=TextureAtlasData,p=c.prototype; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.autoSearch = false; - self.scale = 1; - self.name = null; - self.imagePath = null; - for (var i in self.textures) { - self.textures[i].returnToPool(); - delete self.textures[i]; + var eventDispatcher = self._armature._display; + var events = frame.events; + for (var i = 0, l = events.length; i < l; ++i) { + var eventData = events[i]; + var eventType = ""; + switch (eventData.type) { + case 0 /* Frame */: + eventType = dragonBones.EventObject.FRAME_EVENT; + break; + case 1 /* Sound */: + eventType = dragonBones.EventObject.SOUND_EVENT; + break; + } + if ((eventData.type == 1 /* Sound */ ? + (dragonBones.EventObject._soundEventManager || eventDispatcher) : + eventDispatcher).hasEvent(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.animationState = self._animationState; + if (eventData.bone) { + eventObject.bone = self._armature.getBone(eventData.bone.name); + } + if (eventData.slot) { + eventObject.slot = self._armature.getSlot(eventData.slot.name); + } + eventObject.name = eventData.name; + eventObject.data = eventData.data; + self._armature._bufferEvent(eventObject, eventType); + } } }; - /** - * @deprecated - * @see dragonBones.BaseFactory#removeDragonBonesData() - */ - p.dispose = function () { - this.returnToPool(); - }; - /** - * @private - */ - p.addTextureData = function (value) { - if (value && value.name && !this.textures[value.name]) { - this.textures[value.name] = value; - value.parent = this; - } - else { - throw new Error(); + AnimationTimelineState.prototype.update = function (time) { + var self = this; + var prevTime = self._currentTime; + var prevPlayTimes = self._currentPlayTimes; + if (!self._isCompleted && self._setCurrentTime(time)) { + var eventDispatcher = self._armature._display; + if (!self._isStarted && time != 0) { + self._isStarted = true; + if (eventDispatcher.hasEvent(dragonBones.EventObject.START)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.animationState = self._animationState; + self._armature._bufferEvent(eventObject, dragonBones.EventObject.START); + } + } + if (self._keyFrameCount) { + var currentFrameIndex = self._keyFrameCount > 1 ? Math.floor(self._currentTime * self._frameRate) : 0; + var currentFrame = self._timeline.frames[currentFrameIndex]; + if (self._currentFrame != currentFrame) { + if (self._keyFrameCount > 1) { + var crossedFrame = self._currentFrame; + self._currentFrame = currentFrame; + if (!crossedFrame) { + var prevFrameIndex = Math.floor(prevTime * self._frameRate); + crossedFrame = self._timeline.frames[prevFrameIndex]; + if (self._isReverse) { + } + else { + if (prevTime <= crossedFrame.position || + prevPlayTimes != self._currentPlayTimes) { + crossedFrame = crossedFrame.prev; + } + } + } + if (self._isReverse) { + while (crossedFrame != currentFrame) { + self._onCrossFrame(crossedFrame); + crossedFrame = crossedFrame.prev; + } + } + else { + while (crossedFrame != currentFrame) { + crossedFrame = crossedFrame.next; + self._onCrossFrame(crossedFrame); + } + } + } + else { + self._currentFrame = currentFrame; + self._onCrossFrame(self._currentFrame); + } + } + } + if (prevPlayTimes != self._currentPlayTimes) { + var eventType = self._isCompleted ? dragonBones.EventObject.COMPLETE : dragonBones.EventObject.LOOP_COMPLETE; + if (eventDispatcher.hasEvent(eventType)) { + var eventObject = dragonBones.BaseObject.borrowObject(dragonBones.EventObject); + eventObject.animationState = self._animationState; + self._armature._bufferEvent(eventObject, eventType); + } + } } }; - /** - * @private - */ - p.getTextureData = function (name) { - return this.textures[name]; - }; - return TextureAtlasData; - }(dragonBones.BaseObject)); - dragonBones.TextureAtlasData = TextureAtlasData; - egret.registerClass(TextureAtlasData,'dragonBones.TextureAtlasData'); + return AnimationTimelineState; + }(dragonBones.TimelineState)); + dragonBones.AnimationTimelineState = AnimationTimelineState; /** * @private */ - var TextureData = (function (_super) { - __extends(TextureData, _super); - function TextureData() { - _super.call(this); - this.region = new dragonBones.Rectangle(); - } - var d = __define,c=TextureData,p=c.prototype; - TextureData.generateRectangle = function () { - return new dragonBones.Rectangle(); - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.rotated = false; - self.name = null; - self.frame = null; - self.parent = null; - self.region.clear(); - }; - return TextureData; - }(dragonBones.BaseObject)); - dragonBones.TextureData = TextureData; - egret.registerClass(TextureData,'dragonBones.TextureData'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * Egret 贴图集数据。 - * @version DragonBones 3.0 - */ - var EgretTextureAtlasData = (function (_super) { - __extends(EgretTextureAtlasData, _super); - /** - * @private - */ - function EgretTextureAtlasData() { + var BoneTimelineState = (function (_super) { + __extends(BoneTimelineState, _super); + function BoneTimelineState() { _super.call(this); + this._transform = new dragonBones.Transform(); + this._currentTransform = new dragonBones.Transform(); + this._durationTransform = new dragonBones.Transform(); } - var d = __define,c=EgretTextureAtlasData,p=c.prototype; - /** - * @private - */ - EgretTextureAtlasData.toString = function () { - return "[Class dragonBones.EgretTextureAtlasData]"; + BoneTimelineState.toString = function () { + return "[class dragonBones.BoneTimelineState]"; }; /** * @inheritDoc */ - p._onClear = function () { + BoneTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); - if (this.texture) { - //this.texture.dispose(); - this.texture = null; + this.bone = null; + this._tweenTransform = 0 /* None */; + this._tweenRotate = 0 /* None */; + this._tweenScale = 0 /* None */; + this._boneTransform = null; + this._originTransform = null; + this._transform.identity(); + this._currentTransform.identity(); + this._durationTransform.identity(); + }; + BoneTimelineState.prototype._onFadeIn = function () { + this._originTransform = this._timeline.originTransform; + this._boneTransform = this.bone._animationPose; + }; + BoneTimelineState.prototype._onArriveAtFrame = function (isUpdate) { + var self = this; + _super.prototype._onArriveAtFrame.call(this, isUpdate); + self._currentTransform.copyFrom(self._currentFrame.transform); + self._tweenTransform = 1 /* Once */; + self._tweenRotate = 1 /* Once */; + self._tweenScale = 1 /* Once */; + if (self._keyFrameCount > 1 && (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve)) { + var nextFrame = self._currentFrame.next; + var nextTransform = nextFrame.transform; + // Transform. + self._durationTransform.x = nextTransform.x - self._currentTransform.x; + self._durationTransform.y = nextTransform.y - self._currentTransform.y; + if (self._durationTransform.x != 0 || self._durationTransform.y != 0) { + self._tweenTransform = 2 /* Always */; + } + // Rotate. + var tweenRotate = self._currentFrame.tweenRotate; + if (tweenRotate == tweenRotate) { + if (tweenRotate) { + if (tweenRotate > 0 ? nextTransform.skewY >= self._currentTransform.skewY : nextTransform.skewY <= self._currentTransform.skewY) { + var rotate = tweenRotate > 0 ? tweenRotate - 1 : tweenRotate + 1; + self._durationTransform.skewX = nextTransform.skewX - self._currentTransform.skewX + dragonBones.DragonBones.PI_D * rotate; + self._durationTransform.skewY = nextTransform.skewY - self._currentTransform.skewY + dragonBones.DragonBones.PI_D * rotate; + } + else { + self._durationTransform.skewX = nextTransform.skewX - self._currentTransform.skewX + dragonBones.DragonBones.PI_D * tweenRotate; + self._durationTransform.skewY = nextTransform.skewY - self._currentTransform.skewY + dragonBones.DragonBones.PI_D * tweenRotate; + } + } + else { + self._durationTransform.skewX = dragonBones.Transform.normalizeRadian(nextTransform.skewX - self._currentTransform.skewX); + self._durationTransform.skewY = dragonBones.Transform.normalizeRadian(nextTransform.skewY - self._currentTransform.skewY); + } + if (self._durationTransform.skewX != 0 || self._durationTransform.skewY != 0) { + self._tweenRotate = 2 /* Always */; + } + } + else { + self._durationTransform.skewX = 0; + self._durationTransform.skewY = 0; + } + // Scale. + if (self._currentFrame.tweenScale) { + self._durationTransform.scaleX = nextTransform.scaleX - self._currentTransform.scaleX; + self._durationTransform.scaleY = nextTransform.scaleY - self._currentTransform.scaleY; + if (self._durationTransform.scaleX != 0 || self._durationTransform.scaleY != 0) { + self._tweenScale = 2 /* Always */; + } + } + else { + self._durationTransform.scaleX = 0; + self._durationTransform.scaleY = 0; + } + } + else { + self._durationTransform.x = 0; + self._durationTransform.y = 0; + self._durationTransform.skewX = 0; + self._durationTransform.skewY = 0; + self._durationTransform.scaleX = 0; + self._durationTransform.scaleY = 0; } }; - /** - * @private - */ - p.generateTextureData = function () { - return dragonBones.BaseObject.borrowObject(EgretTextureData); + BoneTimelineState.prototype._onUpdateFrame = function (isUpdate) { + var self = this; + if (self._tweenTransform || self._tweenRotate || self._tweenScale) { + _super.prototype._onUpdateFrame.call(this, isUpdate); + var tweenProgress = 0; + if (self._tweenTransform) { + if (self._tweenTransform == 1 /* Once */) { + self._tweenTransform = 0 /* None */; + tweenProgress = 0; + } + else { + tweenProgress = self._tweenProgress; + } + if (self._animationState.additiveBlending) { + self._transform.x = self._currentTransform.x + self._durationTransform.x * tweenProgress; + self._transform.y = self._currentTransform.y + self._durationTransform.y * tweenProgress; + } + else { + self._transform.x = self._originTransform.x + self._currentTransform.x + self._durationTransform.x * tweenProgress; + self._transform.y = self._originTransform.y + self._currentTransform.y + self._durationTransform.y * tweenProgress; + } + } + if (self._tweenRotate) { + if (self._tweenRotate == 1 /* Once */) { + self._tweenRotate = 0 /* None */; + tweenProgress = 0; + } + else { + tweenProgress = self._tweenProgress; + } + if (self._animationState.additiveBlending) { + self._transform.skewX = self._currentTransform.skewX + self._durationTransform.skewX * tweenProgress; + self._transform.skewY = self._currentTransform.skewY + self._durationTransform.skewY * tweenProgress; + } + else { + self._transform.skewX = self._originTransform.skewX + self._currentTransform.skewX + self._durationTransform.skewX * tweenProgress; + self._transform.skewY = self._originTransform.skewY + self._currentTransform.skewY + self._durationTransform.skewY * tweenProgress; + } + } + if (self._tweenScale) { + if (self._tweenScale == 1 /* Once */) { + self._tweenScale = 0 /* None */; + tweenProgress = 0; + } + else { + tweenProgress = self._tweenProgress; + } + if (self._animationState.additiveBlending) { + self._transform.scaleX = self._currentTransform.scaleX + self._durationTransform.scaleX * tweenProgress; + self._transform.scaleY = self._currentTransform.scaleY + self._durationTransform.scaleY * tweenProgress; + } + else { + self._transform.scaleX = self._originTransform.scaleX * (self._currentTransform.scaleX + self._durationTransform.scaleX * tweenProgress); + self._transform.scaleY = self._originTransform.scaleY * (self._currentTransform.scaleY + self._durationTransform.scaleY * tweenProgress); + } + } + self.bone.invalidUpdate(); + } }; - return EgretTextureAtlasData; - }(dragonBones.TextureAtlasData)); - dragonBones.EgretTextureAtlasData = EgretTextureAtlasData; - egret.registerClass(EgretTextureAtlasData,'dragonBones.EgretTextureAtlasData'); + BoneTimelineState.prototype.fadeOut = function () { + this._transform.skewX = dragonBones.Transform.normalizeRadian(this._transform.skewX); + this._transform.skewY = dragonBones.Transform.normalizeRadian(this._transform.skewY); + }; + BoneTimelineState.prototype.update = function (time) { + var self = this; + _super.prototype.update.call(this, time); + // Blend animation state. + var weight = self._animationState._weightResult; + if (weight > 0) { + if (self.bone._blendIndex == 0) { + self._boneTransform.x = self._transform.x * weight; + self._boneTransform.y = self._transform.y * weight; + self._boneTransform.skewX = self._transform.skewX * weight; + self._boneTransform.skewY = self._transform.skewY * weight; + self._boneTransform.scaleX = (self._transform.scaleX - 1) * weight + 1; + self._boneTransform.scaleY = (self._transform.scaleY - 1) * weight + 1; + } + else { + self._boneTransform.x += self._transform.x * weight; + self._boneTransform.y += self._transform.y * weight; + self._boneTransform.skewX += self._transform.skewX * weight; + self._boneTransform.skewY += self._transform.skewY * weight; + self._boneTransform.scaleX += (self._transform.scaleX - 1) * weight; + self._boneTransform.scaleY += (self._transform.scaleY - 1) * weight; + } + self.bone._blendIndex++; + var fadeProgress = self._animationState._fadeProgress; + if (fadeProgress < 1) { + self.bone.invalidUpdate(); + } + } + }; + return BoneTimelineState; + }(dragonBones.TweenTimelineState)); + dragonBones.BoneTimelineState = BoneTimelineState; /** * @private */ - var EgretTextureData = (function (_super) { - __extends(EgretTextureData, _super); - function EgretTextureData() { + var SlotTimelineState = (function (_super) { + __extends(SlotTimelineState, _super); + function SlotTimelineState() { _super.call(this); + this._color = new dragonBones.ColorTransform(); + this._durationColor = new dragonBones.ColorTransform(); } - var d = __define,c=EgretTextureData,p=c.prototype; - EgretTextureData.toString = function () { - return "[Class dragonBones.EgretTextureData]"; + SlotTimelineState.toString = function () { + return "[class dragonBones.SlotTimelineState]"; }; /** * @inheritDoc */ - p._onClear = function () { + SlotTimelineState.prototype._onClear = function () { _super.prototype._onClear.call(this); - if (this.texture) { - this.texture.dispose(); - this.texture = null; + this.slot = null; + this._colorDirty = false; + this._tweenColor = 0 /* None */; + this._slotColor = null; + this._color.identity(); + this._durationColor.identity(); + }; + SlotTimelineState.prototype._onFadeIn = function () { + this._slotColor = this.slot._colorTransform; + }; + SlotTimelineState.prototype._onArriveAtFrame = function (isUpdate) { + var self = this; + _super.prototype._onArriveAtFrame.call(this, isUpdate); + if (self._animationState._isDisabled(self.slot)) { + self._tweenEasing = dragonBones.DragonBones.NO_TWEEN; + self._curve = null; + self._tweenColor = 0 /* None */; + return; + } + if (self.slot._displayDataSet) { + var displayIndex = self._currentFrame.displayIndex; + if (self.slot.displayIndex >= 0 && displayIndex >= 0) { + if (self.slot._displayDataSet.displays.length > 1) { + self.slot._setDisplayIndex(displayIndex); + } + } + else { + self.slot._setDisplayIndex(displayIndex); + } + self.slot._updateMeshData(true); + } + if (self._currentFrame.displayIndex >= 0) { + self._tweenColor = 0 /* None */; + var currentColor = self._currentFrame.color; + if (self._keyFrameCount > 1 && (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve)) { + var nextFrame = self._currentFrame.next; + var nextColor = nextFrame.color; + if (currentColor != nextColor && nextFrame.displayIndex >= 0) { + self._durationColor.alphaMultiplier = nextColor.alphaMultiplier - currentColor.alphaMultiplier; + self._durationColor.redMultiplier = nextColor.redMultiplier - currentColor.redMultiplier; + self._durationColor.greenMultiplier = nextColor.greenMultiplier - currentColor.greenMultiplier; + self._durationColor.blueMultiplier = nextColor.blueMultiplier - currentColor.blueMultiplier; + self._durationColor.alphaOffset = nextColor.alphaOffset - currentColor.alphaOffset; + self._durationColor.redOffset = nextColor.redOffset - currentColor.redOffset; + self._durationColor.greenOffset = nextColor.greenOffset - currentColor.greenOffset; + self._durationColor.blueOffset = nextColor.blueOffset - currentColor.blueOffset; + if (self._durationColor.alphaMultiplier != 0 || + self._durationColor.redMultiplier != 0 || + self._durationColor.greenMultiplier != 0 || + self._durationColor.blueMultiplier != 0 || + self._durationColor.alphaOffset != 0 || + self._durationColor.redOffset != 0 || + self._durationColor.greenOffset != 0 || + self._durationColor.blueOffset != 0) { + self._tweenColor = 2 /* Always */; + } + } + } + if (self._tweenColor == 0 /* None */) { + if (self._slotColor.alphaMultiplier != currentColor.alphaMultiplier || + self._slotColor.redMultiplier != currentColor.redMultiplier || + self._slotColor.greenMultiplier != currentColor.greenMultiplier || + self._slotColor.blueMultiplier != currentColor.blueMultiplier || + self._slotColor.alphaOffset != currentColor.alphaOffset || + self._slotColor.redOffset != currentColor.redOffset || + self._slotColor.greenOffset != currentColor.greenOffset || + self._slotColor.blueOffset != currentColor.blueOffset) { + self._tweenColor = 1 /* Once */; + } + } + } + else { + self._tweenEasing = dragonBones.DragonBones.NO_TWEEN; + self._curve = null; + self._tweenColor = 0 /* None */; } }; - return EgretTextureData; - }(dragonBones.TextureData)); - dragonBones.EgretTextureData = EgretTextureData; - egret.registerClass(EgretTextureData,'dragonBones.EgretTextureData'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { + SlotTimelineState.prototype._onUpdateFrame = function (isUpdate) { + var self = this; + _super.prototype._onUpdateFrame.call(this, isUpdate); + var tweenProgress = 0; + if (self._tweenColor) { + if (self._tweenColor == 1 /* Once */) { + self._tweenColor = 0 /* None */; + tweenProgress = 0; + } + else { + tweenProgress = self._tweenProgress; + } + var currentColor = self._currentFrame.color; + self._color.alphaMultiplier = currentColor.alphaMultiplier + self._durationColor.alphaMultiplier * tweenProgress; + self._color.redMultiplier = currentColor.redMultiplier + self._durationColor.redMultiplier * tweenProgress; + self._color.greenMultiplier = currentColor.greenMultiplier + self._durationColor.greenMultiplier * tweenProgress; + self._color.blueMultiplier = currentColor.blueMultiplier + self._durationColor.blueMultiplier * tweenProgress; + self._color.alphaOffset = currentColor.alphaOffset + self._durationColor.alphaOffset * tweenProgress; + self._color.redOffset = currentColor.redOffset + self._durationColor.redOffset * tweenProgress; + self._color.greenOffset = currentColor.greenOffset + self._durationColor.greenOffset * tweenProgress; + self._color.blueOffset = currentColor.blueOffset + self._durationColor.blueOffset * tweenProgress; + self._colorDirty = true; + } + }; + SlotTimelineState.prototype.fadeOut = function () { + this._tweenColor = 0 /* None */; + }; + SlotTimelineState.prototype.update = function (time) { + var self = this; + _super.prototype.update.call(this, time); + // Fade animation. + if (self._tweenColor != 0 /* None */ || self._colorDirty) { + var weight = self._animationState._weightResult; + if (weight > 0) { + var fadeProgress = self._animationState._fadeProgress; + if (fadeProgress < 1) { + self._slotColor.alphaMultiplier += (self._color.alphaMultiplier - self._slotColor.alphaMultiplier) * fadeProgress; + self._slotColor.redMultiplier += (self._color.redMultiplier - self._slotColor.redMultiplier) * fadeProgress; + self._slotColor.greenMultiplier += (self._color.greenMultiplier - self._slotColor.greenMultiplier) * fadeProgress; + self._slotColor.blueMultiplier += (self._color.blueMultiplier - self._slotColor.blueMultiplier) * fadeProgress; + self._slotColor.alphaOffset += (self._color.alphaOffset - self._slotColor.alphaOffset) * fadeProgress; + self._slotColor.redOffset += (self._color.redOffset - self._slotColor.redOffset) * fadeProgress; + self._slotColor.greenOffset += (self._color.greenOffset - self._slotColor.greenOffset) * fadeProgress; + self._slotColor.blueOffset += (self._color.blueOffset - self._slotColor.blueOffset) * fadeProgress; + self.slot._colorDirty = true; + } + else if (self._colorDirty) { + self._colorDirty = false; + self._slotColor.alphaMultiplier = self._color.alphaMultiplier; + self._slotColor.redMultiplier = self._color.redMultiplier; + self._slotColor.greenMultiplier = self._color.greenMultiplier; + self._slotColor.blueMultiplier = self._color.blueMultiplier; + self._slotColor.alphaOffset = self._color.alphaOffset; + self._slotColor.redOffset = self._color.redOffset; + self._slotColor.greenOffset = self._color.greenOffset; + self._slotColor.blueOffset = self._color.blueOffset; + self.slot._colorDirty = true; + } + } + } + }; + return SlotTimelineState; + }(dragonBones.TweenTimelineState)); + dragonBones.SlotTimelineState = SlotTimelineState; /** - * @language zh_CN - * Egret 事件。 - * @version DragonBones 4.5 + * @private */ - var EgretEvent = (function (_super) { - __extends(EgretEvent, _super); + var FFDTimelineState = (function (_super) { + __extends(FFDTimelineState, _super); + function FFDTimelineState() { + _super.call(this); + this._ffdVertices = []; + } + FFDTimelineState.toString = function () { + return "[class dragonBones.FFDTimelineState]"; + }; /** - * @private + * @inheritDoc */ - function EgretEvent(type, bubbles, cancelable, data) { - _super.call(this, type, bubbles, cancelable, data); - } - var d = __define,c=EgretEvent,p=c.prototype; - d(p, "eventObject" - /** - * @language zh_CN - * 事件对象。 - * @version DragonBones 4.5 - */ - ,function () { - return this.data; - } - ); - d(p, "frameLabel" - /** - * @see dragonBones.EventObject#name - */ - ,function () { - return this.eventObject.name; + FFDTimelineState.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.slot = null; + this._tweenFFD = 0 /* None */; + this._slotFFDVertices = null; + if (this._durationFFDFrame) { + this._durationFFDFrame.returnToPool(); + this._durationFFDFrame = null; } - ); - d(p, "sound" - /** - * @see dragonBones.EventObject#name - */ - ,function () { - return this.eventObject.name; + if (this._ffdVertices.length) { + this._ffdVertices.length = 0; } - ); - d(p, "animationName" - /** - * @see dragonBones.EventObject#animationName - */ - ,function () { - return this.eventObject.animationState.name; + }; + FFDTimelineState.prototype._onFadeIn = function () { + this._slotFFDVertices = this.slot._ffdVertices; + this._durationFFDFrame = dragonBones.BaseObject.borrowObject(dragonBones.ExtensionFrameData); + this._durationFFDFrame.tweens.length = this._slotFFDVertices.length; + this._ffdVertices.length = this._slotFFDVertices.length; + for (var i = 0, l = this._durationFFDFrame.tweens.length; i < l; ++i) { + this._durationFFDFrame.tweens[i] = 0; } - ); - d(p, "armature" - /** - * @see dragonBones.EventObject#armature - */ - ,function () { - return this.eventObject.armature; + for (var i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0; } - ); - d(p, "bone" - /** - * @see dragonBones.EventObject#bone - */ - ,function () { - return this.eventObject.bone; + }; + FFDTimelineState.prototype._onArriveAtFrame = function (isUpdate) { + var self = this; + _super.prototype._onArriveAtFrame.call(this, isUpdate); + self._tweenFFD = 0 /* None */; + if (self._tweenEasing != dragonBones.DragonBones.NO_TWEEN || self._curve) { + self._tweenFFD = self._updateExtensionKeyFrame(self._currentFrame, self._currentFrame.next, self._durationFFDFrame); + } + if (self._tweenFFD == 0 /* None */) { + var currentFFDVertices = self._currentFrame.tweens; + for (var i = 0, l = currentFFDVertices.length; i < l; ++i) { + if (self._slotFFDVertices[i] != currentFFDVertices[i]) { + self._tweenFFD = 1 /* Once */; + break; + } + } + } + }; + FFDTimelineState.prototype._onUpdateFrame = function (isUpdate) { + var self = this; + _super.prototype._onUpdateFrame.call(this, isUpdate); + var tweenProgress = 0; + if (self._tweenFFD != 0 /* None */) { + if (self._tweenFFD == 1 /* Once */) { + self._tweenFFD = 0 /* None */; + tweenProgress = 0; + } + else { + tweenProgress = self._tweenProgress; + } + var currentFFDVertices = self._currentFrame.tweens; + var nextFFDVertices = self._durationFFDFrame.tweens; + for (var i = 0, l = currentFFDVertices.length; i < l; ++i) { + self._ffdVertices[i] = currentFFDVertices[i] + nextFFDVertices[i] * tweenProgress; + } + self.slot._ffdDirty = true; + } + }; + FFDTimelineState.prototype.update = function (time) { + var self = this; + _super.prototype.update.call(this, time); + // Blend animation. + var weight = self._animationState._weightResult; + if (weight > 0) { + if (self.slot._blendIndex == 0) { + for (var i = 0, l = self._ffdVertices.length; i < l; ++i) { + self._slotFFDVertices[i] = self._ffdVertices[i] * weight; + } + } + else { + for (var i = 0, l = self._ffdVertices.length; i < l; ++i) { + self._slotFFDVertices[i] += self._ffdVertices[i] * weight; + } + } + self.slot._blendIndex++; + var fadeProgress = self._animationState._fadeProgress; + if (fadeProgress < 1) { + self.slot._ffdDirty = true; + } } - ); - d(p, "slot" + }; + return FFDTimelineState; + }(dragonBones.TweenTimelineState)); + dragonBones.FFDTimelineState = FFDTimelineState; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * WorldClock 提供时钟的支持,为每个加入到时钟的 IAnimatable 对象更新时间。 + * @see dragonBones.IAnimatable + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + var WorldClock = (function () { + /** + * @language zh_CN + * 创建一个新的 WorldClock 实例。 + * 通常并不需要单独创建 WorldClock 的实例,可以直接使用 WorldClock.clock 静态实例。 + * (创建更多独立的 WorldClock 可以更灵活的为需要更新的 IAnimateble 实例分组,实现不同组不同速度的动画播放) + * @version DragonBones 3.0 + */ + function WorldClock() { /** - * @see dragonBones.EventObject#slot + * @language zh_CN + * 当前的时间。 (以秒为单位) + * @version DragonBones 3.0 */ - ,function () { - return this.eventObject.slot; - } - ); - d(p, "animationState" + this.time = new Date().getTime() / dragonBones.DragonBones.SECOND_TO_MILLISECOND; /** - * @see dragonBones.EventObject#animationState + * @language zh_CN + * 时间流逝的速度,用于实现动画的变速播放。 [0: 停止播放, (0~1): 慢速播放, 1: 正常播放, (1~N): 快速播放] + * @default 1 + * @version DragonBones 3.0 */ - ,function () { - return this.eventObject.animationState; - } - ); - d(p, "movementID" + this.timeScale = 1; + this._animatebles = []; + } + Object.defineProperty(WorldClock, "clock", { /** - * @deprecated - * @see #animationName + * @language zh_CN + * 一个可以直接使用的全局静态 WorldClock 实例. + * @version DragonBones 3.0 */ - ,function () { - return this.animationName; - } - ); + get: function () { + if (!WorldClock._clock) { + WorldClock._clock = new WorldClock(); + } + return WorldClock._clock; + }, + enumerable: true, + configurable: true + }); /** - * @see dragonBones.EventObject.START + * @language zh_CN + * 为所有的 IAnimatable 实例向前播放一个指定的时间。 (通常这个方法需要在 ENTER_FRAME 事件的响应函数中被调用) + * @param passedTime 前进的时间。 (以秒为单位,当设置为 -1 时将自动计算当前帧与上一帧的时间差) + * @version DragonBones 3.0 */ - EgretEvent.START = dragonBones.EventObject.START; + WorldClock.prototype.advanceTime = function (passedTime) { + if (passedTime != passedTime) { + passedTime = 0; + } + if (passedTime < 0) { + passedTime = new Date().getTime() / dragonBones.DragonBones.SECOND_TO_MILLISECOND - this.time; + } + passedTime *= this.timeScale; + if (passedTime < 0) { + this.time -= passedTime; + } + else { + this.time += passedTime; + } + if (passedTime) { + var i = 0, r = 0, l = this._animatebles.length; + for (; i < l; ++i) { + var animateble = this._animatebles[i]; + if (animateble) { + if (r > 0) { + this._animatebles[i - r] = animateble; + this._animatebles[i] = null; + } + animateble.advanceTime(passedTime); + } + else { + r++; + } + } + if (r > 0) { + l = this._animatebles.length; + for (; i < l; ++i) { + var animateble = this._animatebles[i]; + if (animateble) { + this._animatebles[i - r] = animateble; + } + else { + r++; + } + } + this._animatebles.length -= r; + } + } + }; /** - * @see dragonBones.EventObject.LOOP_COMPLETE + * 是否包含指定的 IAnimatable 实例 + * @param value 指定的 IAnimatable 实例。 + * @returns [true: 包含,false: 不包含]。 + * @version DragonBones 3.0 */ - EgretEvent.LOOP_COMPLETE = dragonBones.EventObject.LOOP_COMPLETE; + WorldClock.prototype.contains = function (value) { + return this._animatebles.indexOf(value) >= 0; + }; /** - * @see dragonBones.EventObject.COMPLETE + * @language zh_CN + * 添加指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 */ - EgretEvent.COMPLETE = dragonBones.EventObject.COMPLETE; + WorldClock.prototype.add = function (value) { + if (value && this._animatebles.indexOf(value) < 0) { + this._animatebles.push(value); + if (dragonBones.DragonBones.DEBUG && value instanceof dragonBones.Armature) { + dragonBones.DragonBones.addArmature(value); + } + } + }; /** - * @see dragonBones.EventObject.FADE_IN + * @language zh_CN + * 移除指定的 IAnimatable 实例。 + * @param value IAnimatable 实例。 + * @version DragonBones 3.0 */ - EgretEvent.FADE_IN = dragonBones.EventObject.FADE_IN; + WorldClock.prototype.remove = function (value) { + var index = this._animatebles.indexOf(value); + if (index >= 0) { + this._animatebles[index] = null; + if (dragonBones.DragonBones.DEBUG && value instanceof dragonBones.Armature) { + dragonBones.DragonBones.removeArmature(value); + } + } + }; /** - * @see dragonBones.EventObject.FADE_IN_COMPLETE + * @language zh_CN + * 清除所有的 IAnimatable 实例。 + * @version DragonBones 3.0 */ - EgretEvent.FADE_IN_COMPLETE = dragonBones.EventObject.FADE_IN_COMPLETE; + WorldClock.prototype.clear = function () { + for (var i = 0, l = this._animatebles.length; i < l; ++i) { + this._animatebles[i] = null; + } + }; + WorldClock._clock = null; + return WorldClock; + }()); + dragonBones.WorldClock = WorldClock; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 骨架,是骨骼动画系统的核心,由显示容器、骨骼、插槽、动画、事件系统构成。 + * @see dragonBones.ArmatureData + * @see dragonBones.Bone + * @see dragonBones.Slot + * @see dragonBones.Animation + * @see dragonBones.IArmatureDisplayContainer + * @version DragonBones 3.0 + */ + var Armature = (function (_super) { + __extends(Armature, _super); /** - * @see dragonBones.EventObject.FADE_OUT + * @private */ - EgretEvent.FADE_OUT = dragonBones.EventObject.FADE_OUT; + function Armature() { + _super.call(this); + /** + * @private Store bones based on bones' hierarchy (From root to leaf) + */ + this._bones = []; + /** + * @private Store slots based on slots' zOrder (From low to high) + */ + this._slots = []; + /** + * @private + */ + this._actions = []; + /** + * @private + */ + this._events = []; + /** + * @deprecated + * @see #cacheFrameRate + */ + this.enableCache = false; + } /** - * @see dragonBones.EventObject.FADE_OUT_COMPLETE + * @private */ - EgretEvent.FADE_OUT_COMPLETE = dragonBones.EventObject.FADE_OUT_COMPLETE; + Armature.toString = function () { + return "[class dragonBones.Armature]"; + }; /** - * @see dragonBones.EventObject.FRAME_EVENT + * @inheritDoc */ - EgretEvent.FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + Armature.prototype._onClear = function () { + this.userData = null; + this._bonesDirty = false; + this._cacheFrameIndex = -1; + this._armatureData = null; + this._skinData = null; + if (this._animation) { + this._animation.returnToPool(); + this._animation = null; + } + if (this._display) { + this._display._onClear(); + this._display = null; + } + this._parent = null; + this._replacedTexture = null; + this._delayDispose = false; + this._lockDispose = false; + this._slotsDirty = false; + if (this._bones.length) { + for (var i = 0, l = this._bones.length; i < l; ++i) { + this._bones[i].returnToPool(); + } + this._bones.length = 0; + } + if (this._slots.length) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].returnToPool(); + } + this._slots.length = 0; + } + if (this._actions.length) { + for (var i = 0, l = this._actions.length; i < l; ++i) { + this._actions[i].returnToPool(); + } + this._actions.length = 0; + } + if (this._events.length) { + for (var i = 0, l = this._events.length; i < l; ++i) { + this._events[i].returnToPool(); + } + this._events.length = 0; + } + }; /** - * @see dragonBones.EventObject.SOUND_EVENT + * @private */ - EgretEvent.SOUND_EVENT = dragonBones.EventObject.SOUND_EVENT; - /** - * @deprecated - * @see dragonBones.EventObject.FRAME_EVENT + Armature.prototype._sortBones = function () { + var total = this._bones.length; + if (!total) { + return; + } + var sortHelper = this._bones.concat(); + var index = 0; + var count = 0; + this._bones.length = 0; + while (count < total) { + var bone = sortHelper[index++]; + if (index >= total) { + index = 0; + } + if (this._bones.indexOf(bone) >= 0) { + continue; + } + if (bone.parent && this._bones.indexOf(bone.parent) < 0) { + continue; + } + if (bone.ik && this._bones.indexOf(bone.ik) < 0) { + continue; + } + if (bone.ik && bone.ikChain > 0 && bone.ikChainIndex == bone.ikChain) { + this._bones.splice(this._bones.indexOf(bone.parent) + 1, 0, bone); // ik, parent, bone, children + } + else { + this._bones.push(bone); + } + count++; + } + }; + /** + * @private */ - EgretEvent.ANIMATION_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + Armature.prototype._sortSlots = function () { + }; /** - * @deprecated - * @see dragonBones.EventObject.FRAME_EVENT + * @private */ - EgretEvent.BONE_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + Armature.prototype._doAction = function (value) { + switch (value.type) { + case 0 /* Play */: + this._animation.play(value.data[0], value.data[1]); + break; + case 1 /* Stop */: + this._animation.stop(value.data[0]); + break; + case 2 /* GotoAndPlay */: + this._animation.gotoAndPlayByTime(value.data[0], value.data[1], value.data[2]); + break; + case 3 /* GotoAndStop */: + this._animation.gotoAndStopByTime(value.data[0], value.data[1]); + break; + case 4 /* FadeIn */: + this._animation.fadeIn(value.data[0], value.data[1], value.data[2]); + break; + case 5 /* FadeOut */: + // TODO fade out + break; + } + }; /** - * @deprecated - * @see dragonBones.EventObject.FRAME_EVENT + * @private */ - EgretEvent.MOVEMENT_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; - return EgretEvent; - }(egret.Event)); - dragonBones.EgretEvent = EgretEvent; - egret.registerClass(EgretEvent,'dragonBones.EgretEvent'); - /** - * @inheritDoc - */ - var EgretArmatureDisplay = (function (_super) { - __extends(EgretArmatureDisplay, _super); + Armature.prototype._addBoneToBoneList = function (value) { + if (this._bones.indexOf(value) < 0) { + this._bonesDirty = true; + this._bones[this._bones.length] = value; + this._animation._timelineStateDirty = true; + } + }; /** * @private */ - function EgretArmatureDisplay() { - _super.call(this); - if (!EgretArmatureDisplay._clock) { - EgretArmatureDisplay._clock = new dragonBones.WorldClock(); - EgretArmatureDisplay._clock.time = egret.getTimer(); - egret.startTick(EgretArmatureDisplay._clockHandler, EgretArmatureDisplay); + Armature.prototype._removeBoneFromBoneList = function (value) { + var index = this._bones.indexOf(value); + if (index >= 0) { + this._bones.splice(index, 1); + this._animation._timelineStateDirty = true; } - } - var d = __define,c=EgretArmatureDisplay,p=c.prototype; - EgretArmatureDisplay._clockHandler = function (time) { - var passedTime = time - EgretArmatureDisplay._clock.time; - EgretArmatureDisplay._clock.advanceTime(passedTime * 0.001); - EgretArmatureDisplay._clock.time = time; - return false; }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - this.advanceTimeBySelf(false); - this._armature = null; + Armature.prototype._addSlotToSlotList = function (value) { + if (this._slots.indexOf(value) < 0) { + this._slotsDirty = true; + this._slots[this._slots.length] = value; + this._animation._timelineStateDirty = true; + } }; /** - * @inheritDoc + * @private */ - p._dispatchEvent = function (eventObject) { - var event = egret.Event.create(EgretEvent, eventObject.type); - event.data = eventObject; - this.dispatchEvent(event); - egret.Event.release(event); + Armature.prototype._removeSlotFromSlotList = function (value) { + var index = this._slots.indexOf(value); + if (index >= 0) { + this._slots.splice(index, 1); + this._animation._timelineStateDirty = true; + } }; /** - * @inheritDoc + * @private */ - p.advanceTime = function (passedTime) { - this._armature.advanceTime(passedTime); + Armature.prototype._bufferAction = function (value) { + this._actions.push(value); }; /** - * @inheritDoc + * @private */ - p.hasEvent = function (type) { - return this.hasEventListener(type); + Armature.prototype._bufferEvent = function (value, type) { + value.type = type; + value.armature = this; + this._events.push(value); }; /** - * @inheritDoc + * @language zh_CN + * 释放骨架。 (会回收到内存池) + * @version DragonBones 3.0 */ - p.addEvent = function (type, listener, target) { - this.addEventListener(type, listener, target); + Armature.prototype.dispose = function () { + this._delayDispose = true; + if (!this._lockDispose) { + this.returnToPool(); + } }; /** - * @inheritDoc + * @language zh_CN + * 更新骨架和动画。 (可以使用时钟实例或显示容器来更新) + * @param passedTime 两帧之前的时间间隔。 (以秒为单位) + * @see dragonBones.IAnimateble + * @see dragonBones.WorldClock + * @see dragonBones.IArmatureDisplay + * @version DragonBones 3.0 */ - p.removeEvent = function (type, listener, target) { - this.removeEventListener(type, listener, target); + Armature.prototype.advanceTime = function (passedTime) { + var self = this; + if (!self._lockDispose) { + self._lockDispose = true; + var scaledPassedTime = passedTime * self._animation.timeScale; + // Animations. + self._animation._advanceTime(scaledPassedTime); + // Bones and slots. + if (self._bonesDirty) { + self._bonesDirty = false; + self._sortBones(); + } + if (self._slotsDirty) { + self._slotsDirty = false; + self._sortSlots(); + } + for (var i = 0, l = self._bones.length; i < l; ++i) { + self._bones[i]._update(self._cacheFrameIndex); + } + for (var i = 0, l = self._slots.length; i < l; ++i) { + var slot = self._slots[i]; + slot._update(self._cacheFrameIndex); + var childArmature = slot._childArmature; + if (childArmature) { + if (slot.inheritAnimation) { + childArmature.advanceTime(scaledPassedTime); + } + else { + childArmature.advanceTime(passedTime); + } + } + } + if (dragonBones.DragonBones.DEBUG_DRAW) { + self._display._debugDraw(); + } + // Actions and events. + if (self._events.length > 0) { + for (var i = 0, l = self._events.length; i < l; ++i) { + var event_5 = self._events[i]; + if (dragonBones.EventObject._soundEventManager && event_5.type == dragonBones.EventObject.SOUND_EVENT) { + dragonBones.EventObject._soundEventManager._dispatchEvent(event_5); + } + else { + self._display._dispatchEvent(event_5); + } + event_5.returnToPool(); + } + self._events.length = 0; + } + if (self._actions.length > 0) { + for (var i = 0, l = self._actions.length; i < l; ++i) { + var action = self._actions[i]; + if (action.slot) { + var slot = self.getSlot(action.slot.name); + if (slot) { + var childArmature = slot._childArmature; + if (childArmature) { + childArmature._doAction(action); + } + } + } + else if (action.bone) { + for (var i_1 = 0, l_1 = self._slots.length; i_1 < l_1; ++i_1) { + var childArmature = self._slots[i_1]._childArmature; + if (childArmature) { + childArmature._doAction(action); + } + } + } + else { + this._doAction(action); + } + } + self._actions.length = 0; + } + self._lockDispose = false; + } + if (self._delayDispose) { + self.returnToPool(); + } }; /** - * @inheritDoc + * @language zh_CN + * 更新骨骼和插槽的变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @param boneName 指定的骨骼名称,如果未设置,将更新所有骨骼。 + * @param updateSlotDisplay 是否更新插槽的显示对象。 + * @see dragonBones.Bone + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - p.advanceTimeBySelf = function (on) { - if (on) { - EgretArmatureDisplay._clock.add(this._armature); + Armature.prototype.invalidUpdate = function (boneName, updateSlotDisplay) { + if (boneName === void 0) { boneName = null; } + if (updateSlotDisplay === void 0) { updateSlotDisplay = false; } + if (boneName) { + var bone = this.getBone(boneName); + if (bone) { + bone.invalidUpdate(); + if (updateSlotDisplay) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + var slot = this._slots[i]; + if (slot.parent == bone) { + slot.invalidUpdate(); + } + } + } + } } else { - EgretArmatureDisplay._clock.remove(this._armature); + for (var i = 0, l = this._bones.length; i < l; ++i) { + this._bones[i].invalidUpdate(); + } + if (updateSlotDisplay) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].invalidUpdate(); + } + } } }; /** - * @inheritDoc + * @language zh_CN + * 获取指定名称的插槽。 + * @param name 插槽的名称。 + * @returns 插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - p.dispose = function () { - if (this._armature) { - this._armature.dispose(); + Armature.prototype.getSlot = function (name) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + var slot = this._slots[i]; + if (slot.name == name) { + return slot; + } } + return null; }; - d(p, "armature" - /** - * @inheritDoc - */ - ,function () { - return this._armature; - } - ); - d(p, "animation" - /** - * @inheritDoc - */ - ,function () { - return this._armature.animation; + /** + * @language zh_CN + * 通过显示对象获取插槽。 + * @param display 显示对象。 + * @returns 包含这个显示对象的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + Armature.prototype.getSlotByDisplay = function (display) { + if (display) { + for (var i = 0, l = this._slots.length; i < l; ++i) { + var slot = this._slots[i]; + if (slot.display == display) { + return slot; + } + } } - ); - EgretArmatureDisplay._clock = null; - return EgretArmatureDisplay; - }(egret.DisplayObjectContainer)); - dragonBones.EgretArmatureDisplay = EgretArmatureDisplay; - egret.registerClass(EgretArmatureDisplay,'dragonBones.EgretArmatureDisplay',["dragonBones.IArmatureDisplay","dragonBones.IEventDispatcher"]); - /** - * @deprecated - * @see dragonBones.EgretEvent - */ - var AnimationEvent = (function (_super) { - __extends(AnimationEvent, _super); - function AnimationEvent() { - _super.apply(this, arguments); - } - var d = __define,c=AnimationEvent,p=c.prototype; - return AnimationEvent; - }(EgretEvent)); - dragonBones.AnimationEvent = AnimationEvent; - egret.registerClass(AnimationEvent,'dragonBones.AnimationEvent'); - /** - * @deprecated - * @see dragonBones.EgretEvent - */ - var FrameEvent = (function (_super) { - __extends(FrameEvent, _super); - function FrameEvent() { - _super.apply(this, arguments); - } - var d = __define,c=FrameEvent,p=c.prototype; - return FrameEvent; - }(EgretEvent)); - dragonBones.FrameEvent = FrameEvent; - egret.registerClass(FrameEvent,'dragonBones.FrameEvent'); - /** - * @deprecated - * @see dragonBones.EgretEvent - */ - var SoundEvent = (function (_super) { - __extends(SoundEvent, _super); - function SoundEvent() { - _super.apply(this, arguments); - } - var d = __define,c=SoundEvent,p=c.prototype; - return SoundEvent; - }(EgretEvent)); - dragonBones.SoundEvent = SoundEvent; - egret.registerClass(SoundEvent,'dragonBones.SoundEvent'); - /** - * @deprecated - * @see dragonBones.EgretTextureAtlasData - */ - var EgretTextureAtlas = (function (_super) { - __extends(EgretTextureAtlas, _super); - function EgretTextureAtlas(texture, rawData, scale) { - if (scale === void 0) { scale = 1; } - _super.call(this); - this._onClear(); - this.texture = texture; - dragonBones.ObjectDataParser.getInstance().parseTextureAtlasData(rawData, this, scale); - } - var d = __define,c=EgretTextureAtlas,p=c.prototype; + return null; + }; /** - * @private + * @language zh_CN + * 将一个指定的插槽添加到骨架中。 + * @param value 需要添加的插槽。 + * @param parentName 需要添加到的父骨骼名称。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - EgretTextureAtlas.toString = function () { - return "[Class dragonBones.EgretTextureAtlas]"; + Armature.prototype.addSlot = function (value, parentName) { + var bone = this.getBone(parentName); + if (bone) { + value._setArmature(this); + value._setParent(bone); + } + else { + throw new Error(); + } }; - return EgretTextureAtlas; - }(dragonBones.EgretTextureAtlasData)); - dragonBones.EgretTextureAtlas = EgretTextureAtlas; - egret.registerClass(EgretTextureAtlas,'dragonBones.EgretTextureAtlas'); - /** - * @deprecated - * @see dragonBones.EgretTextureAtlasData - */ - var EgretSheetAtlas = (function (_super) { - __extends(EgretSheetAtlas, _super); - function EgretSheetAtlas() { - _super.apply(this, arguments); - } - var d = __define,c=EgretSheetAtlas,p=c.prototype; - return EgretSheetAtlas; - }(EgretTextureAtlas)); - dragonBones.EgretSheetAtlas = EgretSheetAtlas; - egret.registerClass(EgretSheetAtlas,'dragonBones.EgretSheetAtlas'); - /** - * @deprecated - * @see dragonBones.EgretFactory#soundEventManater - */ - var SoundEventManager = (function () { - function SoundEventManager() { - } - var d = __define,c=SoundEventManager,p=c.prototype; /** - * @deprecated - * @see dragonBones.EgretFactory#soundEventManater + * @language zh_CN + * 将一个指定的插槽从骨架中移除。 + * @param value 需要移除的插槽 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - SoundEventManager.getInstance = function () { - return dragonBones.Armature._soundEventManager; + Armature.prototype.removeSlot = function (value) { + if (value && value.armature == this) { + value._setParent(null); + value._setArmature(null); + } + else { + throw new Error(); + } }; - return SoundEventManager; - }()); - dragonBones.SoundEventManager = SoundEventManager; - egret.registerClass(SoundEventManager,'dragonBones.SoundEventManager'); - /** - * @deprecated - * @see dragonBones.Armature#cacheFrameRate - * @see dragonBones.Armature#enableAnimationCache() - */ - var AnimationCacheManager = (function () { - function AnimationCacheManager() { - } - var d = __define,c=AnimationCacheManager,p=c.prototype; - return AnimationCacheManager; - }()); - dragonBones.AnimationCacheManager = AnimationCacheManager; - egret.registerClass(AnimationCacheManager,'dragonBones.AnimationCacheManager'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var ColorTransform = (function () { - function ColorTransform(alphaMultiplier, redMultiplier, greenMultiplier, blueMultiplier, alphaOffset, redOffset, greenOffset, blueOffset) { - if (alphaMultiplier === void 0) { alphaMultiplier = 1; } - if (redMultiplier === void 0) { redMultiplier = 1; } - if (greenMultiplier === void 0) { greenMultiplier = 1; } - if (blueMultiplier === void 0) { blueMultiplier = 1; } - if (alphaOffset === void 0) { alphaOffset = 0; } - if (redOffset === void 0) { redOffset = 0; } - if (greenOffset === void 0) { greenOffset = 0; } - if (blueOffset === void 0) { blueOffset = 0; } - this.alphaMultiplier = alphaMultiplier; - this.redMultiplier = redMultiplier; - this.greenMultiplier = greenMultiplier; - this.blueMultiplier = blueMultiplier; - this.alphaOffset = alphaOffset; - this.redOffset = redOffset; - this.greenOffset = greenOffset; - this.blueOffset = blueOffset; - } - var d = __define,c=ColorTransform,p=c.prototype; - p.copyFrom = function (value) { - var self = this; - self.alphaMultiplier = value.alphaMultiplier; - self.redMultiplier = value.redMultiplier; - self.greenMultiplier = value.greenMultiplier; - self.blueMultiplier = value.blueMultiplier; - self.alphaOffset = value.alphaOffset; - self.redOffset = value.redOffset; - self.redOffset = value.redOffset; - self.greenOffset = value.blueOffset; - }; - p.identity = function () { - var self = this; - self.alphaMultiplier = self.redMultiplier = self.greenMultiplier = self.blueMultiplier = 1; - self.alphaOffset = self.redOffset = self.greenOffset = self.blueOffset = 0; + /** + * @language zh_CN + * 获取指定名称的骨骼。 + * @param name 骨骼的名称。 + * @returns 骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + Armature.prototype.getBone = function (name) { + for (var i = 0, l = this._bones.length; i < l; ++i) { + var bone = this._bones[i]; + if (bone.name == name) { + return bone; + } + } + return null; }; - return ColorTransform; - }()); - dragonBones.ColorTransform = ColorTransform; - egret.registerClass(ColorTransform,'dragonBones.ColorTransform'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * 生成骨架的基础工厂。 - * @see dragonBones.DragonBonesData - * @see dragonBones.TextureAtlasData - * @see dragonBones.ArmatureData - * @see dragonBones.Armature - * @version DragonBones 3.0 - */ - var BaseFactory = (function () { /** - * @private + * @language zh_CN + * 通过显示对象获取骨骼。 + * @param display 显示对象。 + * @returns 包含这个显示对象的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - function BaseFactory() { - /** - * @language zh_CN - * 是否开启共享搜索。 [true: 开启, false: 不开启] - * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) - * @see dragonBones.DragonBonesData#autoSearch - * @see dragonBones.TextureAtlasData#autoSearch - * @version DragonBones 4.5 - */ - this.autoSearch = false; - /** - * @private - */ - this._objectDataParser = new dragonBones.ObjectDataParser(); - /** - * @private - */ - this._dragonBonesDataMap = {}; - /** - * @private - */ - this._textureAtlasDataMap = {}; - } - var d = __define,c=BaseFactory,p=c.prototype; + Armature.prototype.getBoneByDisplay = function (display) { + var slot = this.getSlotByDisplay(display); + return slot ? slot.parent : null; + }; /** - * @private + * @language zh_CN + * 将一个指定的骨骼添加到骨架中。 + * @param value 需要添加的骨骼。 + * @param parentName 需要添加到父骨骼的名称,如果未设置,则添加到骨架根部。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - p._getTextureData = function (dragonBonesName, textureName) { - var textureAtlasDataList = this._textureAtlasDataMap[dragonBonesName]; - if (textureAtlasDataList) { - for (var i = 0, l = textureAtlasDataList.length; i < l; ++i) { - var textureData = textureAtlasDataList[i].getTextureData(textureName); - if (textureData) { - return textureData; - } - } + Armature.prototype.addBone = function (value, parentName) { + if (parentName === void 0) { parentName = null; } + if (value) { + value._setArmature(this); + value._setParent(parentName ? this.getBone(parentName) : null); } - if (this.autoSearch) { - for (var i in this._textureAtlasDataMap) { - textureAtlasDataList = this._textureAtlasDataMap[i]; - for (var j = 0, lJ = textureAtlasDataList.length; j < lJ; ++j) { - var textureAtlasData = textureAtlasDataList[j]; - if (textureAtlasData.autoSearch) { - var textureData = textureAtlasData.getTextureData(textureName); - if (textureData) { - return textureData; - } - } - } - } + else { + throw new Error(); } - return null; }; /** - * @private + * @language zh_CN + * 将一个指定的骨骼从骨架中移除。 + * @param value 需要移除的骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - p._fillBuildArmaturePackage = function (dragonBonesName, armatureName, skinName, dataPackage) { - if (dragonBonesName) { - var dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; - if (dragonBonesData) { - var armatureData = dragonBonesData.getArmature(armatureName); - if (armatureData) { - dataPackage.dataName = dragonBonesName; - dataPackage.data = dragonBonesData; - dataPackage.armature = armatureData; - dataPackage.skin = armatureData.getSkin(skinName); - if (!dataPackage.skin) { - dataPackage.skin = armatureData.defaultSkin; - } - return true; - } - } + Armature.prototype.removeBone = function (value) { + if (value && value.armature == this) { + value._setParent(null); + value._setArmature(null); } - if (!dragonBonesName || this.autoSearch) { - for (var eachDragonBonesName in this._dragonBonesDataMap) { - var dragonBonesData = this._dragonBonesDataMap[eachDragonBonesName]; - if (!dragonBonesName || dragonBonesData.autoSearch) { - var armatureData = dragonBonesData.getArmature(armatureName); - if (armatureData) { - dataPackage.dataName = eachDragonBonesName; - dataPackage.data = dragonBonesData; - dataPackage.armature = armatureData; - dataPackage.skin = armatureData.getSkin(skinName); - if (!dataPackage.skin) { - dataPackage.skin = armatureData.defaultSkin; - } - return true; - } - } - } + else { + throw new Error(); } - return false; }; /** - * @private + * @language zh_CN + * 替换骨架的主贴图,根据渲染引擎的不同,提供不同的贴图数据。 + * @param texture 用来替换的贴图,根据渲染平台的不同,类型会有所不同,一般是 Texture 类型。 + * @version DragonBones 4.5 */ - p._buildBones = function (dataPackage, armature) { - var bones = dataPackage.armature.sortedBones; - for (var i = 0, l = bones.length; i < l; ++i) { - var boneData = bones[i]; - var bone = dragonBones.BaseObject.borrowObject(dragonBones.Bone); - bone.name = boneData.name; - bone.inheritTranslation = boneData.inheritTranslation; - bone.inheritRotation = boneData.inheritRotation; - bone.inheritScale = boneData.inheritScale; - bone.length = boneData.length; - bone.origin.copyFrom(boneData.transform); - if (boneData.parent) { - armature.addBone(bone, boneData.parent.name); - } - else { - armature.addBone(bone); - } - if (boneData.ik) { - bone.ikBendPositive = boneData.bendPositive; - bone.ikWeight = boneData.weight; - bone._setIK(armature.getBone(boneData.ik.name), boneData.chain, boneData.chainIndex); - } + Armature.prototype.replaceTexture = function (texture) { + this._replacedTexture = texture; + for (var i = 0, l = this._slots.length; i < l; ++i) { + this._slots[i].invalidUpdate(); } }; /** - * @private + * @language zh_CN + * 获取所有骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 */ - p._buildSlots = function (dataPackage, armature) { - var currentSkin = dataPackage.skin; - var defaultSkin = dataPackage.armature.defaultSkin; - var slotDisplayDataSetMap = {}; - for (var i in defaultSkin.slots) { - var slotDisplayDataSet = defaultSkin.slots[i]; - slotDisplayDataSetMap[slotDisplayDataSet.slot.name] = slotDisplayDataSet; - } - if (currentSkin != defaultSkin) { - for (var i in currentSkin.slots) { - var slotDisplayDataSet = currentSkin.slots[i]; - slotDisplayDataSetMap[slotDisplayDataSet.slot.name] = slotDisplayDataSet; - } - } - var slots = dataPackage.armature.sortedSlots; - for (var i = 0, l = slots.length; i < l; ++i) { - var slotData = slots[i]; - var slotDisplayDataSet = slotDisplayDataSetMap[slotData.name]; - if (!slotDisplayDataSet) { - continue; - } - var slot = this._generateSlot(dataPackage, slotDisplayDataSet); - slot._displayDataSet = slotDisplayDataSet; - slot._setDisplayIndex(slotData.displayIndex); - slot._setBlendMode(slotData.blendMode); - slot._setColor(slotData.color); - slot._replacedDisplayDataSet.length = slot._displayDataSet.displays.length; - armature.addSlot(slot, slotData.parent.name); - } + Armature.prototype.getBones = function () { + return this._bones; }; /** - * @private + * @language zh_CN + * 获取所有插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - p._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { - if (displayIndex < 0) { - displayIndex = slot.displayIndex; - } - if (displayIndex >= 0) { - var displayList = slot.displayList; // Copy. - if (displayList.length <= displayIndex) { - displayList.length = displayIndex + 1; - } - if (!displayData.textureData) { - displayData.textureData = this._getTextureData(dataPackage.dataName, displayData.name); - } - if (displayData.type == 1 /* Armature */) { - var childArmature = this.buildArmature(displayData.name, dataPackage.dataName); - displayList[displayIndex] = childArmature; - } - else { - if (slot._replacedDisplayDataSet.length <= displayIndex) { - slot._replacedDisplayDataSet.length = displayIndex + 1; - } - slot._replacedDisplayDataSet[displayIndex] = displayData; - if (displayData.meshData) { - displayList[displayIndex] = slot.MeshDisplay; - } - else { - displayList[displayIndex] = slot.rawDisplay; + Armature.prototype.getSlots = function () { + return this._slots; + }; + Object.defineProperty(Armature.prototype, "name", { + /** + * @language zh_CN + * 骨架名称。 + * @see dragonBones.ArmatureData#name + * @version DragonBones 3.0 + */ + get: function () { + return this._armatureData ? this._armatureData.name : null; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "armatureData", { + /** + * @language zh_CN + * 获取骨架数据。 + * @see dragonBones.ArmatureData + * @version DragonBones 4.5 + */ + get: function () { + return this._armatureData; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "animation", { + /** + * @language zh_CN + * 获得动画控制器。 + * @see dragonBones.Animation + * @version DragonBones 3.0 + */ + get: function () { + return this._animation; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "display", { + /** + * @language zh_CN + * 获取显示容器,插槽的显示对象都会以此显示容器为父级,根据渲染平台的不同,类型会不同,通常是 DisplayObjectContainer 类型。 + * @version DragonBones 3.0 + */ + get: function () { + return this._display; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "parent", { + /** + * @language zh_CN + * 获取父插槽。 (当此骨架是某个骨架的子骨架时,可以通过此属性向上查找从属关系) + * @see dragonBones.Slot + * @version DragonBones 4.5 + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Armature.prototype, "cacheFrameRate", { + /** + * @language zh_CN + * 动画缓存的帧率,当设置一个大于 0 的帧率时,将会开启动画缓存。 + * 通过将动画数据缓存在内存中来提高运行性能,会有一定的内存开销。 + * 帧率不宜设置的过高,通常跟动画的帧率相当且低于程序运行的帧率。 + * 开启动画缓存后,某些功能将会失效,比如 Bone 和 Slot 的 offset 属性等。 + * @see dragonBones.DragonBonesData#frameRate + * @see dragonBones.ArmatureData#frameRate + * @version DragonBones 4.5 + */ + get: function () { + return this._armatureData.cacheFrameRate; + }, + set: function (value) { + if (this._armatureData.cacheFrameRate != value) { + this._armatureData.cacheFrames(value); + // Set child armature frameRate. + for (var i = 0, l = this._slots.length; i < l; ++i) { + var slot = this._slots[i]; + var childArmature = slot.childArmature; + if (childArmature) { + childArmature.cacheFrameRate = value; + } } } - slot.displayList = displayList; - slot.invalidUpdate(); - } - }; + }, + enumerable: true, + configurable: true + }); /** * @language zh_CN - * 解析并添加龙骨数据。 - * @param rawData 需要解析的原始数据。 (JSON) - * @param dragonBonesName 为数据提供一个名称,以便可以通过这个名称来获取数据,状态,则使用数据中的名称。 - * @returns DragonBonesData - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData + * 开启动画缓存。 + * @param frameRate 动画缓存的帧率 + * @see #cacheFrameRate * @version DragonBones 4.5 */ - p.parseDragonBonesData = function (rawData, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - var dragonBonesData = this._objectDataParser.parseDragonBonesData(rawData); - this.addDragonBonesData(dragonBonesData, dragonBonesName); - return dragonBonesData; + Armature.prototype.enableAnimationCache = function (frameRate) { + this.cacheFrameRate = frameRate; }; /** * @language zh_CN - * 解析并添加贴图集数据。 - * @param rawData 需要解析的原始数据。 (JSON) - * @param textureAtlas 贴图集数据。 (JSON) - * @param name 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 - * @param scale 为贴图集设置一个缩放值。 - * @returns 贴图集数据 - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.TextureAtlasData - * @version DragonBones 4.5 + * 是否包含指定类型的事件。 + * @param type 事件类型。 + * @returns [true: 包含, false: 不包含] + * @version DragonBones 3.0 */ - p.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { - if (name === void 0) { name = null; } - if (scale === void 0) { scale = 0; } - var textureAtlasData = this._generateTextureAtlasData(null, null); - this._objectDataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); - this._generateTextureAtlasData(textureAtlasData, textureAtlas); - this.addTextureAtlasData(textureAtlasData, name); - return textureAtlasData; + Armature.prototype.hasEventListener = function (type) { + this._display.hasEvent(type); }; /** * @language zh_CN - * 获取指定名称的龙骨数据。 - * @param name 数据名称。 - * @returns DragonBonesData - * @see #parseDragonBonesData() - * @see #addDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData + * 添加事件。 + * @param type 事件类型。 + * @param listener 事件回调。 * @version DragonBones 3.0 */ - p.getDragonBonesData = function (name) { - return this._dragonBonesDataMap[name]; + Armature.prototype.addEventListener = function (type, listener, target) { + this._display.addEvent(type, listener, target); }; /** * @language zh_CN - * 添加龙骨数据。 - * @param data 龙骨数据。 - * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #removeDragonBonesData() - * @see dragonBones.DragonBonesData + * 移除事件。 + * @param type 事件类型。 + * @param listener 事件回调。 * @version DragonBones 3.0 */ - p.addDragonBonesData = function (data, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - if (data) { - dragonBonesName = dragonBonesName || data.name; - if (dragonBonesName) { - if (!this._dragonBonesDataMap[dragonBonesName]) { - this._dragonBonesDataMap[dragonBonesName] = data; - } - else { - console.warn("Same name data."); - } - } - else { - console.warn("Unnamed data."); - } - } - else { - throw new Error(); - } + Armature.prototype.removeEventListener = function (type, listener, target) { + this._display.removeEvent(type, listener, target); }; /** - * @language zh_CN - * 移除龙骨数据。 - * @param dragonBonesName 数据名称。 - * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] - * @see #parseDragonBonesData() - * @see #getDragonBonesData() - * @see #addDragonBonesData() - * @see dragonBones.DragonBonesData - * @version DragonBones 3.0 + * @deprecated + * @see #display */ - p.removeDragonBonesData = function (dragonBonesName, disposeData) { - if (disposeData === void 0) { disposeData = true; } - var dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; - if (dragonBonesData) { - if (disposeData) { - if (dragonBones.DragonBones.DEBUG) { - for (var i = 0, l = dragonBones.DragonBones._armatures.length; i < l; ++i) { - var armature = dragonBones.DragonBones._armatures[i]; - if (armature.armatureData.parent == dragonBonesData) { - throw new Error("ArmatureData: " + armature.armatureData.name + " DragonBonesData: " + dragonBonesName); - } - } - } - dragonBonesData.returnToPool(); - } - delete this._dragonBonesDataMap[dragonBonesName]; - } + Armature.prototype.getDisplay = function () { + return this._display; }; + return Armature; + }(dragonBones.BaseObject)); + dragonBones.Armature = Armature; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 基础变换对象。 + * @version DragonBones 4.5 + */ + var TransformObject = (function (_super) { + __extends(TransformObject, _super); /** - * @language zh_CN - * 获取指定名称的贴图集数据列表。 - * @param dragonBonesName 数据名称。 - * @returns 贴图集数据列表。 - * @see #parseTextureAtlasData() - * @see #addTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.textures.TextureAtlasData - * @version DragonBones 3.0 + * @private */ - p.getTextureAtlasData = function (dragonBonesName) { - return this._textureAtlasDataMap[dragonBonesName]; + function TransformObject() { + _super.call(this); + /** + * @language zh_CN + * 相对于骨架坐标系的变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + this.global = new dragonBones.Transform(); + /** + * @language zh_CN + * 相对于骨架或父骨骼坐标系的绑定变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + this.origin = new dragonBones.Transform(); + /** + * @language zh_CN + * 相对于骨架或父骨骼坐标系的偏移变换。 + * @see dragonBones.Transform + * @version DragonBones 3.0 + */ + this.offset = new dragonBones.Transform(); + /** + * @private + */ + this._globalTransformMatrix = new dragonBones.Matrix(); + } + /** + * @inheritDoc + */ + TransformObject.prototype._onClear = function () { + this.userData = null; + this.name = null; + this.globalTransformMatrix = this._globalTransformMatrix; + this.global.identity(); + this.origin.identity(); + this.offset.identity(); + this._armature = null; + this._parent = null; + this._globalTransformMatrix.identity(); }; /** - * @language zh_CN - * 添加贴图集数据。 - * @param data 贴图集数据。 - * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #removeTextureAtlasData() - * @see dragonBones.textures.TextureAtlasData - * @version DragonBones 3.0 + * @private */ - p.addTextureAtlasData = function (data, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - if (data) { - dragonBonesName = dragonBonesName || data.name; - if (dragonBonesName) { - var textureAtlasList = this._textureAtlasDataMap[dragonBonesName] = this._textureAtlasDataMap[dragonBonesName] || []; - if (textureAtlasList.indexOf(data) < 0) { - textureAtlasList.push(data); - } + TransformObject.prototype._setArmature = function (value) { + this._armature = value; + }; + /** + * @private + */ + TransformObject.prototype._setParent = function (value) { + this._parent = value; + }; + Object.defineProperty(TransformObject.prototype, "armature", { + /** + * @language zh_CN + * 所属的骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(TransformObject.prototype, "parent", { + /** + * @language zh_CN + * 所属的父骨骼。 + * @see dragonBones.Bone + * @version DragonBones 3.0 + */ + get: function () { + return this._parent; + }, + enumerable: true, + configurable: true + }); + return TransformObject; + }(dragonBones.BaseObject)); + dragonBones.TransformObject = TransformObject; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 骨骼,一个骨架中可以包含多个骨骼,骨骼以树状结构组成骨架。 + * 骨骼在骨骼动画体系中是最重要的逻辑单元之一,负责动画中的平移旋转缩放的实现。 + * @see dragonBones.BoneData + * @see dragonBones.Armature + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + var Bone = (function (_super) { + __extends(Bone, _super); + /** + * @private + */ + function Bone() { + _super.call(this); + /** + * @private + */ + this._animationPose = new dragonBones.Transform(); + /** + * @private + */ + this._bones = []; + /** + * @private + */ + this._slots = []; + } + /** + * @private + */ + Bone.toString = function () { + return "[class dragonBones.Bone]"; + }; + /** + * @inheritDoc + */ + Bone.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.inheritTranslation = false; + this.inheritRotation = false; + this.inheritScale = false; + this.ikBendPositive = false; + this.ikWeight = 0; + this.length = 0; + this._transformDirty = 2 /* All */; // Update + this._blendIndex = 0; + this._cacheFrames = null; + this._animationPose.identity(); + this._visible = true; + this._ikChain = 0; + this._ikChainIndex = 0; + this._ik = null; + if (this._bones.length) { + this._bones.length = 0; + } + if (this._slots.length) { + this._slots.length = 0; + } + }; + /** + * @private + */ + Bone.prototype._updateGlobalTransformMatrix = function () { + if (this._parent) { + var parentRotation = this._parent.global.skewY; // Only inherit skew y. + var parentMatrix = this._parent.globalTransformMatrix; + if (this.inheritScale) { + if (!this.inheritRotation) { + this.global.skewX -= parentRotation; + this.global.skewY -= parentRotation; + } + this.global.toMatrix(this.globalTransformMatrix); + this.globalTransformMatrix.concat(parentMatrix); + if (!this.inheritTranslation) { + this.globalTransformMatrix.tx = this.global.x; + this.globalTransformMatrix.ty = this.global.y; + } + this.global.fromMatrix(this.globalTransformMatrix); } else { - console.warn("Unnamed data."); + if (this.inheritTranslation) { + var x = this.global.x; + var y = this.global.y; + this.global.x = parentMatrix.a * x + parentMatrix.c * y + parentMatrix.tx; + this.global.y = parentMatrix.d * y + parentMatrix.b * x + parentMatrix.ty; + } + if (this.inheritRotation) { + this.global.skewX += parentRotation; + this.global.skewY += parentRotation; + } + this.global.toMatrix(this.globalTransformMatrix); } } else { - throw new Error(); + this.global.toMatrix(this.globalTransformMatrix); } }; /** - * @language zh_CN - * 移除贴图集数据。 - * @param dragonBonesName 数据名称。 - * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] - * @see #parseTextureAtlasData() - * @see #getTextureAtlasData() - * @see #addTextureAtlasData() - * @see dragonBones.textures.TextureAtlasData - * @version DragonBones 3.0 + * @private */ - p.removeTextureAtlasData = function (dragonBonesName, disposeData) { - if (disposeData === void 0) { disposeData = true; } - var textureAtlasDataList = this._textureAtlasDataMap[dragonBonesName]; - if (textureAtlasDataList) { - if (disposeData) { - for (var i = 0, l = textureAtlasDataList.length; i < l; ++i) { - textureAtlasDataList[i].returnToPool(); - } + Bone.prototype._computeIKA = function () { + var ikGlobal = this._ik.global; + var x = this.globalTransformMatrix.a * this.length; + var y = this.globalTransformMatrix.b * this.length; + var ikRadian = (Math.atan2(ikGlobal.y - this.global.y, ikGlobal.x - this.global.x) + + this.offset.skewY - + this.global.skewY * 2 + + Math.atan2(y, x)) * this.ikWeight; // Support offset. + this.global.skewX += ikRadian; + this.global.skewY += ikRadian; + this.global.toMatrix(this.globalTransformMatrix); + }; + /** + * @private + */ + Bone.prototype._computeIKB = function () { + var parentGlobal = this._parent.global; + var ikGlobal = this._ik.global; + var x = this.globalTransformMatrix.a * this.length; + var y = this.globalTransformMatrix.b * this.length; + var lLL = x * x + y * y; + var lL = Math.sqrt(lLL); + var dX = this.global.x - parentGlobal.x; + var dY = this.global.y - parentGlobal.y; + var lPP = dX * dX + dY * dY; + var lP = Math.sqrt(lPP); + dX = ikGlobal.x - parentGlobal.x; + dY = ikGlobal.y - parentGlobal.y; + var lTT = dX * dX + dY * dY; + var lT = Math.sqrt(lTT); + var ikRadianA = 0; + if (lL + lP <= lT || lT + lL <= lP || lT + lP <= lL) { + ikRadianA = Math.atan2(ikGlobal.y - parentGlobal.y, ikGlobal.x - parentGlobal.x) + this._parent.offset.skewY; // Support offset. + if (lL + lP <= lT) { } - delete this._textureAtlasDataMap[dragonBonesName]; + else if (lP < lL) { + ikRadianA += Math.PI; + } + } + else { + var h = (lPP - lLL + lTT) / (2 * lTT); + var r = Math.sqrt(lPP - h * h * lTT) / lT; + var hX = parentGlobal.x + (dX * h); + var hY = parentGlobal.y + (dY * h); + var rX = -dY * r; + var rY = dX * r; + if (this.ikBendPositive) { + this.global.x = hX - rX; + this.global.y = hY - rY; + } + else { + this.global.x = hX + rX; + this.global.y = hY + rY; + } + ikRadianA = Math.atan2(this.global.y - parentGlobal.y, this.global.x - parentGlobal.x) + this._parent.offset.skewY; // Support offset. } + ikRadianA = (ikRadianA - parentGlobal.skewY) * this.ikWeight; + parentGlobal.skewX += ikRadianA; + parentGlobal.skewY += ikRadianA; + parentGlobal.toMatrix(this._parent.globalTransformMatrix); + this._parent._transformDirty = 1 /* Self */; + this.global.x = parentGlobal.x + Math.cos(parentGlobal.skewY) * lP; + this.global.y = parentGlobal.y + Math.sin(parentGlobal.skewY) * lP; + var ikRadianB = (Math.atan2(ikGlobal.y - this.global.y, ikGlobal.x - this.global.x) + this.offset.skewY - + this.global.skewY * 2 + Math.atan2(y, x)) * this.ikWeight; // Support offset. + this.global.skewX += ikRadianB; + this.global.skewY += ikRadianB; + this.global.toMatrix(this.globalTransformMatrix); }; /** - * @language zh_CN - * 清除所有的数据。 - * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] - * @version DragonBones 4.5 + * @inheritDoc */ - p.clear = function (disposeData) { - if (disposeData === void 0) { disposeData = true; } - var self = this; - for (var i in self._dragonBonesDataMap) { - if (disposeData) { - self._dragonBonesDataMap[i].returnToPool(); + Bone.prototype._setArmature = function (value) { + if (this._armature == value) { + return; + } + this._ik = null; + var oldSlots = null; + var oldBones = null; + if (this._armature) { + oldSlots = this.getSlots(); + oldBones = this.getBones(); + this._armature._removeBoneFromBoneList(this); + } + this._armature = value; + if (this._armature) { + this._armature._addBoneToBoneList(this); + } + if (oldSlots) { + for (var i = 0, l = oldSlots.length; i < l; ++i) { + var slot = oldSlots[i]; + if (slot.parent == this) { + slot._setArmature(this._armature); + } } - delete self._dragonBonesDataMap[i]; } - for (var i in self._textureAtlasDataMap) { - if (disposeData) { - var textureAtlasDataList = self._textureAtlasDataMap[i]; - for (var i_2 = 0, l = textureAtlasDataList.length; i_2 < l; ++i_2) { - textureAtlasDataList[i_2].returnToPool(); + if (oldBones) { + for (var i = 0, l = oldBones.length; i < l; ++i) { + var bone = oldBones[i]; + if (bone.parent == this) { + bone._setArmature(this._armature); } } - delete self._textureAtlasDataMap[i]; } }; /** - * @language zh_CN - * 创建一个指定名称的骨架。 - * @param armatureName 骨架数据名称。 - * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 - * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 - * @returns 骨架 - * @see dragonBones.Armature - * @version DragonBones 3.0 + * @private */ - p.buildArmature = function (armatureName, dragonBonesName, skinName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - if (skinName === void 0) { skinName = null; } - var dataPackage = {}; - if (this._fillBuildArmaturePackage(dragonBonesName, armatureName, skinName, dataPackage)) { - var armature = this._generateArmature(dataPackage); - this._buildBones(dataPackage, armature); - this._buildSlots(dataPackage, armature); - if (armature.armatureData.actions.length > 0) { - armature._action = armature.armatureData.actions[armature.armatureData.actions.length - 1]; + Bone.prototype._setIK = function (value, chain, chainIndex) { + if (value) { + if (chain == chainIndex) { + var chainEnd = this._parent; + if (chain && chainEnd) { + chain = 1; + } + else { + chain = 0; + chainIndex = 0; + chainEnd = this; + } + if (chainEnd == value || chainEnd.contains(value)) { + value = null; + chain = 0; + chainIndex = 0; + } + else { + var ancestor = value; + while (ancestor.ik && ancestor.ikChain) { + if (chainEnd.contains(ancestor.ik)) { + value = null; + chain = 0; + chainIndex = 0; + break; + } + ancestor = ancestor.parent; + } + } } - armature.advanceTime(0); // Update armature pose. - return armature; } - return null; + else { + chain = 0; + chainIndex = 0; + } + this._ik = value; + this._ikChain = chain; + this._ikChainIndex = chainIndex; + if (this._armature) { + this._armature._bonesDirty = true; + } }; /** - * @language zh_CN - * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) - * @param toArmature 指定的骨架。 - * @param fromArmatreName 其他骨架的名称。 - * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 - * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 - * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除] - * @returns 是否替换成功。 [true: 成功, false: 不成功] - * @see dragonBones.Armature - * @version DragonBones 4.5 + * @private */ - p.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, ifRemoveOriginalAnimationList) { - if (fromSkinName === void 0) { fromSkinName = null; } - if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; } - if (ifRemoveOriginalAnimationList === void 0) { ifRemoveOriginalAnimationList = true; } - var dataPackage = {}; - if (this._fillBuildArmaturePackage(fromDragonBonesDataName, fromArmatreName, fromSkinName, dataPackage)) { - var fromArmatureData = dataPackage.armature; - if (ifRemoveOriginalAnimationList) { - toArmature.animation.animations = fromArmatureData.animations; + Bone.prototype._update = function (cacheFrameIndex) { + var self = this; + self._blendIndex = 0; + if (cacheFrameIndex >= 0) { + var cacheFrame = self._cacheFrames[cacheFrameIndex]; + if (self.globalTransformMatrix == cacheFrame) { + self._transformDirty = 0 /* None */; + } + else if (cacheFrame) { + self._transformDirty = 2 /* All */; // For update children and ik children. + self.globalTransformMatrix = cacheFrame; + } + else if (self._transformDirty == 2 /* All */ || + (self._parent && self._parent._transformDirty != 0 /* None */) || + (self._ik && self.ikWeight > 0 && self._ik._transformDirty != 0 /* None */)) { + self._transformDirty = 2 /* All */; // For update children and ik children. + self.globalTransformMatrix = self._globalTransformMatrix; + } + else if (self.globalTransformMatrix != self._globalTransformMatrix) { + self._transformDirty = 0 /* None */; + self._cacheFrames[cacheFrameIndex] = self.globalTransformMatrix; } else { - var animations = {}; - for (var animationName in toArmature.animation.animations) { - animations[animationName] = toArmature.animation.animations[animationName]; - } - for (var animationName in fromArmatureData.animations) { - animations[animationName] = fromArmatureData.animations[animationName]; - } - toArmature.animation.animations = animations; + self._transformDirty = 2 /* All */; + self.globalTransformMatrix = self._globalTransformMatrix; } - if (dataPackage.skin) { - var slots = toArmature.getSlots(); - for (var i = 0, l = slots.length; i < l; ++i) { - var toSlot = slots[i]; - var toSlotDisplayList = toSlot.displayList; - for (var i_3 = 0, l_2 = toSlotDisplayList.length; i_3 < l_2; ++i_3) { - var toDisplayObject = toSlotDisplayList[i_3]; - if (toDisplayObject instanceof dragonBones.Armature) { - var displays = dataPackage.skin.getSlot(toSlot.name).displays; - if (i_3 < displays.length) { - var fromDisplayData = displays[i_3]; - if (fromDisplayData.type == 1 /* Armature */) { - this.copyAnimationsToArmature(toDisplayObject, fromDisplayData.name, fromSkinName, fromDragonBonesDataName, ifRemoveOriginalAnimationList); - } - } + } + else if (self._transformDirty == 2 /* All */ || + (self._parent && self._parent._transformDirty != 0 /* None */) || + (self._ik && self.ikWeight > 0 && self._ik._transformDirty != 0 /* None */)) { + self._transformDirty = 2 /* All */; // For update children and ik children. + self.globalTransformMatrix = self._globalTransformMatrix; + } + if (self._transformDirty != 0 /* None */) { + if (self._transformDirty == 2 /* All */) { + self._transformDirty = 1 /* Self */; + if (self.globalTransformMatrix == self._globalTransformMatrix) { + /*self.global.copyFrom(self.origin).add(self.offset).add(self._animationPose);*/ + self.global.x = self.origin.x + self.offset.x + self._animationPose.x; + self.global.y = self.origin.y + self.offset.y + self._animationPose.y; + self.global.skewX = self.origin.skewX + self.offset.skewX + self._animationPose.skewX; + self.global.skewY = self.origin.skewY + self.offset.skewY + self._animationPose.skewY; + self.global.scaleX = self.origin.scaleX * self.offset.scaleX * self._animationPose.scaleX; + self.global.scaleY = self.origin.scaleY * self.offset.scaleY * self._animationPose.scaleY; + self._updateGlobalTransformMatrix(); + if (self._ik && self._ikChainIndex == self._ikChain && self.ikWeight > 0) { + if (self.inheritTranslation && self._ikChain > 0 && self._parent) { + self._computeIKB(); + } + else { + self._computeIKA(); } } + if (cacheFrameIndex >= 0) { + self.globalTransformMatrix = dragonBones.BoneTimelineData.cacheFrame(self._cacheFrames, cacheFrameIndex, self._globalTransformMatrix); + } } - return true; + } + else { + self._transformDirty = 0 /* None */; } } - return false; }; /** * @language zh_CN - * 将指定插槽的显示对象替换为指定资源创造出的显示对象。 - * @param dragonBonesName 指定的龙骨数据名称。 - * @param armatureName 指定的骨架名称。 - * @param slotName 指定的插槽名称。 - * @param displayName 指定的显示对象名称。 - * @param slot 指定的插槽实例。 - * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 - * @version DragonBones 4.5 + * 下一帧更新变换。 (当骨骼没有动画状态或动画状态播放完成时,骨骼将不在更新) + * @version DragonBones 3.0 */ - p.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { - if (displayIndex === void 0) { displayIndex = -1; } - var dataPackage = {}; - if (this._fillBuildArmaturePackage(dragonBonesName, armatureName, null, dataPackage)) { - var slotDisplayDataSet = dataPackage.skin.getSlot(slotName); - if (slotDisplayDataSet) { - for (var i = 0, l = slotDisplayDataSet.displays.length; i < l; ++i) { - var displayData = slotDisplayDataSet.displays[i]; - if (displayData.name == displayName) { - this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex); - break; - } - } - } - } + Bone.prototype.invalidUpdate = function () { + this._transformDirty = 2 /* All */; }; /** * @language zh_CN - * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。 - * @param dragonBonesName 指定的 DragonBonesData 名称。 - * @param armatureName 指定的骨架名称。 - * @param slotName 指定的插槽名称。 - * @param slot 指定的插槽实例。 - * @version DragonBones 4.5 + * 是否包含某个指定的骨骼或插槽。 + * @returns [true: 包含,false: 不包含] + * @see dragonBones.TransformObject + * @version DragonBones 3.0 */ - p.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { - var dataPackage = {}; - if (this._fillBuildArmaturePackage(dragonBonesName, armatureName, null, dataPackage)) { - var slotDisplayDataSet = dataPackage.skin.getSlot(slotName); - if (slotDisplayDataSet) { - var displayIndex = 0; - for (var i = 0, l = slotDisplayDataSet.displays.length; i < l; ++i) { - var displayData = slotDisplayDataSet.displays[i]; - this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); - } + Bone.prototype.contains = function (child) { + if (child) { + if (child == this) { + return false; + } + var ancestor = child; + while (ancestor != this && ancestor) { + ancestor = ancestor.parent; } + return ancestor == this; } + return false; }; - /** - * @deprecated - * @see #clear() - */ - p.dispose = function () { - this.clear(); - }; - return BaseFactory; - }()); - dragonBones.BaseFactory = BaseFactory; - egret.registerClass(BaseFactory,'dragonBones.BaseFactory'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * Egret 工厂。 - * @version DragonBones 3.0 - */ - var EgretFactory = (function (_super) { - __extends(EgretFactory, _super); /** * @language zh_CN - * 创建一个工厂。 + * 所有的子骨骼。 * @version DragonBones 3.0 */ - function EgretFactory() { - _super.call(this); - if (!dragonBones.Armature._soundEventManager) { - dragonBones.Armature._soundEventManager = new dragonBones.EgretArmatureDisplay(); - } - } - var d = __define,c=EgretFactory,p=c.prototype; - /** - * @private - */ - p._generateTextureAtlasData = function (textureAtlasData, textureAtlas) { - if (textureAtlasData) { - textureAtlasData.texture = textureAtlas; - } - else { - textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); + Bone.prototype.getBones = function () { + this._bones.length = 0; + var bones = this._armature.getBones(); + for (var i = 0, l = bones.length; i < l; ++i) { + var bone = bones[i]; + if (bone.parent == this) { + this._bones.push(bone); + } } - return textureAtlasData; + return this._bones; }; /** - * @private + * @language zh_CN + * 所有的插槽。 + * @see dragonBones.Slot + * @version DragonBones 3.0 */ - p._generateArmature = function (dataPackage) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); - var armatureDisplayContainer = new dragonBones.EgretArmatureDisplay(); - armature._armatureData = dataPackage.armature; - armature._skinData = dataPackage.skin; - armature._animation = dragonBones.BaseObject.borrowObject(dragonBones.Animation); - armature._display = armatureDisplayContainer; - armatureDisplayContainer._armature = armature; - armature._animation._armature = armature; - armature.animation.animations = dataPackage.armature.animations; - return armature; + Bone.prototype.getSlots = function () { + this._slots.length = 0; + var slots = this._armature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var slot = slots[i]; + if (slot.parent == this) { + this._slots.push(slot); + } + } + return this._slots; }; - /** - * @private - */ - p._generateSlot = function (dataPackage, slotDisplayDataSet) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.EgretSlot); - var slotData = slotDisplayDataSet.slot; - var displayList = []; - slot.name = slotData.name; - slot._rawDisplay = new egret.Bitmap(); - for (var i = 0, l = slotDisplayDataSet.displays.length; i < l; ++i) { - var displayData = slotDisplayDataSet.displays[i]; - switch (displayData.type) { - case 0 /* Image */: - if (!displayData.textureData) { - displayData.textureData = this._getTextureData(dataPackage.dataName, displayData.name); - } - displayList.push(slot._rawDisplay); - break; - case 2 /* Mesh */: - if (!displayData.textureData) { - displayData.textureData = this._getTextureData(dataPackage.dataName, displayData.name); - } - if (egret.Capabilities.renderMode == "webgl") { - if (!slot._meshDisplay) { - slot._meshDisplay = new egret.Mesh(); - } - displayList.push(slot._meshDisplay); - } - else { - displayList.push(slot._rawDisplay); - } - break; - case 1 /* Armature */: - var childArmature = this.buildArmature(displayData.name, dataPackage.dataName); - if (childArmature) { - if (slotData.actions.length > 0) { - childArmature._action = slotData.actions[slotData.actions.length - 1]; - } - else { - childArmature.animation.play(); - } - } - displayList.push(childArmature); - break; - default: - displayList.push(null); - break; - } - } - slot._setDisplayList(displayList); - return slot; - }; - /** - * @language zh_CN - * 创建一个指定名称的骨架,并使用骨架的显示容器来更新骨架动画。 - * @param armatureName 骨架数据名称。 - * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 - * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 - * @returns 骨架的显示容器。 - * @see dragonBones.IArmatureDisplayContainer - * @version DragonBones 4.5 - */ - p.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - if (skinName === void 0) { skinName = null; } - var armature = this.buildArmature(armatureName, dragonBonesName, skinName); - var armatureDisplay = armature ? armature._display : null; - if (armatureDisplay) { - armatureDisplay.advanceTimeBySelf(true); - } - return armatureDisplay; - }; - /** - * @language zh_CN - * 获取带有指定贴图的显示对象。 - * @param textureName 指定的贴图名称。 - * @param dragonBonesName 指定的龙骨数据名称,如果未设置,将检索所有的龙骨数据。 - * @version DragonBones 3.0 - */ - p.getTextureDisplay = function (textureName, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - var textureData = this._getTextureData(dragonBonesName, textureName); - if (textureData) { - return new egret.Bitmap(textureData.texture); - } - return null; - }; - d(p, "soundEventManater" + Object.defineProperty(Bone.prototype, "ikChain", { + /** + * @private + */ + get: function () { + return this._ikChain; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "ikChainIndex", { + /** + * @private + */ + get: function () { + return this._ikChainIndex; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "ik", { /** * @language zh_CN - * 获取全局声音事件管理器。 + * 当前的 IK 约束目标。 * @version DragonBones 4.5 */ - ,function () { - return dragonBones.Armature._soundEventManager; - } - ); - /** - * @deprecated - * @see dragonBones.BaseFactory#addDragonBonesData() - */ - p.addSkeletonData = function (dragonBonesData, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - this.addDragonBonesData(dragonBonesData, dragonBonesName); - }; - /** - * @deprecated - * @see dragonBones.BaseFactory#getDragonBonesData() - */ - p.getSkeletonData = function (dragonBonesName) { - return this.getDragonBonesData(dragonBonesName); - }; - /** - * @deprecated - * @see dragonBones.BaseFactory#removeSkeletonData() - */ - p.removeSkeletonData = function (dragonBonesName) { - this.removeDragonBonesData(dragonBonesName); - }; - /** - * @deprecated - * @see dragonBones.BaseFactory#addTextureAtlasData() - */ - p.addTextureAtlas = function (textureAtlasData, dragonBonesName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - this.addTextureAtlasData(textureAtlasData, dragonBonesName); - }; - /** - * @deprecated - * @see dragonBones.BaseFactory#getTextureAtlasData() - */ - p.getTextureAtlas = function (dragonBonesName) { - return this.getTextureAtlasData(dragonBonesName); - }; - /** - * @deprecated - * @see dragonBones.BaseFactory#removeTextureAtlasData() - */ - p.removeTextureAtlas = function (dragonBonesName) { - this.removeTextureAtlasData(dragonBonesName); - }; - /** - * @deprecated - * @see dragonBones.BaseFactory#buildArmature() - */ - p.buildFastArmature = function (armatureName, dragonBonesName, skinName) { - if (dragonBonesName === void 0) { dragonBonesName = null; } - if (skinName === void 0) { skinName = null; } - return this.buildArmature(armatureName, dragonBonesName, skinName); - }; - return EgretFactory; - }(dragonBones.BaseFactory)); - dragonBones.EgretFactory = EgretFactory; - egret.registerClass(EgretFactory,'dragonBones.EgretFactory'); + get: function () { + return this._ik; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "visible", { + /** + * @language zh_CN + * 控制此骨骼所有插槽的显示。 + * @default true + * @see dragonBones.Slot + * @version DragonBones 3.0 + */ + get: function () { + return this._visible; + }, + set: function (value) { + if (this._visible == value) { + return; + } + this._visible = value; + var slots = this._armature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var slot = slots[i]; + if (slot._parent == this) { + slot._updateVisible(); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Bone.prototype, "slot", { + /** + * @deprecated + * @see dragonBones.Armature#getSlot() + */ + get: function () { + var slots = this._armature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var slot = slots[i]; + if (slot.parent == this) { + return slot; + } + } + return null; + }, + enumerable: true, + configurable: true + }); + return Bone; + }(dragonBones.TransformObject)); + dragonBones.Bone = Bone; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** * @language zh_CN - * Egret 插槽。 + * 插槽,附着在骨骼上,控制显示对象的显示状态和属性。 + * 一个骨骼上可以包含多个插槽。 + * 一个插槽中可以包含多个显示对象,同一时间只能显示其中的一个显示对象,但可以在动画播放的过程中切换显示对象实现帧动画。 + * 显示对象可以是普通的图片纹理,也可以是子骨架的显示容器,网格显示对象,还可以是自定义的其他显示对象。 + * @see dragonBones.Armature + * @see dragonBones.Bone + * @see dragonBones.SlotData * @version DragonBones 3.0 */ - var EgretSlot = (function (_super) { - __extends(EgretSlot, _super); + var Slot = (function (_super) { + __extends(Slot, _super); /** - * @language zh_CN - * 创建一个空的插槽。 - * @version DragonBones 3.0 + * @private */ - function EgretSlot() { + function Slot() { _super.call(this); + /** + * @private + */ + this._colorTransform = new dragonBones.ColorTransform(); + /** + * @private + */ + this._ffdVertices = []; + /** + * @private + */ + this._replacedDisplayDataSet = []; + /** + * @private + */ + this._localMatrix = new dragonBones.Matrix(); + /** + * @private + */ + this._displayList = []; + /** + * @private + */ + this._meshBones = []; } - var d = __define,c=EgretSlot,p=c.prototype; - /** - * @private - */ - EgretSlot.toString = function () { - return "[Class dragonBones.EgretSlot]"; - }; /** * @inheritDoc */ - p._onClear = function () { + Slot.prototype._onClear = function () { _super.prototype._onClear.call(this); - this.transformUpdateEnabled = false; - this._renderDisplay = null; - this._colorFilter = null; - }; - /** - * @private - */ - p._onUpdateDisplay = function () { - var self = this; - if (!self._rawDisplay) { - self._rawDisplay = new egret.Bitmap(); + var disposeDisplayList = []; + for (var i = 0, l = this._displayList.length; i < l; ++i) { + var eachDisplay = this._displayList[i]; + if (eachDisplay != this._rawDisplay && eachDisplay != this._meshDisplay && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + for (var i = 0, l = disposeDisplayList.length; i < l; ++i) { + var eachDisplay = disposeDisplayList[i]; + if (eachDisplay instanceof dragonBones.Armature) { + eachDisplay.dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + if (this._meshDisplay && this._meshDisplay != this._rawDisplay) { + this._disposeDisplay(this._meshDisplay); + } + if (this._rawDisplay) { + this._disposeDisplay(this._rawDisplay); + } + this.inheritAnimation = true; + this.displayController = null; + this._colorDirty = false; + this._ffdDirty = false; + this._blendIndex = 0; + this._zOrder = 0; + this._displayDataSet = null; + this._meshData = null; + this._childArmature = null; + this._rawDisplay = null; + this._meshDisplay = null; + this._cacheFrames = null; + this._colorTransform.identity(); + if (this._ffdVertices.length) { + this._ffdVertices.length = 0; + } + if (this._replacedDisplayDataSet.length) { + this._replacedDisplayDataSet.length = 0; + } + this._displayDirty = false; + this._blendModeDirty = false; + this._originDirty = false; + this._transformDirty = false; + this._displayIndex = 0; + this._blendMode = 0 /* Normal */; + this._display = null; + this._localMatrix.identity(); + if (this._displayList.length) { + this._displayList.length = 0; + } + if (this._meshBones.length) { + this._meshBones.length = 0; } - self._renderDisplay = (self._display || self._rawDisplay); - }; - /** - * @private - */ - p._initDisplay = function (value) { - }; - /** - * @private - */ - p._addDisplay = function () { - var container = this._armature._display; - container.addChild(this._renderDisplay); }; /** * @private */ - p._replaceDisplay = function (value) { - var container = this._armature._display; - var prevDisplay = value; - container.addChild(this._renderDisplay); - container.swapChildren(this._renderDisplay, prevDisplay); - container.removeChild(prevDisplay); + Slot.prototype._isMeshBonesUpdate = function () { + for (var i = 0, l = this._meshBones.length; i < l; ++i) { + if (this._meshBones[i]._transformDirty != 0 /* None */) { + return true; + } + } + return false; }; /** * @private */ - p._removeDisplay = function () { - this._renderDisplay.parent.removeChild(this._renderDisplay); + Slot.prototype._updateDisplay = function () { + var prevDisplay = this._display || this._rawDisplay; + var prevChildArmature = this._childArmature; + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._display = this._displayList[this._displayIndex]; + if (this._display instanceof dragonBones.Armature) { + this._childArmature = this._display; + this._display = this._childArmature._display; + } + else { + this._childArmature = null; + } + } + else { + this._display = null; + this._childArmature = null; + } + var currentDisplay = this._display || this._rawDisplay; + if (currentDisplay != prevDisplay) { + this._onUpdateDisplay(); + if (prevDisplay) { + this._replaceDisplay(prevDisplay); + } + else { + this._addDisplay(); + } + this._blendModeDirty = true; + this._colorDirty = true; + } + // Update origin. + if (this._displayDataSet && this._displayIndex >= 0 && this._displayIndex < this._displayDataSet.displays.length) { + this.origin.copyFrom(this._displayDataSet.displays[this._displayIndex].transform); + this._originDirty = true; + } + // Update meshData. + this._updateMeshData(false); + // Update frame. + if (currentDisplay == this._rawDisplay || currentDisplay == this._meshDisplay) { + this._updateFrame(); + } + // Update child armature. + if (this._childArmature != prevChildArmature) { + if (prevChildArmature) { + prevChildArmature._parent = null; // Update child armature parent. + if (this.inheritAnimation) { + prevChildArmature.animation.reset(); + } + } + if (this._childArmature) { + this._childArmature._parent = this; // Update child armature parent. + if (this.inheritAnimation) { + // Set child armature frameRate. + var cacheFrameRate = this._armature.cacheFrameRate; + if (cacheFrameRate) { + this._childArmature.cacheFrameRate = cacheFrameRate; + } + var slotData = this._armature.armatureData.getSlot(this.name); + if (slotData.actions.length > 0) { + for (var i = 0, l = slotData.actions.length; i < l; ++i) { + this._childArmature._bufferAction(slotData.actions[i]); + } + } + else { + this._childArmature.animation.play(); + } + } + } + } }; /** * @private */ - p._disposeDisplay = function (value) { + Slot.prototype._updateLocalTransformMatrix = function () { + this.global.copyFrom(this.origin).add(this.offset).toMatrix(this._localMatrix); }; /** * @private */ - p._updateVisible = function () { - this._renderDisplay.visible = this._parent.visible; + Slot.prototype._updateGlobalTransformMatrix = function () { + this.globalTransformMatrix.copyFrom(this._localMatrix); + this.globalTransformMatrix.concat(this._parent.globalTransformMatrix); + this.global.fromMatrix(this.globalTransformMatrix); }; /** - * @private + * @inheritDoc */ - p._updateBlendMode = function () { - if (this._blendMode < EgretSlot.BLEND_MODE_LIST.length) { - var blendMode = EgretSlot.BLEND_MODE_LIST[this._blendMode]; - if (blendMode) { - this._renderDisplay.blendMode = blendMode; - } + Slot.prototype._setArmature = function (value) { + if (this._armature == value) { + return; + } + if (this._armature) { + this._armature._removeSlotFromSlotList(this); + } + this._armature = value; + this._onUpdateDisplay(); + if (this._armature) { + this._armature._addSlotToSlotList(this); + this._addDisplay(); + } + else { + this._removeDisplay(); } }; /** - * @private + * @private Armature */ - p._updateColor = function () { - var self = this; - if (self._colorTransform.redMultiplier != 1 || - self._colorTransform.greenMultiplier != 1 || - self._colorTransform.blueMultiplier != 1 || - self._colorTransform.redOffset != 0 || - self._colorTransform.greenOffset != 0 || - self._colorTransform.blueOffset != 0) { - if (!self._colorFilter) { - self._colorFilter = new egret.ColorMatrixFilter(); - } - var colorMatrix = self._colorFilter.matrix; - colorMatrix[0] = self._colorTransform.redMultiplier; - colorMatrix[6] = self._colorTransform.greenMultiplier; - colorMatrix[12] = self._colorTransform.blueMultiplier; - colorMatrix[18] = self._colorTransform.alphaMultiplier; - colorMatrix[4] = self._colorTransform.redOffset; - colorMatrix[9] = self._colorTransform.greenOffset; - colorMatrix[14] = self._colorTransform.blueOffset; - colorMatrix[19] = self._colorTransform.alphaOffset; - self._colorFilter.matrix = colorMatrix; - var filters = self._renderDisplay.filters; - if (!filters) { - filters = []; - } - if (filters.indexOf(self._colorFilter) < 0) { - filters.push(self._colorFilter); - } - self._renderDisplay.filters = filters; + Slot.prototype._updateMeshData = function (isTimelineUpdate) { + var prevMeshData = this._meshData; + if (this._meshDisplay && this._displayDataSet && this._displayIndex >= 0 && this._displayIndex < this._displayDataSet.displays.length) { + this._meshData = this._displayDataSet.displays[this._displayIndex].mesh; } else { - if (self._colorFilter) { - self._colorFilter = null; - self._renderDisplay.filters = null; + this._meshData = null; + } + if (this._meshData != prevMeshData) { + if (this._meshData) { + if (this._meshData.skinned) { + this._meshBones.length = this._meshData.bones.length; + for (var i = 0, l = this._meshBones.length; i < l; ++i) { + this._meshBones[i] = this._armature.getBone(this._meshData.bones[i].name); + } + var ffdVerticesCount = 0; + for (var i = 0, l = this._meshData.boneIndices.length; i < l; ++i) { + ffdVerticesCount += this._meshData.boneIndices[i].length; + } + this._ffdVertices.length = ffdVerticesCount * 2; + } + else { + this._meshBones.length = 0; + this._ffdVertices.length = this._meshData.vertices.length; + } + for (var i = 0, l = this._ffdVertices.length; i < l; ++i) { + this._ffdVertices[i] = 0; + } + this._ffdDirty = true; + } + else { + this._meshBones.length = 0; + this._ffdVertices.length = 0; + } + if (isTimelineUpdate) { + this._armature.animation._updateFFDTimelineStates(); } - self._renderDisplay.$setAlpha(self._colorTransform.alphaMultiplier); } }; /** - * @private - */ - p._updateFilters = function () { }; - /** - * @private + * @private Armature */ - p._updateFrame = function () { + Slot.prototype._update = function (cacheFrameIndex) { var self = this; - var frameDisplay = self._renderDisplay; - if (self._display && self._displayIndex >= 0) { - var rawDisplayData = self._displayIndex < self._displayDataSet.displays.length ? self._displayDataSet.displays[self._displayIndex] : null; - var replacedDisplayData = self._displayIndex < self._replacedDisplayDataSet.length ? self._replacedDisplayDataSet[self._displayIndex] : null; - var currentDisplayData = replacedDisplayData || rawDisplayData; - var currentTextureData = currentDisplayData.textureData; - if (currentTextureData) { - var textureAtlasTexture = currentTextureData.parent.texture; - if (!currentTextureData.texture && textureAtlasTexture) { - currentTextureData.texture = new egret.Texture(); - currentTextureData.texture._bitmapData = textureAtlasTexture._bitmapData; - currentTextureData.texture.$initData(currentTextureData.region.x, currentTextureData.region.y, currentTextureData.region.width, currentTextureData.region.height, 0, 0, currentTextureData.region.width, currentTextureData.region.height, textureAtlasTexture.textureWidth, textureAtlasTexture.textureHeight); - } - var texture = self._armature._replacedTexture || currentTextureData.texture; - if (texture) { - if (self._meshData && self._display == self._meshDisplay) { - var meshDisplay = self._meshDisplay; - var meshNode = meshDisplay.$renderNode; - for (var i = 0, l = self._meshData.vertices.length; i < l; ++i) { - meshNode.uvs[i] = self._meshData.uvs[i]; - meshNode.vertices[i] = self._meshData.vertices[i]; - } - for (var i = 0, l = self._meshData.vertexIndices.length; i < l; ++i) { - meshNode.indices[i] = self._meshData.vertexIndices[i]; - } - meshDisplay.$setBitmapData(texture); - meshDisplay.$updateVertices(); - meshDisplay.$invalidateTransform(); - } - else { - var rect = currentTextureData.frame || currentTextureData.region; - var width = rect.width; - var height = rect.height; - if (currentTextureData.rotated) { - width = rect.height; - height = rect.width; - } - var pivotX = currentDisplayData.pivot.x; - var pivotY = currentDisplayData.pivot.y; - if (currentDisplayData.isRelativePivot) { - pivotX = width * pivotX; - pivotY = height * pivotY; - } - if (currentTextureData.frame) { - pivotX += currentTextureData.frame.x; - pivotY += currentTextureData.frame.y; - } - if (rawDisplayData && replacedDisplayData) { - pivotX += rawDisplayData.transform.x - replacedDisplayData.transform.x; - pivotY += rawDisplayData.transform.y - replacedDisplayData.transform.y; - } - frameDisplay.$setBitmapData(texture); - frameDisplay.$setAnchorOffsetX(pivotX); - frameDisplay.$setAnchorOffsetY(pivotY); - } - self._updateVisible(); - return; + self._blendIndex = 0; + if (self._displayDirty) { + self._displayDirty = false; + self._updateDisplay(); + } + if (!self._display) { + return; + } + if (self._blendModeDirty) { + self._blendModeDirty = false; + self._updateBlendMode(); + } + if (self._colorDirty) { + self._colorDirty = false; + self._updateColor(); + } + if (self._meshData) { + if (self._ffdDirty || (self._meshData.skinned && self._isMeshBonesUpdate())) { + self._ffdDirty = false; + self._updateMesh(); + } + if (self._meshData.skinned) { + return; + } + } + if (self._originDirty) { + self._originDirty = false; + self._transformDirty = true; + self._updateLocalTransformMatrix(); + } + if (cacheFrameIndex >= 0) { + var cacheFrame = self._cacheFrames[cacheFrameIndex]; + if (self.globalTransformMatrix == cacheFrame) { + self._transformDirty = false; + } + else if (cacheFrame) { + self._transformDirty = true; + self.globalTransformMatrix = cacheFrame; + } + else if (self._transformDirty || self._parent._transformDirty != 0 /* None */) { + self._transformDirty = true; + self.globalTransformMatrix = self._globalTransformMatrix; + } + else if (self.globalTransformMatrix != self._globalTransformMatrix) { + self._transformDirty = false; + self._cacheFrames[cacheFrameIndex] = self.globalTransformMatrix; + } + else { + self._transformDirty = true; + self.globalTransformMatrix = self._globalTransformMatrix; + } + } + else if (self._transformDirty || self._parent._transformDirty != 0 /* None */) { + self._transformDirty = true; + self.globalTransformMatrix = self._globalTransformMatrix; + } + if (self._transformDirty) { + self._transformDirty = false; + if (self.globalTransformMatrix == self._globalTransformMatrix) { + self._updateGlobalTransformMatrix(); + if (cacheFrameIndex >= 0) { + self.globalTransformMatrix = dragonBones.SlotTimelineData.cacheFrame(self._cacheFrames, cacheFrameIndex, self._globalTransformMatrix); } } + self._updateTransform(); } - frameDisplay.visible = false; - frameDisplay.$setBitmapData(null); - frameDisplay.$setAnchorOffsetX(0); - frameDisplay.$setAnchorOffsetY(0); - frameDisplay.x = 0; - frameDisplay.y = 0; }; /** - * @private + * @private Factory */ - p._updateMesh = function () { - var self = this; - var meshDisplay = self._meshDisplay; - var meshNode = meshDisplay.$renderNode; - var hasFFD = self._ffdVertices.length > 0; - if (self._meshData.skinned) { - for (var i = 0, iF = 0, l = self._meshData.vertices.length; i < l; i += 2) { - var iH = i / 2; - var boneIndices = self._meshData.boneIndices[iH]; - var boneVertices = self._meshData.boneVertices[iH]; - var weights = self._meshData.weights[iH]; - var xG = 0, yG = 0; - for (var iB = 0, lB = boneIndices.length; iB < lB; ++iB) { - var bone = self._meshBones[boneIndices[iB]]; - var matrix = bone.globalTransformMatrix; - var weight = weights[iB]; - var xL = 0, yL = 0; - if (hasFFD) { - xL = boneVertices[iB * 2] + self._ffdVertices[iF]; - yL = boneVertices[iB * 2 + 1] + self._ffdVertices[iF + 1]; - } - else { - xL = boneVertices[iB * 2]; - yL = boneVertices[iB * 2 + 1]; - } - xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; - yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; - iF += 2; + Slot.prototype._setDisplayList = function (value) { + if (value && value.length) { + if (this._displayList.length != value.length) { + this._displayList.length = value.length; + } + for (var i = 0, l = this._displayList.length; i < l; ++i) { + var eachDisplay = value[i]; + if (eachDisplay && eachDisplay != this._rawDisplay && eachDisplay != this._meshDisplay && !(eachDisplay instanceof dragonBones.Armature) && + this._displayList.indexOf(eachDisplay) < 0) { + this._initDisplay(eachDisplay); } - meshNode.vertices[i] = xG; - meshNode.vertices[i + 1] = yG; + this._displayList[i] = eachDisplay; } - meshDisplay.$updateVertices(); - meshDisplay.$invalidateTransform(); } - else if (hasFFD) { - var vertices = self._meshData.vertices; - for (var i = 0, l = self._meshData.vertices.length; i < l; i += 2) { - var xG = vertices[i] + self._ffdVertices[i]; - var yG = vertices[i + 1] + self._ffdVertices[i + 1]; - meshNode.vertices[i] = xG; - meshNode.vertices[i + 1] = yG; - } - meshDisplay.$updateVertices(); - meshDisplay.$invalidateTransform(); + else if (this._displayList.length) { + this._displayList.length = 0; + } + if (this._displayIndex >= 0 && this._displayIndex < this._displayList.length) { + this._displayDirty = this._display != this._displayList[this._displayIndex]; + } + else { + this._displayDirty = this._display != null; } + return this._displayDirty; }; /** - * @private + * @private Factory */ - p._updateTransform = function () { - var self = this; - self._renderDisplay.$setMatrix(self.globalTransformMatrix, self.transformUpdateEnabled); + Slot.prototype._setDisplayIndex = function (value) { + if (this._displayIndex == value) { + return false; + } + this._displayIndex = value; + this._displayDirty = true; + return this._displayDirty; }; /** - * @private + * @private Factory */ - EgretSlot.BLEND_MODE_LIST = [ - egret.BlendMode.NORMAL, - egret.BlendMode.ADD, - null, - null, - null, - egret.BlendMode.ERASE, - null, - null, - null, - null, - null, - null, - null, - null - ]; - return EgretSlot; - }(dragonBones.Slot)); - dragonBones.EgretSlot = EgretSlot; - egret.registerClass(EgretSlot,'dragonBones.EgretSlot'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * 2D 矩阵。 - * @version DragonBones 3.0 - */ - var Matrix = (function () { - function Matrix(a, b, c, d, tx, ty) { - if (a === void 0) { a = 1; } - if (b === void 0) { b = 0; } - if (c === void 0) { c = 0; } - if (d === void 0) { d = 1; } - if (tx === void 0) { tx = 0; } - if (ty === void 0) { ty = 0; } - this.a = a; - this.b = b; - this.c = c; - this.d = d; - this.tx = tx; - this.ty = ty; - } - var d = __define,c=Matrix,p=c.prototype; - /** - * @language zh_CN - * 复制矩阵。 - * @param value 需要复制的矩阵。 - * @version DragonBones 3.0 - */ - p.copyFrom = function (value) { - var self = this; - self.a = value.a; - self.b = value.b; - self.c = value.c; - self.d = value.d; - self.tx = value.tx; - self.ty = value.ty; + Slot.prototype._setBlendMode = function (value) { + if (this._blendMode == value) { + return false; + } + this._blendMode = value; + this._blendModeDirty = true; + return true; }; /** - * @language zh_CN - * 转换为恒等矩阵。 - * @version DragonBones 3.0 + * @private Factory */ - p.identity = function () { - var self = this; - self.a = self.d = 1; - self.b = self.c = 0; - self.tx = self.ty = 0; + Slot.prototype._setColor = function (value) { + this._colorTransform.copyFrom(value); + this._colorDirty = true; + return true; }; /** * @language zh_CN - * 将当前矩阵与另一个矩阵相乘。 - * @param value 需要相乘的矩阵。 - * @version DragonBones 3.0 + * 在下一帧更新显示对象的状态。 + * @version DragonBones 4.5 */ - p.concat = function (value) { - var self = this; - var aA = self.a; - var bA = self.b; - var cA = self.c; - var dA = self.d; - var txA = self.tx; - var tyA = self.ty; - var aB = value.a; - var bB = value.b; - var cB = value.c; - var dB = value.d; - var txB = value.tx; - var tyB = value.ty; - self.a = aA * aB + bA * cB; - self.b = aA * bB + bA * dB; - self.c = cA * aB + dA * cB; - self.d = cA * bB + dA * dB; - self.tx = aB * txA + cB * tyA + txB; - self.ty = dB * tyA + bB * txA + tyB; - /* - [ - self.a, - self.b, - self.c, - self.d, - self.tx, - self.ty - ] = [ - self.a * value.a + self.b * value.c, - self.a * value.b + self.b * value.d, - self.c * value.a + self.d * value.c, - self.c * value.b + self.d * value.d, - value.a * self.tx + value.c * self.tx + value.tx, - value.d * self.ty + value.b * self.ty + value.ty - ]; - */ + Slot.prototype.invalidUpdate = function () { + this._displayDirty = true; }; + Object.defineProperty(Slot.prototype, "rawDisplay", { + /** + * @private + */ + get: function () { + return this._rawDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "MeshDisplay", { + /** + * @private + */ + get: function () { + return this._meshDisplay; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayIndex", { + /** + * @language zh_CN + * 此时显示的显示对象在显示列表中的索引。 + * @version DragonBones 4.5 + */ + get: function () { + return this._displayIndex; + }, + set: function (value) { + if (this._setDisplayIndex(value)) { + this._update(-1); + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "displayList", { + /** + * @language zh_CN + * 包含显示对象或子骨架的显示列表。 + * @version DragonBones 3.0 + */ + get: function () { + return this._displayList.concat(); + }, + set: function (value) { + var backupDisplayList = this._displayList.concat(); // Copy. + var disposeDisplayList = []; + if (this._setDisplayList(value)) { + this._update(-1); + } + // Release replaced render displays. + for (var i = 0, l = backupDisplayList.length; i < l; ++i) { + var eachDisplay = backupDisplayList[i]; + if (eachDisplay != this._rawDisplay && eachDisplay != this._meshDisplay && + this._displayList.indexOf(eachDisplay) < 0 && + disposeDisplayList.indexOf(eachDisplay) < 0) { + disposeDisplayList.push(eachDisplay); + } + } + for (var i = 0, l = disposeDisplayList.length; i < l; ++i) { + var eachDisplay = disposeDisplayList[i]; + if (eachDisplay instanceof dragonBones.Armature) { + (eachDisplay).dispose(); + } + else { + this._disposeDisplay(eachDisplay); + } + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "display", { + /** + * @language zh_CN + * 此时显示的显示对象。 + * @version DragonBones 3.0 + */ + get: function () { + return this._display; + }, + set: function (value) { + if (this._display == value) { + return; + } + var displayListLength = this._displayList.length; + if (this._displayIndex < 0 && displayListLength == 0) { + this._displayIndex = 0; + } + if (this._displayIndex < 0) { + return; + } + else { + var replaceDisplayList = this.displayList; // Copy. + if (displayListLength <= this._displayIndex) { + replaceDisplayList.length = this._displayIndex + 1; + } + replaceDisplayList[this._displayIndex] = value; + this.displayList = replaceDisplayList; + } + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(Slot.prototype, "childArmature", { + /** + * @language zh_CN + * 此时显示的子骨架。 + * @see dragonBones.Armature + * @version DragonBones 3.0 + */ + get: function () { + return this._childArmature; + }, + set: function (value) { + if (this._childArmature == value) { + return; + } + value.display.advanceTimeBySelf(false); // Stop child armature self advanceTime. + this.display = value; + }, + enumerable: true, + configurable: true + }); /** - * @language zh_CN - * 转换为逆矩阵。 - * @version DragonBones 3.0 + * @deprecated + * @see #display */ - p.invert = function () { - var self = this; - var aA = self.a; - var bA = self.b; - var cA = self.c; - var dA = self.d; - var txA = self.tx; - var tyA = self.ty; - var n = aA * dA - bA * cA; - self.a = dA / n; - self.b = -bA / n; - self.c = -cA / n; - self.d = aA / n; - self.tx = (cA * tyA - dA * txA) / n; - self.ty = -(aA * tyA - bA * txA) / n; + Slot.prototype.getDisplay = function () { + return this._display; }; /** - * @language zh_CN - * 将矩阵转换应用于指定点。 - * @param x 横坐标。 - * @param y 纵坐标。 - * @param result 应用转换之后的坐标。 - * @params delta 是否忽略 tx,ty 对坐标的转换。 - * @version DragonBones 3.0 + * @deprecated + * @see #display */ - p.transformPoint = function (x, y, result, delta) { - if (delta === void 0) { delta = false; } - var self = this; - result.x = self.a * x + self.c * y; - result.y = self.b * x + self.d * y; - if (!delta) { - result.x += self.tx; - result.y += self.ty; - } - }; - return Matrix; - }()); - dragonBones.Matrix = Matrix; - egret.registerClass(Matrix,'dragonBones.Matrix'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var Point = (function () { - function Point(x, y) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - this.x = x; - this.y = y; - } - var d = __define,c=Point,p=c.prototype; - p.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - }; - p.clear = function () { - this.x = this.y = 0; - }; - return Point; - }()); - dragonBones.Point = Point; - egret.registerClass(Point,'dragonBones.Point'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var Rectangle = (function () { - function Rectangle(x, y, width, height) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (width === void 0) { width = 0; } - if (height === void 0) { height = 0; } - this.x = x; - this.y = y; - this.width = width; - this.height = height; - } - var d = __define,c=Rectangle,p=c.prototype; - p.copyFrom = function (value) { - this.x = value.x; - this.y = value.y; - this.width = value.width; - this.height = value.height; - }; - p.clear = function () { - this.x = this.y = 0; - this.width = this.height = 0; + Slot.prototype.setDisplay = function (value) { + this.display = value; }; - return Rectangle; - }()); - dragonBones.Rectangle = Rectangle; - egret.registerClass(Rectangle,'dragonBones.Rectangle'); + return Slot; + }(dragonBones.TransformObject)); + dragonBones.Slot = Slot; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** * @language zh_CN - * 2D 变换。 + * 生成骨架的基础工厂。 + * @see dragonBones.DragonBonesData + * @see dragonBones.TextureAtlasData + * @see dragonBones.ArmatureData + * @see dragonBones.Armature * @version DragonBones 3.0 */ - var Transform = (function () { + var BaseFactory = (function () { /** * @private */ - function Transform( - /** - * @language zh_CN - * 水平位移。 - * @version DragonBones 3.0 - */ - x, - /** - * @language zh_CN - * 垂直位移。 - * @version DragonBones 3.0 - */ - y, + function BaseFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } /** * @language zh_CN - * 水平倾斜。 (以弧度为单位) - * @version DragonBones 3.0 + * 是否开启共享搜索。 [true: 开启, false: 不开启] + * 如果开启,创建一个骨架时,可以从多个龙骨数据中寻找骨架数据,或贴图集数据中寻找贴图数据。 (通常在有共享导出的数据时开启) + * @see dragonBones.DragonBonesData#autoSearch + * @see dragonBones.TextureAtlasData#autoSearch + * @version DragonBones 4.5 */ - skewX, + this.autoSearch = false; /** - * @language zh_CN - * 垂直倾斜。 (以弧度为单位) - * @version DragonBones 3.0 + * @private */ - skewY, + this._dataParser = null; /** - * @language zh_CN - * 水平缩放。 - * @version DragonBones 3.0 + * @private */ - scaleX, + this._dragonBonesDataMap = {}; /** - * @language zh_CN - * 垂直缩放。 - * @version DragonBones 3.0 + * @private */ - scaleY) { - if (x === void 0) { x = 0; } - if (y === void 0) { y = 0; } - if (skewX === void 0) { skewX = 0; } - if (skewY === void 0) { skewY = 0; } - if (scaleX === void 0) { scaleX = 1; } - if (scaleY === void 0) { scaleY = 1; } - this.x = x; - this.y = y; - this.skewX = skewX; - this.skewY = skewY; - this.scaleX = scaleX; - this.scaleY = scaleY; + this._textureAtlasDataMap = {}; + this._dataParser = dataParser || dragonBones.ObjectDataParser.getInstance(); } - var d = __define,c=Transform,p=c.prototype; /** * @private */ - Transform.normalizeRadian = function (value) { - value = (value + Math.PI) % (Math.PI * 2); - value += value > 0 ? -Math.PI : Math.PI; - return value; + BaseFactory.prototype._getTextureData = function (dragonBonesName, textureName) { + var textureAtlasDataList = this._textureAtlasDataMap[dragonBonesName]; + if (textureAtlasDataList) { + for (var i = 0, l = textureAtlasDataList.length; i < l; ++i) { + var textureData = textureAtlasDataList[i].getTextureData(textureName); + if (textureData) { + return textureData; + } + } + } + if (this.autoSearch) { + for (var i in this._textureAtlasDataMap) { + textureAtlasDataList = this._textureAtlasDataMap[i]; + for (var j = 0, lJ = textureAtlasDataList.length; j < lJ; ++j) { + var textureAtlasData = textureAtlasDataList[j]; + if (textureAtlasData.autoSearch) { + var textureData = textureAtlasData.getTextureData(textureName); + if (textureData) { + return textureData; + } + } + } + } + } + return null; }; /** * @private */ - p.toString = function () { - return "[object dragonBones.Transform] x:" + this.x + " y:" + this.y + " skewX:" + this.skewX * 180 / Math.PI + " skewY:" + this.skewY * 180 / Math.PI + " scaleX:" + this.scaleX + " scaleY:" + this.scaleY; + BaseFactory.prototype._fillBuildArmaturePackage = function (dragonBonesName, armatureName, skinName, dataPackage) { + if (dragonBonesName) { + var dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; + if (dragonBonesData) { + var armatureData = dragonBonesData.getArmature(armatureName); + if (armatureData) { + dataPackage.dataName = dragonBonesName; + dataPackage.data = dragonBonesData; + dataPackage.armature = armatureData; + dataPackage.skin = armatureData.getSkin(skinName); + if (!dataPackage.skin) { + dataPackage.skin = armatureData.defaultSkin; + } + return true; + } + } + } + if (!dragonBonesName || this.autoSearch) { + for (var eachDragonBonesName in this._dragonBonesDataMap) { + var dragonBonesData = this._dragonBonesDataMap[eachDragonBonesName]; + if (!dragonBonesName || dragonBonesData.autoSearch) { + var armatureData = dragonBonesData.getArmature(armatureName); + if (armatureData) { + dataPackage.dataName = eachDragonBonesName; + dataPackage.data = dragonBonesData; + dataPackage.armature = armatureData; + dataPackage.skin = armatureData.getSkin(skinName); + if (!dataPackage.skin) { + dataPackage.skin = armatureData.defaultSkin; + } + return true; + } + } + } + } + return false; }; /** * @private */ - p.copyFrom = function (value) { - var self = this; - self.x = value.x; - self.y = value.y; - self.skewX = value.skewX; - self.skewY = value.skewY; - self.scaleX = value.scaleX; - self.scaleY = value.scaleY; - return this; + BaseFactory.prototype._buildBones = function (dataPackage, armature) { + var bones = dataPackage.armature.sortedBones; + for (var i = 0, l = bones.length; i < l; ++i) { + var boneData = bones[i]; + var bone = dragonBones.BaseObject.borrowObject(dragonBones.Bone); + bone.name = boneData.name; + bone.inheritTranslation = boneData.inheritTranslation; + bone.inheritRotation = boneData.inheritRotation; + bone.inheritScale = boneData.inheritScale; + bone.length = boneData.length; + bone.origin.copyFrom(boneData.transform); + if (boneData.parent) { + armature.addBone(bone, boneData.parent.name); + } + else { + armature.addBone(bone); + } + if (boneData.ik) { + bone.ikBendPositive = boneData.bendPositive; + bone.ikWeight = boneData.weight; + bone._setIK(armature.getBone(boneData.ik.name), boneData.chain, boneData.chainIndex); + } + } }; /** * @private */ - p.clone = function () { - var value = new Transform(); - value.copyFrom(this); - return value; + BaseFactory.prototype._buildSlots = function (dataPackage, armature) { + var currentSkin = dataPackage.skin; + var defaultSkin = dataPackage.armature.defaultSkin; + var slotDisplayDataSetMap = {}; + for (var i in defaultSkin.slots) { + var slotDisplayDataSet = defaultSkin.slots[i]; + slotDisplayDataSetMap[slotDisplayDataSet.slot.name] = slotDisplayDataSet; + } + if (currentSkin != defaultSkin) { + for (var i in currentSkin.slots) { + var slotDisplayDataSet = currentSkin.slots[i]; + slotDisplayDataSetMap[slotDisplayDataSet.slot.name] = slotDisplayDataSet; + } + } + var slots = dataPackage.armature.sortedSlots; + for (var i = 0, l = slots.length; i < l; ++i) { + var slotData = slots[i]; + var slotDisplayDataSet = slotDisplayDataSetMap[slotData.name]; + if (!slotDisplayDataSet) { + continue; + } + var slot = this._generateSlot(dataPackage, slotDisplayDataSet); + if (slot) { + slot._displayDataSet = slotDisplayDataSet; + slot._setDisplayIndex(slotData.displayIndex); + slot._setBlendMode(slotData.blendMode); + slot._setColor(slotData.color); + slot._replacedDisplayDataSet.length = slot._displayDataSet.displays.length; + armature.addSlot(slot, slotData.parent.name); + } + } }; /** * @private */ - p.identity = function () { - var self = this; - self.x = self.y = self.skewX = self.skewY = 0; - self.scaleX = self.scaleY = 1; - return this; + BaseFactory.prototype._replaceSlotDisplay = function (dataPackage, displayData, slot, displayIndex) { + if (displayIndex < 0) { + displayIndex = slot.displayIndex; + } + if (displayIndex >= 0) { + var displayList = slot.displayList; // Copy. + if (displayList.length <= displayIndex) { + displayList.length = displayIndex + 1; + } + if (!displayData.texture) { + displayData.texture = this._getTextureData(dataPackage.dataName, displayData.name); + } + if (displayData.type == 1 /* Armature */) { + var childArmature = this.buildArmature(displayData.name, dataPackage.dataName); + displayList[displayIndex] = childArmature; + } + else { + if (slot._replacedDisplayDataSet.length <= displayIndex) { + slot._replacedDisplayDataSet.length = displayIndex + 1; + } + slot._replacedDisplayDataSet[displayIndex] = displayData; + if (displayData.mesh) { + displayList[displayIndex] = slot.MeshDisplay; + } + else { + displayList[displayIndex] = slot.rawDisplay; + } + } + slot.displayList = displayList; + slot.invalidUpdate(); + } }; /** - * @private + * @language zh_CN + * 解析并添加龙骨数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param dragonBonesName 为数据提供一个名称,以便可以通过这个名称来获取数据,状态,则使用数据中的名称。 + * @returns DragonBonesData + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 4.5 */ - p.add = function (value) { - var self = this; - self.x += value.x; - self.y += value.y; - self.skewX += value.skewX; - self.skewY += value.skewY; - self.scaleX *= value.scaleX; - self.scaleY *= value.scaleY; - return this; + BaseFactory.prototype.parseDragonBonesData = function (rawData, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + var dragonBonesData = this._dataParser.parseDragonBonesData(rawData, 1); + this.addDragonBonesData(dragonBonesData, dragonBonesName); + return dragonBonesData; }; /** - * @private + * @language zh_CN + * 解析并添加贴图集数据。 + * @param rawData 需要解析的原始数据。 (JSON) + * @param textureAtlas 贴图集数据。 (JSON) + * @param name 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 + * @param scale 为贴图集设置一个缩放值。 + * @returns 贴图集数据 + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.TextureAtlasData + * @version DragonBones 4.5 */ - p.minus = function (value) { - var self = this; - self.x -= value.x; - self.y -= value.y; - self.skewX = Transform.normalizeRadian(self.skewX - value.skewX); - self.skewY = Transform.normalizeRadian(self.skewY - value.skewY); - self.scaleX /= value.scaleX; - self.scaleY /= value.scaleY; - return this; + BaseFactory.prototype.parseTextureAtlasData = function (rawData, textureAtlas, name, scale) { + if (name === void 0) { name = null; } + if (scale === void 0) { scale = 0; } + var textureAtlasData = this._generateTextureAtlasData(null, null); + this._dataParser.parseTextureAtlasData(rawData, textureAtlasData, scale); + this._generateTextureAtlasData(textureAtlasData, textureAtlas); + this.addTextureAtlasData(textureAtlasData, name); + return textureAtlasData; }; /** - * @private + * @language zh_CN + * 获取指定名称的龙骨数据。 + * @param name 数据名称。 + * @returns DragonBonesData + * @see #parseDragonBonesData() + * @see #addDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 */ - p.fromMatrix = function (matrix) { - var self = this; - var PI_Q = Math.PI * 0.25; - var backupScaleX = self.scaleX, backupScaleY = self.scaleY; - self.x = matrix.tx; - self.y = matrix.ty; - self.skewX = Math.atan(-matrix.c / matrix.d); - self.skewY = Math.atan(matrix.b / matrix.a); - if (self.skewX != self.skewX) - self.skewX = 0; - if (self.skewY != self.skewY) - self.skewY = 0; - self.scaleY = (self.skewX > -PI_Q && self.skewX < PI_Q) ? matrix.d / Math.cos(self.skewX) : -matrix.c / Math.sin(self.skewX); - self.scaleX = (self.skewY > -PI_Q && self.skewY < PI_Q) ? matrix.a / Math.cos(self.skewY) : matrix.b / Math.sin(self.skewY); - if (backupScaleX >= 0 && self.scaleX < 0) { - self.scaleX = -self.scaleX; - self.skewY = self.skewY - Math.PI; - } - if (backupScaleY >= 0 && self.scaleY < 0) { - self.scaleY = -self.scaleY; - self.skewX = self.skewX - Math.PI; - } - return this; + BaseFactory.prototype.getDragonBonesData = function (name) { + return this._dragonBonesDataMap[name]; }; /** * @language zh_CN - * 转换为矩阵。 - * @param 矩阵。 + * 添加龙骨数据。 + * @param data 龙骨数据。 + * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #removeDragonBonesData() + * @see dragonBones.DragonBonesData * @version DragonBones 3.0 */ - p.toMatrix = function (matrix) { - var self = this; - matrix.a = self.scaleX * Math.cos(self.skewY); - matrix.b = self.scaleX * Math.sin(self.skewY); - matrix.c = -self.scaleY * Math.sin(self.skewX); - matrix.d = self.scaleY * Math.cos(self.skewX); - matrix.tx = self.x; - matrix.ty = self.y; - }; - d(p, "rotation" - /** - * @language zh_CN - * 旋转。 (以弧度为单位) - * @version DragonBones 3.0 - */ - ,function () { - return this.skewY; - } - ,function (value) { - var dValue = value - this.skewY; - this.skewX += dValue; - this.skewY += dValue; - } - ); - return Transform; - }()); - dragonBones.Transform = Transform; - egret.registerClass(Transform,'dragonBones.Transform'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var TimelineData = (function (_super) { - __extends(TimelineData, _super); - function TimelineData() { - _super.call(this); - /** - * @private - */ - this.frames = []; - } - var d = __define,c=TimelineData,p=c.prototype; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.scale = 1; - self.offset = 0; - if (self.frames.length) { - var prevFrame = null; - for (var i = 0, l = self.frames.length; i < l; ++i) { - var frame = self.frames[i]; - if (prevFrame && frame != prevFrame) { - prevFrame.returnToPool(); + BaseFactory.prototype.addDragonBonesData = function (data, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (data) { + dragonBonesName = dragonBonesName || data.name; + if (dragonBonesName) { + if (!this._dragonBonesDataMap[dragonBonesName]) { + this._dragonBonesDataMap[dragonBonesName] = data; } - prevFrame = frame; + else { + console.warn("Same name data."); + } + } + else { + console.warn("Unnamed data."); } - self.frames.length = 0; } - }; - return TimelineData; - }(dragonBones.BaseObject)); - dragonBones.TimelineData = TimelineData; - egret.registerClass(TimelineData,'dragonBones.TimelineData'); - /** - * @private - */ - var BoneTimelineData = (function (_super) { - __extends(BoneTimelineData, _super); - function BoneTimelineData() { - _super.call(this); - this.bone = null; - this.originTransform = new dragonBones.Transform(); - this.cachedFrames = []; - } - var d = __define,c=BoneTimelineData,p=c.prototype; - BoneTimelineData.cacheFrame = function (cacheFrames, cacheFrameIndex, globalTransformMatrix) { - var cacheMatrix = cacheFrames[cacheFrameIndex] = new dragonBones.Matrix(); - cacheMatrix.copyFrom(globalTransformMatrix); - return cacheMatrix; - }; - BoneTimelineData.toString = function () { - return "[Class dragonBones.BoneTimelineData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.bone = null; - self.originTransform.identity(); - if (self.cachedFrames.length) { - self.cachedFrames.length = 0; - } - }; - p.cacheFrames = function (cacheFrameCount) { - this.cachedFrames.length = 0; - this.cachedFrames.length = cacheFrameCount; - }; - return BoneTimelineData; - }(TimelineData)); - dragonBones.BoneTimelineData = BoneTimelineData; - egret.registerClass(BoneTimelineData,'dragonBones.BoneTimelineData'); - /** - * @private - */ - var SlotTimelineData = (function (_super) { - __extends(SlotTimelineData, _super); - function SlotTimelineData() { - _super.call(this); - this.slot = null; - this.cachedFrames = []; - } - var d = __define,c=SlotTimelineData,p=c.prototype; - SlotTimelineData.cacheFrame = function (cacheFrames, cacheFrameIndex, globalTransformMatrix) { - var cacheMatrix = cacheFrames[cacheFrameIndex] = new dragonBones.Matrix(); - cacheMatrix.copyFrom(globalTransformMatrix); - return cacheMatrix; - }; - SlotTimelineData.toString = function () { - return "[Class dragonBones.SlotTimelineData]"; + else { + throw new Error(); + } }; /** - * @inheritDoc + * @language zh_CN + * 移除龙骨数据。 + * @param dragonBonesName 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseDragonBonesData() + * @see #getDragonBonesData() + * @see #addDragonBonesData() + * @see dragonBones.DragonBonesData + * @version DragonBones 3.0 */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.slot = null; - if (self.cachedFrames.length) { - self.cachedFrames.length = 0; + BaseFactory.prototype.removeDragonBonesData = function (dragonBonesName, disposeData) { + if (disposeData === void 0) { disposeData = true; } + var dragonBonesData = this._dragonBonesDataMap[dragonBonesName]; + if (dragonBonesData) { + if (disposeData) { + if (dragonBones.DragonBones.DEBUG) { + for (var i = 0, l = dragonBones.DragonBones._armatures.length; i < l; ++i) { + var armature = dragonBones.DragonBones._armatures[i]; + if (armature.armatureData.parent == dragonBonesData) { + throw new Error("ArmatureData: " + armature.armatureData.name + " DragonBonesData: " + dragonBonesName); + } + } + } + dragonBonesData.returnToPool(); + } + delete this._dragonBonesDataMap[dragonBonesName]; } }; - p.cacheFrames = function (cacheFrameCount) { - this.cachedFrames.length = 0; - this.cachedFrames.length = cacheFrameCount; - }; - return SlotTimelineData; - }(TimelineData)); - dragonBones.SlotTimelineData = SlotTimelineData; - egret.registerClass(SlotTimelineData,'dragonBones.SlotTimelineData'); - /** - * @private - */ - var FFDTimelineData = (function (_super) { - __extends(FFDTimelineData, _super); - function FFDTimelineData() { - _super.call(this); - this.displayIndex = 0; - this.skin = null; - this.slot = null; - } - var d = __define,c=FFDTimelineData,p=c.prototype; - FFDTimelineData.toString = function () { - return "[Class dragonBones.FFDTimelineData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.displayIndex = 0; - self.skin = null; - self.slot = null; - }; - return FFDTimelineData; - }(TimelineData)); - dragonBones.FFDTimelineData = FFDTimelineData; - egret.registerClass(FFDTimelineData,'dragonBones.FFDTimelineData'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * 动画数据。 - * @version DragonBones 3.0 - */ - var AnimationData = (function (_super) { - __extends(AnimationData, _super); - /** - * @private - */ - function AnimationData() { - _super.call(this); - /** - * @private - */ - this.boneTimelines = {}; - /** - * @private - */ - this.slotTimelines = {}; - /** - * @private - */ - this.ffdTimelines = {}; // skin slot displayIndex - /** - * @private - */ - this.cachedFrames = []; - } - var d = __define,c=AnimationData,p=c.prototype; /** - * @private + * @language zh_CN + * 获取指定名称的贴图集数据列表。 + * @param dragonBonesName 数据名称。 + * @returns 贴图集数据列表。 + * @see #parseTextureAtlasData() + * @see #addTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 */ - AnimationData.toString = function () { - return "[Class dragonBones.AnimationData]"; + BaseFactory.prototype.getTextureAtlasData = function (dragonBonesName) { + return this._textureAtlasDataMap[dragonBonesName]; }; /** - * @inheritDoc + * @language zh_CN + * 添加贴图集数据。 + * @param data 贴图集数据。 + * @param dragonBonesName 为数据指定一个名称,以便可以通过这个名称来访问数据,如果未设置,则使用数据中的名称。 + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #removeTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.hasAsynchronyTimeline = false; - self.cacheTimeToFrameScale = 0; - self.position = 0; - self.duration = 0; - self.playTimes = 0; - self.fadeInTime = 0; - self.name = null; - self.animation = null; - for (var i in self.boneTimelines) { - self.boneTimelines[i].returnToPool(); - delete self.boneTimelines[i]; - } - for (var i in self.slotTimelines) { - self.slotTimelines[i].returnToPool(); - delete self.slotTimelines[i]; - } - for (var i in self.ffdTimelines) { - for (var j in self.ffdTimelines[i]) { - for (var k in self.ffdTimelines[i][j]) { - self.ffdTimelines[i][j][k].returnToPool(); + BaseFactory.prototype.addTextureAtlasData = function (data, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (data) { + dragonBonesName = dragonBonesName || data.name; + if (dragonBonesName) { + var textureAtlasList = this._textureAtlasDataMap[dragonBonesName] = this._textureAtlasDataMap[dragonBonesName] || []; + if (textureAtlasList.indexOf(data) < 0) { + textureAtlasList.push(data); } } - delete self.ffdTimelines[i]; + else { + console.warn("Unnamed data."); + } } - if (self.cachedFrames.length) { - self.cachedFrames.length = 0; + else { + throw new Error(); } }; /** - * @private + * @language zh_CN + * 移除贴图集数据。 + * @param dragonBonesName 数据名称。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @see #parseTextureAtlasData() + * @see #getTextureAtlasData() + * @see #addTextureAtlasData() + * @see dragonBones.textures.TextureAtlasData + * @version DragonBones 3.0 */ - p.cacheFrames = function (value) { - var self = this; - if (self.animation) { - return; - } - var cacheFrameCount = Math.max(Math.floor(self.frameCount * self.scale * value), 1); - self.cacheTimeToFrameScale = cacheFrameCount / (self.duration + 0.000001); // - self.cachedFrames.length = 0; - self.cachedFrames.length = cacheFrameCount; - for (var i in self.boneTimelines) { - self.boneTimelines[i].cacheFrames(cacheFrameCount); - } - for (var i in self.slotTimelines) { - self.slotTimelines[i].cacheFrames(cacheFrameCount); + BaseFactory.prototype.removeTextureAtlasData = function (dragonBonesName, disposeData) { + if (disposeData === void 0) { disposeData = true; } + var textureAtlasDataList = this._textureAtlasDataMap[dragonBonesName]; + if (textureAtlasDataList) { + if (disposeData) { + for (var i = 0, l = textureAtlasDataList.length; i < l; ++i) { + textureAtlasDataList[i].returnToPool(); + } + } + delete this._textureAtlasDataMap[dragonBonesName]; } }; /** - * @private + * @language zh_CN + * 清除所有的数据。 + * @param disposeData 是否释放数据。 [false: 不释放, true: 释放] + * @version DragonBones 4.5 */ - p.addBoneTimeline = function (value) { - if (value && value.bone && !this.boneTimelines[value.bone.name]) { - this.boneTimelines[value.bone.name] = value; + BaseFactory.prototype.clear = function (disposeData) { + if (disposeData === void 0) { disposeData = true; } + for (var i in this._dragonBonesDataMap) { + if (disposeData) { + this._dragonBonesDataMap[i].returnToPool(); + } + delete this._dragonBonesDataMap[i]; } - else { - throw new Error(); + for (var i in this._textureAtlasDataMap) { + if (disposeData) { + var textureAtlasDataList = this._textureAtlasDataMap[i]; + for (var i_2 = 0, l = textureAtlasDataList.length; i_2 < l; ++i_2) { + textureAtlasDataList[i_2].returnToPool(); + } + } + delete this._textureAtlasDataMap[i]; } }; /** - * @private + * @language zh_CN + * 创建一个指定名称的骨架。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,当多个龙骨数据中包含同名的骨架数据时,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @returns 骨架 + * @see dragonBones.Armature + * @version DragonBones 3.0 */ - p.addSlotTimeline = function (value) { - if (value && value.slot && !this.slotTimelines[value.slot.name]) { - this.slotTimelines[value.slot.name] = value; - } - else { - throw new Error(); + BaseFactory.prototype.buildArmature = function (armatureName, dragonBonesName, skinName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + var dataPackage = {}; + if (this._fillBuildArmaturePackage(dragonBonesName, armatureName, skinName, dataPackage)) { + var armature = this._generateArmature(dataPackage); + this._buildBones(dataPackage, armature); + this._buildSlots(dataPackage, armature); + if (armature.armatureData.actions.length > 0) { + for (var i = 0, l = armature.armatureData.actions.length; i < l; ++i) { + armature._bufferAction(armature.armatureData.actions[i]); + } + } + armature.advanceTime(0); // Update armature pose. + return armature; } + return null; }; /** - * @private + * @language zh_CN + * 将指定骨架的动画替换成其他骨架的动画。 (通常这些骨架应该具有相同的骨架结构) + * @param toArmature 指定的骨架。 + * @param fromArmatreName 其他骨架的名称。 + * @param fromSkinName 其他骨架的皮肤名称,如果未设置,则使用默认皮肤。 + * @param fromDragonBonesDataName 其他骨架属于的龙骨数据名称,如果未设置,则检索所有的龙骨数据。 + * @param ifRemoveOriginalAnimationList 是否移除原有的动画。 [true: 移除, false: 不移除] + * @returns 是否替换成功。 [true: 成功, false: 不成功] + * @see dragonBones.Armature + * @version DragonBones 4.5 */ - p.addFFDTimeline = function (value) { - if (value && value.skin && value.slot) { - var skin = this.ffdTimelines[value.skin.name] = this.ffdTimelines[value.skin.name] || {}; - var slot = skin[value.slot.slot.name] = skin[value.slot.slot.name] || {}; - if (!slot[value.displayIndex]) { - slot[value.displayIndex] = value; + BaseFactory.prototype.copyAnimationsToArmature = function (toArmature, fromArmatreName, fromSkinName, fromDragonBonesDataName, ifRemoveOriginalAnimationList) { + if (fromSkinName === void 0) { fromSkinName = null; } + if (fromDragonBonesDataName === void 0) { fromDragonBonesDataName = null; } + if (ifRemoveOriginalAnimationList === void 0) { ifRemoveOriginalAnimationList = true; } + var dataPackage = {}; + if (this._fillBuildArmaturePackage(fromDragonBonesDataName, fromArmatreName, fromSkinName, dataPackage)) { + var fromArmatureData = dataPackage.armature; + if (ifRemoveOriginalAnimationList) { + toArmature.animation.animations = fromArmatureData.animations; } else { - throw new Error(); + var animations = {}; + for (var animationName in toArmature.animation.animations) { + animations[animationName] = toArmature.animation.animations[animationName]; + } + for (var animationName in fromArmatureData.animations) { + animations[animationName] = fromArmatureData.animations[animationName]; + } + toArmature.animation.animations = animations; + } + if (dataPackage.skin) { + var slots = toArmature.getSlots(); + for (var i = 0, l = slots.length; i < l; ++i) { + var toSlot = slots[i]; + var toSlotDisplayList = toSlot.displayList; + for (var i_3 = 0, l_2 = toSlotDisplayList.length; i_3 < l_2; ++i_3) { + var toDisplayObject = toSlotDisplayList[i_3]; + if (toDisplayObject instanceof dragonBones.Armature) { + var displays = dataPackage.skin.getSlot(toSlot.name).displays; + if (i_3 < displays.length) { + var fromDisplayData = displays[i_3]; + if (fromDisplayData.type == 1 /* Armature */) { + this.copyAnimationsToArmature(toDisplayObject, fromDisplayData.name, fromSkinName, fromDragonBonesDataName, ifRemoveOriginalAnimationList); + } + } + } + } + } + return true; } } - else { - throw new Error(); - } + return false; }; /** - * @private + * @language zh_CN + * 将指定插槽的显示对象替换为指定资源创造出的显示对象。 + * @param dragonBonesName 指定的龙骨数据名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param displayName 指定的显示对象名称。 + * @param slot 指定的插槽实例。 + * @param displayIndex 要替换的显示对象的索引,如果未设置,则替换当前正在显示的显示对象。 + * @version DragonBones 4.5 */ - p.getBoneTimeline = function (name) { - return this.boneTimelines[name]; + BaseFactory.prototype.replaceSlotDisplay = function (dragonBonesName, armatureName, slotName, displayName, slot, displayIndex) { + if (displayIndex === void 0) { displayIndex = -1; } + var dataPackage = {}; + if (this._fillBuildArmaturePackage(dragonBonesName, armatureName, null, dataPackage)) { + var slotDisplayDataSet = dataPackage.skin.getSlot(slotName); + if (slotDisplayDataSet) { + for (var i = 0, l = slotDisplayDataSet.displays.length; i < l; ++i) { + var displayData = slotDisplayDataSet.displays[i]; + if (displayData.name == displayName) { + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex); + break; + } + } + } + } }; /** - * @private + * @language zh_CN + * 将指定插槽的显示对象列表替换为指定资源创造出的显示对象列表。 + * @param dragonBonesName 指定的 DragonBonesData 名称。 + * @param armatureName 指定的骨架名称。 + * @param slotName 指定的插槽名称。 + * @param slot 指定的插槽实例。 + * @version DragonBones 4.5 */ - p.getSlotTimeline = function (name) { - return this.slotTimelines[name]; + BaseFactory.prototype.replaceSlotDisplayList = function (dragonBonesName, armatureName, slotName, slot) { + var dataPackage = {}; + if (this._fillBuildArmaturePackage(dragonBonesName, armatureName, null, dataPackage)) { + var slotDisplayDataSet = dataPackage.skin.getSlot(slotName); + if (slotDisplayDataSet) { + var displayIndex = 0; + for (var i = 0, l = slotDisplayDataSet.displays.length; i < l; ++i) { + var displayData = slotDisplayDataSet.displays[i]; + this._replaceSlotDisplay(dataPackage, displayData, slot, displayIndex++); + } + } + } }; /** - * @private + * @deprecated + * @see #clear() */ - p.getFFDTimeline = function (skinName, slotName, displayIndex) { - var skin = this.ffdTimelines[skinName]; - if (skin) { - var slot = skin[slotName]; - if (slot) { - return slot[displayIndex]; - } - } - return null; + BaseFactory.prototype.dispose = function () { + this.clear(); }; - return AnimationData; - }(dragonBones.TimelineData)); - dragonBones.AnimationData = AnimationData; - egret.registerClass(AnimationData,'dragonBones.AnimationData'); + return BaseFactory; + }()); + dragonBones.BaseFactory = BaseFactory; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { /** - * @language zh_CN - * 骨架数据。 - * @see dragonBones.Armature - * @version DragonBones 3.0 + * @private */ - var ArmatureData = (function (_super) { - __extends(ArmatureData, _super); - /** - * @private - */ - function ArmatureData() { - _super.call(this); - /** - * @private - */ - this.parent = null; - /** - * @language zh_CN - * 所有的骨骼数据。 - * @see dragonBones.BoneData - * @version DragonBones 3.0 - */ - this.bones = {}; - /** - * @language zh_CN - * 所有的插槽数据。 - * @see dragonBones.SlotData - * @version DragonBones 3.0 - */ - this.slots = {}; - /** - * @language zh_CN - * 所有的皮肤数据。 - * @see dragonBones.SkinData - * @version DragonBones 3.0 - */ - this.skins = {}; - /** - * @language zh_CN - * 所有的动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 - */ - this.animations = {}; - /** - * @private - */ - this.actions = []; - this._sortedBones = []; - this._sortedSlots = []; - this._bonesChildren = {}; + var DataParser = (function () { + function DataParser() { + this._data = null; + this._armature = null; + this._skin = null; + this._slotDisplayDataSet = null; + this._mesh = null; + this._animation = null; + this._timeline = null; + this._isOldData = false; // For 2.x ~ 3.x + this._isGlobalTransform = false; // For 2.x ~ 3.x + this._isAutoTween = false; // For 2.x ~ 3.x + this._animationTweenEasing = 0; // For 2.x ~ 3.x + this._timelinePivot = new dragonBones.Point(); // For 2.x ~ 3.x + this._armatureScale = 1; + this._helpPoint = new dragonBones.Point(); + this._helpTransformA = new dragonBones.Transform(); + this._helpTransformB = new dragonBones.Transform(); + this._helpMatrix = new dragonBones.Matrix(); + this._rawBones = []; // For skinned mesh } - var d = __define,c=ArmatureData,p=c.prototype; - ArmatureData._onSortSlots = function (a, b) { - return a.zOrder > b.zOrder ? 1 : -1; - }; - /** - * @private - */ - ArmatureData.toString = function () { - return "[Class dragonBones.ArmatureData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.frameRate = 0; - self.cacheFrameRate = 0; - self.type = 0 /* Armature */; - self.name = null; - self.parent = null; - for (var i in self.bones) { - self.bones[i].returnToPool(); - delete self.bones[i]; - } - for (var i in self.slots) { - self.slots[i].returnToPool(); - delete self.slots[i]; - } - for (var i in self.skins) { - self.skins[i].returnToPool(); - delete self.skins[i]; - } - for (var i in self.animations) { - self.animations[i].returnToPool(); - delete self.animations[i]; - } - if (self.actions.length) { - for (var i = 0, l = self.actions.length; i < l; ++i) { - self.actions[i].returnToPool(); - } - self.actions.length = 0; + DataParser._getArmatureType = function (value) { + switch (value.toLowerCase()) { + case "stage": + return 0 /* Armature */; + case "armature": + return 0 /* Armature */; + case "movieclip": + return 1 /* MovieClip */; + default: + return 0 /* Armature */; } - self._boneDirty = false; - self._slotDirty = false; - self._defaultSkin = null; - self._defaultAnimation = null; - if (self._sortedBones.length) { - self._sortedBones.length = 0; + }; + DataParser._getDisplayType = function (value) { + switch (value.toLowerCase()) { + case "image": + return 0 /* Image */; + case "armature": + return 1 /* Armature */; + case "mesh": + return 2 /* Mesh */; + default: + return 0 /* Image */; } - if (self._sortedSlots.length) { - self._sortedSlots.length = 0; + }; + DataParser._getBlendMode = function (value) { + switch (value.toLowerCase()) { + case "normal": + return 0 /* Normal */; + case "add": + return 1 /* Add */; + case "alpha": + return 2 /* Alpha */; + case "darken": + return 3 /* Darken */; + case "difference": + return 4 /* Difference */; + case "erase": + return 5 /* Erase */; + case "hardlight": + return 6 /* HardLight */; + case "invert": + return 7 /* Invert */; + case "layer": + return 8 /* Layer */; + case "lighten": + return 9 /* Lighten */; + case "multiply": + return 10 /* Multiply */; + case "overlay": + return 11 /* Overlay */; + case "screen": + return 12 /* Screen */; + case "subtract": + return 13 /* Subtract */; + default: + return 0 /* Normal */; } - for (var i in self._bonesChildren) { - delete self._bonesChildren[i]; + }; + DataParser._getActionType = function (value) { + switch (value.toLowerCase()) { + case "play": + return 0 /* Play */; + case "stop": + return 1 /* Stop */; + case "gotoandplay": + return 2 /* GotoAndPlay */; + case "gotoandstop": + return 3 /* GotoAndStop */; + case "fadein": + return 4 /* FadeIn */; + case "fadeout": + return 5 /* FadeOut */; + default: + return 4 /* FadeIn */; } }; - p._sortBones = function () { - var self = this; - var total = self._sortedBones.length; - if (!total) { - return; + DataParser.prototype._getTimelineFrameMatrix = function (animation, timeline, position, transform) { + var frameIndex = Math.floor(position * animation.frameCount / animation.duration); // uint() + if (timeline.frames.length == 1 || frameIndex >= timeline.frames.length) { + transform.copyFrom(timeline.frames[0].transform); } - var sortHelper = self._sortedBones.concat(); - var index = 0; - var count = 0; - self._sortedBones.length = 0; - while (count < total) { - var bone = sortHelper[index++]; - if (index >= total) { - index = 0; - } - if (self._sortedBones.indexOf(bone) >= 0) { - continue; - } - if (bone.parent && self._sortedBones.indexOf(bone.parent) < 0) { - continue; - } - if (bone.ik && self._sortedBones.indexOf(bone.ik) < 0) { - continue; - } - if (bone.ik && bone.chain > 0 && bone.chainIndex == bone.chain) { - self._sortedBones.splice(self._sortedBones.indexOf(bone.parent) + 1, 0, bone); + else { + var frame = timeline.frames[frameIndex]; + var tweenProgress = 0; + if (frame.tweenEasing != dragonBones.DragonBones.NO_TWEEN) { + tweenProgress = (position - frame.position) / frame.duration; + if (frame.tweenEasing != 0) { + tweenProgress = dragonBones.TweenTimelineState._getEasingValue(tweenProgress, frame.tweenEasing); + } } - else { - self._sortedBones.push(bone); + else if (frame.curve) { + tweenProgress = (position - frame.position) / frame.duration; + tweenProgress = dragonBones.TweenTimelineState._getCurveEasingValue(tweenProgress, frame.curve); } - count++; - } - }; - p._sortSlots = function () { - this._sortedSlots.sort(ArmatureData._onSortSlots); - }; - /** - * @private - */ - p.cacheFrames = function (value) { - var self = this; - if (self.cacheFrameRate == value) { - return; - } - self.cacheFrameRate = value; - var frameScale = self.cacheFrameRate / self.frameRate; - for (var i in self.animations) { - self.animations[i].cacheFrames(frameScale); + var nextFrame = frame.next; + transform.x = nextFrame.transform.x - frame.transform.x; + transform.y = nextFrame.transform.y - frame.transform.y; + transform.skewX = dragonBones.Transform.normalizeRadian(nextFrame.transform.skewX - frame.transform.skewX); + transform.skewY = dragonBones.Transform.normalizeRadian(nextFrame.transform.skewY - frame.transform.skewY); + transform.scaleX = nextFrame.transform.scaleX - frame.transform.scaleX; + transform.scaleY = nextFrame.transform.scaleY - frame.transform.scaleY; + transform.x = frame.transform.x + transform.x * tweenProgress; + transform.y = frame.transform.y + transform.y * tweenProgress; + transform.skewX = frame.transform.skewX + transform.skewX * tweenProgress; + transform.skewY = frame.transform.skewY + transform.skewY * tweenProgress; + transform.scaleX = frame.transform.scaleX + transform.scaleX * tweenProgress; + transform.scaleY = frame.transform.scaleY + transform.scaleY * tweenProgress; } + transform.add(timeline.originTransform); }; - /** - * @private - */ - p.addBone = function (value, parentName) { - var self = this; - if (value && value.name && !self.bones[value.name]) { - if (parentName) { - var parent_1 = self.getBone(parentName); - if (parent_1) { - value.parent = parent_1; - } - else { - (self._bonesChildren[parentName] = self._bonesChildren[parentName] || []).push(value); - } + DataParser.prototype._globalToLocal = function (armature) { + var keyFrames = []; + var bones = armature.sortedBones.concat().reverse(); + for (var i = 0, l = bones.length; i < l; ++i) { + var bone = bones[i]; + if (bone.parent) { + bone.parent.transform.toMatrix(this._helpMatrix); + this._helpMatrix.invert(); + this._helpMatrix.transformPoint(bone.transform.x, bone.transform.y, bone.transform); + bone.transform.rotation -= bone.parent.transform.rotation; } - var children = self._bonesChildren[value.name]; - if (children) { - for (var i = 0, l = children.length; i < l; ++i) { - children[i].parent = value; + for (var i_4 in armature.animations) { + var animation = armature.animations[i_4]; + var timeline = animation.getBoneTimeline(bone.name); + if (!timeline) { + continue; + } + var parentTimeline = bone.parent ? animation.getBoneTimeline(bone.parent.name) : null; + this._helpTransformB.copyFrom(timeline.originTransform); + keyFrames.length = 0; + for (var i_5 = 0, l_3 = timeline.frames.length; i_5 < l_3; ++i_5) { + var frame = timeline.frames[i_5]; + if (keyFrames.indexOf(frame) >= 0) { + continue; + } + keyFrames.push(frame); + if (parentTimeline) { + this._getTimelineFrameMatrix(animation, parentTimeline, frame.position, this._helpTransformA); + frame.transform.add(this._helpTransformB); + this._helpTransformA.toMatrix(this._helpMatrix); + this._helpMatrix.invert(); + this._helpMatrix.transformPoint(frame.transform.x, frame.transform.y, frame.transform); + frame.transform.rotation -= this._helpTransformA.rotation; + } + else { + frame.transform.add(this._helpTransformB); + } + frame.transform.minus(bone.transform); + if (i_5 == 0) { + timeline.originTransform.copyFrom(frame.transform); + frame.transform.identity(); + } + else { + frame.transform.minus(timeline.originTransform); + } } - delete self._bonesChildren[value.name]; } - self.bones[value.name] = value; - self._sortedBones.push(value); - self._boneDirty = true; - } - else { - throw new Error(); } }; - /** - * @private - */ - p.addSlot = function (value) { - if (value && value.name && !this.slots[value.name]) { - this.slots[value.name] = value; - this._sortedSlots.push(value); - this._slotDirty = true; + DataParser.prototype._mergeFrameToAnimationTimeline = function (frame, actions, events) { + var frameStart = Math.floor(frame.position * this._armature.frameRate); // uint() + var frames = this._animation.frames; + if (frames.length == 0) { + var startFrame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); // Add start frame. + startFrame.position = 0; + if (this._animation.frameCount > 1) { + frames.length = this._animation.frameCount + 1; // One more count for zero duration frame. + var endFrame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); // Add end frame to keep animation timeline has two different frames atleast. + endFrame.position = this._animation.frameCount / this._armature.frameRate; + frames[0] = startFrame; + frames[this._animation.frameCount] = endFrame; + } } - else { - throw new Error(); + var insertedFrame = null; + var replacedFrame = frames[frameStart]; + if (replacedFrame && (frameStart == 0 || frames[frameStart - 1] == replacedFrame.prev)) { + insertedFrame = replacedFrame; } - }; - /** - * @private - */ - p.addSkin = function (value) { - if (value && value.name && !this.skins[value.name]) { - this.skins[value.name] = value; - if (!this._defaultSkin) { - this._defaultSkin = value; + else { + insertedFrame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); // Create frame. + insertedFrame.position = frameStart / this._armature.frameRate; + frames[frameStart] = insertedFrame; + for (var i = frameStart + 1, l = frames.length; i < l; ++i) { + if (replacedFrame && frames[i] == replacedFrame) { + frames[i] = null; + } } } - else { - throw new Error(); + if (actions) { + for (var i = 0, l = actions.length; i < l; ++i) { + insertedFrame.actions.push(actions[i]); + } } - }; - /** - * @private - */ - p.addAnimation = function (value) { - if (value && value.name && !this.animations[value.name]) { - this.animations[value.name] = value; - if (!this._defaultAnimation) { - this._defaultAnimation = value; + if (events) { + for (var i = 0, l = events.length; i < l; ++i) { + insertedFrame.events.push(events[i]); } } - else { - throw new Error(); + // Modify frame link and duration. + var prevFrame = null; + var nextFrame = null; + for (var i = 0, l = frames.length; i < l; ++i) { + var currentFrame = frames[i]; + if (currentFrame && nextFrame != currentFrame) { + nextFrame = currentFrame; + if (prevFrame) { + nextFrame.prev = prevFrame; + prevFrame.next = nextFrame; + prevFrame.duration = nextFrame.position - prevFrame.position; + } + prevFrame = nextFrame; + } + else { + frames[i] = prevFrame; + } } + nextFrame.duration = this._animation.duration - nextFrame.position; + nextFrame = frames[0]; + prevFrame.next = nextFrame; + nextFrame.prev = prevFrame; }; /** - * @language zh_CN - * 获取指定名称的骨骼数据。 - * @param name 骨骼数据名称。 - * @see dragonBones.BoneData - * @version DragonBones 3.0 - */ - p.getBone = function (name) { - return this.bones[name]; - }; - /** - * @language zh_CN - * 获取指定名称的插槽数据。 - * @param name 插槽数据名称。 - * @see dragonBones.SlotData - * @version DragonBones 3.0 - */ - p.getSlot = function (name) { - return this.slots[name]; - }; - /** - * @language zh_CN - * 获取指定名称的皮肤数据。 - * @param name 皮肤数据名称。 - * @see dragonBones.SkinData - * @version DragonBones 3.0 + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() */ - p.getSkin = function (name) { - return name ? this.skins[name] : this._defaultSkin; + DataParser.parseDragonBonesData = function (rawData) { + return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); }; /** - * @language zh_CN - * 获取指定名称的动画数据。 - * @param name 动画数据名称。 - * @see dragonBones.AnimationData - * @version DragonBones 3.0 + * @deprecated + * @see dragonBones.BaseFactory#parsetTextureAtlasData() */ - p.getAnimation = function (name) { - return name ? this.animations[name] : this._defaultAnimation; - }; - d(p, "sortedBones" - /** - * @private - */ - ,function () { - if (this._boneDirty) { - this._boneDirty = false; - this._sortBones(); - } - return this._sortedBones; - } - ); - d(p, "sortedSlots" - /** - * @private - */ - ,function () { - if (this._slotDirty) { - this._slotDirty = false; - this._sortSlots(); + DataParser.parseTextureAtlasData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + var textureAtlasData = {}; + var subTextureList = rawData[DataParser.SUB_TEXTURE]; + for (var i = 0, len = subTextureList.length; i < len; i++) { + var subTextureObject = subTextureList[i]; + var subTextureName = subTextureObject[DataParser.NAME]; + var subTextureRegion = new dragonBones.Rectangle(); + var subTextureFrame = null; + subTextureRegion.x = subTextureObject[DataParser.X] / scale; + subTextureRegion.y = subTextureObject[DataParser.Y] / scale; + subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; + subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; + if (DataParser.FRAME_WIDTH in subTextureObject) { + subTextureFrame = new dragonBones.Rectangle(); + subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; + subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; + subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; + subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; } - return this._sortedSlots; + textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; } - ); - d(p, "defaultSkin" - /** - * @language zh_CN - * 获取默认的皮肤数据。 - * @see dragonBones.SkinData - * @version DragonBones 4.5 - */ - ,function () { - return this._defaultSkin; - } - ); - d(p, "defaultAnimation" - /** - * @language zh_CN - * 获取默认的动画数据。 - * @see dragonBones.AnimationData - * @version DragonBones 4.5 - */ - ,function () { - return this._defaultAnimation; - } - ); - return ArmatureData; - }(dragonBones.BaseObject)); - dragonBones.ArmatureData = ArmatureData; - egret.registerClass(ArmatureData,'dragonBones.ArmatureData'); - /** - * @language zh_CN - * 骨骼数据。 - * @see dragonBones.Bone - * @version DragonBones 3.0 - */ - var BoneData = (function (_super) { - __extends(BoneData, _super); - /** - * @private - */ - function BoneData() { - _super.call(this); - /** - * @private - */ - this.transform = new dragonBones.Transform(); - } - var d = __define,c=BoneData,p=c.prototype; - /** - * @private - */ - BoneData.toString = function () { - return "[Class dragonBones.BoneData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.inheritTranslation = false; - self.inheritRotation = false; - self.inheritScale = false; - self.bendPositive = false; - self.chain = 0; - self.chainIndex = 0; - self.weight = 0; - self.length = 0; - self.name = null; - self.parent = null; - self.ik = null; - self.transform.identity(); + return textureAtlasData; }; - return BoneData; - }(dragonBones.BaseObject)); - dragonBones.BoneData = BoneData; - egret.registerClass(BoneData,'dragonBones.BoneData'); + DataParser.DATA_VERSION_2_3 = "2.3"; + DataParser.DATA_VERSION_3_0 = "3.0"; + DataParser.DATA_VERSION_4_0 = "4.0"; + DataParser.DATA_VERSION = "4.5"; + DataParser.TEXTURE_ATLAS = "TextureAtlas"; + DataParser.SUB_TEXTURE = "SubTexture"; + DataParser.FORMAT = "format"; + DataParser.IMAGE_PATH = "imagePath"; + DataParser.WIDTH = "width"; + DataParser.HEIGHT = "height"; + DataParser.ROTATED = "rotated"; + DataParser.FRAME_X = "frameX"; + DataParser.FRAME_Y = "frameY"; + DataParser.FRAME_WIDTH = "frameWidth"; + DataParser.FRAME_HEIGHT = "frameHeight"; + DataParser.DRADON_BONES = "dragonBones"; + DataParser.ARMATURE = "armature"; + DataParser.BONE = "bone"; + DataParser.IK = "ik"; + DataParser.SLOT = "slot"; + DataParser.SKIN = "skin"; + DataParser.DISPLAY = "display"; + DataParser.ANIMATION = "animation"; + DataParser.FFD = "ffd"; + DataParser.FRAME = "frame"; + DataParser.PIVOT = "pivot"; + DataParser.TRANSFORM = "transform"; + DataParser.AABB = "aabb"; + DataParser.COLOR = "color"; + DataParser.FILTER = "filter"; + DataParser.VERSION = "version"; + DataParser.IS_GLOBAL = "isGlobal"; + DataParser.FRAME_RATE = "frameRate"; + DataParser.TYPE = "type"; + DataParser.NAME = "name"; + DataParser.PARENT = "parent"; + DataParser.LENGTH = "length"; + DataParser.DATA = "data"; + DataParser.DISPLAY_INDEX = "displayIndex"; + DataParser.Z_ORDER = "z"; + DataParser.BLEND_MODE = "blendMode"; + DataParser.INHERIT_TRANSLATION = "inheritTranslation"; + DataParser.INHERIT_ROTATION = "inheritRotation"; + DataParser.INHERIT_SCALE = "inheritScale"; + DataParser.TARGET = "target"; + DataParser.BEND_POSITIVE = "bendPositive"; + DataParser.CHAIN = "chain"; + DataParser.WEIGHT = "weight"; + DataParser.FADE_IN_TIME = "fadeInTime"; + DataParser.PLAY_TIMES = "playTimes"; + DataParser.SCALE = "scale"; + DataParser.OFFSET = "offset"; + DataParser.POSITION = "position"; + DataParser.DURATION = "duration"; + DataParser.TWEEN_EASING = "tweenEasing"; + DataParser.TWEEN_ROTATE = "tweenRotate"; + DataParser.TWEEN_SCALE = "tweenScale"; + DataParser.CURVE = "curve"; + DataParser.EVENT = "event"; + DataParser.SOUND = "sound"; + DataParser.ACTION = "action"; + DataParser.ACTIONS = "actions"; + DataParser.DEFAULT_ACTIONS = "defaultActions"; + DataParser.X = "x"; + DataParser.Y = "y"; + DataParser.SKEW_X = "skX"; + DataParser.SKEW_Y = "skY"; + DataParser.SCALE_X = "scX"; + DataParser.SCALE_Y = "scY"; + DataParser.ALPHA_OFFSET = "aO"; + DataParser.RED_OFFSET = "rO"; + DataParser.GREEN_OFFSET = "gO"; + DataParser.BLUE_OFFSET = "bO"; + DataParser.ALPHA_MULTIPLIER = "aM"; + DataParser.RED_MULTIPLIER = "rM"; + DataParser.GREEN_MULTIPLIER = "gM"; + DataParser.BLUE_MULTIPLIER = "bM"; + DataParser.UVS = "uvs"; + DataParser.VERTICES = "vertices"; + DataParser.TRIANGLES = "triangles"; + DataParser.WEIGHTS = "weights"; + DataParser.SLOT_POSE = "slotPose"; + DataParser.BONE_POSE = "bonePose"; + DataParser.TWEEN = "tween"; + DataParser.KEY = "key"; + DataParser.COLOR_TRANSFORM = "colorTransform"; + DataParser.TIMELINE = "timeline"; + DataParser.PIVOT_X = "pX"; + DataParser.PIVOT_Y = "pY"; + DataParser.LOOP = "loop"; + DataParser.AUTO_TWEEN = "autoTween"; + DataParser.HIDE = "hide"; + DataParser.RECTANGLE = "rectangle"; + DataParser.ELLIPSE = "ellipse"; + return DataParser; + }()); + dragonBones.DataParser = DataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { /** - * @language zh_CN - * 插槽数据。 - * @see dragonBones.Slot - * @version DragonBones 3.0 + * @private */ - var SlotData = (function (_super) { - __extends(SlotData, _super); + var ObjectDataParser = (function (_super) { + __extends(ObjectDataParser, _super); /** * @private */ - function SlotData() { + function ObjectDataParser() { _super.call(this); - /** - * @private - */ - this.actions = []; } - var d = __define,c=SlotData,p=c.prototype; /** * @private */ - SlotData.generateColor = function () { - return new dragonBones.ColorTransform(); + ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + var valueType = typeof value; + if (valueType == "boolean") { + return value; + } + else if (valueType == "string") { + switch (value) { + case "0": + case "NaN": + case "": + case "false": + case "null": + case "undefined": + return false; + default: + return true; + } + } + else { + return Boolean(value); + } + } + return defaultValue; }; /** * @private */ - SlotData.toString = function () { - return "[Class dragonBones.SlotData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.displayIndex = 0; - self.zOrder = 0; - self.blendMode = 0 /* Normal */; - self.name = null; - self.parent = null; - self.color = null; - if (self.actions.length) { - for (var i = 0, l = self.actions.length; i < l; ++i) { - self.actions[i].returnToPool(); + ObjectDataParser._getNumber = function (rawData, key, defaultValue) { + if (key in rawData) { + var value = rawData[key]; + if (value == null || value == "NaN") { + return defaultValue; } - self.actions.length = 0; + return Number(value); } + return defaultValue; }; /** * @private */ - SlotData.DEFAULT_COLOR = new dragonBones.ColorTransform(); - return SlotData; - }(dragonBones.BaseObject)); - dragonBones.SlotData = SlotData; - egret.registerClass(SlotData,'dragonBones.SlotData'); - /** - * @language zh_CN - * 皮肤数据。 - * @version DragonBones 3.0 - */ - var SkinData = (function (_super) { - __extends(SkinData, _super); - /** - * @private - */ - function SkinData() { - _super.call(this); - /** - * @language zh_CN - * 数据名称。 - * @version DragonBones 3.0 - */ - this.name = null; - /** - * @private - */ - this.slots = {}; - } - var d = __define,c=SkinData,p=c.prototype; - /** - * @private - */ - SkinData.toString = function () { - return "[Class dragonBones.SkinData]"; + ObjectDataParser._getString = function (rawData, key, defaultValue) { + if (key in rawData) { + return String(rawData[key]); + } + return defaultValue; }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - self.name = null; - for (var i in self.slots) { - self.slots[i].returnToPool(); - delete self.slots[i]; + ObjectDataParser._getParameter = function (rawData, index, defaultValue) { + if (rawData && rawData.length > index) { + return rawData[index]; } + return defaultValue; }; /** * @private */ - p.addSlot = function (value) { - if (value && value.slot && !this.slots[value.slot.name]) { - this.slots[value.slot.name] = value; + ObjectDataParser.prototype._parseArmature = function (rawData) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); + armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); + armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate) || this._data.frameRate; + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] == "string") { + armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); } else { - throw new Error(); + armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Armature */); } - }; - /** - * @private - */ - p.getSlot = function (name) { - return this.slots[name]; - }; - return SkinData; - }(dragonBones.BaseObject)); - dragonBones.SkinData = SkinData; - egret.registerClass(SkinData,'dragonBones.SkinData'); - /** - * @private - */ - var SlotDisplayDataSet = (function (_super) { - __extends(SlotDisplayDataSet, _super); - function SlotDisplayDataSet() { - _super.call(this); - this.displays = []; - } - var d = __define,c=SlotDisplayDataSet,p=c.prototype; - SlotDisplayDataSet.toString = function () { - return "[Class dragonBones.SlotDisplayDataSet]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - this.slot = null; - if (this.displays.length) { - for (var i = 0, l = this.displays.length; i < l; ++i) { - this.displays[i].returnToPool(); - } - this.displays.length = 0; - } - }; - return SlotDisplayDataSet; - }(dragonBones.BaseObject)); - dragonBones.SlotDisplayDataSet = SlotDisplayDataSet; - egret.registerClass(SlotDisplayDataSet,'dragonBones.SlotDisplayDataSet'); - /** - * @private - */ - var DisplayData = (function (_super) { - __extends(DisplayData, _super); - function DisplayData() { - _super.call(this); - this.pivot = new dragonBones.Point(); - this.transform = new dragonBones.Transform(); - } - var d = __define,c=DisplayData,p=c.prototype; - DisplayData.toString = function () { - return "[Class dragonBones.DisplayData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.isRelativePivot = false; - self.type = 0 /* Image */; - self.name = null; - self.textureData = null; - self.armatureData = null; - if (self.meshData) { - self.meshData.returnToPool(); - self.meshData = null; - } - self.pivot.clear(); - self.transform.identity(); - }; - return DisplayData; - }(dragonBones.BaseObject)); - dragonBones.DisplayData = DisplayData; - egret.registerClass(DisplayData,'dragonBones.DisplayData'); - /** - * @private - */ - var MeshData = (function (_super) { - __extends(MeshData, _super); - function MeshData() { - _super.call(this); - this.slotPose = new dragonBones.Matrix(); - this.uvs = []; // vertices * 2 - this.vertices = []; // vertices * 2 - this.vertexIndices = []; // triangles * 3 - this.boneIndices = []; // vertices bones - this.weights = []; // vertices bones - this.boneVertices = []; // vertices bones * 2 - this.bones = []; // bones - this.inverseBindPose = []; // bones - } - var d = __define,c=MeshData,p=c.prototype; - MeshData.toString = function () { - return "[Class dragonBones.MeshData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - self.skinned = false; - self.slotPose.identity(); - if (self.uvs.length) { - self.uvs.length = 0; + this._armature = armature; + this._rawBones.length = 0; + if (ObjectDataParser.AABB in rawData) { + var aabbObject = rawData[ObjectDataParser.AABB]; + armature.aabb.x = ObjectDataParser._getNumber(aabbObject, ObjectDataParser.X, 0); + armature.aabb.y = ObjectDataParser._getNumber(aabbObject, ObjectDataParser.Y, 0); + armature.aabb.width = ObjectDataParser._getNumber(aabbObject, ObjectDataParser.WIDTH, 0); + armature.aabb.height = ObjectDataParser._getNumber(aabbObject, ObjectDataParser.HEIGHT, 0); } - if (self.vertices.length) { - self.vertices.length = 0; + if (ObjectDataParser.BONE in rawData) { + var bones = rawData[ObjectDataParser.BONE]; + for (var i = 0, l = bones.length; i < l; ++i) { + var boneObject = bones[i]; + var bone = this._parseBone(boneObject); + armature.addBone(bone, ObjectDataParser._getString(boneObject, ObjectDataParser.PARENT, null)); + this._rawBones.push(bone); + } } - if (self.vertexIndices.length) { - self.vertexIndices.length = 0; + if (ObjectDataParser.IK in rawData) { + var iks = rawData[ObjectDataParser.IK]; + for (var i = 0, l = iks.length; i < l; ++i) { + this._parseIK(iks[i]); + } } - if (self.boneIndices.length) { - self.boneIndices.length = 0; + if (ObjectDataParser.SLOT in rawData) { + var slots = rawData[ObjectDataParser.SLOT]; + for (var i = 0, l = slots.length; i < l; ++i) { + armature.addSlot(this._parseSlot(slots[i])); + } } - if (self.weights.length) { - self.weights.length = 0; + if (ObjectDataParser.SKIN in rawData) { + var skins = rawData[ObjectDataParser.SKIN]; + for (var i = 0, l = skins.length; i < l; ++i) { + armature.addSkin(this._parseSkin(skins[i])); + } } - if (self.boneVertices.length) { - self.boneVertices.length = 0; + if (ObjectDataParser.ANIMATION in rawData) { + var animations = rawData[ObjectDataParser.ANIMATION]; + for (var i = 0, l = animations.length; i < l; ++i) { + armature.addAnimation(this._parseAnimation(animations[i])); + } } - if (self.bones.length) { - self.bones.length = 0; + if ((ObjectDataParser.ACTIONS in rawData) || + (ObjectDataParser.DEFAULT_ACTIONS in rawData)) { + this._parseActionData(rawData, armature.actions, null, null); } - if (self.inverseBindPose.length) { - self.inverseBindPose.length = 0; + if (this._isOldData && this._isGlobalTransform) { + this._globalToLocal(armature); } + this._armature = null; + this._rawBones.length = 0; + return armature; }; - return MeshData; - }(dragonBones.BaseObject)); - dragonBones.MeshData = MeshData; - egret.registerClass(MeshData,'dragonBones.MeshData'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @language zh_CN - * 龙骨数据,包含多个骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - */ - var DragonBonesData = (function (_super) { - __extends(DragonBonesData, _super); /** * @private */ - function DragonBonesData() { - _super.call(this); - /** - * @language zh_CN - * 所有的骨架数据。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 - */ - this.armatures = {}; - this._armatureNames = []; - } - var d = __define,c=DragonBonesData,p=c.prototype; + ObjectDataParser.prototype._parseBone = function (rawData) { + var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); + bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); + bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); + bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); + bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); + bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armatureScale; + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform); + } + if (this._isOldData) { + bone.inheritRotation = true; + bone.inheritScale = false; + } + return bone; + }; /** * @private */ - DragonBonesData.toString = function () { - return "[Class dragonBones.DragonBonesData]"; + ObjectDataParser.prototype._parseIK = function (rawData) { + var bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, null)); + if (bone) { + bone.ik = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, null)); + bone.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); + bone.chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); + bone.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1); + if (bone.chain > 0 && bone.parent && !bone.parent.ik) { + bone.parent.ik = bone.ik; + bone.parent.chainIndex = 0; + bone.parent.chain = 0; + bone.chainIndex = 1; + } + else { + bone.chain = 0; + bone.chainIndex = 0; + } + } }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - self.autoSearch = false; - self.frameRate = 0; - self.name = null; - for (var i in self.armatures) { - self.armatures[i].returnToPool(); - delete self.armatures[i]; + ObjectDataParser.prototype._parseSlot = function (rawData) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); + slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); + slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, null)); + slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + slot.zOrder = ObjectDataParser._getNumber(rawData, ObjectDataParser.Z_ORDER, this._armature.sortedSlots.length); // TODO zOrder. + if (ObjectDataParser.COLOR in rawData) { + slot.color = dragonBones.SlotData.generateColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); + } + else { + slot.color = dragonBones.SlotData.DEFAULT_COLOR; + } + if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] == "string") { + slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); + } + else { + slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, 0 /* Normal */); + } + if ((ObjectDataParser.ACTIONS in rawData) || + (ObjectDataParser.DEFAULT_ACTIONS in rawData)) { + this._parseActionData(rawData, slot.actions, null, null); } - if (self._armatureNames.length) { - self._armatureNames.length = 0; + if (this._isOldData) { + if (ObjectDataParser.COLOR_TRANSFORM in rawData) { + slot.color = dragonBones.SlotData.generateColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR_TRANSFORM], slot.color); + } + else { + slot.color = dragonBones.SlotData.DEFAULT_COLOR; + } } + return slot; }; /** - * @language zh_CN - * 获取指定名称的骨架。 - * @param name 骨架数据骨架名称。 - * @see dragonBones.ArmatureData - * @version DragonBones 3.0 + * @private */ - p.getArmature = function (name) { - return this.armatures[name]; + ObjectDataParser.prototype._parseSkin = function (rawData) { + var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); + skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "__default") || "__default"; + if (ObjectDataParser.SLOT in rawData) { + this._skin = skin; + var slots = rawData[ObjectDataParser.SLOT]; + for (var i = 0, l = slots.length; i < l; ++i) { + if (this._isOldData) { + this._armature.addSlot(this._parseSlot(slots[i])); + } + skin.addSlot(this._parseSlotDisplaySet(slots[i])); + } + this._skin = null; + } + return skin; }; /** * @private */ - p.addArmature = function (value) { - if (value && value.name && !this.armatures[value.name]) { - this.armatures[value.name] = value; - this._armatureNames.push(value.name); - value.parent = this; - } - else { - throw new Error(); + ObjectDataParser.prototype._parseSlotDisplaySet = function (rawData) { + var slotDisplayDataSet = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayDataSet); + slotDisplayDataSet.slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null)); + if (ObjectDataParser.DISPLAY in rawData) { + var displayObjectSet = rawData[ObjectDataParser.DISPLAY]; + var displayDataSet = slotDisplayDataSet.displays; + this._slotDisplayDataSet = slotDisplayDataSet; + for (var i = 0, l = displayObjectSet.length; i < l; ++i) { + displayDataSet.push(this._parseDisplay(displayObjectSet[i])); + } + this._slotDisplayDataSet = null; } + return slotDisplayDataSet; }; - d(p, "armatureNames" - /** - * @language zh_CN - * 所有的骨架数据名称。 - * @see #armatures - * @version DragonBones 3.0 - */ - ,function () { - return this._armatureNames; - } - ); /** - * @deprecated - * @see dragonBones.BaseFactory#removeDragonBonesData() + * @private */ - p.dispose = function () { - this.returnToPool(); - }; - return DragonBonesData; - }(dragonBones.BaseObject)); - dragonBones.DragonBonesData = DragonBonesData; - egret.registerClass(DragonBonesData,'dragonBones.DragonBonesData'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var ActionData = (function (_super) { - __extends(ActionData, _super); - function ActionData() { - _super.call(this); - } - var d = __define,c=ActionData,p=c.prototype; - ActionData.toString = function () { - return "[Class dragonBones.ActionData]"; - }; - p._onClear = function () { - var self = this; - self.type = 0 /* Play */; - self.data = null; - self.bone = null; - self.slot = null; - }; - return ActionData; - }(dragonBones.BaseObject)); - dragonBones.ActionData = ActionData; - egret.registerClass(ActionData,'dragonBones.ActionData'); - /** - * @private - */ - var EventData = (function (_super) { - __extends(EventData, _super); - function EventData() { - _super.call(this); - } - var d = __define,c=EventData,p=c.prototype; - EventData.toString = function () { - return "[Class dragonBones.EventData]"; - }; - p._onClear = function () { - var self = this; - self.type = 0 /* Frame */; - self.name = null; - self.data = null; - self.bone = null; - self.slot = null; + ObjectDataParser.prototype._parseDisplay = function (rawData) { + var display = dragonBones.BaseObject.borrowObject(dragonBones.DisplayData); + display.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); + if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] == "string") { + display.type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); + } + else { + display.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Image */); + } + display.isRelativePivot = true; + if (ObjectDataParser.PIVOT in rawData) { + var pivotObject = rawData[ObjectDataParser.PIVOT]; + display.pivot.x = ObjectDataParser._getNumber(pivotObject, ObjectDataParser.X, 0); + display.pivot.y = ObjectDataParser._getNumber(pivotObject, ObjectDataParser.Y, 0); + } + else if (this._isOldData) { + var transformObject = rawData[ObjectDataParser.TRANSFORM]; + display.isRelativePivot = false; + display.pivot.x = ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_X, 0) * this._armatureScale; + display.pivot.y = ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_Y, 0) * this._armatureScale; + } + else { + display.pivot.x = 0.5; + display.pivot.y = 0.5; + } + if (ObjectDataParser.TRANSFORM in rawData) { + this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform); + } + switch (display.type) { + case 0 /* Image */: + break; + case 1 /* Armature */: + break; + case 2 /* Mesh */: + display.mesh = this._parseMesh(rawData); + break; + } + return display; }; - return EventData; - }(dragonBones.BaseObject)); - dragonBones.EventData = EventData; - egret.registerClass(EventData,'dragonBones.EventData'); - /** - * @private - */ - var FrameData = (function (_super) { - __extends(FrameData, _super); - function FrameData() { - _super.call(this); - } - var d = __define,c=FrameData,p=c.prototype; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - self.position = 0; - self.duration = 0; - self.prev = null; - self.next = null; - }; - return FrameData; - }(dragonBones.BaseObject)); - dragonBones.FrameData = FrameData; - egret.registerClass(FrameData,'dragonBones.FrameData'); - /** - * @private - */ - var TweenFrameData = (function (_super) { - __extends(TweenFrameData, _super); - function TweenFrameData() { - _super.call(this); - } - var d = __define,c=TweenFrameData,p=c.prototype; - TweenFrameData.samplingCurve = function (curve, frameCount) { - if (curve.length == 0 || frameCount == 0) { - return null; + ObjectDataParser.prototype._parseMesh = function (rawData) { + var mesh = dragonBones.BaseObject.borrowObject(dragonBones.MeshData); + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var rawUVs = rawData[ObjectDataParser.UVS]; + var rawTriangles = rawData[ObjectDataParser.TRIANGLES]; + var numVertices = Math.floor(rawVertices.length / 2); // uint() + var numTriangles = Math.floor(rawTriangles.length / 3); // uint() + var inverseBindPose = new Array(this._armature.sortedBones.length); + mesh.skinned = (ObjectDataParser.WEIGHTS in rawData) && rawData[ObjectDataParser.WEIGHTS].length > 0; + mesh.uvs.length = numVertices * 2; + mesh.vertices.length = numVertices * 2; + mesh.vertexIndices.length = numTriangles * 3; + if (mesh.skinned) { + mesh.boneIndices.length = numVertices; + mesh.weights.length = numVertices; + mesh.boneVertices.length = numVertices; + if (ObjectDataParser.SLOT_POSE in rawData) { + var rawSlotPose = rawData[ObjectDataParser.SLOT_POSE]; + mesh.slotPose.a = rawSlotPose[0]; + mesh.slotPose.b = rawSlotPose[1]; + mesh.slotPose.c = rawSlotPose[2]; + mesh.slotPose.d = rawSlotPose[3]; + mesh.slotPose.tx = rawSlotPose[4]; + mesh.slotPose.ty = rawSlotPose[5]; + } + if (ObjectDataParser.BONE_POSE in rawData) { + var rawBonePose = rawData[ObjectDataParser.BONE_POSE]; + for (var i = 0, l = rawBonePose.length; i < l; i += 7) { + var rawBoneIndex = rawBonePose[i]; + var boneMatrix = inverseBindPose[rawBoneIndex] = new dragonBones.Matrix(); + boneMatrix.a = rawBonePose[i + 1]; + boneMatrix.b = rawBonePose[i + 2]; + boneMatrix.c = rawBonePose[i + 3]; + boneMatrix.d = rawBonePose[i + 4]; + boneMatrix.tx = rawBonePose[i + 5]; + boneMatrix.ty = rawBonePose[i + 6]; + boneMatrix.invert(); + } + } } - var samplingTimes = frameCount + 2; - var samplingStep = 1 / samplingTimes; - var sampling = new Array((samplingTimes - 1) * 2); - // - curve.unshift(0, 0); - curve.push(1, 1); - var stepIndex = 0; - for (var i = 0; i < samplingTimes - 1; ++i) { - var step = samplingStep * (i + 1); - while (curve[stepIndex + 6] < step) { - stepIndex += 6; // stepIndex += 3 * 2 + for (var i = 0, iW = 0, l = rawVertices.length; i < l; i += 2) { + var iN = i + 1; + var vertexIndex = i / 2; + var x = mesh.vertices[i] = rawVertices[i] * this._armatureScale; + var y = mesh.vertices[iN] = rawVertices[iN] * this._armatureScale; + mesh.uvs[i] = rawUVs[i]; + mesh.uvs[iN] = rawUVs[iN]; + if (mesh.skinned) { + var rawWeights = rawData[ObjectDataParser.WEIGHTS]; + var numBones = rawWeights[iW]; + var indices = mesh.boneIndices[vertexIndex] = new Array(numBones); + var weights = mesh.weights[vertexIndex] = new Array(numBones); + var boneVertices = mesh.boneVertices[vertexIndex] = new Array(numBones * 2); + mesh.slotPose.transformPoint(x, y, this._helpPoint); + x = mesh.vertices[i] = this._helpPoint.x; + y = mesh.vertices[iN] = this._helpPoint.y; + for (var iB = 0; iB < numBones; ++iB) { + var iI = iW + 1 + iB * 2; + var rawBoneIndex = rawWeights[iI]; + var boneData = this._rawBones[rawBoneIndex]; + var boneIndex = mesh.bones.indexOf(boneData); + if (boneIndex < 0) { + boneIndex = mesh.bones.length; + mesh.bones[boneIndex] = boneData; + mesh.inverseBindPose[boneIndex] = inverseBindPose[rawBoneIndex]; + } + mesh.inverseBindPose[boneIndex].transformPoint(x, y, this._helpPoint); + indices[iB] = boneIndex; + weights[iB] = rawWeights[iI + 1]; + boneVertices[iB * 2] = this._helpPoint.x; + boneVertices[iB * 2 + 1] = this._helpPoint.y; + } + iW += numBones * 2 + 1; } - var x1 = curve[stepIndex]; - var x4 = curve[stepIndex + 6]; - var t = (step - x1) / (x4 - x1); - var l_t = 1 - t; - var powA = l_t * l_t; - var powB = t * t; - var kA = l_t * powA; - var kB = 3 * t * powA; - var kC = 3 * l_t * powB; - var kD = t * powB; - sampling[i * 2] = kA * x1 + kB * curve[stepIndex + 2] + kC * curve[stepIndex + 4] + kD * x4; - sampling[i * 2 + 1] = kA * curve[stepIndex + 1] + kB * curve[stepIndex + 3] + kC * curve[stepIndex + 5] + kD * curve[stepIndex + 7]; } - return sampling; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - _super.prototype._onClear.call(this); - this.tweenEasing = 0; - this.curve = null; - }; - return TweenFrameData; - }(FrameData)); - dragonBones.TweenFrameData = TweenFrameData; - egret.registerClass(TweenFrameData,'dragonBones.TweenFrameData'); - /** - * @private - */ - var AnimationFrameData = (function (_super) { - __extends(AnimationFrameData, _super); - function AnimationFrameData() { - _super.call(this); - this.actions = []; - this.events = []; - } - var d = __define,c=AnimationFrameData,p=c.prototype; - AnimationFrameData.toString = function () { - return "[Class dragonBones.AnimationFrameData]"; + for (var i = 0, l = rawTriangles.length; i < l; ++i) { + mesh.vertexIndices[i] = rawTriangles[i]; + } + return mesh; }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - if (self.actions.length) { - for (var i = 0, l = self.actions.length; i < l; ++i) { - self.actions[i].returnToPool(); + ObjectDataParser.prototype._parseAnimation = function (rawData) { + var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); + animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "__default") || "__default"; + animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); + animation.position = ObjectDataParser._getNumber(rawData, ObjectDataParser.POSITION, 0) / this._armature.frameRate; + animation.duration = animation.frameCount / this._armature.frameRate; + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); + animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0); + this._animation = animation; + var animationName = ObjectDataParser._getString(rawData, ObjectDataParser.ANIMATION, null); + if (animationName) { + animation.animation = this._armature.getAnimation(animationName); + if (!animation.animation) { } - self.actions.length = 0; + return animation; } - if (self.events.length) { - for (var i = 0, l = self.events.length; i < l; ++i) { - self.events[i].returnToPool(); + this._parseTimeline(rawData, animation, this._parseAnimationFrame); + if (ObjectDataParser.BONE in rawData) { + var boneTimelines = rawData[ObjectDataParser.BONE]; + for (var i = 0, l = boneTimelines.length; i < l; ++i) { + animation.addBoneTimeline(this._parseBoneTimeline(boneTimelines[i])); } - self.events.length = 0; } + if (ObjectDataParser.SLOT in rawData) { + var slotTimelines = rawData[ObjectDataParser.SLOT]; + for (var i = 0, l = slotTimelines.length; i < l; ++i) { + animation.addSlotTimeline(this._parseSlotTimeline(slotTimelines[i])); + } + } + if (ObjectDataParser.FFD in rawData) { + var ffdTimelines = rawData[ObjectDataParser.FFD]; + for (var i = 0, l = ffdTimelines.length; i < l; ++i) { + animation.addFFDTimeline(this._parseFFDTimeline(ffdTimelines[i])); + } + } + if (this._isOldData) { + this._isAutoTween = ObjectDataParser._getBoolean(rawData, ObjectDataParser.AUTO_TWEEN, true); + this._animationTweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, 0) || 0; + animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.LOOP, 1); + if (ObjectDataParser.TIMELINE in rawData) { + var timelines = rawData[ObjectDataParser.TIMELINE]; + for (var i = 0, l = timelines.length; i < l; ++i) { + animation.addBoneTimeline(this._parseBoneTimeline(timelines[i])); + } + for (var i = 0, l = timelines.length; i < l; ++i) { + animation.addSlotTimeline(this._parseSlotTimeline(timelines[i])); + } + } + } + else { + this._isAutoTween = false; + this._animationTweenEasing = 0; + } + for (var i in this._armature.bones) { + var bone = this._armature.bones[i]; + if (!animation.getBoneTimeline(bone.name)) { + var boneTimeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTimelineData); + var boneFrame = dragonBones.BaseObject.borrowObject(dragonBones.BoneFrameData); + boneTimeline.bone = bone; + boneTimeline.frames[0] = boneFrame; + animation.addBoneTimeline(boneTimeline); + } + } + for (var i in this._armature.slots) { + var slot = this._armature.slots[i]; + if (!animation.getSlotTimeline(slot.name)) { + var slotTimeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotTimelineData); + var slotFrame = dragonBones.BaseObject.borrowObject(dragonBones.SlotFrameData); + slotTimeline.slot = slot; + slotFrame.displayIndex = slot.displayIndex; + //slotFrame.zOrder = -2; // TODO zOrder. + if (slot.color == dragonBones.SlotData.DEFAULT_COLOR) { + slotFrame.color = dragonBones.SlotFrameData.DEFAULT_COLOR; + } + else { + slotFrame.color = dragonBones.SlotFrameData.generateColor(); + slotFrame.color.copyFrom(slot.color); + } + slotTimeline.frames[0] = slotFrame; + animation.addSlotTimeline(slotTimeline); + if (this._isOldData) { + slotFrame.displayIndex = -1; + } + } + } + this._animation = null; + return animation; }; - return AnimationFrameData; - }(FrameData)); - dragonBones.AnimationFrameData = AnimationFrameData; - egret.registerClass(AnimationFrameData,'dragonBones.AnimationFrameData'); - /** - * @private - */ - var BoneFrameData = (function (_super) { - __extends(BoneFrameData, _super); - function BoneFrameData() { - _super.call(this); - this.transform = new dragonBones.Transform(); - } - var d = __define,c=BoneFrameData,p=c.prototype; - BoneFrameData.toString = function () { - return "[Class dragonBones.BoneFrameData]"; - }; - /** - * @inheritDoc - */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.tweenScale = false; - self.tweenRotate = 0; - self.transform.identity(); - }; - return BoneFrameData; - }(TweenFrameData)); - dragonBones.BoneFrameData = BoneFrameData; - egret.registerClass(BoneFrameData,'dragonBones.BoneFrameData'); - /** - * @private - */ - var SlotFrameData = (function (_super) { - __extends(SlotFrameData, _super); - function SlotFrameData() { - _super.call(this); - } - var d = __define,c=SlotFrameData,p=c.prototype; - SlotFrameData.generateColor = function () { - return new dragonBones.ColorTransform(); - }; - SlotFrameData.toString = function () { - return "[Class dragonBones.SlotFrameData]"; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneTimeline = function (rawData) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTimelineData); + timeline.bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null)); + this._parseTimeline(rawData, timeline, this._parseBoneFrame); + var originTransform = timeline.originTransform; + var prevFrame = null; + for (var i = 0, l = timeline.frames.length; i < l; ++i) { + var frame = timeline.frames[i]; + if (!prevFrame) { + originTransform.copyFrom(frame.transform); + frame.transform.identity(); + if (originTransform.scaleX == 0) { + originTransform.scaleX = 0.001; + } + if (originTransform.scaleY == 0) { + originTransform.scaleY = 0.001; + } + } + else if (prevFrame != frame) { + frame.transform.minus(originTransform); + } + prevFrame = frame; + } + if (timeline.scale != 1 || timeline.offset != 0) { + this._animation.hasAsynchronyTimeline = true; + } + if (this._isOldData && + ((ObjectDataParser.PIVOT_X in rawData) || + (ObjectDataParser.PIVOT_Y in rawData))) { + this._timelinePivot.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.PIVOT_X, 0); + this._timelinePivot.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.PIVOT_Y, 0); + } + else { + this._timelinePivot.clear(); + } + return timeline; }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.displayIndex = 0; - self.zOrder = 0; - self.color = null; + ObjectDataParser.prototype._parseSlotTimeline = function (rawData) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotTimelineData); + timeline.slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null)); + this._parseTimeline(rawData, timeline, this._parseSlotFrame); + if (timeline.scale != 1 || timeline.offset != 0) { + this._animation.hasAsynchronyTimeline = true; + } + return timeline; }; - SlotFrameData.DEFAULT_COLOR = new dragonBones.ColorTransform(); - return SlotFrameData; - }(TweenFrameData)); - dragonBones.SlotFrameData = SlotFrameData; - egret.registerClass(SlotFrameData,'dragonBones.SlotFrameData'); - /** - * @private - */ - var ExtensionFrameData = (function (_super) { - __extends(ExtensionFrameData, _super); - function ExtensionFrameData() { - _super.call(this); - this.tweens = []; - this.keys = []; - } - var d = __define,c=ExtensionFrameData,p=c.prototype; - ExtensionFrameData.toString = function () { - return "[Class dragonBones.ExtensionFrameData]"; + /** + * @private + */ + ObjectDataParser.prototype._parseFFDTimeline = function (rawData) { + var timeline = dragonBones.BaseObject.borrowObject(dragonBones.FFDTimelineData); + timeline.skin = this._armature.getSkin(ObjectDataParser._getString(rawData, ObjectDataParser.SKIN, null)); + timeline.slot = timeline.skin.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.SLOT, null)); // NAME; + var meshName = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); + for (var i = 0, l = timeline.slot.displays.length; i < l; ++i) { + var displayData = timeline.slot.displays[i]; + if (displayData.mesh && displayData.name == meshName) { + timeline.displayIndex = i; // rawData[DISPLAY_INDEX]; + this._mesh = displayData.mesh; // Find the ffd's mesh. + break; + } + } + this._parseTimeline(rawData, timeline, this._parseFFDFrame); + this._mesh = null; + return timeline; }; /** - * @inheritDoc + * @private */ - p._onClear = function () { - var self = this; - _super.prototype._onClear.call(this); - self.type = 0 /* FFD */; - if (self.tweens.length) { - self.tweens.length = 0; + ObjectDataParser.prototype._parseAnimationFrame = function (rawData, frameStart, frameCount) { + var frame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); + this._parseFrame(rawData, frame, frameStart, frameCount); + if ((ObjectDataParser.ACTION in rawData) || + (ObjectDataParser.ACTIONS in rawData)) { + this._parseActionData(rawData, frame.actions, null, null); } - if (self.keys.length) { - self.keys.length = 0; + if ((ObjectDataParser.EVENT in rawData) || (ObjectDataParser.SOUND in rawData)) { + this._parseEventData(rawData, frame.events, null, null); } + return frame; }; - return ExtensionFrameData; - }(TweenFrameData)); - dragonBones.ExtensionFrameData = ExtensionFrameData; - egret.registerClass(ExtensionFrameData,'dragonBones.ExtensionFrameData'); -})(dragonBones || (dragonBones = {})); -var dragonBones; -(function (dragonBones) { - /** - * @private - */ - var DataParser = (function () { - function DataParser() { - this._data = null; - this._armature = null; - this._skin = null; - this._slotDisplayDataSet = null; - this._mesh = null; - this._animation = null; - this._timeline = null; - this._isParentCooriinate = false; - this._isAutoTween = false; - this._animationTweenEasing = 0; - this._armatureScale = 1; - this._helpPoint = new dragonBones.Point(); - this._helpTransform = new dragonBones.Transform(); - this._helpMatrix = new dragonBones.Matrix(); - this._rawBones = []; - } - var d = __define,c=DataParser,p=c.prototype; - DataParser._getArmatureType = function (value) { - switch (value.toLowerCase()) { - case "stage": - return 0 /* Armature */; - case "armature": - return 0 /* Armature */; - case "movieClip": - return 1 /* MovieClip */; - default: - return 0 /* Armature */; + /** + * @private + */ + ObjectDataParser.prototype._parseBoneFrame = function (rawData, frameStart, frameCount) { + var frame = dragonBones.BaseObject.borrowObject(dragonBones.BoneFrameData); + frame.tweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0); + frame.tweenScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.TWEEN_SCALE, true); + this._parseTweenFrame(rawData, frame, frameStart, frameCount); + if (ObjectDataParser.TRANSFORM in rawData) { + var transformObject = rawData[ObjectDataParser.TRANSFORM]; + this._parseTransform(transformObject, frame.transform); + if (this._isOldData) { + this._helpPoint.x = this._timelinePivot.x + ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_X, 0); + this._helpPoint.y = this._timelinePivot.y + ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_Y, 0); + frame.transform.toMatrix(this._helpMatrix); + this._helpMatrix.transformPoint(this._helpPoint.x, this._helpPoint.y, this._helpPoint, true); + frame.transform.x += this._helpPoint.x; + frame.transform.y += this._helpPoint.y; + } } - }; - DataParser._getDisplayType = function (value) { - switch (value.toLowerCase()) { - case "image": - return 0 /* Image */; - case "armature": - return 1 /* Armature */; - case "mesh": - return 2 /* Mesh */; - default: - return 0 /* Image */; + var bone = this._timeline.bone; + if ((ObjectDataParser.ACTION in rawData) || + (ObjectDataParser.ACTIONS in rawData)) { + var slot = this._armature.getSlot(bone.name); + var actions = []; + this._parseActionData(rawData, actions, bone, slot); + this._mergeFrameToAnimationTimeline(frame, actions, null); // Merge actions and events to animation timeline. } + if ((ObjectDataParser.EVENT in rawData) || (ObjectDataParser.SOUND in rawData)) { + var events = []; + this._parseEventData(rawData, events, bone, null); + this._mergeFrameToAnimationTimeline(frame, null, events); // Merge actions and events to animation timeline. + } + return frame; }; - DataParser._getBlendMode = function (value) { - switch (value.toLowerCase()) { - case "normal": - return 0 /* Normal */; - case "add": - return 1 /* Add */; - case "alpha": - return 2 /* Alpha */; - case "darken": - return 3 /* Darken */; - case "difference": - return 4 /* Difference */; - case "erase": - return 5 /* Erase */; - case "hardlight": - return 6 /* HardLight */; - case "invert": - return 7 /* Invert */; - case "layer": - return 8 /* Layer */; - case "lighten": - return 9 /* Lighten */; - case "multiply": - return 10 /* Multiply */; - case "overlay": - return 11 /* Overlay */; - case "screen": - return 12 /* Screen */; - case "subtract": - return 13 /* Subtract */; - default: - return 0 /* Normal */; + /** + * @private + */ + ObjectDataParser.prototype._parseSlotFrame = function (rawData, frameStart, frameCount) { + var frame = dragonBones.BaseObject.borrowObject(dragonBones.SlotFrameData); + frame.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); + //frame.zOrder = _getNumber(rawData, Z_ORDER, -1); // TODO zorder + this._parseTweenFrame(rawData, frame, frameStart, frameCount); + if ((ObjectDataParser.COLOR in rawData) || + (ObjectDataParser.COLOR_TRANSFORM in rawData)) { + frame.color = dragonBones.SlotFrameData.generateColor(); + this._parseColorTransform(rawData[ObjectDataParser.COLOR] || rawData[ObjectDataParser.COLOR_TRANSFORM], frame.color); + } + else { + frame.color = dragonBones.SlotFrameData.DEFAULT_COLOR; + } + if (this._isOldData) { + if (ObjectDataParser._getBoolean(rawData, ObjectDataParser.HIDE, false)) { + frame.displayIndex = -1; + } + } + else if ((ObjectDataParser.ACTION in rawData) || + (ObjectDataParser.ACTIONS in rawData)) { + var slot = this._timeline.slot; + var actions = []; + this._parseActionData(rawData, actions, slot.parent, slot); + this._mergeFrameToAnimationTimeline(frame, actions, null); // Merge actions and events to animation timeline. } + return frame; }; - DataParser._getActionType = function (value) { - switch (value.toLowerCase()) { - case "play": - return 0 /* Play */; - case "stop": - return 1 /* Stop */; - case "gotoandplay": - return 2 /* GotoAndPlay */; - case "gotoandstop": - return 3 /* GotoAndStop */; - case "fadein": - return 4 /* FadeIn */; - case "fadeout": - return 5 /* FadeOut */; - default: - return 4 /* FadeIn */; + /** + * @private + */ + ObjectDataParser.prototype._parseFFDFrame = function (rawData, frameStart, frameCount) { + var frame = dragonBones.BaseObject.borrowObject(dragonBones.ExtensionFrameData); + frame.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* FFD */); + this._parseTweenFrame(rawData, frame, frameStart, frameCount); + var rawVertices = rawData[ObjectDataParser.VERTICES]; + var offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); + var x = 0; + var y = 0; + for (var i = 0, l = this._mesh.vertices.length; i < l; i += 2) { + if (!rawVertices || i < offset || i - offset >= rawVertices.length) { + x = 0; + y = 0; + } + else { + x = rawVertices[i - offset] * this._armatureScale; + y = rawVertices[i + 1 - offset] * this._armatureScale; + } + if (this._mesh.skinned) { + this._mesh.slotPose.transformPoint(x, y, this._helpPoint, true); + x = this._helpPoint.x; + y = this._helpPoint.y; + var boneIndices = this._mesh.boneIndices[i / 2]; + for (var iB = 0, lB = boneIndices.length; iB < lB; ++iB) { + var boneIndex = boneIndices[iB]; + this._mesh.inverseBindPose[boneIndex].transformPoint(x, y, this._helpPoint, true); + frame.tweens.push(this._helpPoint.x, this._helpPoint.y); + } + } + else { + frame.tweens.push(x, y); + } } + return frame; }; - p._getTimelineFrameMatrix = function (animation, timeline, position, transform) { - var frameIndex = Math.floor(position * animation.frameCount / animation.duration); // uint() - if (timeline.frames.length == 1 || frameIndex >= timeline.frames.length) { - transform.copyFrom(timeline.frames[0].transform); + /** + * @private + */ + ObjectDataParser.prototype._parseTweenFrame = function (rawData, frame, frameStart, frameCount) { + this._parseFrame(rawData, frame, frameStart, frameCount); + if (frame.duration > 0) { + if (ObjectDataParser.TWEEN_EASING in rawData) { + frame.tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, dragonBones.DragonBones.NO_TWEEN); + } + else if (this._isOldData) { + frame.tweenEasing = this._isAutoTween ? this._animationTweenEasing : dragonBones.DragonBones.NO_TWEEN; + } + else { + frame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; + } + if (this._isOldData && this._animation.scale == 1 && this._timeline.scale == 1 && frame.duration * this._armature.frameRate < 2) { + frame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; + } + if (ObjectDataParser.CURVE in rawData) { + frame.curve = dragonBones.TweenFrameData.samplingCurve(rawData[ObjectDataParser.CURVE], frameCount); + } } else { - var frame = timeline.frames[frameIndex]; - var tweenProgress = 0; - if (frame.duration > 0 && frame.tweenEasing != dragonBones.DragonBones.NO_TWEEN) { - tweenProgress = (position - frame.position) / frame.duration; - if (frame.tweenEasing != 0) { - tweenProgress = dragonBones.TweenTimelineState._getEasingValue(tweenProgress, frame.tweenEasing); + frame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; + frame.curve = null; + } + }; + /** + * @private + */ + ObjectDataParser.prototype._parseFrame = function (rawData, frame, frameStart, frameCount) { + frame.position = frameStart / this._armature.frameRate; + frame.duration = frameCount / this._armature.frameRate; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTimeline = function (rawData, timeline, frameParser) { + timeline.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1); + timeline.offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); + this._timeline = timeline; + if (ObjectDataParser.FRAME in rawData) { + var rawFrames = rawData[ObjectDataParser.FRAME]; + if (rawFrames.length) { + if (rawFrames.length == 1) { + timeline.frames.length = 1; + timeline.frames[0] = frameParser.call(this, rawFrames[0], 0, ObjectDataParser._getNumber(rawFrames[0], ObjectDataParser.DURATION, 1)); + } + else { + timeline.frames.length = this._animation.frameCount + 1; + var frameStart = 0; + var frameCount = 0; + var frame = null; + var prevFrame = null; + for (var i = 0, iW = 0, l = this._animation.frameCount + 1; i < l; ++i) { + if (frameStart + frameCount <= i && iW < rawFrames.length) { + var frameObject = rawFrames[iW++]; + frameStart = i; + frameCount = ObjectDataParser._getNumber(frameObject, ObjectDataParser.DURATION, 1); + frame = frameParser.call(this, frameObject, frameStart, frameCount); + if (prevFrame) { + prevFrame.next = frame; + frame.prev = prevFrame; + if (this._isOldData) { + if (prevFrame instanceof dragonBones.TweenFrameData && frameObject[ObjectDataParser.DISPLAY_INDEX] == -1) { + prevFrame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; + } + } + } + prevFrame = frame; + } + timeline.frames[i] = frame; + } + frame.duration = this._animation.duration - frame.position; // Modify last frame duration. + frame = timeline.frames[0]; + prevFrame.next = frame; + frame.prev = prevFrame; + if (this._isOldData) { + if (prevFrame instanceof dragonBones.TweenFrameData && rawFrames[0][ObjectDataParser.DISPLAY_INDEX] == -1) { + prevFrame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; + } + } + } + } + } + this._timeline = null; + }; + /** + * @private + */ + ObjectDataParser.prototype._parseActionData = function (rawData, actions, bone, slot) { + var actionsObject = rawData[ObjectDataParser.ACTION] || rawData[ObjectDataParser.ACTIONS] || rawData[ObjectDataParser.DEFAULT_ACTIONS]; + if (typeof actionsObject == "string") { + var actionData = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + actionData.type = 4 /* FadeIn */; + actionData.data = [actionsObject, -1, -1]; + actionData.bone = bone; + actionData.slot = slot; + actions.push(actionData); + } + else if (actionsObject instanceof Array) { + for (var i = 0, l = actionsObject.length; i < l; ++i) { + var actionObject = (actionsObject[i] instanceof Array ? actionsObject[i] : null); + var actionData = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); + var animationName = actionObject ? null : actionsObject[i]["gotoAndPlay"]; + if (actionObject) { + var actionType = actionObject[0]; + if (typeof actionType == "string") { + actionData.type = ObjectDataParser._getActionType(actionType); + } + else { + actionData.type = ObjectDataParser._getParameter(actionObject, 0, 4 /* FadeIn */); + } + } + else { + actionData.type = 2 /* GotoAndPlay */; + } + switch (actionData.type) { + case 0 /* Play */: + actionData.data = [ + actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, + ObjectDataParser._getParameter(actionObject, 2, -1), + ]; + break; + case 1 /* Stop */: + actionData.data = [ + actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, + ]; + break; + case 2 /* GotoAndPlay */: + actionData.data = [ + actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, + ObjectDataParser._getParameter(actionObject, 2, 0), + ObjectDataParser._getParameter(actionObject, 3, -1) // playTimes + ]; + break; + case 3 /* GotoAndStop */: + actionData.data = [ + actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, + ObjectDataParser._getParameter(actionObject, 2, 0), + ]; + break; + case 4 /* FadeIn */: + actionData.data = [ + actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, + ObjectDataParser._getParameter(actionObject, 2, -1), + ObjectDataParser._getParameter(actionObject, 3, -1) // playTimes + ]; + break; + case 5 /* FadeOut */: + actionData.data = [ + actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, + ObjectDataParser._getParameter(actionObject, 2, 0) // fadeOutTime + ]; + break; } + actionData.bone = bone; + actionData.slot = slot; + actions.push(actionData); } - else if (frame.curve) { - tweenProgress = (position - frame.position) / frame.duration; - tweenProgress = dragonBones.TweenTimelineState._getCurveEasingValue(tweenProgress, frame.curve); - } - transform.x = frame.next.transform.x - frame.transform.x; - transform.y = frame.next.transform.y - frame.transform.y; - transform.skewX = dragonBones.Transform.normalizeRadian(frame.next.transform.skewX - frame.transform.skewX); - transform.skewY = dragonBones.Transform.normalizeRadian(frame.next.transform.skewY - frame.transform.skewY); - transform.scaleX = frame.next.transform.scaleX - frame.transform.scaleX; - transform.scaleY = frame.next.transform.scaleY - frame.transform.scaleY; - transform.x = frame.transform.x + transform.x * tweenProgress; - transform.y = frame.transform.y + transform.y * tweenProgress; - transform.skewX = frame.transform.skewX + transform.skewX * tweenProgress; - transform.skewY = frame.transform.skewY + transform.skewY * tweenProgress; - transform.scaleX = frame.transform.scaleX + transform.scaleX * tweenProgress; - transform.scaleY = frame.transform.scaleY + transform.scaleY * tweenProgress; } - transform.add(timeline.originTransform); }; - p._mergeFrameToAnimationTimeline = function (frame, actions, events) { - var frameStart = Math.floor(frame.position * this._armature.frameRate); // uint() - var frames = this._animation.frames; - if (frames.length == 0) { - var startFrame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); // Add start frame. - startFrame.position = 0; - if (this._animation.frameCount > 1) { - frames.length = this._animation.frameCount + 1; // One more count for zero duration frame. - var endFrame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); // Add end frame to keep animation timeline has two different frames atleast. - endFrame.position = this._animation.frameCount / this._armature.frameRate; - frames[0] = startFrame; - frames[this._animation.frameCount] = endFrame; - } - } - var insertedFrame = null; - var replacedFrame = frames[frameStart]; - if (replacedFrame && (frameStart == 0 || frames[frameStart - 1] == replacedFrame.prev)) { - insertedFrame = replacedFrame; + /** + * @private + */ + ObjectDataParser.prototype._parseEventData = function (rawData, events, bone, slot) { + if (ObjectDataParser.SOUND in rawData) { + var soundEventData = dragonBones.BaseObject.borrowObject(dragonBones.EventData); + soundEventData.type = 1 /* Sound */; + soundEventData.name = rawData[ObjectDataParser.SOUND]; + soundEventData.bone = bone; + soundEventData.slot = slot; + events.push(soundEventData); } - else { - insertedFrame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); // Create frame. - insertedFrame.position = frameStart / this._armature.frameRate; - frames[frameStart] = insertedFrame; - for (var i = frameStart + 1, l = frames.length; i < l; ++i) { - if (replacedFrame && frames[i] == replacedFrame) { - frames[i] = null; - } + if (ObjectDataParser.EVENT in rawData) { + var eventData = dragonBones.BaseObject.borrowObject(dragonBones.EventData); + eventData.type = 0 /* Frame */; + eventData.name = rawData[ObjectDataParser.EVENT]; + eventData.bone = bone; + eventData.slot = slot; + if (ObjectDataParser.DATA in rawData) { + eventData.data = rawData[ObjectDataParser.DATA]; } + events.push(eventData); } - if (actions) { - for (var i = 0, l = actions.length; i < l; ++i) { - insertedFrame.actions.push(actions[i]); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseTransform = function (rawData, transform) { + transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0) * this._armatureScale; + transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0) * this._armatureScale; + transform.skewX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0) * dragonBones.DragonBones.ANGLE_TO_RADIAN; + transform.skewY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0) * dragonBones.DragonBones.ANGLE_TO_RADIAN; + transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1); + transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1); + }; + /** + * @private + */ + ObjectDataParser.prototype._parseColorTransform = function (rawData, color) { + color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; + color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; + color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; + color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; + color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); + color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); + color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); + color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + }; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseDragonBonesData = function (rawData, scale) { + if (scale === void 0) { scale = 1; } + if (rawData) { + var version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, null); + this._isOldData = version == ObjectDataParser.DATA_VERSION_2_3 || version == ObjectDataParser.DATA_VERSION_3_0; + if (this._isOldData) { + this._isGlobalTransform = ObjectDataParser._getBoolean(rawData, ObjectDataParser.IS_GLOBAL, true); } - } - if (events) { - for (var i = 0, l = events.length; i < l; ++i) { - insertedFrame.events.push(events[i]); + else { + this._isGlobalTransform = false; } - } - // Modify frame link and duration. - var prevFrame = null; - var nextFrame = null; - for (var i = 0, l = frames.length; i < l; ++i) { - var currentFrame = frames[i]; - if (currentFrame && nextFrame != currentFrame) { - nextFrame = currentFrame; - if (prevFrame) { - nextFrame.prev = prevFrame; - prevFrame.next = nextFrame; - prevFrame.duration = nextFrame.position - prevFrame.position; + this._armatureScale = scale; + if (version == ObjectDataParser.DATA_VERSION || + version == ObjectDataParser.DATA_VERSION_4_0 || + this._isOldData) { + var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); + data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); + data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24) || 24; + if (ObjectDataParser.ARMATURE in rawData) { + this._data = data; + var armatures = rawData[ObjectDataParser.ARMATURE]; + for (var i = 0, l = armatures.length; i < l; ++i) { + data.addArmature(this._parseArmature(armatures[i])); + } + this._data = null; } - prevFrame = nextFrame; + return data; } else { - frames[i] = prevFrame; + throw new Error("Nonsupport data version."); } } - nextFrame.duration = this._animation.duration - nextFrame.position; - nextFrame = frames[0]; - prevFrame.next = nextFrame; - nextFrame.prev = prevFrame; + else { + throw new Error(); + } + // return null; }; - p._globalToLocal = function (armature) { - var keyFrames = []; - var bones = armature.sortedBones.concat().reverse(); - for (var i = 0, l = bones.length; i < l; ++i) { - var bone = bones[i]; - if (bone.parent) { - bone.parent.transform.toMatrix(this._helpMatrix); - this._helpMatrix.invert(); - this._helpMatrix.transformPoint(bone.transform.x, bone.transform.y, bone.transform); - bone.transform.rotation -= bone.parent.transform.rotation; + /** + * @inheritDoc + */ + ObjectDataParser.prototype.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { + if (scale === void 0) { scale = 0; } + if (rawData) { + textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); + textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, null); + // Texture format. + if (scale > 0) { + textureAtlasData.scale = scale; } - for (var i_4 in armature.animations) { - var animation = armature.animations[i_4]; - var timeline = animation.getBoneTimeline(bone.name); - if (!timeline) { - continue; - } - var parentTimeline = timeline.bone.parent ? animation.getBoneTimeline(timeline.bone.parent.name) : null; - keyFrames.length = 0; - for (var i_5 = 0, l_3 = timeline.frames.length; i_5 < l_3; ++i_5) { - var frame = timeline.frames[i_5]; - if (keyFrames.indexOf(frame) >= 0) { - continue; - } - keyFrames.push(frame); - if (parentTimeline) { - this._getTimelineFrameMatrix(animation, parentTimeline, frame.position, this._helpTransform); - frame.transform.add(timeline.originTransform); - this._helpTransform.toMatrix(this._helpMatrix); - this._helpMatrix.invert(); - this._helpMatrix.transformPoint(frame.transform.x, frame.transform.y, frame.transform); - frame.transform.rotation -= this._helpTransform.rotation; - } - else { - frame.transform.add(timeline.originTransform); - } - } - keyFrames.length = 0; - for (var i_6 = 0, l_4 = timeline.frames.length; i_6 < l_4; ++i_6) { - var frame = timeline.frames[i_6]; - if (keyFrames.indexOf(frame) >= 0) { - continue; - } - keyFrames.push(frame); - frame.transform.minus(timeline.bone.transform); - if (i_6 == 0) { - timeline.originTransform.copyFrom(frame.transform); - frame.transform.identity(); - } - else { - frame.transform.minus(timeline.originTransform); + else { + scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + } + scale = 1 / scale; + if (ObjectDataParser.SUB_TEXTURE in rawData) { + var textures = rawData[ObjectDataParser.SUB_TEXTURE]; + for (var i = 0, l = textures.length; i < l; ++i) { + var textureObject = textures[i]; + var textureData = textureAtlasData.generateTextureData(); + textureData.name = ObjectDataParser._getString(textureObject, ObjectDataParser.NAME, null); + textureData.rotated = ObjectDataParser._getBoolean(textureObject, ObjectDataParser.ROTATED, false); + textureData.region.x = ObjectDataParser._getNumber(textureObject, ObjectDataParser.X, 0) * scale; + textureData.region.y = ObjectDataParser._getNumber(textureObject, ObjectDataParser.Y, 0) * scale; + textureData.region.width = ObjectDataParser._getNumber(textureObject, ObjectDataParser.WIDTH, 0) * scale; + textureData.region.height = ObjectDataParser._getNumber(textureObject, ObjectDataParser.HEIGHT, 0) * scale; + var frameWidth = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_WIDTH, -1); + var frameHeight = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_HEIGHT, -1); + if (frameWidth > 0 && frameHeight > 0) { + textureData.frame = dragonBones.TextureData.generateRectangle(); + textureData.frame.x = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_X, 0) * scale; + textureData.frame.y = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_Y, 0) * scale; + textureData.frame.width = frameWidth * scale; + textureData.frame.height = frameHeight * scale; } + textureAtlasData.addTextureData(textureData); } } + return textureAtlasData; + } + else { + throw new Error(); + } + // return null; + }; + /** + * @deprecated + * @see dragonBones.BaseFactory#parseDragonBonesData() + */ + ObjectDataParser.getInstance = function () { + if (!ObjectDataParser._instance) { + ObjectDataParser._instance = new ObjectDataParser(); + } + return ObjectDataParser._instance; + }; + /** + * @private + */ + ObjectDataParser._instance = null; + return ObjectDataParser; + }(dragonBones.DataParser)); + dragonBones.ObjectDataParser = ObjectDataParser; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * 贴图集数据。 + * @version DragonBones 3.0 + */ + var TextureAtlasData = (function (_super) { + __extends(TextureAtlasData, _super); + /** + * @private + */ + function TextureAtlasData() { + _super.call(this); + /** + * @private + */ + this.textures = {}; + } + /** + * @inheritDoc + */ + TextureAtlasData.prototype._onClear = function () { + this.autoSearch = false; + this.scale = 1; + this.name = null; + this.imagePath = null; + for (var i in this.textures) { + this.textures[i].returnToPool(); + delete this.textures[i]; } }; /** * @deprecated - * @see dragonBones.BaseFactory#parseDragonBonesData() + * @see dragonBones.BaseFactory#removeDragonBonesData() */ - DataParser.parseDragonBonesData = function (rawData) { - return dragonBones.ObjectDataParser.getInstance().parseDragonBonesData(rawData); + TextureAtlasData.prototype.dispose = function () { + this.returnToPool(); }; /** - * @deprecated - * @see dragonBones.BaseFactory#parsetTextureAtlasData() + * @private */ - DataParser.parseTextureAtlasData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - var textureAtlasData = {}; - var subTextureList = rawData[DataParser.SUB_TEXTURE]; - for (var i = 0, len = subTextureList.length; i < len; i++) { - var subTextureObject = subTextureList[i]; - var subTextureName = subTextureObject[DataParser.NAME]; - var subTextureRegion = new dragonBones.Rectangle(); - var subTextureFrame = null; - subTextureRegion.x = subTextureObject[DataParser.X] / scale; - subTextureRegion.y = subTextureObject[DataParser.Y] / scale; - subTextureRegion.width = subTextureObject[DataParser.WIDTH] / scale; - subTextureRegion.height = subTextureObject[DataParser.HEIGHT] / scale; - if (DataParser.FRAME_WIDTH in subTextureObject) { - subTextureFrame = new dragonBones.Rectangle(); - subTextureFrame.x = subTextureObject[DataParser.FRAME_X] / scale; - subTextureFrame.y = subTextureObject[DataParser.FRAME_Y] / scale; - subTextureFrame.width = subTextureObject[DataParser.FRAME_WIDTH] / scale; - subTextureFrame.height = subTextureObject[DataParser.FRAME_HEIGHT] / scale; - } - textureAtlasData[subTextureName] = { region: subTextureRegion, frame: subTextureFrame, rotated: false }; + TextureAtlasData.prototype.addTextureData = function (value) { + if (value && value.name && !this.textures[value.name]) { + this.textures[value.name] = value; + value.parent = this; + } + else { } - return textureAtlasData; }; - DataParser.DATA_VERSION_2_3 = "2.3"; - DataParser.DATA_VERSION_3_0 = "3.0"; - DataParser.DATA_VERSION_4_0 = "4.0"; - DataParser.DATA_VERSION = "4.5"; - DataParser.TEXTURE_ATLAS = "TextureAtlas"; - DataParser.SUB_TEXTURE = "SubTexture"; - DataParser.FORMAT = "format"; - DataParser.IMAGE_PATH = "imagePath"; - DataParser.WIDTH = "width"; - DataParser.HEIGHT = "height"; - DataParser.ROTATED = "rotated"; - DataParser.FRAME_X = "frameX"; - DataParser.FRAME_Y = "frameY"; - DataParser.FRAME_WIDTH = "frameWidth"; - DataParser.FRAME_HEIGHT = "frameHeight"; - DataParser.DRADON_BONES = "dragonBones"; - DataParser.ARMATURE = "armature"; - DataParser.BONE = "bone"; - DataParser.IK = "ik"; - DataParser.SLOT = "slot"; - DataParser.SKIN = "skin"; - DataParser.DISPLAY = "display"; - DataParser.ANIMATION = "animation"; - DataParser.FFD = "ffd"; - DataParser.FRAME = "frame"; - DataParser.PIVOT = "pivot"; - DataParser.TRANSFORM = "transform"; - DataParser.COLOR = "color"; - DataParser.FILTER = "filter"; - DataParser.VERSION = "version"; - DataParser.IS_GLOBAL = "isGlobal"; - DataParser.FRAME_RATE = "frameRate"; - DataParser.TYPE = "type"; - DataParser.NAME = "name"; - DataParser.PARENT = "parent"; - DataParser.LENGTH = "length"; - DataParser.DATA = "data"; - DataParser.DISPLAY_INDEX = "displayIndex"; - DataParser.Z_ORDER = "z"; - DataParser.BLEND_MODE = "blendMode"; - DataParser.INHERIT_TRANSLATION = "inheritTranslation"; - DataParser.INHERIT_ROTATION = "inheritRotation"; - DataParser.INHERIT_SCALE = "inheritScale"; - DataParser.TARGET = "target"; - DataParser.BEND_POSITIVE = "bendPositive"; - DataParser.CHAIN = "chain"; - DataParser.WEIGHT = "weight"; - DataParser.FADE_IN_TIME = "fadeInTime"; - DataParser.PLAY_TIMES = "playTimes"; - DataParser.SCALE = "scale"; - DataParser.OFFSET = "offset"; - DataParser.POSITION = "position"; - DataParser.DURATION = "duration"; - DataParser.TWEEN_EASING = "tweenEasing"; - DataParser.TWEEN_ROTATE = "tweenRotate"; - DataParser.TWEEN_SCALE = "tweenScale"; - DataParser.CURVE = "curve"; - DataParser.EVENT = "event"; - DataParser.SOUND = "sound"; - DataParser.ACTION = "action"; - DataParser.ACTIONS = "actions"; - DataParser.DEFAULT_ACTIONS = "defaultActions"; - DataParser.X = "x"; - DataParser.Y = "y"; - DataParser.SKEW_X = "skX"; - DataParser.SKEW_Y = "skY"; - DataParser.SCALE_X = "scX"; - DataParser.SCALE_Y = "scY"; - DataParser.ALPHA_OFFSET = "aO"; - DataParser.RED_OFFSET = "rO"; - DataParser.GREEN_OFFSET = "gO"; - DataParser.BLUE_OFFSET = "bO"; - DataParser.ALPHA_MULTIPLIER = "aM"; - DataParser.RED_MULTIPLIER = "rM"; - DataParser.GREEN_MULTIPLIER = "gM"; - DataParser.BLUE_MULTIPLIER = "bM"; - DataParser.UVS = "uvs"; - DataParser.VERTICES = "vertices"; - DataParser.TRIANGLES = "triangles"; - DataParser.WEIGHTS = "weights"; - DataParser.SLOT_POSE = "slotPose"; - DataParser.BONE_POSE = "bonePose"; - DataParser.TWEEN = "tween"; - DataParser.KEY = "key"; - DataParser.COLOR_TRANSFORM = "colorTransform"; - DataParser.TIMELINE = "timeline"; - DataParser.PIVOT_X = "pX"; - DataParser.PIVOT_Y = "pY"; - DataParser.LOOP = "loop"; - DataParser.AUTO_TWEEN = "autoTween"; - DataParser.HIDE = "hide"; - DataParser.RECTANGLE = "rectangle"; - DataParser.ELLIPSE = "ellipse"; - return DataParser; - }()); - dragonBones.DataParser = DataParser; - egret.registerClass(DataParser,'dragonBones.DataParser'); + /** + * @private + */ + TextureAtlasData.prototype.getTextureData = function (name) { + return this.textures[name]; + }; + return TextureAtlasData; + }(dragonBones.BaseObject)); + dragonBones.TextureAtlasData = TextureAtlasData; + /** + * @private + */ + var TextureData = (function (_super) { + __extends(TextureData, _super); + function TextureData() { + _super.call(this); + this.region = new dragonBones.Rectangle(); + } + TextureData.generateRectangle = function () { + return new dragonBones.Rectangle(); + }; + /** + * @inheritDoc + */ + TextureData.prototype._onClear = function () { + this.rotated = false; + this.name = null; + this.frame = null; + this.parent = null; + this.region.clear(); + }; + return TextureData; + }(dragonBones.BaseObject)); + dragonBones.TextureData = TextureData; })(dragonBones || (dragonBones = {})); var dragonBones; (function (dragonBones) { + /** + * @language zh_CN + * Egret 贴图集数据。 + * @version DragonBones 3.0 + */ + var EgretTextureAtlasData = (function (_super) { + __extends(EgretTextureAtlasData, _super); + /** + * @private + */ + function EgretTextureAtlasData() { + _super.call(this); + } + /** + * @private + */ + EgretTextureAtlasData.toString = function () { + return "[class dragonBones.EgretTextureAtlasData]"; + }; + /** + * @inheritDoc + */ + EgretTextureAtlasData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.texture) { + //this.texture.dispose(); + this.texture = null; + } + }; + /** + * @private + */ + EgretTextureAtlasData.prototype.generateTextureData = function () { + return dragonBones.BaseObject.borrowObject(EgretTextureData); + }; + return EgretTextureAtlasData; + }(dragonBones.TextureAtlasData)); + dragonBones.EgretTextureAtlasData = EgretTextureAtlasData; /** * @private */ - var ObjectDataParser = (function (_super) { - __extends(ObjectDataParser, _super); + var EgretTextureData = (function (_super) { + __extends(EgretTextureData, _super); + function EgretTextureData() { + _super.call(this); + } + EgretTextureData.toString = function () { + return "[class dragonBones.EgretTextureData]"; + }; + /** + * @inheritDoc + */ + EgretTextureData.prototype._onClear = function () { + _super.prototype._onClear.call(this); + if (this.texture) { + this.texture.dispose(); + this.texture = null; + } + }; + return EgretTextureData; + }(dragonBones.TextureData)); + dragonBones.EgretTextureData = EgretTextureData; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * Egret 事件。 + * @version DragonBones 4.5 + */ + var EgretEvent = (function (_super) { + __extends(EgretEvent, _super); + /** + * @private + */ + function EgretEvent(type, bubbles, cancelable, data) { + _super.call(this, type, bubbles, cancelable, data); + } + Object.defineProperty(EgretEvent.prototype, "eventObject", { + /** + * @language zh_CN + * 事件对象。 + * @version DragonBones 4.5 + */ + get: function () { + return this.data; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "frameLabel", { + /** + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "sound", { + /** + * @see dragonBones.EventObject#name + */ + get: function () { + return this.eventObject.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationName", { + /** + * @see dragonBones.EventObject#animationName + */ + get: function () { + return this.eventObject.animationState.name; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "armature", { + /** + * @see dragonBones.EventObject#armature + */ + get: function () { + return this.eventObject.armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "bone", { + /** + * @see dragonBones.EventObject#bone + */ + get: function () { + return this.eventObject.bone; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "slot", { + /** + * @see dragonBones.EventObject#slot + */ + get: function () { + return this.eventObject.slot; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "animationState", { + /** + * @see dragonBones.EventObject#animationState + */ + get: function () { + return this.eventObject.animationState; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretEvent.prototype, "movementID", { + /** + * @deprecated + * @see #animationName + */ + get: function () { + return this.animationName; + }, + enumerable: true, + configurable: true + }); /** - * @private + * @see dragonBones.EventObject.START */ - function ObjectDataParser() { - _super.call(this); - } - var d = __define,c=ObjectDataParser,p=c.prototype; + EgretEvent.START = dragonBones.EventObject.START; /** - * @private + * @see dragonBones.EventObject.LOOP_COMPLETE */ - ObjectDataParser._getBoolean = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - var valueType = typeof value; - if (valueType == "boolean") { - return value; - } - else if (valueType == "string") { - switch (value) { - case "0": - case "NaN": - case "": - case "false": - case "null": - case "undefined": - return false; - default: - return true; - } - } - else { - return Boolean(value); - } - } - return defaultValue; - }; + EgretEvent.LOOP_COMPLETE = dragonBones.EventObject.LOOP_COMPLETE; /** - * @private + * @see dragonBones.EventObject.COMPLETE */ - ObjectDataParser._getNumber = function (rawData, key, defaultValue) { - if (key in rawData) { - var value = rawData[key]; - if (value == null || value == "NaN") { - return defaultValue; - } - return Number(value); - } - return defaultValue; - }; + EgretEvent.COMPLETE = dragonBones.EventObject.COMPLETE; /** - * @private + * @see dragonBones.EventObject.FADE_IN */ - ObjectDataParser._getString = function (rawData, key, defaultValue) { - if (key in rawData) { - return String(rawData[key]); - } - return defaultValue; - }; + EgretEvent.FADE_IN = dragonBones.EventObject.FADE_IN; /** - * @private + * @see dragonBones.EventObject.FADE_IN_COMPLETE */ - ObjectDataParser._getParameter = function (rawData, index, defaultValue) { - if (rawData && rawData.length > index) { - return rawData[index]; - } - return defaultValue; - }; + EgretEvent.FADE_IN_COMPLETE = dragonBones.EventObject.FADE_IN_COMPLETE; /** - * @private + * @see dragonBones.EventObject.FADE_OUT */ - p._parseArmature = function (rawData) { - var armature = dragonBones.BaseObject.borrowObject(dragonBones.ArmatureData); - armature.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); - armature.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, this._data.frameRate) || this._data.frameRate; - if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] == "string") { - armature.type = ObjectDataParser._getArmatureType(rawData[ObjectDataParser.TYPE]); - } - else { - armature.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Armature */); - } - this._armature = armature; - this._rawBones.length = 0; - if (ObjectDataParser.BONE in rawData) { - var bones = rawData[ObjectDataParser.BONE]; - for (var i = 0, l = bones.length; i < l; ++i) { - var boneObject = bones[i]; - var bone = this._parseBone(boneObject); - armature.addBone(bone, ObjectDataParser._getString(boneObject, ObjectDataParser.PARENT, null)); - this._rawBones.push(bone); - } - } - if (ObjectDataParser.IK in rawData) { - var iks = rawData[ObjectDataParser.IK]; - for (var i = 0, l = iks.length; i < l; ++i) { - this._parseIK(iks[i]); - } - } - if (ObjectDataParser.SLOT in rawData) { - var slots = rawData[ObjectDataParser.SLOT]; - for (var i = 0, l = slots.length; i < l; ++i) { - armature.addSlot(this._parseSlot(slots[i])); - } - } - if (ObjectDataParser.SKIN in rawData) { - var skins = rawData[ObjectDataParser.SKIN]; - for (var i = 0, l = skins.length; i < l; ++i) { - armature.addSkin(this._parseSkin(skins[i])); - } - } - if (ObjectDataParser.ANIMATION in rawData) { - var animations = rawData[ObjectDataParser.ANIMATION]; - for (var i = 0, l = animations.length; i < l; ++i) { - armature.addAnimation(this._parseAnimation(animations[i])); - } - } - if ((ObjectDataParser.ACTIONS in rawData) || - (ObjectDataParser.DEFAULT_ACTIONS in rawData)) { - this._parseActionData(rawData, armature.actions, null, null); - } - if (this._isParentCooriinate && ObjectDataParser._getBoolean(rawData, ObjectDataParser.IS_GLOBAL, true)) { - this._globalToLocal(armature); - } - this._armature = null; - this._rawBones.length = 0; - return armature; - }; + EgretEvent.FADE_OUT = dragonBones.EventObject.FADE_OUT; + /** + * @see dragonBones.EventObject.FADE_OUT_COMPLETE + */ + EgretEvent.FADE_OUT_COMPLETE = dragonBones.EventObject.FADE_OUT_COMPLETE; + /** + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND_EVENT = dragonBones.EventObject.SOUND_EVENT; + /** + * @deprecated + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.ANIMATION_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.BONE_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * @see dragonBones.EventObject.FRAME_EVENT + */ + EgretEvent.MOVEMENT_FRAME_EVENT = dragonBones.EventObject.FRAME_EVENT; + /** + * @deprecated + * @see dragonBones.EventObject.SOUND_EVENT + */ + EgretEvent.SOUND = dragonBones.EventObject.SOUND_EVENT; + return EgretEvent; + }(egret.Event)); + dragonBones.EgretEvent = EgretEvent; + /** + * @inheritDoc + */ + var EgretArmatureDisplay = (function (_super) { + __extends(EgretArmatureDisplay, _super); /** * @private */ - p._parseBone = function (rawData) { - var bone = dragonBones.BaseObject.borrowObject(dragonBones.BoneData); - bone.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); - bone.inheritTranslation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_TRANSLATION, true); - bone.inheritRotation = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_ROTATION, true); - bone.inheritScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.INHERIT_SCALE, true); - bone.length = ObjectDataParser._getNumber(rawData, ObjectDataParser.LENGTH, 0) * this._armatureScale; - if (ObjectDataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[ObjectDataParser.TRANSFORM], bone.transform); - } - if (this._isParentCooriinate) { - bone.inheritRotation = true; - bone.inheritScale = false; + function EgretArmatureDisplay() { + _super.call(this); + if (!EgretArmatureDisplay._clock) { + EgretArmatureDisplay._clock = new dragonBones.WorldClock(); + EgretArmatureDisplay._clock.time = egret.getTimer() * 0.001; + egret.startTick(EgretArmatureDisplay._clockHandler, EgretArmatureDisplay); } - return bone; + } + EgretArmatureDisplay._clockHandler = function (time) { + time *= 0.001; + var passedTime = EgretArmatureDisplay.passTime > 0 ? EgretArmatureDisplay.passTime : (time - EgretArmatureDisplay._clock.time); + EgretArmatureDisplay._clock.advanceTime(passedTime); + EgretArmatureDisplay._clock.time = time; + return false; }; /** - * @private + * @inheritDoc */ - p._parseIK = function (rawData) { - var bone = this._armature.getBone(ObjectDataParser._getString(rawData, (ObjectDataParser.BONE in rawData) ? ObjectDataParser.BONE : ObjectDataParser.NAME, null)); - if (bone) { - bone.ik = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.TARGET, null)); - bone.bendPositive = ObjectDataParser._getBoolean(rawData, ObjectDataParser.BEND_POSITIVE, true); - bone.chain = ObjectDataParser._getNumber(rawData, ObjectDataParser.CHAIN, 0); - bone.weight = ObjectDataParser._getNumber(rawData, ObjectDataParser.WEIGHT, 1); - if (bone.chain > 0 && bone.parent && !bone.parent.ik) { - bone.parent.ik = bone.ik; - bone.parent.chainIndex = 0; - bone.parent.chain = 0; - bone.chainIndex = 1; - } - else { - bone.chain = 0; - bone.chainIndex = 0; - } - } + EgretArmatureDisplay.prototype._onClear = function () { + this._armature = null; + this._debugDrawer = null; }; /** - * @private + * @inheritDoc */ - p._parseSlot = function (rawData) { - var slot = dragonBones.BaseObject.borrowObject(dragonBones.SlotData); - slot.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); - slot.parent = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.PARENT, null)); - slot.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); - slot.zOrder = ObjectDataParser._getNumber(rawData, ObjectDataParser.Z_ORDER, this._armature.sortedSlots.length); // TODO zOrder. - if (ObjectDataParser.COLOR in rawData) { - slot.color = dragonBones.SlotData.generateColor(); - this._parseColorTransform(rawData[ObjectDataParser.COLOR], slot.color); - } - else { - slot.color = dragonBones.SlotData.DEFAULT_COLOR; - } - if (ObjectDataParser.BLEND_MODE in rawData && typeof rawData[ObjectDataParser.BLEND_MODE] == "string") { - slot.blendMode = ObjectDataParser._getBlendMode(rawData[ObjectDataParser.BLEND_MODE]); - } - else { - slot.blendMode = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLEND_MODE, 0 /* Normal */); - } - if ((ObjectDataParser.ACTIONS in rawData) || - (ObjectDataParser.DEFAULT_ACTIONS in rawData)) { - this._parseActionData(rawData, slot.actions, null, null); - } - if (this._isParentCooriinate) { - if (ObjectDataParser.COLOR_TRANSFORM in rawData) { - slot.color = dragonBones.SlotData.generateColor(); - this._parseColorTransform(rawData[ObjectDataParser.COLOR_TRANSFORM], slot.color); - } - else { - slot.color = dragonBones.SlotData.DEFAULT_COLOR; - } - } - return slot; + EgretArmatureDisplay.prototype._dispatchEvent = function (eventObject) { + var event = egret.Event.create(EgretEvent, eventObject.type); + event.data = eventObject; + this.dispatchEvent(event); + egret.Event.release(event); }; /** - * @private + * @inheritDoc */ - p._parseSkin = function (rawData) { - var skin = dragonBones.BaseObject.borrowObject(dragonBones.SkinData); - skin.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "__default") || "__default"; - if (ObjectDataParser.SLOT in rawData) { - this._skin = skin; - var slots = rawData[ObjectDataParser.SLOT]; - for (var i = 0, l = slots.length; i < l; ++i) { - if (this._isParentCooriinate) { - this._armature.addSlot(this._parseSlot(slots[i])); - } - skin.addSlot(this._parseSlotDisplaySet(slots[i])); - } - this._skin = null; + EgretArmatureDisplay.prototype._debugDraw = function () { + if (!this._debugDrawer) { + this._debugDrawer = new egret.Shape(); + } + this.addChild(this._debugDrawer); + this._debugDrawer.graphics.clear(); + var bones = this._armature.getBones(); + for (var i = 0, l = bones.length; i < l; ++i) { + var bone = bones[i]; + var boneLength = Math.max(bone.length, 5); + var startX = bone.globalTransformMatrix.tx; + var startY = bone.globalTransformMatrix.ty; + var endX = startX + bone.globalTransformMatrix.a * boneLength; + var endY = startY + bone.globalTransformMatrix.b * boneLength; + this._debugDrawer.graphics.lineStyle(1, bone.ik ? 0xFF0000 : 0x00FF00, 0.5); + this._debugDrawer.graphics.moveTo(startX, startY); + this._debugDrawer.graphics.lineTo(endX, endY); } - return skin; }; /** - * @private + * @inheritDoc */ - p._parseSlotDisplaySet = function (rawData) { - var slotDisplayDataSet = dragonBones.BaseObject.borrowObject(dragonBones.SlotDisplayDataSet); - slotDisplayDataSet.slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null)); - if (ObjectDataParser.DISPLAY in rawData) { - var displayObjectSet = rawData[ObjectDataParser.DISPLAY]; - var displayDataSet = slotDisplayDataSet.displays; - this._slotDisplayDataSet = slotDisplayDataSet; - for (var i = 0, l = displayObjectSet.length; i < l; ++i) { - displayDataSet.push(this._parseDisplay(displayObjectSet[i])); - } - this._slotDisplayDataSet = null; - } - return slotDisplayDataSet; + EgretArmatureDisplay.prototype.hasEvent = function (type) { + return this.hasEventListener(type); }; /** - * @private + * @inheritDoc */ - p._parseDisplay = function (rawData) { - var display = dragonBones.BaseObject.borrowObject(dragonBones.DisplayData); - display.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); - if (ObjectDataParser.TYPE in rawData && typeof rawData[ObjectDataParser.TYPE] == "string") { - display.type = ObjectDataParser._getDisplayType(rawData[ObjectDataParser.TYPE]); - } - else { - display.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* Image */); - } - display.isRelativePivot = true; - if (ObjectDataParser.PIVOT in rawData) { - var pivotObject = rawData[ObjectDataParser.PIVOT]; - display.pivot.x = ObjectDataParser._getNumber(pivotObject, ObjectDataParser.X, 0); - display.pivot.y = ObjectDataParser._getNumber(pivotObject, ObjectDataParser.Y, 0); - } - else if (this._isParentCooriinate) { - var transformObject = rawData[ObjectDataParser.TRANSFORM]; - display.isRelativePivot = false; - display.pivot.x = ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_X, 0) * this._armatureScale; - display.pivot.y = ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_Y, 0) * this._armatureScale; + EgretArmatureDisplay.prototype.addEvent = function (type, listener, target) { + this.addEventListener(type, listener, target); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.removeEvent = function (type, listener, target) { + this.removeEventListener(type, listener, target); + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.advanceTimeBySelf = function (on) { + if (on) { + EgretArmatureDisplay._clock.add(this._armature); } else { - display.pivot.x = 0.5; - display.pivot.y = 0.5; - } - if (ObjectDataParser.TRANSFORM in rawData) { - this._parseTransform(rawData[ObjectDataParser.TRANSFORM], display.transform); + EgretArmatureDisplay._clock.remove(this._armature); } - switch (display.type) { - case 0 /* Image */: - break; - case 1 /* Armature */: - break; - case 2 /* Mesh */: - display.meshData = this._parseMesh(rawData); - break; + }; + /** + * @inheritDoc + */ + EgretArmatureDisplay.prototype.dispose = function () { + if (this._armature) { + this.advanceTimeBySelf(false); + this._armature.dispose(); + this._armature = null; } - return display; }; + Object.defineProperty(EgretArmatureDisplay.prototype, "armature", { + /** + * @inheritDoc + */ + get: function () { + return this._armature; + }, + enumerable: true, + configurable: true + }); + Object.defineProperty(EgretArmatureDisplay.prototype, "animation", { + /** + * @inheritDoc + */ + get: function () { + return this._armature.animation; + }, + enumerable: true, + configurable: true + }); + EgretArmatureDisplay.passTime = 0; + EgretArmatureDisplay._clock = null; + return EgretArmatureDisplay; + }(egret.DisplayObjectContainer)); + dragonBones.EgretArmatureDisplay = EgretArmatureDisplay; + /** + * @deprecated + * @see dragonBones.EgretEvent + */ + var AnimationEvent = (function (_super) { + __extends(AnimationEvent, _super); + function AnimationEvent() { + _super.apply(this, arguments); + } + return AnimationEvent; + }(EgretEvent)); + dragonBones.AnimationEvent = AnimationEvent; + /** + * @deprecated + * @see dragonBones.EgretEvent + */ + var FrameEvent = (function (_super) { + __extends(FrameEvent, _super); + function FrameEvent() { + _super.apply(this, arguments); + } + return FrameEvent; + }(EgretEvent)); + dragonBones.FrameEvent = FrameEvent; + /** + * @deprecated + * @see dragonBones.EgretEvent + */ + var SoundEvent = (function (_super) { + __extends(SoundEvent, _super); + function SoundEvent() { + _super.apply(this, arguments); + } + return SoundEvent; + }(EgretEvent)); + dragonBones.SoundEvent = SoundEvent; + /** + * @deprecated + * @see dragonBones.EgretTextureAtlasData + */ + var EgretTextureAtlas = (function (_super) { + __extends(EgretTextureAtlas, _super); + function EgretTextureAtlas(texture, rawData, scale) { + if (scale === void 0) { scale = 1; } + _super.call(this); + this._onClear(); + this.texture = texture; + dragonBones.ObjectDataParser.getInstance().parseTextureAtlasData(rawData, this, scale); + } /** * @private */ - p._parseMesh = function (rawData) { - var mesh = dragonBones.BaseObject.borrowObject(dragonBones.MeshData); - var rawVertices = rawData[ObjectDataParser.VERTICES]; - var rawUVs = rawData[ObjectDataParser.UVS]; - var rawTriangles = rawData[ObjectDataParser.TRIANGLES]; - var numVertices = Math.floor(rawVertices.length / 2); // uint() - var numTriangles = Math.floor(rawTriangles.length / 3); // uint() - var inverseBindPose = new Array(this._armature.sortedBones.length); - mesh.skinned = (ObjectDataParser.WEIGHTS in rawData) && rawData[ObjectDataParser.WEIGHTS].length > 0; - mesh.uvs.length = numVertices * 2; - mesh.vertices.length = numVertices * 2; - mesh.vertexIndices.length = numTriangles * 3; - if (mesh.skinned) { - mesh.boneIndices.length = numVertices; - mesh.weights.length = numVertices; - mesh.boneVertices.length = numVertices; - if (ObjectDataParser.SLOT_POSE in rawData) { - var rawSlotPose = rawData[ObjectDataParser.SLOT_POSE]; - mesh.slotPose.a = rawSlotPose[0]; - mesh.slotPose.b = rawSlotPose[1]; - mesh.slotPose.c = rawSlotPose[2]; - mesh.slotPose.d = rawSlotPose[3]; - mesh.slotPose.tx = rawSlotPose[4]; - mesh.slotPose.ty = rawSlotPose[5]; - } - if (ObjectDataParser.BONE_POSE in rawData) { - var rawBonePose = rawData[ObjectDataParser.BONE_POSE]; - for (var i = 0, l = rawBonePose.length; i < l; i += 7) { - var rawBoneIndex = rawBonePose[i]; - var boneMatrix = inverseBindPose[rawBoneIndex] = new dragonBones.Matrix(); - boneMatrix.a = rawBonePose[i + 1]; - boneMatrix.b = rawBonePose[i + 2]; - boneMatrix.c = rawBonePose[i + 3]; - boneMatrix.d = rawBonePose[i + 4]; - boneMatrix.tx = rawBonePose[i + 5]; - boneMatrix.ty = rawBonePose[i + 6]; - boneMatrix.invert(); - } - } - } - for (var i = 0, iW = 0, l = rawVertices.length; i < l; i += 2) { - var iN = i + 1; - var vertexIndex = i / 2; - var x = mesh.vertices[i] = rawVertices[i] * this._armatureScale; - var y = mesh.vertices[iN] = rawVertices[iN] * this._armatureScale; - mesh.uvs[i] = rawUVs[i]; - mesh.uvs[iN] = rawUVs[iN]; - if (mesh.skinned) { - var rawWeights = rawData[ObjectDataParser.WEIGHTS]; - var numBones = rawWeights[iW]; - var indices = mesh.boneIndices[vertexIndex] = new Array(numBones); - var weights = mesh.weights[vertexIndex] = new Array(numBones); - var boneVertices = mesh.boneVertices[vertexIndex] = new Array(numBones * 2); - mesh.slotPose.transformPoint(x, y, this._helpPoint); - x = mesh.vertices[i] = this._helpPoint.x; - y = mesh.vertices[iN] = this._helpPoint.y; - for (var iB = 0; iB < numBones; ++iB) { - var iI = iW + 1 + iB * 2; - var rawBoneIndex = rawWeights[iI]; - var boneData = this._rawBones[rawBoneIndex]; - var boneIndex = mesh.bones.indexOf(boneData); - if (boneIndex < 0) { - boneIndex = mesh.bones.length; - mesh.bones[boneIndex] = boneData; - mesh.inverseBindPose[boneIndex] = inverseBindPose[rawBoneIndex]; - } - mesh.inverseBindPose[boneIndex].transformPoint(x, y, this._helpPoint); - indices[iB] = boneIndex; - weights[iB] = rawWeights[iI + 1]; - boneVertices[iB * 2] = this._helpPoint.x; - boneVertices[iB * 2 + 1] = this._helpPoint.y; - } - iW += numBones * 2 + 1; - } - } - for (var i = 0, l = rawTriangles.length; i < l; ++i) { - mesh.vertexIndices[i] = rawTriangles[i]; + EgretTextureAtlas.toString = function () { + return "[class dragonBones.EgretTextureAtlas]"; + }; + return EgretTextureAtlas; + }(dragonBones.EgretTextureAtlasData)); + dragonBones.EgretTextureAtlas = EgretTextureAtlas; + /** + * @deprecated + * @see dragonBones.EgretTextureAtlasData + */ + var EgretSheetAtlas = (function (_super) { + __extends(EgretSheetAtlas, _super); + function EgretSheetAtlas() { + _super.apply(this, arguments); + } + return EgretSheetAtlas; + }(EgretTextureAtlas)); + dragonBones.EgretSheetAtlas = EgretSheetAtlas; + /** + * @deprecated + * @see dragonBones.EgretFactory#soundEventManater + */ + var SoundEventManager = (function () { + function SoundEventManager() { + } + /** + * @deprecated + * @see dragonBones.EgretFactory#soundEventManater + */ + SoundEventManager.getInstance = function () { + return dragonBones.EventObject._soundEventManager; + }; + return SoundEventManager; + }()); + dragonBones.SoundEventManager = SoundEventManager; + /** + * @deprecated + * @see dragonBones.Armature#cacheFrameRate + * @see dragonBones.Armature#enableAnimationCache() + */ + var AnimationCacheManager = (function () { + function AnimationCacheManager() { + } + return AnimationCacheManager; + }()); + dragonBones.AnimationCacheManager = AnimationCacheManager; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * Egret 工厂。 + * @version DragonBones 3.0 + */ + var EgretFactory = (function (_super) { + __extends(EgretFactory, _super); + /** + * @language zh_CN + * 创建一个工厂。 + * @param dataParser 龙骨数据解析器,如果不设置,则使用默认解析器。 + * @version DragonBones 3.0 + */ + function EgretFactory(dataParser) { + if (dataParser === void 0) { dataParser = null; } + _super.call(this, dataParser); + if (!dragonBones.EventObject._soundEventManager) { + dragonBones.EventObject._soundEventManager = new dragonBones.EgretArmatureDisplay(); } - return mesh; - }; + } /** * @private */ - p._parseAnimation = function (rawData) { - var animation = dragonBones.BaseObject.borrowObject(dragonBones.AnimationData); - animation.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, "__default") || "__default"; - animation.frameCount = Math.max(ObjectDataParser._getNumber(rawData, ObjectDataParser.DURATION, 1), 1); - animation.position = ObjectDataParser._getNumber(rawData, ObjectDataParser.POSITION, 0) / this._armature.frameRate; - animation.duration = animation.frameCount / this._armature.frameRate; - animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.PLAY_TIMES, 1); - animation.fadeInTime = ObjectDataParser._getNumber(rawData, ObjectDataParser.FADE_IN_TIME, 0); - this._animation = animation; - var animationName = ObjectDataParser._getString(rawData, ObjectDataParser.ANIMATION, null); - if (animationName) { - animation.animation = this._armature.getAnimation(animationName); - if (!animation.animation) { - } - return animation; - } - this._parseTimeline(rawData, animation, this._parseAnimationFrame); - if (ObjectDataParser.BONE in rawData) { - var boneTimelines = rawData[ObjectDataParser.BONE]; - for (var i = 0, l = boneTimelines.length; i < l; ++i) { - animation.addBoneTimeline(this._parseBoneTimeline(boneTimelines[i])); - } - } - if (ObjectDataParser.SLOT in rawData) { - var slotTimelines = rawData[ObjectDataParser.SLOT]; - for (var i = 0, l = slotTimelines.length; i < l; ++i) { - animation.addSlotTimeline(this._parseSlotTimeline(slotTimelines[i])); - } - } - if (ObjectDataParser.FFD in rawData) { - var ffdTimelines = rawData[ObjectDataParser.FFD]; - for (var i = 0, l = ffdTimelines.length; i < l; ++i) { - animation.addFFDTimeline(this._parseFFDTimeline(ffdTimelines[i])); - } - } - if (this._isParentCooriinate) { - this._isAutoTween = ObjectDataParser._getBoolean(rawData, ObjectDataParser.AUTO_TWEEN, true); - this._animationTweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, 0) || 0; - animation.playTimes = ObjectDataParser._getNumber(rawData, ObjectDataParser.LOOP, 1); - if (ObjectDataParser.TIMELINE in rawData) { - var timelines = rawData[ObjectDataParser.TIMELINE]; - for (var i = 0, l = timelines.length; i < l; ++i) { - animation.addBoneTimeline(this._parseBoneTimeline(timelines[i])); - } - for (var i = 0, l = timelines.length; i < l; ++i) { - animation.addSlotTimeline(this._parseSlotTimeline(timelines[i])); - } - } + EgretFactory.prototype._generateTextureAtlasData = function (textureAtlasData, textureAtlas) { + if (textureAtlasData) { + textureAtlasData.texture = textureAtlas; } else { - this._isAutoTween = false; - this._animationTweenEasing = 0; - } - for (var i in this._armature.bones) { - var bone = this._armature.bones[i]; - if (!animation.getBoneTimeline(bone.name)) { - var boneTimeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTimelineData); - var boneFrame = dragonBones.BaseObject.borrowObject(dragonBones.BoneFrameData); - boneTimeline.bone = bone; - boneTimeline.frames[0] = boneFrame; - animation.addBoneTimeline(boneTimeline); - } - } - for (var i in this._armature.slots) { - var slot = this._armature.slots[i]; - if (!animation.getSlotTimeline(slot.name)) { - var slotTimeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotTimelineData); - var slotFrame = dragonBones.BaseObject.borrowObject(dragonBones.SlotFrameData); - slotTimeline.slot = slot; - slotFrame.displayIndex = slot.displayIndex; - //slotFrame.zOrder = -2; // TODO zOrder. - if (slot.color == dragonBones.SlotData.DEFAULT_COLOR) { - slotFrame.color = dragonBones.SlotFrameData.DEFAULT_COLOR; - } - else { - slotFrame.color = dragonBones.SlotFrameData.generateColor(); - slotFrame.color.copyFrom(slot.color); - } - slotTimeline.frames[0] = slotFrame; - animation.addSlotTimeline(slotTimeline); - if (this._isParentCooriinate) { - slotFrame.displayIndex = -1; - } - } + textureAtlasData = dragonBones.BaseObject.borrowObject(dragonBones.EgretTextureAtlasData); } - this._animation = null; - return animation; + return textureAtlasData; }; /** * @private */ - p._parseBoneTimeline = function (rawData) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.BoneTimelineData); - timeline.bone = this._armature.getBone(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null)); - this._parseTimeline(rawData, timeline, this._parseBoneFrame); - var originTransform = timeline.originTransform; - var prevFrame = null; - for (var i = 0, l = timeline.frames.length; i < l; ++i) { - var frame = timeline.frames[i]; - if (!prevFrame) { - originTransform.copyFrom(frame.transform); - frame.transform.identity(); - if (originTransform.scaleX == 0) { - originTransform.scaleX = 0.001; - } - if (originTransform.scaleY == 0) { - originTransform.scaleY = 0.001; - } - } - else if (prevFrame != frame) { - frame.transform.minus(originTransform); - } - prevFrame = frame; - } - if (timeline.scale != 1 || timeline.offset != 0) { - this._animation.hasAsynchronyTimeline = true; - } - return timeline; + EgretFactory.prototype._generateArmature = function (dataPackage) { + var armature = dragonBones.BaseObject.borrowObject(dragonBones.Armature); + var armatureDisplayContainer = new dragonBones.EgretArmatureDisplay(); + // Test + //const armatureDisplayContainer = new BitmapContainer(); + armature._armatureData = dataPackage.armature; + armature._skinData = dataPackage.skin; + armature._animation = dragonBones.BaseObject.borrowObject(dragonBones.Animation); + armature._display = armatureDisplayContainer; + armatureDisplayContainer._armature = armature; + armature._animation._armature = armature; + armature.animation.animations = dataPackage.armature.animations; + return armature; }; /** * @private */ - p._parseSlotTimeline = function (rawData) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.SlotTimelineData); - timeline.slot = this._armature.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null)); - this._parseTimeline(rawData, timeline, this._parseSlotFrame); - if (timeline.scale != 1 || timeline.offset != 0) { - this._animation.hasAsynchronyTimeline = true; + EgretFactory.prototype._generateSlot = function (dataPackage, slotDisplayDataSet) { + var slot = dragonBones.BaseObject.borrowObject(dragonBones.EgretSlot); + var slotData = slotDisplayDataSet.slot; + var displayList = []; + slot.name = slotData.name; + slot._rawDisplay = new egret.Bitmap(); + for (var i = 0, l = slotDisplayDataSet.displays.length; i < l; ++i) { + var displayData = slotDisplayDataSet.displays[i]; + switch (displayData.type) { + case 0 /* Image */: + if (!displayData.texture) { + displayData.texture = this._getTextureData(dataPackage.dataName, displayData.name); + } + displayList.push(slot._rawDisplay); + break; + case 2 /* Mesh */: + if (!displayData.texture) { + displayData.texture = this._getTextureData(dataPackage.dataName, displayData.name); + } + if (egret.Capabilities.renderMode == "webgl") { + if (!slot._meshDisplay) { + slot._meshDisplay = new egret.Mesh(); + } + displayList.push(slot._meshDisplay); + } + else { + displayList.push(slot._rawDisplay); + } + break; + case 1 /* Armature */: + var childArmature = this.buildArmature(displayData.name, dataPackage.dataName); + if (childArmature) { + if (slotData.actions.length > 0) { + for (var i_6 = 0, l_4 = slotData.actions.length; i_6 < l_4; ++i_6) { + childArmature._bufferAction(slotData.actions[i_6]); + } + } + else { + childArmature.animation.play(); + } + displayData.armature = childArmature.armatureData; // + } + displayList.push(childArmature); + break; + default: + displayList.push(null); + break; + } } - return timeline; + slot._setDisplayList(displayList); + return slot; }; /** - * @private + * @language zh_CN + * 创建一个指定名称的骨架,并使用骨架的显示容器来更新骨架动画。 + * @param armatureName 骨架数据名称。 + * @param dragonBonesName 龙骨数据名称,如果未设置,将检索所有的龙骨数据,如果多个数据中包含同名的骨架数据,可能无法创建出准确的骨架。 + * @param skinName 皮肤名称,如果未设置,则使用默认皮肤。 + * @returns 骨架的显示容器。 + * @see dragonBones.IArmatureDisplayContainer + * @version DragonBones 4.5 */ - p._parseFFDTimeline = function (rawData) { - var timeline = dragonBones.BaseObject.borrowObject(dragonBones.FFDTimelineData); - timeline.skin = this._armature.getSkin(ObjectDataParser._getString(rawData, ObjectDataParser.SKIN, null)); - timeline.slot = timeline.skin.getSlot(ObjectDataParser._getString(rawData, ObjectDataParser.SLOT, null)); // NAME; - var meshName = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); - for (var i = 0, l = timeline.slot.displays.length; i < l; ++i) { - var displayData = timeline.slot.displays[i]; - if (displayData.meshData && displayData.name == meshName) { - timeline.displayIndex = i; // rawData[DISPLAY_INDEX]; - this._mesh = displayData.meshData; // Find the ffd's mesh. - break; - } + EgretFactory.prototype.buildArmatureDisplay = function (armatureName, dragonBonesName, skinName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + var armature = this.buildArmature(armatureName, dragonBonesName, skinName); + var armatureDisplay = armature ? armature._display : null; + if (armatureDisplay) { + armatureDisplay.advanceTimeBySelf(true); } - this._parseTimeline(rawData, timeline, this._parseFFDFrame); - this._mesh = null; - return timeline; + return armatureDisplay; }; /** - * @private + * @language zh_CN + * 获取带有指定贴图的显示对象。 + * @param textureName 指定的贴图名称。 + * @param dragonBonesName 指定的龙骨数据名称,如果未设置,将检索所有的龙骨数据。 + * @version DragonBones 3.0 */ - p._parseAnimationFrame = function (rawData, frameStart, frameCount) { - var frame = dragonBones.BaseObject.borrowObject(dragonBones.AnimationFrameData); - this._parseFrame(rawData, frame, frameStart, frameCount); - if ((ObjectDataParser.ACTION in rawData) || - (ObjectDataParser.ACTIONS in rawData)) { - this._parseActionData(rawData, frame.actions, null, null); - } - if ((ObjectDataParser.EVENT in rawData) || (ObjectDataParser.SOUND in rawData)) { - this._parseEventData(rawData, frame.events, null, null); + EgretFactory.prototype.getTextureDisplay = function (textureName, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + var textureData = this._getTextureData(dragonBonesName, textureName); + if (textureData) { + return new egret.Bitmap(textureData.texture); } - return frame; + return null; + }; + Object.defineProperty(EgretFactory.prototype, "soundEventManater", { + /** + * @language zh_CN + * 获取全局声音事件管理器。 + * @version DragonBones 4.5 + */ + get: function () { + return dragonBones.EventObject._soundEventManager; + }, + enumerable: true, + configurable: true + }); + /** + * @deprecated + * @see dragonBones.BaseFactory#addDragonBonesData() + */ + EgretFactory.prototype.addSkeletonData = function (dragonBonesData, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + this.addDragonBonesData(dragonBonesData, dragonBonesName); }; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#getDragonBonesData() */ - p._parseBoneFrame = function (rawData, frameStart, frameCount) { - var frame = dragonBones.BaseObject.borrowObject(dragonBones.BoneFrameData); - frame.tweenRotate = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_ROTATE, 0); - frame.tweenScale = ObjectDataParser._getBoolean(rawData, ObjectDataParser.TWEEN_SCALE, true); - this._parseTweenFrame(rawData, frame, frameStart, frameCount); - if (ObjectDataParser.TRANSFORM in rawData) { - var transformObject = rawData[ObjectDataParser.TRANSFORM]; - this._parseTransform(transformObject, frame.transform); - if (this._isParentCooriinate) { - this._helpPoint.x = ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_X, 0); - this._helpPoint.y = ObjectDataParser._getNumber(transformObject, ObjectDataParser.PIVOT_Y, 0); - frame.transform.toMatrix(this._helpMatrix); - this._helpMatrix.transformPoint(this._helpPoint.x, this._helpPoint.y, this._helpPoint, true); - frame.transform.x += this._helpPoint.x; - frame.transform.y += this._helpPoint.y; - } - } - var bone = this._timeline.bone; - if ((ObjectDataParser.ACTION in rawData) || - (ObjectDataParser.ACTIONS in rawData)) { - var slot = this._armature.getSlot(bone.name); - var actions = []; - this._parseActionData(rawData, actions, bone, slot); - this._mergeFrameToAnimationTimeline(frame, actions, null); // Merge actions and events to animation timeline. - } - if ((ObjectDataParser.EVENT in rawData) || (ObjectDataParser.SOUND in rawData)) { - var events = []; - this._parseEventData(rawData, events, bone, null); - this._mergeFrameToAnimationTimeline(frame, null, events); // Merge actions and events to animation timeline. - } - return frame; + EgretFactory.prototype.getSkeletonData = function (dragonBonesName) { + return this.getDragonBonesData(dragonBonesName); }; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#removeSkeletonData() */ - p._parseSlotFrame = function (rawData, frameStart, frameCount) { - var frame = dragonBones.BaseObject.borrowObject(dragonBones.SlotFrameData); - frame.displayIndex = ObjectDataParser._getNumber(rawData, ObjectDataParser.DISPLAY_INDEX, 0); - //frame.zOrder = _getNumber(rawData, Z_ORDER, -1); // TODO zorder - this._parseTweenFrame(rawData, frame, frameStart, frameCount); - if (ObjectDataParser.COLOR in rawData || ObjectDataParser.COLOR_TRANSFORM in rawData) { - frame.color = dragonBones.SlotFrameData.generateColor(); - this._parseColorTransform(rawData[ObjectDataParser.COLOR] || rawData[ObjectDataParser.COLOR_TRANSFORM], frame.color); - } - else { - frame.color = dragonBones.SlotFrameData.DEFAULT_COLOR; - } - if (this._isParentCooriinate) { - if (ObjectDataParser._getBoolean(rawData, ObjectDataParser.HIDE, false)) { - frame.displayIndex = -1; - } - } - else if ((ObjectDataParser.ACTION in rawData) || - (ObjectDataParser.ACTIONS in rawData)) { - var slot = this._timeline.slot; - var actions = []; - this._parseActionData(rawData, actions, slot.parent, slot); - this._mergeFrameToAnimationTimeline(frame, actions, null); // Merge actions and events to animation timeline. - } - return frame; + EgretFactory.prototype.removeSkeletonData = function (dragonBonesName) { + this.removeDragonBonesData(dragonBonesName); }; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#addTextureAtlasData() */ - p._parseFFDFrame = function (rawData, frameStart, frameCount) { - var frame = dragonBones.BaseObject.borrowObject(dragonBones.ExtensionFrameData); - frame.type = ObjectDataParser._getNumber(rawData, ObjectDataParser.TYPE, 0 /* FFD */); - this._parseTweenFrame(rawData, frame, frameStart, frameCount); - var rawVertices = rawData[ObjectDataParser.VERTICES]; - var offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); - var x = 0; - var y = 0; - for (var i = 0, l = this._mesh.vertices.length; i < l; i += 2) { - if (!rawVertices || i < offset || i - offset >= rawVertices.length) { - x = 0; - y = 0; - } - else { - x = rawVertices[i - offset] * this._armatureScale; - y = rawVertices[i + 1 - offset] * this._armatureScale; - } - if (this._mesh.skinned) { - this._mesh.slotPose.transformPoint(x, y, this._helpPoint, true); - x = this._helpPoint.x; - y = this._helpPoint.y; - var boneIndices = this._mesh.boneIndices[i / 2]; - for (var iB = 0, lB = boneIndices.length; iB < lB; ++iB) { - var boneIndex = boneIndices[iB]; - this._mesh.inverseBindPose[boneIndex].transformPoint(x, y, this._helpPoint, true); - frame.tweens.push(this._helpPoint.x, this._helpPoint.y); - } - } - else { - frame.tweens.push(x, y); - } - } - return frame; + EgretFactory.prototype.addTextureAtlas = function (textureAtlasData, dragonBonesName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + this.addTextureAtlasData(textureAtlasData, dragonBonesName); }; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#getTextureAtlasData() */ - p._parseTweenFrame = function (rawData, frame, frameStart, frameCount) { - this._parseFrame(rawData, frame, frameStart, frameCount); - if (ObjectDataParser.TWEEN_EASING in rawData) { - frame.tweenEasing = ObjectDataParser._getNumber(rawData, ObjectDataParser.TWEEN_EASING, dragonBones.DragonBones.NO_TWEEN); - } - else if (this._isParentCooriinate) { - frame.tweenEasing = this._isAutoTween ? this._animationTweenEasing : dragonBones.DragonBones.NO_TWEEN; - } - if (this._isParentCooriinate && this._animation.scale == 1 && this._timeline.scale == 1 && frame.duration * this._armature.frameRate < 2) { - frame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; - } - if (ObjectDataParser.CURVE in rawData) { - frame.curve = dragonBones.TweenFrameData.samplingCurve(rawData[ObjectDataParser.CURVE], frameCount); - } + EgretFactory.prototype.getTextureAtlas = function (dragonBonesName) { + return this.getTextureAtlasData(dragonBonesName); }; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#removeTextureAtlasData() */ - p._parseFrame = function (rawData, frame, frameStart, frameCount) { - frame.position = frameStart / this._armature.frameRate; - frame.duration = frameCount / this._armature.frameRate; + EgretFactory.prototype.removeTextureAtlas = function (dragonBonesName) { + this.removeTextureAtlasData(dragonBonesName); }; /** - * @private + * @deprecated + * @see dragonBones.BaseFactory#buildArmature() */ - p._parseTimeline = function (rawData, timeline, frameParser) { - timeline.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, 1); - timeline.offset = ObjectDataParser._getNumber(rawData, ObjectDataParser.OFFSET, 0); - this._timeline = timeline; - if (ObjectDataParser.FRAME in rawData) { - var rawFrames = rawData[ObjectDataParser.FRAME]; - if (rawFrames.length) { - if (rawFrames.length == 1) { - timeline.frames.length = 1; - timeline.frames[0] = frameParser.call(this, rawFrames[0], 0, ObjectDataParser._getNumber(rawFrames[0], ObjectDataParser.DURATION, 1)); - } - else { - timeline.frames.length = this._animation.frameCount + 1; - var frameStart = 0; - var frameCount = 0; - var frame = null; - var prevFrame = null; - for (var i = 0, iW = 0, l = this._animation.frameCount + 1; i < l; ++i) { - if (frameStart + frameCount <= i && iW < rawFrames.length) { - var frameObject = rawFrames[iW++]; - frameStart = i; - frameCount = ObjectDataParser._getNumber(frameObject, ObjectDataParser.DURATION, 1); - frame = frameParser.call(this, frameObject, frameStart, frameCount); - if (prevFrame) { - prevFrame.next = frame; - frame.prev = prevFrame; - if (this._isParentCooriinate) { - if (prevFrame instanceof dragonBones.TweenFrameData && frameObject[ObjectDataParser.DISPLAY_INDEX] == -1) { - prevFrame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; - } - } - } - prevFrame = frame; - } - timeline.frames[i] = frame; - } - frame.duration = this._animation.duration - frame.position; // Modify last frame duration. - frame = timeline.frames[0]; - prevFrame.next = frame; - frame.prev = prevFrame; - if (this._isParentCooriinate) { - if (prevFrame instanceof dragonBones.TweenFrameData && rawFrames[0][ObjectDataParser.DISPLAY_INDEX] == -1) { - prevFrame.tweenEasing = dragonBones.DragonBones.NO_TWEEN; - } - } - } - } - } - this._timeline = null; + EgretFactory.prototype.buildFastArmature = function (armatureName, dragonBonesName, skinName) { + if (dragonBonesName === void 0) { dragonBonesName = null; } + if (skinName === void 0) { skinName = null; } + return this.buildArmature(armatureName, dragonBonesName, skinName); }; + return EgretFactory; + }(dragonBones.BaseFactory)); + dragonBones.EgretFactory = EgretFactory; +})(dragonBones || (dragonBones = {})); +var dragonBones; +(function (dragonBones) { + /** + * @language zh_CN + * Egret 插槽。 + * @version DragonBones 3.0 + */ + var EgretSlot = (function (_super) { + __extends(EgretSlot, _super); /** - * @private + * @language zh_CN + * 创建一个空的插槽。 + * @version DragonBones 3.0 */ - p._parseActionData = function (rawData, actions, bone, slot) { - var actionsObject = rawData[ObjectDataParser.ACTION] || rawData[ObjectDataParser.ACTIONS] || rawData[ObjectDataParser.DEFAULT_ACTIONS]; - if (typeof actionsObject == "string") { - var actionData = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - actionData.type = 4 /* FadeIn */; - actionData.data = [actionsObject, -1, -1]; - actionData.bone = bone; - actionData.slot = slot; - actions.push(actionData); - } - else if (actionsObject instanceof Array) { - for (var i = 0, l = actionsObject.length; i < l; ++i) { - var actionObject = (actionsObject[i] instanceof Array ? actionsObject[i] : null); - var actionData = dragonBones.BaseObject.borrowObject(dragonBones.ActionData); - var animationName = actionObject ? null : actionsObject[i]["gotoAndPlay"]; - if (actionObject) { - var actionType = actionObject[0]; - if (typeof actionType == "string") { - actionData.type = ObjectDataParser._getActionType(actionType); - } - else { - actionData.type = ObjectDataParser._getParameter(actionObject, 0, 4 /* FadeIn */); - } - } - else { - actionData.type = 2 /* GotoAndPlay */; - } - switch (actionData.type) { - case 0 /* Play */: - actionData.data = [ - actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, - ObjectDataParser._getParameter(actionObject, 2, -1), - ]; - break; - case 1 /* Stop */: - actionData.data = [ - actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, - ]; - break; - case 2 /* GotoAndPlay */: - actionData.data = [ - actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, - ObjectDataParser._getParameter(actionObject, 2, 0), - ObjectDataParser._getParameter(actionObject, 3, -1) // playTimes - ]; - break; - case 3 /* GotoAndStop */: - actionData.data = [ - actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, - ObjectDataParser._getParameter(actionObject, 2, 0), - ]; - break; - case 4 /* FadeIn */: - actionData.data = [ - actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, - ObjectDataParser._getParameter(actionObject, 2, -1), - ObjectDataParser._getParameter(actionObject, 3, -1) // playTimes - ]; - break; - case 5 /* FadeOut */: - actionData.data = [ - actionObject ? ObjectDataParser._getParameter(actionObject, 1, null) : animationName, - ObjectDataParser._getParameter(actionObject, 2, 0) // fadeOutTime - ]; - break; - } - actionData.bone = bone; - actionData.slot = slot; - actions.push(actionData); - } - } + function EgretSlot() { + _super.call(this); + } + /** + * @private + */ + EgretSlot.toString = function () { + return "[class dragonBones.EgretSlot]"; + }; + /** + * @inheritDoc + */ + EgretSlot.prototype._onClear = function () { + _super.prototype._onClear.call(this); + this.transformUpdateEnabled = false; + this._renderDisplay = null; + this._colorFilter = null; }; /** * @private */ - p._parseEventData = function (rawData, events, bone, slot) { - if (ObjectDataParser.SOUND in rawData) { - var soundEventData = dragonBones.BaseObject.borrowObject(dragonBones.EventData); - soundEventData.type = 1 /* Sound */; - soundEventData.name = rawData[ObjectDataParser.SOUND]; - soundEventData.bone = bone; - soundEventData.slot = slot; - events.push(soundEventData); - } - if (ObjectDataParser.EVENT in rawData) { - var eventData = dragonBones.BaseObject.borrowObject(dragonBones.EventData); - eventData.type = 0 /* Frame */; - eventData.name = rawData[ObjectDataParser.EVENT]; - eventData.bone = bone; - eventData.slot = slot; - if (ObjectDataParser.DATA in rawData) { - eventData.data = rawData[ObjectDataParser.DATA]; - } - events.push(eventData); + EgretSlot.prototype._onUpdateDisplay = function () { + if (!this._rawDisplay) { + this._rawDisplay = new egret.Bitmap(); } + this._renderDisplay = (this._display || this._rawDisplay); }; /** * @private */ - p._parseTransform = function (rawData, transform) { - transform.x = ObjectDataParser._getNumber(rawData, ObjectDataParser.X, 0) * this._armatureScale; - transform.y = ObjectDataParser._getNumber(rawData, ObjectDataParser.Y, 0) * this._armatureScale; - transform.skewX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_X, 0) * dragonBones.DragonBones.ANGLE_TO_RADIAN; - transform.skewY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SKEW_Y, 0) * dragonBones.DragonBones.ANGLE_TO_RADIAN; - transform.scaleX = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_X, 1); - transform.scaleY = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE_Y, 1); + EgretSlot.prototype._initDisplay = function (value) { }; /** * @private */ - p._parseColorTransform = function (rawData, color) { - color.alphaMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_MULTIPLIER, 100) * 0.01; - color.redMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_MULTIPLIER, 100) * 0.01; - color.greenMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_MULTIPLIER, 100) * 0.01; - color.blueMultiplier = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_MULTIPLIER, 100) * 0.01; - color.alphaOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.ALPHA_OFFSET, 0); - color.redOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.RED_OFFSET, 0); - color.greenOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.GREEN_OFFSET, 0); - color.blueOffset = ObjectDataParser._getNumber(rawData, ObjectDataParser.BLUE_OFFSET, 0); + EgretSlot.prototype._addDisplay = function () { + var container = this._armature._display; + container.addChild(this._renderDisplay); }; /** - * @inheritDoc + * @private */ - p.parseDragonBonesData = function (rawData, scale) { - if (scale === void 0) { scale = 1; } - if (rawData) { - var version = ObjectDataParser._getString(rawData, ObjectDataParser.VERSION, null); - this._isParentCooriinate = version == ObjectDataParser.DATA_VERSION_2_3 || version == ObjectDataParser.DATA_VERSION_3_0; - this._armatureScale = scale; - if (version == ObjectDataParser.DATA_VERSION || - version == ObjectDataParser.DATA_VERSION_4_0 || - this._isParentCooriinate) { - var data = dragonBones.BaseObject.borrowObject(dragonBones.DragonBonesData); - data.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); - data.frameRate = ObjectDataParser._getNumber(rawData, ObjectDataParser.FRAME_RATE, 24) || 24; - if (ObjectDataParser.ARMATURE in rawData) { - this._data = data; - var armatures = rawData[ObjectDataParser.ARMATURE]; - for (var i = 0, l = armatures.length; i < l; ++i) { - data.addArmature(this._parseArmature(armatures[i])); - } - this._data = null; - } - return data; + EgretSlot.prototype._replaceDisplay = function (value) { + var container = this._armature._display; + var prevDisplay = value; + container.addChild(this._renderDisplay); + container.swapChildren(this._renderDisplay, prevDisplay); + container.removeChild(prevDisplay); + }; + /** + * @private + */ + EgretSlot.prototype._removeDisplay = function () { + this._renderDisplay.parent.removeChild(this._renderDisplay); + }; + /** + * @private + */ + EgretSlot.prototype._disposeDisplay = function (value) { + // + }; + /** + * @private + */ + EgretSlot.prototype._updateVisible = function () { + this._renderDisplay.visible = this._parent.visible; + }; + /** + * @private + */ + EgretSlot.prototype._updateBlendMode = function () { + if (this._blendMode < EgretSlot.BLEND_MODE_LIST.length) { + var blendMode = EgretSlot.BLEND_MODE_LIST[this._blendMode]; + if (blendMode) { + this._renderDisplay.blendMode = blendMode; } - else { - throw new Error("Nonsupport data version."); + } + }; + /** + * @private + */ + EgretSlot.prototype._updateColor = function () { + if (this._colorTransform.redMultiplier != 1 || + this._colorTransform.greenMultiplier != 1 || + this._colorTransform.blueMultiplier != 1 || + this._colorTransform.redOffset != 0 || + this._colorTransform.greenOffset != 0 || + this._colorTransform.blueOffset != 0) { + if (!this._colorFilter) { + this._colorFilter = new egret.ColorMatrixFilter(); + } + var colorMatrix = this._colorFilter.matrix; + colorMatrix[0] = this._colorTransform.redMultiplier; + colorMatrix[6] = this._colorTransform.greenMultiplier; + colorMatrix[12] = this._colorTransform.blueMultiplier; + colorMatrix[18] = this._colorTransform.alphaMultiplier; + colorMatrix[4] = this._colorTransform.redOffset; + colorMatrix[9] = this._colorTransform.greenOffset; + colorMatrix[14] = this._colorTransform.blueOffset; + colorMatrix[19] = this._colorTransform.alphaOffset; + this._colorFilter.matrix = colorMatrix; + var filters = this._renderDisplay.filters; + if (!filters) { + filters = []; } + if (filters.indexOf(this._colorFilter) < 0) { + filters.push(this._colorFilter); + } + this._renderDisplay.filters = filters; } else { - throw new Error(); + if (this._colorFilter) { + this._colorFilter = null; + this._renderDisplay.filters = null; + } + this._renderDisplay.$setAlpha(this._colorTransform.alphaMultiplier); } - // return null; }; /** - * @inheritDoc + * @private */ - p.parseTextureAtlasData = function (rawData, textureAtlasData, scale) { - if (scale === void 0) { scale = 0; } - if (rawData) { - textureAtlasData.name = ObjectDataParser._getString(rawData, ObjectDataParser.NAME, null); - textureAtlasData.imagePath = ObjectDataParser._getString(rawData, ObjectDataParser.IMAGE_PATH, null); - // Texture format. - if (scale > 0) { - textureAtlasData.scale = scale; - } - else { - scale = textureAtlasData.scale = ObjectDataParser._getNumber(rawData, ObjectDataParser.SCALE, textureAtlasData.scale); + EgretSlot.prototype._updateFilters = function () { }; + /** + * @private + */ + EgretSlot.prototype._updateFrame = function () { + var frameDisplay = this._renderDisplay; + if (this._display && this._displayIndex >= 0) { + var rawDisplayData = this._displayIndex < this._displayDataSet.displays.length ? this._displayDataSet.displays[this._displayIndex] : null; + var replacedDisplayData = this._displayIndex < this._replacedDisplayDataSet.length ? this._replacedDisplayDataSet[this._displayIndex] : null; + var currentDisplayData = replacedDisplayData || rawDisplayData; + var currentTextureData = currentDisplayData.texture; + if (currentTextureData) { + var textureAtlasTexture = currentTextureData.parent.texture; + if (!currentTextureData.texture && textureAtlasTexture) { + currentTextureData.texture = new egret.Texture(); + currentTextureData.texture._bitmapData = textureAtlasTexture._bitmapData; + currentTextureData.texture.$initData(currentTextureData.region.x, currentTextureData.region.y, Math.min(currentTextureData.region.width, textureAtlasTexture.textureWidth - currentTextureData.region.x), Math.min(currentTextureData.region.height, textureAtlasTexture.textureHeight - currentTextureData.region.y), 0, 0, Math.min(currentTextureData.region.width, textureAtlasTexture.textureWidth - currentTextureData.region.x), Math.min(currentTextureData.region.height, textureAtlasTexture.textureHeight - currentTextureData.region.y), textureAtlasTexture.textureWidth, textureAtlasTexture.textureHeight); + } + var texture = this._armature._replacedTexture || currentTextureData.texture; + if (texture) { + if (this._meshData && this._display == this._meshDisplay) { + var meshDisplay = this._meshDisplay; + var meshNode = meshDisplay.$renderNode; + meshNode.uvs.length = 0; + meshNode.vertices.length = 0; + meshNode.indices.length = 0; + for (var i = 0, l = this._meshData.vertices.length; i < l; ++i) { + meshNode.uvs[i] = this._meshData.uvs[i]; + meshNode.vertices[i] = this._meshData.vertices[i]; + } + for (var i = 0, l = this._meshData.vertexIndices.length; i < l; ++i) { + meshNode.indices[i] = this._meshData.vertexIndices[i]; + } + meshDisplay.$setBitmapData(texture); + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); + // Identity transform. + if (this._meshData.skinned) { + var transformationMatrix = meshDisplay.matrix; + transformationMatrix.identity(); + meshDisplay.matrix = transformationMatrix; + } + } + else { + var rect = currentTextureData.frame || currentTextureData.region; + var width = rect.width; + var height = rect.height; + if (currentTextureData.rotated) { + width = rect.height; + height = rect.width; + } + var pivotX = currentDisplayData.pivot.x; + var pivotY = currentDisplayData.pivot.y; + if (currentDisplayData.isRelativePivot) { + pivotX = width * pivotX; + pivotY = height * pivotY; + } + if (currentTextureData.frame) { + pivotX += currentTextureData.frame.x; + pivotY += currentTextureData.frame.y; + } + if (rawDisplayData && rawDisplayData != currentDisplayData) { + pivotX += rawDisplayData.transform.x - currentDisplayData.transform.x; + pivotY += rawDisplayData.transform.y - currentDisplayData.transform.y; + } + frameDisplay.$setBitmapData(texture); + frameDisplay.$setAnchorOffsetX(pivotX); + frameDisplay.$setAnchorOffsetY(pivotY); + } + this._updateVisible(); + return; + } } - scale = 1 / scale; - if (ObjectDataParser.SUB_TEXTURE in rawData) { - var textures = rawData[ObjectDataParser.SUB_TEXTURE]; - for (var i = 0, l = textures.length; i < l; ++i) { - var textureObject = textures[i]; - var textureData = textureAtlasData.generateTextureData(); - textureData.name = ObjectDataParser._getString(textureObject, ObjectDataParser.NAME, null); - textureData.rotated = ObjectDataParser._getBoolean(textureObject, ObjectDataParser.ROTATED, false); - textureData.region.x = ObjectDataParser._getNumber(textureObject, ObjectDataParser.X, 0) * scale; - textureData.region.y = ObjectDataParser._getNumber(textureObject, ObjectDataParser.Y, 0) * scale; - textureData.region.width = ObjectDataParser._getNumber(textureObject, ObjectDataParser.WIDTH, 0) * scale; - textureData.region.height = ObjectDataParser._getNumber(textureObject, ObjectDataParser.HEIGHT, 0) * scale; - var frameWidth = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_WIDTH, -1); - var frameHeight = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_HEIGHT, -1); - if (frameWidth > 0 && frameHeight > 0) { - textureData.frame = dragonBones.TextureData.generateRectangle(); - textureData.frame.x = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_X, 0) * scale; - textureData.frame.y = ObjectDataParser._getNumber(textureObject, ObjectDataParser.FRAME_Y, 0) * scale; - textureData.frame.width = frameWidth * scale; - textureData.frame.height = frameHeight * scale; + } + frameDisplay.visible = false; + frameDisplay.$setBitmapData(null); + frameDisplay.$setAnchorOffsetX(0); + frameDisplay.$setAnchorOffsetY(0); + frameDisplay.x = 0; + frameDisplay.y = 0; + }; + /** + * @private + */ + EgretSlot.prototype._updateMesh = function () { + var meshDisplay = this._meshDisplay; + var meshNode = meshDisplay.$renderNode; + var hasFFD = this._ffdVertices.length > 0; + if (this._meshData.skinned) { + for (var i = 0, iF = 0, l = this._meshData.vertices.length; i < l; i += 2) { + var iH = i / 2; + var boneIndices = this._meshData.boneIndices[iH]; + var boneVertices = this._meshData.boneVertices[iH]; + var weights = this._meshData.weights[iH]; + var xG = 0, yG = 0; + for (var iB = 0, lB = boneIndices.length; iB < lB; ++iB) { + var bone = this._meshBones[boneIndices[iB]]; + var matrix = bone.globalTransformMatrix; + var weight = weights[iB]; + var xL = 0, yL = 0; + if (hasFFD) { + xL = boneVertices[iB * 2] + this._ffdVertices[iF]; + yL = boneVertices[iB * 2 + 1] + this._ffdVertices[iF + 1]; } - textureAtlasData.addTextureData(textureData); + else { + xL = boneVertices[iB * 2]; + yL = boneVertices[iB * 2 + 1]; + } + xG += (matrix.a * xL + matrix.c * yL + matrix.tx) * weight; + yG += (matrix.b * xL + matrix.d * yL + matrix.ty) * weight; + iF += 2; } + meshNode.vertices[i] = xG; + meshNode.vertices[i + 1] = yG; } - return textureAtlasData; + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); } - else { - throw new Error(); + else if (hasFFD) { + var vertices = this._meshData.vertices; + for (var i = 0, l = this._meshData.vertices.length; i < l; i += 2) { + var xG = vertices[i] + this._ffdVertices[i]; + var yG = vertices[i + 1] + this._ffdVertices[i + 1]; + meshNode.vertices[i] = xG; + meshNode.vertices[i + 1] = yG; + } + meshDisplay.$updateVertices(); + meshDisplay.$invalidateTransform(); } - // return null; }; /** - * @deprecated - * @see dragonBones.BaseFactory#parseDragonBonesData() + * @private */ - ObjectDataParser.getInstance = function () { - if (!ObjectDataParser._instance) { - ObjectDataParser._instance = new ObjectDataParser(); - } - return ObjectDataParser._instance; + EgretSlot.prototype._updateTransform = function () { + this._renderDisplay.$setMatrix(this.globalTransformMatrix, this.transformUpdateEnabled); }; /** - * @deprecated + * @private */ - ObjectDataParser._instance = null; - return ObjectDataParser; - }(dragonBones.DataParser)); - dragonBones.ObjectDataParser = ObjectDataParser; - egret.registerClass(ObjectDataParser,'dragonBones.ObjectDataParser'); + EgretSlot.BLEND_MODE_LIST = [ + egret.BlendMode.NORMAL, + egret.BlendMode.ADD, + null, + null, + null, + egret.BlendMode.ERASE, + null, + null, + null, + null, + null, + null, + null, + null + ]; + return EgretSlot; + }(dragonBones.Slot)); + dragonBones.EgretSlot = EgretSlot; })(dragonBones || (dragonBones = {})); diff --git a/build/dragonBones/dragonBones.min.js b/build/dragonBones/dragonBones.min.js index 6467cbdd96..c163b7dd51 100644 --- a/build/dragonBones/dragonBones.min.js +++ b/build/dragonBones/dragonBones.min.js @@ -1,4 +1,4 @@ -var dragonBones;!function(e){var t=function(){function e(){this.hashCode=e._hashCode++}var t=(__define,e),a=t.prototype;return e._returnObject=function(t){var a=t.constructor,n=String(a),r=null==e._maxCountMap[n]?e._defaultMaxCount:e._maxCountMap[n],i=e._poolsMap[n]=e._poolsMap[n]||[];if(i.lengtha||a!=a)&&(a=0),t){var n=String(t);e._maxCountMap[n]=a;var r=e._poolsMap[n];r&&r.length>a&&(r.length=a)}else{e._defaultMaxCount=a;for(var n in e._poolsMap)if(null!=e._maxCountMap[n]){var r=e._poolsMap[n];r.length>a&&(r.length=a)}}},e.clearPool=function(t){if(void 0===t&&(t=null),t){var a=e._poolsMap[String(t)];a&&a.length&&(a.length=0)}else for(var n in e._poolsMap){var a=e._poolsMap[n];a.length=0}},e.borrowObject=function(t){var a=e._poolsMap[String(t)];if(a&&a.length)return a.pop();var n=new t;return n._onClear(),n},a.returnToPool=function(){this._onClear(),e._returnObject(this)},e._hashCode=0,e._defaultMaxCount=5e3,e._maxCountMap={},e._poolsMap={},e}();e.BaseObject=t,egret.registerClass(t,"dragonBones.BaseObject")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this),this._animations={},this._animationNames=[],this._animationStates=[]}__extends(a,t);var n=__define,r=a,i=r.prototype;return a._sortAnimationState=function(e,t){return e.layer>t.layer?1:-1},a.toString=function(){return"[Class dragonBones.Animation]"},i._onClear=function(){var e=this;e.timeScale=1,e._animationStateDirty=!1,e._timelineStateDirty=!1,e._armature=null,e._isPlaying=!1,e._time=0,e._lastAnimationState=null;for(var t in e._animations)delete e._animations[t];e._animationNames.length&&(e._animationNames.length=0);for(var t=0,a=e._animationStates.length;a>t;++t)e._animationStates[t].returnToPool();e._animationStates.length=0},i._fadeOut=function(e,t,a,n,r){var i=this,o=0,s=i._animationStates.length,l=null;switch(n){case 0:break;case 1:for(;s>o;++o)l=i._animationStates[o],l.layer==t&&l.fadeOut(e,r);break;case 2:for(;s>o;++o)l=i._animationStates[o],l.group==a&&l.fadeOut(e,r);break;case 4:for(;s>o;++o)l=i._animationStates[o],l.fadeOut(e,r);break;case 3:for(;s>o;++o)l=i._animationStates[o],l.layer==t&&l.group==a&&l.fadeOut(e,r)}},i._updateFFDTimelineStates=function(){for(var e=this,t=0,a=e._animationStates.length;a>t;++t)e._animationStates[t]._updateFFDTimelineStates()},i._advanceTime=function(e){var t=this;if(t._isPlaying){0>e&&(e=-e);var a=t._animationStates.length;if(1==a){var n=t._animationStates[0];n._isFadeOutComplete?(n.returnToPool(),t._animationStates.length=0,t._animationStateDirty=!0,t._lastAnimationState=null):(t._timelineStateDirty&&n._updateTimelineStates(),n._advanceTime(e,1,0))}else if(a>1)for(var r=t._animationStates[0]._layer,i=1,o=0,s=1,l=0,_=0;a>l;++l){var n=t._animationStates[l];n._isFadeOutComplete?(_++,n.returnToPool(),t._lastAnimationState==n&&(l-_>=0?t._lastAnimationState=t._animationStates[l-_]:t._lastAnimationState=null)):(_>0&&(t._animationStates[l-_]=n),r!=n._layer&&(r=n._layer,o>=i?i=0:i-=o,o=0),t._timelineStateDirty&&n._updateTimelineStates(),n._advanceTime(e,i,s),0!=n._weightResult&&(o+=n._weightResult,s++)),l==a-1&&_>0&&(t._animationStates.length-=_)}t._timelineStateDirty=!1}},i.reset=function(){var e=this;e._isPlaying=!1,e._lastAnimationState=null;for(var t=0,a=e._animationStates.length;a>t;++t)e._animationStates[t].returnToPool();e._animationStates.length=0},i.stop=function(e){if(void 0===e&&(e=null),e){var t=this.getState(e);t&&t.stop()}else this._isPlaying=!1},i.play=function(e,t){void 0===e&&(e=null),void 0===t&&(t=-1);var a=this,n=null;if(e)n=a.fadeIn(e,0,t,0,null,4);else if(a._lastAnimationState)a._isPlaying?n=a.fadeIn(a._lastAnimationState.name,0,t,0,null,4):a._isPlaying=!0;else{var r=a._armature.armatureData.defaultAnimation;r&&(n=a.fadeIn(r.name,0,t,0,null,4))}return n},i.fadeIn=function(t,n,r,i,o,s,l,_,u,f){void 0===n&&(n=-1),void 0===r&&(r=-1),void 0===i&&(i=0),void 0===o&&(o=null),void 0===s&&(s=3),void 0===l&&(l=!1),void 0===_&&(_=!0),void 0===u&&(u=!0),void 0===f&&(f=!0);var m=this,h=m._animations[t];if(!h)return m._time=0,console.warn("No animation."," Armature: "+m._armature.name," Animation: "+t),null;m._isPlaying=!0,(n!=n||0>n)&&(n=m._lastAnimationState?h.fadeInTime:0),0>r&&(r=h.playTimes),m._fadeOut(n,i,o,s,u),m._lastAnimationState=e.BaseObject.borrowObject(e.AnimationState),m._lastAnimationState._layer=i,m._lastAnimationState._group=o,m._lastAnimationState.additiveBlending=l,m._lastAnimationState.displayControl=_,m._lastAnimationState._fadeIn(m._armature,h.animation||h,t,r,h.position,h.duration,m._time,1/h.scale,n,f),m._animationStates.push(m._lastAnimationState),m._animationStateDirty=!0,m._time=0,m._animationStates.length>1&&m._animationStates.sort(a._sortAnimationState);for(var c=m._armature.getSlots(),d=0,g=c.length;g>d;++d){var p=c[d];if(p.inheritAnimation){var v=p.childArmature;v&&v.animation.hasAnimation(t)&&!v.animation.getState(t)&&v.animation.fadeIn(t)}}return m._armature.advanceTime(0),m._lastAnimationState},i.gotoAndPlayByTime=function(e,t,a){return void 0===t&&(t=0),void 0===a&&(a=-1),this._time=t,this.fadeIn(e,0,a,0,null,4)},i.gotoAndPlayByFrame=function(e,t,a){void 0===t&&(t=0),void 0===a&&(a=-1);var n=this._animations[e];return n&&(this._time=n.duration*t/n.frameCount),this.fadeIn(e,0,a,0,null,4)},i.gotoAndPlayByProgress=function(e,t,a){void 0===t&&(t=0),void 0===a&&(a=-1);var n=this._animations[e];return n&&(this._time=n.duration*Math.max(t,0)),this.fadeIn(e,0,a,0,null,4)},i.gotoAndStopByTime=function(e,t){void 0===t&&(t=0);var a=this.gotoAndPlayByTime(e,t,1);return a&&(this._isPlaying=!1,a.stop()),a},i.gotoAndStopByFrame=function(e,t){void 0===t&&(t=0);var a=this.gotoAndPlayByFrame(e,t,1);return a&&(this._isPlaying=!1,a.stop()),a},i.gotoAndStopByProgress=function(e,t){void 0===t&&(t=0);var a=this.gotoAndPlayByProgress(e,t,1);return a&&(this._isPlaying=!1,a.stop()),a},i.getState=function(e){for(var t=0,a=this._animationStates.length;a>t;++t){var n=this._animationStates[t];if(n.name==e)return n}return null},i.hasAnimation=function(e){return null!=this._animations[e]},n(i,"isPlaying",function(){return this._isPlaying}),n(i,"isCompleted",function(){var e=this;if(e._lastAnimationState){if(!e._lastAnimationState.isCompleted)return!1;for(var t=0,a=e._animationStates.length;a>t;++t)if(!e._animationStates[t].isCompleted)return!1}return!0}),n(i,"lastAnimationName",function(){return this._lastAnimationState?this._lastAnimationState.name:null}),n(i,"lastAnimationState",function(){return this._lastAnimationState}),n(i,"animationNames",function(){return this._animationNames}),n(i,"animations",function(){return this._animations},function(e){var t=this;if(t._animations!=e){for(var a in t._animations)delete t._animations[a];if(t._animationNames.length=0,e)for(var a in e)t._animations[a]=e[a],t._animationNames.push(a)}}),i.gotoAndPlay=function(e,t,a,n,r,i,o,s,l){void 0===t&&(t=-1),void 0===a&&(a=-1),void 0===n&&(n=-1),void 0===r&&(r=0),void 0===i&&(i=null),void 0===o&&(o=3),void 0===s&&(s=!0),void 0===l&&(l=!0);var _=this.fadeIn(e,t,n,r,i,o,!1,!0,s,l);return _&&a&&a>0&&(_.timeScale=_.totalTime/a),_},i.gotoAndStop=function(e,t){return void 0===t&&(t=0),this.gotoAndStopByTime(e,t)},n(i,"animationList",function(){return this._animationNames}),n(i,"animationDataList",function(){for(var e=[],t=0,a=this._animationNames.length;a>t;++t)e.push(this._animations[this._animationNames[t]]);return e}),a}(e.BaseObject);e.Animation=t,egret.registerClass(t,"dragonBones.Animation")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this),this._boneMask=[],this._boneTimelines=[],this._slotTimelines=[],this._ffdTimelines=[],this.autoTween=!1}__extends(a,t);var n=__define,r=a,i=r.prototype;return a.toString=function(){return"[Class dragonBones.AnimationState]"},i._onClear=function(){var e=this;e.displayControl=!0,e.additiveBlending=!1,e.playTimes=1,e.timeScale=1,e.weight=1,e.autoFadeOutTime=-1,e.fadeTotalTime=0,e._isFadeOutComplete=!1,e._layer=0,e._position=0,e._duration=0,e._weightResult=0,e._fadeProgress=0,e._group=null,e._timeline&&(e._timeline.returnToPool(),e._timeline=null),e._isPlaying=!0,e._isPausePlayhead=!1,e._isFadeOut=!1,e._currentPlayTimes=0,e._fadeTime=0,e._time=0,e._name=null,e._armature=null,e._animationData=null,e._boneMask.length&&(e._boneMask.length=0);for(var t=0,a=e._boneTimelines.length;a>t;++t)e._boneTimelines[t].returnToPool();for(var t=0,a=e._slotTimelines.length;a>t;++t)e._slotTimelines[t].returnToPool();for(var t=0,a=e._ffdTimelines.length;a>t;++t)e._ffdTimelines[t].returnToPool();e._boneTimelines.length=0,e._slotTimelines.length=0,e._ffdTimelines.length=0},i._advanceFadeTime=function(t){var a=this;0>t&&(t=-t),a._fadeTime+=t;var n=0;if(n=a._fadeTime>=a.fadeTotalTime?a._isFadeOut?0:1:a._fadeTime>0?a._isFadeOut?1-a._fadeTime/a.fadeTotalTime:a._fadeTime/a.fadeTotalTime:a._isFadeOut?1:0,a._fadeProgress!=n){a._fadeProgress=n;var r=a._armature._display;if(a._fadeTime<=t)if(a._isFadeOut){if(r.hasEvent(e.EventObject.FADE_OUT)){var i=e.BaseObject.borrowObject(e.EventObject);i.animationState=this,a._armature._bufferEvent(i,e.EventObject.FADE_OUT)}}else if(r.hasEvent(e.EventObject.FADE_IN)){var o=e.BaseObject.borrowObject(e.EventObject);o.animationState=this,a._armature._bufferEvent(o,e.EventObject.FADE_IN)}if(a._fadeTime>=a.fadeTotalTime)if(a._isFadeOut){if(a._isFadeOutComplete=!0,r.hasEvent(e.EventObject.FADE_OUT_COMPLETE)){var s=e.BaseObject.borrowObject(e.EventObject);s.animationState=this,a._armature._bufferEvent(s,e.EventObject.FADE_OUT_COMPLETE)}}else if(a._isPausePlayhead=!1,r.hasEvent(e.EventObject.FADE_IN_COMPLETE)){var l=e.BaseObject.borrowObject(e.EventObject);l.animationState=this,a._armature._bufferEvent(l,e.EventObject.FADE_IN_COMPLETE)}}},i._isDisabled=function(e){return!this.displayControl||e.displayController&&e.displayController!=this._name&&e.displayController!=this._group?!0:!1},i._fadeIn=function(t,a,n,r,i,o,s,l,_,u){var f=this;f._armature=t,f._animationData=a,f._name=n,f.playTimes=r,f.timeScale=l,f.fadeTotalTime=_,f._position=i,f._duration=o,f._time=s,f._isPausePlayhead=u,0==f.fadeTotalTime&&(f._fadeProgress=.999999),f._timeline=e.BaseObject.borrowObject(e.AnimationTimelineState),f._timeline.fadeIn(f._armature,f,f._animationData,f._time),f._updateTimelineStates()},i._updateTimelineStates=function(){var t=this,a=t._time;t._animationData.hasAsynchronyTimeline||(a=t._timeline._currentTime);for(var n={},r={},i=0,o=t._boneTimelines.length;o>i;++i){var s=t._boneTimelines[i];n[s.bone.name]=s}for(var l=t._armature.getBones(),i=0,o=l.length;o>i;++i){var _=l[i],u=_.name,f=t._animationData.getBoneTimeline(u);if(f&&t.containsBoneMask(u)){var s=n[u];s?delete n[u]:(s=e.BaseObject.borrowObject(e.BoneTimelineState),s.bone=_,s.fadeIn(t._armature,this,f,a),t._boneTimelines.push(s))}}for(var i in n){var s=n[i];s.bone.invalidUpdate(),t._boneTimelines.splice(t._boneTimelines.indexOf(s),1),s.returnToPool()}for(var i=0,o=t._slotTimelines.length;o>i;++i){var m=t._slotTimelines[i];r[m.slot.name]=m}for(var h=t._armature.getSlots(),i=0,o=h.length;o>i;++i){var c=h[i],d=c.name,g=c.parent.name,p=t._animationData.getSlotTimeline(d);if(p&&t.containsBoneMask(g)&&!t._isFadeOut){var m=r[d];m?delete r[d]:(m=e.BaseObject.borrowObject(e.SlotTimelineState),m.slot=c,m.fadeIn(t._armature,this,p,a),t._slotTimelines.push(m))}}for(var i in r){var m=r[i];t._slotTimelines.splice(t._slotTimelines.indexOf(m),1),m.returnToPool()}t._updateFFDTimelineStates()},i._updateFFDTimelineStates=function(){var t=this,a=t._time;t._animationData.hasAsynchronyTimeline||(a=t._timeline._currentTime);for(var n={},r=0,i=t._ffdTimelines.length;i>r;++r){var o=t._ffdTimelines[r];n[o.slot.name]=o}for(var s=t._armature.getSlots(),r=0,i=s.length;i>r;++r){var l=s[r],_=l.name,u=l.parent.name;if(l._meshData){var f=t._animationData.getFFDTimeline(t._armature._skinData.name,_,l.displayIndex);if(f&&t.containsBoneMask(u)){var o=n[_];o?delete n[_]:(o=e.BaseObject.borrowObject(e.FFDTimelineState),o.slot=l,o.fadeIn(t._armature,this,f,a),t._ffdTimelines.push(o))}else{for(var m=0,h=l._ffdVertices.length;h>m;++m)l._ffdVertices[m]=0;l._ffdDirty=!0}}}for(var r in n){var o=n[r];o.slot._ffdDirty=!0,t._ffdTimelines.splice(t._ffdTimelines.indexOf(o),1),o.returnToPool()}},i._advanceTime=function(e,t,a){var n=this;if(0!=e&&n._advanceFadeTime(e),e*=n.timeScale,0!=e&&n._isPlaying&&!n._isPausePlayhead&&(n._time+=e),n._weightResult=n.weight*n._fadeProgress*t,0!=n._weightResult){var r=n._fadeProgress>=1&&0==a&&n._armature.cacheFrameRate>0,i=n._animationData.cacheTimeToFrameScale,o=!0,s=!0,l=r?Math.floor(n._time*i)/i:n._time;if(n._timeline.update(l),n._animationData.hasAsynchronyTimeline||(l=n._timeline._currentTime),r){var _=Math.floor(n._timeline._currentTime*i);if(n._armature._cacheFrameIndex==_)o=!1,s=!1;else{if(n._armature._cacheFrameIndex=_,n._armature._animation._animationStateDirty){n._armature._animation._animationStateDirty=!1;for(var u=0,f=n._boneTimelines.length;f>u;++u){var m=n._boneTimelines[u];m.bone._cacheFrames=m._timeline.cachedFrames}for(var u=0,f=n._slotTimelines.length;f>u;++u){var h=n._slotTimelines[u];h.slot._cacheFrames=h._timeline.cachedFrames}}n._animationData.cachedFrames[_]?s=!1:n._animationData.cachedFrames[_]=!0}}else n._armature._cacheFrameIndex=-1;if(o){if(s)for(var u=0,f=n._boneTimelines.length;f>u;++u)n._boneTimelines[u].update(l);for(var u=0,f=n._slotTimelines.length;f>u;++u)n._slotTimelines[u].update(l);for(var u=0,f=n._ffdTimelines.length;f>u;++u)n._ffdTimelines[u].update(l)}}n.autoFadeOutTime>=0&&n._fadeProgress>=1&&n._timeline._isCompleted&&n.fadeOut(n.autoFadeOutTime)},i.play=function(){this._isPlaying=!0},i.stop=function(){this._isPlaying=!1},i.fadeOut=function(e,t){void 0===t&&(t=!0);var a=this;if((0>e||e!=e)&&(e=0),a._isPausePlayhead=t,a._isFadeOut){if(e>e-a._fadeTime)return}else{a._isFadeOut=!0,(0==e||a._fadeProgress<=0)&&(a._fadeProgress=1e-6);for(var n=0,r=a._boneTimelines.length;r>n;++n)a._boneTimelines[n].fadeOut();for(var n=0,r=a._slotTimelines.length;r>n;++n)a._slotTimelines[n].fadeOut()}a.displayControl=!1,a.fadeTotalTime=a._fadeProgress>1e-6?e/a._fadeProgress:0,a._fadeTime=a.fadeTotalTime*(1-a._fadeProgress)},i.containsBoneMask=function(e){return!this._boneMask.length||this._boneMask.indexOf(e)>=0},i.addBoneMask=function(e,t){void 0===t&&(t=!0);var a=this,n=a._armature.getBone(e);if(n){if(a._boneMask.indexOf(e)<0&&a._animationData.getBoneTimeline(e)&&a._boneMask.push(e),t)for(var r=a._armature.getBones(),i=0,o=r.length;o>i;++i){var s=r[i],l=s.name;a._boneMask.indexOf(l)<0&&a._animationData.getBoneTimeline(l)&&n.contains(s)&&a._boneMask.push(l)}a._updateTimelineStates()}},i.removeBoneMask=function(e,t){void 0===t&&(t=!0);var a=this,n=a._boneMask.indexOf(e);if(n>=0&&a._boneMask.splice(n,1),t){var r=a._armature.getBone(e);if(r)for(var i=a._armature.getBones(),o=0,s=i.length;s>o;++o){var l=i[o],_=l.name,u=a._boneMask.indexOf(_);u>=0&&r.contains(l)&&a._boneMask.splice(u,1)}}a._updateTimelineStates()},i.removeAllBoneMask=function(){this._boneMask.length=0,this._updateTimelineStates()},n(i,"layer",function(){return this._layer}),n(i,"group",function(){return this._group}),n(i,"name",function(){return this._name}),n(i,"animationData",function(){return this._animationData}),n(i,"isCompleted",function(){return this._timeline._isCompleted}),n(i,"isPlaying",function(){return this._isPlaying&&!this._timeline._isCompleted}),n(i,"currentPlayTimes",function(){return this._currentPlayTimes}),n(i,"totalTime",function(){return this._duration}),n(i,"currentTime",function(){return this._timeline._currentTime},function(e){var t=this;if((0>e||e!=e)&&(e=0),t._time=e,t._timeline.setCurrentTime(t._time),0!=t._weightResult){var a=t._time;t._animationData.hasAsynchronyTimeline||(a=t._timeline._currentTime);for(var n=0,r=t._boneTimelines.length;r>n;++n)t._boneTimelines[n].setCurrentTime(a);for(var n=0,r=t._slotTimelines.length;r>n;++n)t._slotTimelines[n].setCurrentTime(a);for(var n=0,r=t._ffdTimelines.length;r>n;++n)t._ffdTimelines[n].setCurrentTime(a)}}),n(i,"clip",function(){return this._animationData}),a}(e.BaseObject);e.AnimationState=t,egret.registerClass(t,"dragonBones.AnimationState")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this)}__extends(t,e);var a=(__define,t),n=a.prototype;return n._onClear=function(){var e=this;e._isCompleted=!1,e._currentPlayTimes=0,e._currentTime=0,e._timeline=null,e._isReverse=!1,e._hasAsynchronyTimeline=!1,e._frameRate=0,e._keyFrameCount=0,e._frameCount=0,e._position=0,e._duration=0,e._animationDutation=0,e._timeScale=1,e._timeOffset=0,e._currentFrame=null,e._armature=null,e._animationState=null},n._onFadeIn=function(){},n._onUpdateFrame=function(e){},n._onArriveAtFrame=function(e){},n._onCrossFrame=function(e){},n._setCurrentTime=function(e){var t=this,a=0;if(t._hasAsynchronyTimeline){var n=t._animationState.playTimes,r=n*t._duration;e*=t._timeScale,0!=t._timeOffset&&(e+=t._timeOffset*t._animationDutation),n>0&&(e>=r||-r>=e)?(t._isCompleted=!0,a=n,e=0>e?0:t._duration):(t._isCompleted=!1,0>e?(a=Math.floor(-e/t._duration),e=t._duration- -e%t._duration):(a=Math.floor(e/t._duration),e%=t._duration),n>0&&a>n&&(a=n)),e+=t._position}else t._isCompleted=t._animationState._timeline._isCompleted,a=t._animationState._timeline._currentPlayTimes;return t._currentTime==e?!1:(1==t._keyFrameCount&&e>t._position&&this!=t._animationState._timeline&&(t._isCompleted=!0),t._isReverse=t._currentTime>e&&t._currentPlayTimes==a,t._currentTime=e,t._currentPlayTimes=a,!0)},n.setCurrentTime=function(e){var t=this;switch(t._setCurrentTime(e),t._keyFrameCount){case 0:break;case 1:t._currentFrame=t._timeline.frames[0],t._onArriveAtFrame(!1),t._onUpdateFrame(!1);break;default:t._currentFrame=t._timeline.frames[Math.floor(t._currentTime*t._frameRate)],t._onArriveAtFrame(!1),t._onUpdateFrame(!1)}t._currentFrame=null},n.fadeIn=function(e,t,a,n){var r=this;r._armature=e,r._animationState=t,r._timeline=a;var i=this==r._animationState._timeline;r._hasAsynchronyTimeline=i||r._animationState.animationData.hasAsynchronyTimeline,r._frameRate=r._armature.armatureData.frameRate,r._keyFrameCount=r._timeline.frames.length,r._frameCount=r._animationState.animationData.frameCount,r._position=r._animationState._position,r._duration=r._animationState._duration,r._animationDutation=r._animationState.animationData.duration,r._timeScale=i?1:1/r._timeline.scale,r._timeOffset=i?0:r._timeline.offset,r._onFadeIn(),r.setCurrentTime(n)},n.fadeOut=function(){},n.update=function(e){var t=this,a=t._currentTime;if(!t._isCompleted&&t._setCurrentTime(e)&&t._keyFrameCount){var n=t._keyFrameCount>1?Math.floor(t._currentTime*t._frameRate):0,r=t._timeline.frames[n];if(t._currentFrame!=r)if(t._keyFrameCount>1){var i=t._currentFrame;if(t._currentFrame=r,!i){var o=Math.floor(a*t._frameRate);i=t._timeline.frames[o],!t._isReverse&&a<=i.position&&(i=i.prev)}if(t._isReverse)for(;i!=r;)t._onCrossFrame(i),i=i.prev;else for(;i!=r;)i=i.next,t._onCrossFrame(i);t._onArriveAtFrame(!0)}else t._currentFrame=r,t._onCrossFrame(t._currentFrame),t._onArriveAtFrame(!0);t._onUpdateFrame(!0)}},t}(e.BaseObject);e.TimelineState=t,egret.registerClass(t,"dragonBones.TimelineState");var a=function(t){function a(){t.call(this)}__extends(a,t);var n=(__define,a),r=n.prototype;return a._getEasingValue=function(e,t){var a=1;if(t>2)return e;if(t>1)a=.5*(1-Math.cos(e*Math.PI)),t-=1;else if(t>0)a=1-Math.pow(1-e,2);else if(t>=-1)t*=-1,a=Math.pow(e,2);else{if(!(t>=-2))return e;t*=-1,a=Math.acos(1-2*e)/Math.PI,t-=1}return(a-e)*t+e},a._getCurveEasingValue=function(e,t){for(var a=0,n=0,r=0,i=t.length;i>r;r+=2)if(a=t[r],n=t[r+1],a>=e){if(0==r)return n*e/a;var o=t[r-2],s=t[r-1];return s+(n-s)*(e-o)/(a-o)}return n+(1-n)*(e-a)/(1-a)},r._onClear=function(){t.prototype._onClear.call(this),this._tweenProgress=0,this._tweenEasing=e.DragonBones.NO_TWEEN,this._curve=null},r._onArriveAtFrame=function(t){var a=this;a._tweenEasing=a._currentFrame.tweenEasing,a._curve=a._currentFrame.curve,(1==a._keyFrameCount||a._currentFrame.next==a._timeline.frames[0]&&(a._tweenEasing!=e.DragonBones.NO_TWEEN||a._curve)&&a._animationState.playTimes>0&&a._animationState.currentPlayTimes==a._animationState.playTimes-1)&&(a._tweenEasing=e.DragonBones.NO_TWEEN,a._curve=null)},r._onUpdateFrame=function(t){var n=this;n._tweenEasing!=e.DragonBones.NO_TWEEN&&n._currentFrame.duration>0?(n._tweenProgress=(n._currentTime-n._currentFrame.position+n._position)/n._currentFrame.duration,0!=n._tweenEasing&&(n._tweenProgress=a._getEasingValue(n._tweenProgress,n._tweenEasing))):n._curve?(n._tweenProgress=(n._currentTime-n._currentFrame.position+n._position)/n._currentFrame.duration,n._tweenProgress=a._getCurveEasingValue(n._tweenProgress,n._curve)):n._tweenProgress=0},r._updateExtensionKeyFrame=function(e,t,a){var n=0;if(e.type==t.type)for(var r=0,i=e.tweens.length;i>r;++r){var o=t.tweens[r]-e.tweens[r];a.tweens[r]=o,0!=o&&(n=2)}if(0==n){a.type!=e.type&&(n=1,a.type=e.type),a.tweens.length!=e.tweens.length&&(n=1,a.tweens.length=e.tweens.length),a.keys.length!=e.keys.length&&(n=1,a.keys.length=e.keys.length);for(var r=0,i=e.keys.length;i>r;++r){var s=e.keys[r];a.keys[r]!=s&&(n=1,a.keys[r]=s)}}return n},a}(t);e.TweenTimelineState=a,egret.registerClass(a,"dragonBones.TweenTimelineState")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this)}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.AnimationTimelineState]"},r._onClear=function(){t.prototype._onClear.call(this),this._isStarted=!1},r._onCrossFrame=function(t){for(var a=this,n=t.actions,r=0,i=n.length;i>r;++r){var o=n[r];if(o.slot){var s=a._armature.getSlot(o.slot.name);if(s){var l=s.childArmature;l&&(l._action=o)}}else if(o.bone)for(var _=a._armature.getSlots(),u=0,f=_.length;f>u;++u){var m=_[u].childArmature;m&&(m._action=o)}else a._armature._action=o}for(var h=a._armature._display,c=t.events,r=0,i=c.length;i>r;++r){var d=c[r],g="";switch(d.type){case 0:g=e.EventObject.FRAME_EVENT;break;case 1:g=e.EventObject.SOUND_EVENT}if(h.hasEvent(g)){var p=e.BaseObject.borrowObject(e.EventObject);p.animationState=a._animationState,d.bone&&(p.bone=a._armature.getBone(d.bone.name)),d.slot&&(p.slot=a._armature.getSlot(d.slot.name)),p.name=d.name,p.data=d.data,a._armature._bufferEvent(p,g)}}},r.update=function(a){var n=this,r=n._currentPlayTimes,i=n._armature._display;if(!n._isStarted&&0!=a&&(n._isStarted=!0,i.hasEvent(e.EventObject.START))){var o=e.BaseObject.borrowObject(e.EventObject);o.animationState=n._animationState,n._armature._bufferEvent(o,e.EventObject.START)}if(t.prototype.update.call(this,a),r!=n._currentPlayTimes){var s=n._isCompleted?e.EventObject.COMPLETE:e.EventObject.LOOP_COMPLETE;if(i.hasEvent(s)){var o=e.BaseObject.borrowObject(e.EventObject);o.animationState=n._animationState,n._armature._bufferEvent(o,s)}}},a}(e.TimelineState);e.AnimationTimelineState=t,egret.registerClass(t,"dragonBones.AnimationTimelineState");var a=function(t){function a(){t.call(this),this._transform=new e.Transform,this._currentTransform=new e.Transform,this._durationTransform=new e.Transform}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.BoneTimelineState]"},r._onClear=function(){var e=this;t.prototype._onClear.call(this),e.bone=null,e._tweenTransform=0,e._tweenRotate=0,e._tweenScale=0,e._boneTransform=null,e._originTransform=null,e._transform.identity(),e._currentTransform.identity(),e._durationTransform.identity()},r._onFadeIn=function(){var e=this;e._originTransform=e._timeline.originTransform,e._boneTransform=e.bone._animationPose},r._onArriveAtFrame=function(a){var n=this;if(t.prototype._onArriveAtFrame.call(this,a),n._currentTransform.copyFrom(n._currentFrame.transform),n._tweenTransform=1,n._tweenRotate=1,n._tweenScale=1,n._keyFrameCount>1&&(n._tweenEasing!=e.DragonBones.NO_TWEEN||n._curve)){var r=n._currentFrame.next,i=r.transform;n._durationTransform.x=i.x-n._currentTransform.x,n._durationTransform.y=i.y-n._currentTransform.y,(0!=n._durationTransform.x||0!=n._durationTransform.y)&&(n._tweenTransform=2);var o=n._currentFrame.tweenRotate;if(o==o){if(o)if(o>0?i.skewY>=n._currentTransform.skewY:i.skewY<=n._currentTransform.skewY){var s=o>0?o-1:o+1;n._durationTransform.skewX=i.skewX-n._currentTransform.skewX+e.DragonBones.PI_D*s,n._durationTransform.skewY=i.skewY-n._currentTransform.skewY+e.DragonBones.PI_D*s}else n._durationTransform.skewX=i.skewX-n._currentTransform.skewX+e.DragonBones.PI_D*o,n._durationTransform.skewY=i.skewY-n._currentTransform.skewY+e.DragonBones.PI_D*o;else n._durationTransform.skewX=e.Transform.normalizeRadian(i.skewX-n._currentTransform.skewX),n._durationTransform.skewY=e.Transform.normalizeRadian(i.skewY-n._currentTransform.skewY);(0!=n._durationTransform.skewX||0!=n._durationTransform.skewY)&&(n._tweenRotate=2)}else n._durationTransform.skewX=0,n._durationTransform.skewY=0;n._currentFrame.tweenScale?(n._durationTransform.scaleX=i.scaleX-n._currentTransform.scaleX,n._durationTransform.scaleY=i.scaleY-n._currentTransform.scaleY,(0!=n._durationTransform.scaleX||0!=n._durationTransform.scaleY)&&(n._tweenScale=2)):(n._durationTransform.scaleX=0,n._durationTransform.scaleY=0)}else n._durationTransform.x=0,n._durationTransform.y=0,n._durationTransform.skewX=0,n._durationTransform.skewY=0,n._durationTransform.scaleX=0,n._durationTransform.scaleY=0},r._onUpdateFrame=function(e){var a=this;(a._tweenTransform||a._tweenRotate||a._tweenScale)&&(t.prototype._onUpdateFrame.call(this,e),a._tweenTransform&&(1==a._tweenTransform&&(a._tweenTransform=0),a._animationState.additiveBlending?(a._transform.x=a._currentTransform.x+a._durationTransform.x*a._tweenProgress,a._transform.y=a._currentTransform.y+a._durationTransform.y*a._tweenProgress):(a._transform.x=a._originTransform.x+a._currentTransform.x+a._durationTransform.x*a._tweenProgress,a._transform.y=a._originTransform.y+a._currentTransform.y+a._durationTransform.y*a._tweenProgress)),a._tweenRotate&&(1==a._tweenRotate&&(a._tweenRotate=0),a._animationState.additiveBlending?(a._transform.skewX=a._currentTransform.skewX+a._durationTransform.skewX*a._tweenProgress,a._transform.skewY=a._currentTransform.skewY+a._durationTransform.skewY*a._tweenProgress):(a._transform.skewX=a._originTransform.skewX+a._currentTransform.skewX+a._durationTransform.skewX*a._tweenProgress,a._transform.skewY=a._originTransform.skewY+a._currentTransform.skewY+a._durationTransform.skewY*a._tweenProgress)),a._tweenScale&&(1==a._tweenScale&&(a._tweenScale=0),a._animationState.additiveBlending?(a._transform.scaleX=a._currentTransform.scaleX+a._durationTransform.scaleX*a._tweenProgress,a._transform.scaleY=a._currentTransform.scaleY+a._durationTransform.scaleY*a._tweenProgress):(a._transform.scaleX=a._originTransform.scaleX*(a._currentTransform.scaleX+a._durationTransform.scaleX*a._tweenProgress),a._transform.scaleY=a._originTransform.scaleY*(a._currentTransform.scaleY+a._durationTransform.scaleY*a._tweenProgress))),a.bone.invalidUpdate())},r.fadeOut=function(){var t=this;t._transform.skewX=e.Transform.normalizeRadian(t._transform.skewX),t._transform.skewY=e.Transform.normalizeRadian(t._transform.skewY)},r.update=function(e){var a=this;t.prototype.update.call(this,e);var n=a._animationState._weightResult;if(n>0){0==a.bone._blendIndex?(a._boneTransform.x=a._transform.x*n,a._boneTransform.y=a._transform.y*n,a._boneTransform.skewX=a._transform.skewX*n,a._boneTransform.skewY=a._transform.skewY*n,a._boneTransform.scaleX=(a._transform.scaleX-1)*n+1,a._boneTransform.scaleY=(a._transform.scaleY-1)*n+1):(a._boneTransform.x+=a._transform.x*n,a._boneTransform.y+=a._transform.y*n,a._boneTransform.skewX+=a._transform.skewX*n,a._boneTransform.skewY+=a._transform.skewY*n,a._boneTransform.scaleX+=(a._transform.scaleX-1)*n,a._boneTransform.scaleY+=(a._transform.scaleY-1)*n),a.bone._blendIndex++;var r=a._animationState._fadeProgress;1>r&&a.bone.invalidUpdate()}},a}(e.TweenTimelineState);e.BoneTimelineState=a,egret.registerClass(a,"dragonBones.BoneTimelineState");var n=function(t){function a(){t.call(this),this._color=new e.ColorTransform,this._durationColor=new e.ColorTransform}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.SlotTimelineState]"},r._onClear=function(){var e=this;t.prototype._onClear.call(this),e.slot=null,e._colorDirty=!1,e._tweenColor=0,e._slotColor=null,e._color.identity(),e._durationColor.identity()},r._onFadeIn=function(){this._slotColor=this.slot._colorTransform},r._onArriveAtFrame=function(a){var n=this;if(t.prototype._onArriveAtFrame.call(this,a),n._animationState._isDisabled(n.slot))return n._tweenEasing=e.DragonBones.NO_TWEEN,n._curve=null,void(n._tweenColor=0);if(n.slot._displayDataSet){var r=n._currentFrame.displayIndex;n.slot.displayIndex>=0&&r>=0?n.slot._displayDataSet.displays.length>1&&n.slot._setDisplayIndex(r):n.slot._setDisplayIndex(r),n.slot._updateMeshData(!0)}if(n._currentFrame.displayIndex>=0){n._tweenColor=0;var i=n._currentFrame.color;if(n._keyFrameCount>1&&(n._tweenEasing!=e.DragonBones.NO_TWEEN||n._curve)){var o=n._currentFrame.next,s=o.color;i!=s&&o.displayIndex>=0&&(n._durationColor.alphaMultiplier=s.alphaMultiplier-i.alphaMultiplier,n._durationColor.redMultiplier=s.redMultiplier-i.redMultiplier,n._durationColor.greenMultiplier=s.greenMultiplier-i.greenMultiplier,n._durationColor.blueMultiplier=s.blueMultiplier-i.blueMultiplier,n._durationColor.alphaOffset=s.alphaOffset-i.alphaOffset,n._durationColor.redOffset=s.redOffset-i.redOffset,n._durationColor.greenOffset=s.greenOffset-i.greenOffset,n._durationColor.blueOffset=s.blueOffset-i.blueOffset,(0!=n._durationColor.alphaMultiplier||0!=n._durationColor.redMultiplier||0!=n._durationColor.greenMultiplier||0!=n._durationColor.blueMultiplier||0!=n._durationColor.alphaOffset||0!=n._durationColor.redOffset||0!=n._durationColor.greenOffset||0!=n._durationColor.blueOffset)&&(n._tweenColor=2))}0==n._tweenColor&&(n._durationColor.alphaMultiplier=i.alphaMultiplier-n._slotColor.alphaMultiplier,n._durationColor.redMultiplier=i.redMultiplier-n._slotColor.redMultiplier,n._durationColor.greenMultiplier=i.greenMultiplier-n._slotColor.greenMultiplier,n._durationColor.blueMultiplier=i.blueMultiplier-n._slotColor.blueMultiplier,n._durationColor.alphaOffset=i.alphaOffset-n._slotColor.alphaOffset,n._durationColor.redOffset=i.redOffset-n._slotColor.redOffset,n._durationColor.greenOffset=i.greenOffset-n._slotColor.greenOffset,n._durationColor.blueOffset=i.blueOffset-n._slotColor.blueOffset,(0!=n._durationColor.alphaMultiplier||0!=n._durationColor.redMultiplier||0!=n._durationColor.greenMultiplier||0!=n._durationColor.blueMultiplier||0!=n._durationColor.alphaOffset||0!=n._durationColor.redOffset||0!=n._durationColor.greenOffset||0!=n._durationColor.blueOffset)&&(n._tweenColor=1))}else n._tweenEasing=e.DragonBones.NO_TWEEN,n._curve=null,n._tweenColor=0},r._onUpdateFrame=function(e){var a=this;if(t.prototype._onUpdateFrame.call(this,e),a._tweenColor){1==a._tweenColor&&(a._tweenColor=0);var n=a._currentFrame.color;a._color.alphaMultiplier=n.alphaMultiplier+a._durationColor.alphaMultiplier*a._tweenProgress,a._color.redMultiplier=n.redMultiplier+a._durationColor.redMultiplier*a._tweenProgress,a._color.greenMultiplier=n.greenMultiplier+a._durationColor.greenMultiplier*a._tweenProgress,a._color.blueMultiplier=n.blueMultiplier+a._durationColor.blueMultiplier*a._tweenProgress,a._color.alphaOffset=n.alphaOffset+a._durationColor.alphaOffset*a._tweenProgress,a._color.redOffset=n.redOffset+a._durationColor.redOffset*a._tweenProgress,a._color.greenOffset=n.greenOffset+a._durationColor.greenOffset*a._tweenProgress,a._color.blueOffset=n.blueOffset+a._durationColor.blueOffset*a._tweenProgress,a._colorDirty=!0}},r.fadeOut=function(){this._tweenColor=0},r.update=function(e){var a=this; -if(t.prototype.update.call(this,e),0!=a._tweenColor||a._colorDirty){var n=a._animationState._weightResult;if(n>0){var r=a._animationState._fadeProgress;1>r?(a._slotColor.alphaMultiplier+=(a._color.alphaMultiplier-a._slotColor.alphaMultiplier)*r,a._slotColor.redMultiplier+=(a._color.redMultiplier-a._slotColor.redMultiplier)*r,a._slotColor.greenMultiplier+=(a._color.greenMultiplier-a._slotColor.greenMultiplier)*r,a._slotColor.blueMultiplier+=(a._color.blueMultiplier-a._slotColor.blueMultiplier)*r,a._slotColor.alphaOffset+=(a._color.alphaOffset-a._slotColor.alphaOffset)*r,a._slotColor.redOffset+=(a._color.redOffset-a._slotColor.redOffset)*r,a._slotColor.greenOffset+=(a._color.greenOffset-a._slotColor.greenOffset)*r,a._slotColor.blueOffset+=(a._color.blueOffset-a._slotColor.blueOffset)*r,a.slot._colorDirty=!0):a._colorDirty&&(a._colorDirty=!1,a._slotColor.alphaMultiplier=a._color.alphaMultiplier,a._slotColor.redMultiplier=a._color.redMultiplier,a._slotColor.greenMultiplier=a._color.greenMultiplier,a._slotColor.blueMultiplier=a._color.blueMultiplier,a._slotColor.alphaOffset=a._color.alphaOffset,a._slotColor.redOffset=a._color.redOffset,a._slotColor.greenOffset=a._color.greenOffset,a._slotColor.blueOffset=a._color.blueOffset,a.slot._colorDirty=!0)}}},a}(e.TweenTimelineState);e.SlotTimelineState=n,egret.registerClass(n,"dragonBones.SlotTimelineState");var r=function(t){function a(){t.call(this),this._ffdVertices=[]}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.FFDTimelineState]"},r._onClear=function(){var e=this;t.prototype._onClear.call(this),e.slot=null,e._tweenFFD=0,e._slotFFDVertices=null,e._durationFFDFrame&&(e._durationFFDFrame.returnToPool(),e._durationFFDFrame=null),e._ffdVertices.length&&(e._ffdVertices.length=0)},r._onFadeIn=function(){var t=this;t._slotFFDVertices=t.slot._ffdVertices,t._durationFFDFrame=e.BaseObject.borrowObject(e.ExtensionFrameData),t._durationFFDFrame.tweens.length=t._slotFFDVertices.length,t._ffdVertices.length=t._slotFFDVertices.length;for(var a=0,n=t._durationFFDFrame.tweens.length;n>a;++a)t._durationFFDFrame.tweens[a]=0;for(var a=0,n=t._ffdVertices.length;n>a;++a)t._ffdVertices[a]=0},r._onArriveAtFrame=function(a){var n=this;if(t.prototype._onArriveAtFrame.call(this,a),n._tweenFFD=0,(n._tweenEasing!=e.DragonBones.NO_TWEEN||n._curve)&&(n._tweenFFD=n._updateExtensionKeyFrame(n._currentFrame,n._currentFrame.next,n._durationFFDFrame)),0==n._tweenFFD)for(var r=n._currentFrame.tweens,i=0,o=r.length;o>i;++i)if(n._slotFFDVertices[i]!=r[i]){n._tweenFFD=1;break}},r._onUpdateFrame=function(e){var a=this;if(t.prototype._onUpdateFrame.call(this,e),0!=a._tweenFFD){1==a._tweenFFD&&(a._tweenFFD=0);for(var n=a._currentFrame.tweens,r=a._durationFFDFrame.tweens,i=0,o=n.length;o>i;++i)a._ffdVertices[i]=n[i]+r[i]*a._tweenProgress;a.slot._ffdDirty=!0}},r.update=function(e){var a=this;t.prototype.update.call(this,e);var n=a._animationState._weightResult;if(n>0){if(0==a.slot._blendIndex)for(var r=0,i=a._ffdVertices.length;i>r;++r)a._slotFFDVertices[r]=a._ffdVertices[r]*n;else for(var r=0,i=a._ffdVertices.length;i>r;++r)a._slotFFDVertices[r]+=a._ffdVertices[r]*n;a.slot._blendIndex++;var o=a._animationState._fadeProgress;1>o&&(a.slot._ffdDirty=!0)}},a}(e.TweenTimelineState);e.FFDTimelineState=r,egret.registerClass(r,"dragonBones.FFDTimelineState")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function t(){this.time=(new Date).getTime()/e.DragonBones.SECOND_TO_MILLISECOND,this.timeScale=1,this._animatebles=[]}var a=__define,n=t,r=n.prototype;return a(t,"clock",function(){return t._clock||(t._clock=new t),t._clock}),r.advanceTime=function(t){var a=this;if(t!=t&&(t=0),0>t&&(t=(new Date).getTime()/e.DragonBones.SECOND_TO_MILLISECOND-a.time),t*=a.timeScale,0>t?a.time-=t:a.time+=t,t){for(var n=0,r=0,i=a._animatebles.length;i>n;++n){var o=a._animatebles[n];o?o.advanceTime(t):r++}if(r>0){for(r=0,i=a._animatebles.length;i>n;++n){var o=a._animatebles[n];o?a._animatebles[n-r]=o:r++}a._animatebles.length-=r}}},r.contains=function(e){return this._animatebles.indexOf(e)>=0},r.add=function(t){t&&this._animatebles.indexOf(t)<0&&(this._animatebles.push(t),e.DragonBones.DEBUG&&t instanceof e.Armature&&e.DragonBones.addArmature(t))},r.remove=function(t){var a=this._animatebles.indexOf(t);a>=0&&(this._animatebles[a]=null,e.DragonBones.DEBUG&&t instanceof e.Armature&&e.DragonBones.removeArmature(t))},r.clear=function(){for(var e=0,t=this._animatebles.length;t>e;++e)this._animatebles[e]=null},t._clock=null,t}();e.WorldClock=t,egret.registerClass(t,"dragonBones.WorldClock",["dragonBones.IAnimateble"])}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this),this._bones=[],this._slots=[],this._events=[],this.enableCache=!1}__extends(a,t);var n=__define,r=a,i=r.prototype;return a.toString=function(){return"[Class dragonBones.Armature]"},i._onClear=function(){var e=this;if(e.userData=null,e._bonesDirty=!1,e._cacheFrameIndex=-1,e._armatureData=null,e._skinData=null,e._animation&&(e._animation.returnToPool(),e._animation=null),e._display&&(e._display._onClear(),e._display=null),e._parent=null,e._action=null,e._replacedTexture=null,e._delayDispose=!1,e._lockDispose=!1,e._slotsDirty=!1,e._bones.length){for(var t=0,a=e._bones.length;a>t;++t)e._bones[t].returnToPool();e._bones.length=0}if(e._slots.length){for(var t=0,a=e._slots.length;a>t;++t)e._slots[t].returnToPool();e._slots.length=0}if(e._events.length){for(var t=0,a=e._events.length;a>t;++t)e._events[t].returnToPool();e._events.length=0}},i._sortBones=function(){var e=this._bones.length;if(e){var t=this._bones.concat(),a=0,n=0;for(this._bones.length=0;e>n;){var r=t[a++];a>=e&&(a=0),this._bones.indexOf(r)>=0||r.parent&&this._bones.indexOf(r.parent)<0||r.ik&&this._bones.indexOf(r.ik)<0||(r.ik&&r.ikChain>0&&r.ikChainIndex==r.ikChain?this._bones.splice(this._bones.indexOf(r.parent)+1,0,r):this._bones.push(r),n++)}}},i._sortSlots=function(){},i._addBoneToBoneList=function(e){this._bones.indexOf(e)<0&&(this._bonesDirty=!0,this._bones[this._bones.length]=e,this._animation._timelineStateDirty=!0)},i._removeBoneFromBoneList=function(e){var t=this._bones.indexOf(e);t>=0&&(this._bones.splice(t,1),this._animation._timelineStateDirty=!0)},i._addSlotToSlotList=function(e){this._slots.indexOf(e)<0&&(this._slotsDirty=!0,this._slots[this._slots.length]=e,this._animation._timelineStateDirty=!0)},i._removeSlotFromSlotList=function(e){var t=this._slots.indexOf(e);t>=0&&(this._slots.splice(t,1),this._animation._timelineStateDirty=!0)},i._bufferEvent=function(e,t){e.type=t,e.armature=this,this._events.push(e)},i.dispose=function(){this._delayDispose=!0,this._lockDispose||this.returnToPool()},i.advanceTime=function(t){var n=this;if(!n._lockDispose){n._lockDispose=!0;var r=t*n._animation.timeScale;n._animation._advanceTime(r),n._bonesDirty&&(n._bonesDirty=!1,n._sortBones()),n._slotsDirty&&(n._slotsDirty=!1,n._sortSlots());for(var i=0,o=n._bones.length;o>i;++i)n._bones[i]._update(n._cacheFrameIndex);for(var i=0,o=n._slots.length;o>i;++i){var s=n._slots[i];s._update(n._cacheFrameIndex);var l=s.childArmature;l&&(s.inheritAnimation?l.advanceTime(r):l.advanceTime(t))}if(n._action){switch(n._action.type){case 0:n._animation.play(n._action.data[0],n._action.data[1]);break;case 1:n._animation.stop(n._action.data[0]);break;case 2:n._animation.gotoAndPlayByTime(n._action.data[0],n._action.data[1],n._action.data[2]);break;case 3:n._animation.gotoAndStopByTime(n._action.data[0],n._action.data[1]);break;case 4:n._animation.fadeIn(n._action.data[0],n._action.data[1],n._action.data[2]);break;case 5:}n._action=null}if(n._events.length>0){for(var i=0,o=n._events.length;o>i;++i){var _=n._events[i];a._soundEventManager&&_.type==e.EventObject.SOUND_EVENT?a._soundEventManager._dispatchEvent(_):n._display._dispatchEvent(_),_.returnToPool()}n._events.length=0}n._lockDispose=!1}n._delayDispose&&n.returnToPool()},i.invalidUpdate=function(e,t){if(void 0===e&&(e=null),void 0===t&&(t=!1),e){var a=this.getBone(e);if(a&&(a.invalidUpdate(),t))for(var n=0,r=this._slots.length;r>n;++n){var i=this._slots[n];i.parent==a&&i.invalidUpdate()}}else{for(var n=0,r=this._bones.length;r>n;++n)this._bones[n].invalidUpdate();if(t)for(var n=0,r=this._slots.length;r>n;++n)this._slots[n].invalidUpdate()}},i.getSlot=function(e){for(var t=0,a=this._slots.length;a>t;++t){var n=this._slots[t];if(n.name==e)return n}return null},i.getSlotByDisplay=function(e){if(e)for(var t=0,a=this._slots.length;a>t;++t){var n=this._slots[t];if(n.display==e)return n}return null},i.addSlot=function(e,t){var a=this.getBone(t);if(!a)throw new Error;e._setArmature(this),e._setParent(a)},i.removeSlot=function(e){if(!e||e.armature!=this)throw new Error;e._setParent(null),e._setArmature(null)},i.getBone=function(e){for(var t=0,a=this._bones.length;a>t;++t){var n=this._bones[t];if(n.name==e)return n}return null},i.getBoneByDisplay=function(e){var t=this.getSlotByDisplay(e);return t?t.parent:null},i.addBone=function(e,t){if(void 0===t&&(t=null),!e)throw new Error;e._setArmature(this),e._setParent(t?this.getBone(t):null)},i.removeBone=function(e){if(!e||e.armature!=this)throw new Error;e._setParent(null),e._setArmature(null)},i.replaceTexture=function(e){this._replacedTexture=e;for(var t=0,a=this._slots.length;a>t;++t)this._slots[t].invalidUpdate()},i.getBones=function(){return this._bones},i.getSlots=function(){return this._slots},n(i,"name",function(){return this._armatureData?this._armatureData.name:null}),n(i,"armatureData",function(){return this._armatureData}),n(i,"animation",function(){return this._animation}),n(i,"display",function(){return this._display}),n(i,"parent",function(){return this._parent}),n(i,"cacheFrameRate",function(){return this._armatureData.cacheFrameRate},function(e){if(this._armatureData.cacheFrameRate!=e){this._armatureData.cacheFrames(e);for(var t=0,a=this._slots.length;a>t;++t){var n=this._slots[t],r=n.childArmature;r&&(r.cacheFrameRate=e)}}}),i.enableAnimationCache=function(e){this.cacheFrameRate=e},i.hasEventListener=function(e){this._display.hasEvent(e)},i.addEventListener=function(e,t,a){this._display.addEvent(e,t,a)},i.removeEventListener=function(e,t,a){this._display.removeEvent(e,t,a)},i.getDisplay=function(){return this._display},a._soundEventManager=null,a}(e.BaseObject);e.Armature=t,egret.registerClass(t,"dragonBones.Armature",["dragonBones.IAnimateble"])}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this),this.global=new e.Transform,this.origin=new e.Transform,this.offset=new e.Transform,this._globalTransformMatrix=new e.Matrix}__extends(a,t);var n=__define,r=a,i=r.prototype;return i._onClear=function(){var e=this;e.userData=null,e.name=null,e.globalTransformMatrix=e._globalTransformMatrix,e.global.identity(),e.origin.identity(),e.offset.identity(),e._armature=null,e._parent=null,e._globalTransformMatrix.identity()},i._setArmature=function(e){this._armature=e},i._setParent=function(e){this._parent=e},n(i,"armature",function(){return this._armature}),n(i,"parent",function(){return this._parent}),a}(e.BaseObject);e.TransformObject=t,egret.registerClass(t,"dragonBones.TransformObject")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this),this._animationPose=new e.Transform,this._bones=[],this._slots=[]}__extends(a,t);var n=__define,r=a,i=r.prototype;return a.toString=function(){return"[Class dragonBones.Bone]"},i._onClear=function(){var e=this;t.prototype._onClear.call(this),e.inheritTranslation=!1,e.inheritRotation=!1,e.inheritScale=!1,e.ikBendPositive=!1,e.ikWeight=0,e.length=0,e._transformDirty=2,e._blendIndex=0,e._cacheFrames=null,e._animationPose.identity(),e._visible=!0,e._ikChain=0,e._ikChainIndex=0,e._ik=null,e._bones.length&&(e._bones.length=0),e._slots.length&&(e._slots.length=0)},i._updateGlobalTransformMatrix=function(){var e=this;if(e._parent){var t=e._parent.global.skewY,a=e._parent.globalTransformMatrix;if(e.inheritScale)e.inheritRotation||(e.global.skewX-=t,e.global.skewY-=t),e.global.toMatrix(e.globalTransformMatrix),e.globalTransformMatrix.concat(a),e.inheritTranslation||(e.globalTransformMatrix.tx=e.global.x,e.globalTransformMatrix.ty=e.global.y),e.global.fromMatrix(e.globalTransformMatrix);else{if(e.inheritTranslation){var n=e.global.x,r=e.global.y;e.global.x=a.a*n+a.c*r+a.tx,e.global.y=a.d*r+a.b*n+a.ty}e.inheritRotation&&(e.global.skewX+=t,e.global.skewY+=t),e.global.toMatrix(e.globalTransformMatrix)}}else e.global.toMatrix(e.globalTransformMatrix)},i._computeIKA=function(){var e=this,t=e._ik.global,a=e.globalTransformMatrix.a*e.length,n=e.globalTransformMatrix.b*e.length,r=(Math.atan2(t.y-e.global.y,t.x-e.global.x)+e.offset.skewY-2*e.global.skewY+Math.atan2(n,a))*e.ikWeight;e.global.skewX+=r,e.global.skewY+=r,e.global.toMatrix(e.globalTransformMatrix)},i._computeIKB=function(){var e=this,t=e._parent.global,a=e._ik.global,n=e.globalTransformMatrix.a*e.length,r=e.globalTransformMatrix.b*e.length,i=n*n+r*r,o=Math.sqrt(i),s=e.global.x-t.x,l=e.global.y-t.y,_=s*s+l*l,u=Math.sqrt(_);s=a.x-t.x,l=a.y-t.y;var f=s*s+l*l,m=Math.sqrt(f),h=0;if(m>=o+u||u>=m+o||o>=m+u)h=Math.atan2(a.y-t.y,a.x-t.x)+e._parent.offset.skewY,m>=o+u||o>u&&(h+=Math.PI);else{var c=(_-i+f)/(2*f),d=Math.sqrt(_-c*c*f)/m,g=t.x+s*c,p=t.y+l*c,v=-l*d,T=s*d;e.ikBendPositive?(e.global.x=g-v,e.global.y=p-T):(e.global.x=g+v,e.global.y=p+T),h=Math.atan2(e.global.y-t.y,e.global.x-t.x)+e._parent.offset.skewY}h=(h-t.skewY)*e.ikWeight,t.skewX+=h,t.skewY+=h,t.toMatrix(e._parent.globalTransformMatrix),e._parent._transformDirty=1,e.global.x=t.x+Math.cos(t.skewY)*u,e.global.y=t.y+Math.sin(t.skewY)*u;var y=(Math.atan2(a.y-e.global.y,a.x-e.global.x)+e.offset.skewY-2*e.global.skewY+Math.atan2(r,n))*e.ikWeight;e.global.skewX+=y,e.global.skewY+=y,e.global.toMatrix(e.globalTransformMatrix)},i._setArmature=function(e){var t=this;if(t._armature!=e){t._ik=null;var a=null,n=null;if(t._armature&&(a=t.getSlots(),n=t.getBones(),t._armature._removeBoneFromBoneList(this)),t._armature=e,t._armature&&t._armature._addBoneToBoneList(this),a)for(var r=0,i=a.length;i>r;++r){var o=a[r];o.parent==this&&o._setArmature(t._armature)}if(n)for(var r=0,i=n.length;i>r;++r){var s=n[r];s.parent==this&&s._setArmature(t._armature)}}},i._setIK=function(e,t,a){var n=this;if(e){if(t==a){var r=n._parent;if(t&&r?t=1:(t=0,a=0,r=this),r==e||r.contains(e))e=null,t=0,a=0;else for(var i=e;i.ik&&i.ikChain;){if(r.contains(i.ik)){e=null,t=0,a=0;break}i=i.parent}}}else t=0,a=0;n._ik=e,n._ikChain=t,n._ikChainIndex=a,n._armature&&(n._armature._bonesDirty=!0)},i._update=function(t){var a=this;if(a._blendIndex=0,t>=0){var n=a._cacheFrames[t];a.globalTransformMatrix==n?a._transformDirty=0:n?(a._transformDirty=2,a.globalTransformMatrix=n):2==a._transformDirty||a._parent&&0!=a._parent._transformDirty||a._ik&&a.ikWeight>0&&0!=a._ik._transformDirty?(a._transformDirty=2,a.globalTransformMatrix=a._globalTransformMatrix):a.globalTransformMatrix!=a._globalTransformMatrix?(a._transformDirty=0,a._cacheFrames[t]=a.globalTransformMatrix):(a._transformDirty=1,a.globalTransformMatrix=a._globalTransformMatrix)}else(2==a._transformDirty||a._parent&&0!=a._parent._transformDirty||a._ik&&a.ikWeight>0&&0!=a._ik._transformDirty)&&(a._transformDirty=2,a.globalTransformMatrix=a._globalTransformMatrix);0!=a._transformDirty&&(2==a._transformDirty?a._transformDirty=1:a._transformDirty=0,a.globalTransformMatrix==a._globalTransformMatrix&&(a.global.x=a.origin.x+a.offset.x+a._animationPose.x,a.global.y=a.origin.y+a.offset.y+a._animationPose.y,a.global.skewX=a.origin.skewX+a.offset.skewX+a._animationPose.skewX,a.global.skewY=a.origin.skewY+a.offset.skewY+a._animationPose.skewY,a.global.scaleX=a.origin.scaleX*a.offset.scaleX*a._animationPose.scaleX,a.global.scaleY=a.origin.scaleY*a.offset.scaleY*a._animationPose.scaleY,a._updateGlobalTransformMatrix(),a._ik&&a._ikChainIndex==a._ikChain&&a.ikWeight>0&&(a.inheritTranslation&&a._ikChain>0&&a._parent?a._computeIKB():a._computeIKA()),t>=0&&(a.globalTransformMatrix=e.BoneTimelineData.cacheFrame(a._cacheFrames,t,a._globalTransformMatrix))))},i.invalidUpdate=function(){this._transformDirty=2},i.contains=function(e){if(e){if(e==this)return!1;for(var t=e;t!=this&&t;)t=t.parent;return t==this}return!1},i.getBones=function(){this._bones.length=0;for(var e=this._armature.getBones(),t=0,a=e.length;a>t;++t){var n=e[t];n.parent==this&&this._bones.push(n)}return this._bones},i.getSlots=function(){this._slots.length=0;for(var e=this._armature.getSlots(),t=0,a=e.length;a>t;++t){var n=e[t];n.parent==this&&this._slots.push(n)}return this._slots},n(i,"ikChain",function(){return this._ikChain}),n(i,"ikChainIndex",function(){return this._ikChainIndex}),n(i,"ik",function(){return this._ik}),n(i,"visible",function(){return this._visible},function(e){if(this._visible!=e){this._visible=e;for(var t=this._armature.getSlots(),a=0,n=t.length;n>a;++a){var r=t[a];r._parent==this&&r._updateVisible()}}}),n(i,"slot",function(){for(var e=this._armature.getSlots(),t=0,a=e.length;a>t;++t){var n=e[t];if(n.parent==this)return n}return null}),a}(e.TransformObject);e.Bone=t,egret.registerClass(t,"dragonBones.Bone")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this),this._colorTransform=new e.ColorTransform,this._ffdVertices=[],this._replacedDisplayDataSet=[],this._localMatrix=new e.Matrix,this._displayList=[],this._meshBones=[]}__extends(a,t);var n=__define,r=a,i=r.prototype;return i._onClear=function(){var a=this;t.prototype._onClear.call(this);for(var n=[],r=0,i=a._displayList.length;i>r;++r){var o=a._displayList[r];o!=a._rawDisplay&&o!=a._meshDisplay&&n.indexOf(o)<0&&n.push(o)}for(var r=0,i=n.length;i>r;++r){var o=n[r];o instanceof e.Armature?o.returnToPool():a._disposeDisplay(o)}a._meshDisplay&&a._meshDisplay!=a._rawDisplay&&a._disposeDisplay(a._meshDisplay),a._rawDisplay&&a._disposeDisplay(a._rawDisplay),a.inheritAnimation=!0,a.displayController=null,a._colorDirty=!1,a._ffdDirty=!1,a._blendIndex=0,a._zOrder=0,a._displayDataSet=null,a._meshData=null,a._cacheFrames=null,a._rawDisplay=null,a._meshDisplay=null,a._colorTransform.identity(),a._ffdVertices.length&&(a._ffdVertices.length=0),a._replacedDisplayDataSet.length&&(a._replacedDisplayDataSet.length=0),a._displayDirty=!1,a._blendModeDirty=!1,a._originDirty=!1,a._transformDirty=!1,a._displayIndex=0,a._blendMode=0,a._display=null,a._childArmature=null,a._localMatrix.identity(),a._displayList.length&&(a._displayList.length=0),a._meshBones.length&&(a._meshBones.length=0)},i._isMeshBonesUpdate=function(){for(var e=0,t=this._meshBones.length;t>e;++e)if(0!=this._meshBones[e]._transformDirty)return!0;return!1},i._updateDisplay=function(){var t=this,a=t._display||t._rawDisplay,n=t._childArmature;t._displayIndex>=0&&t._displayIndex=0&&t._displayIndex0?t._childArmature._action=o.actions[o.actions.length-1]:t._childArmature.animation.play()}},i._updateLocalTransformMatrix=function(){var e=this;e.global.copyFrom(e.origin).add(e.offset).toMatrix(e._localMatrix)},i._updateGlobalTransformMatrix=function(){var e=this;e.globalTransformMatrix.copyFrom(e._localMatrix),e.globalTransformMatrix.concat(e._parent.globalTransformMatrix),e.global.fromMatrix(e.globalTransformMatrix)},i._setArmature=function(e){var t=this;t._armature!=e&&(t._armature&&t._armature._removeSlotFromSlotList(this),t._armature=e,t._onUpdateDisplay(),t._armature?(t._armature._addSlotToSlotList(this),t._addDisplay()):t._removeDisplay())},i._updateMeshData=function(e){var t=this,a=t._meshData;if(t._display==t._meshDisplay&&t._displayDataSet&&t._displayIndex>=0&&t._displayIndexn;++n)t._meshBones[n]=t._armature.getBone(t._meshData.bones[n].name);for(var i=0,n=0,r=t._meshData.boneIndices.length;r>n;++n)i+=t._meshData.boneIndices[n].length;t._ffdVertices.length=2*i}else t._meshBones.length=0,t._ffdVertices.length=t._meshData.vertices.length;for(var n=0,r=t._ffdVertices.length;r>n;++n)t._ffdVertices[n]=0;t._ffdDirty=!0}else t._meshBones.length=0,t._ffdVertices.length=0;e&&t._armature.animation._updateFFDTimelineStates()}},i._update=function(t){var a=this;if(a._blendIndex=0,a._displayDirty&&(a._displayDirty=!1,a._updateDisplay()),a._display&&(a._blendModeDirty&&(a._blendModeDirty=!1,a._updateBlendMode()),a._colorDirty&&(a._colorDirty=!1,a._updateColor()),!a._meshData||((a._ffdDirty||a._meshData.skinned&&a._isMeshBonesUpdate())&&(a._ffdDirty=!1,a._updateMesh()),!a._meshData.skinned))){if(a._originDirty&&(a._originDirty=!1,a._transformDirty=!0,a._updateLocalTransformMatrix()),t>=0){var n=a._cacheFrames[t];a.globalTransformMatrix==n?a._transformDirty=!1:n?(a._transformDirty=!0,a.globalTransformMatrix=n):a._transformDirty||0!=a._parent._transformDirty?(a._transformDirty=!0,a.globalTransformMatrix=a._globalTransformMatrix):a.globalTransformMatrix!=a._globalTransformMatrix?(a._transformDirty=!1,a._cacheFrames[t]=a.globalTransformMatrix):(a._transformDirty=!0,a.globalTransformMatrix=a._globalTransformMatrix)}else(a._transformDirty||0!=a._parent._transformDirty)&&(a._transformDirty=!0,a.globalTransformMatrix=a._globalTransformMatrix);a._transformDirty&&(a._transformDirty=!1,a.globalTransformMatrix==a._globalTransformMatrix&&(a._updateGlobalTransformMatrix(),t>=0&&(a.globalTransformMatrix=e.SlotTimelineData.cacheFrame(a._cacheFrames,t,a._globalTransformMatrix))),a._updateTransform())}},i._setDisplayList=function(t){var a=this;if(t&&t.length){a._displayList.length!=t.length&&(a._displayList.length=t.length);for(var n=0,r=a._displayList.length;r>n;++n){var i=t[n];i&&i!=a._rawDisplay&&i!=a._meshDisplay&&!(i instanceof e.Armature)&&a._displayList.indexOf(i)<0&&a._initDisplay(i),a._displayList[n]=i}}else a._displayList.length&&(a._displayList.length=0);return a._displayIndex>=0&&a._displayIndexi;++i){var s=n[i];s!=a._rawDisplay&&s!=a._meshDisplay&&a._displayList.indexOf(s)<0&&r.indexOf(s)<0&&r.push(s)}for(var i=0,o=r.length;o>i;++i){var s=r[i];s instanceof e.Armature?s.returnToPool():a._disposeDisplay(s)}}),n(i,"display",function(){return this._display},function(e){var t=this;if(t._display!=e){var a=t._displayList.length;if(t._displayIndex<0&&0==a&&(t._displayIndex=0),!(t._displayIndex<0)){var n=t.displayList;a<=t._displayIndex&&(n.length=t._displayIndex+1),n[t._displayIndex]=e,t.displayList=n}}}),n(i,"childArmature",function(){return this._childArmature},function(e){this._childArmature!=e&&(this.display=e)}),i.getDisplay=function(){return this._display},i.setDisplay=function(e){this.display=e},a}(e.TransformObject);e.Slot=t,egret.registerClass(t,"dragonBones.Slot")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function e(){}var t=(__define,e);t.prototype;return e.hasArmature=function(t){return e._armatures.indexOf(t)>=0},e.addArmature=function(t){t&&e._armatures.indexOf(t)<0&&e._armatures.push(t)},e.removeArmature=function(t){if(t){var a=e._armatures.indexOf(t);a>=0&&e._armatures.splice(a,1)}},e.PI_D=2*Math.PI,e.PI_H=Math.PI/2,e.PI_Q=Math.PI/4,e.ANGLE_TO_RADIAN=Math.PI/180,e.RADIAN_TO_ANGLE=180/Math.PI,e.SECOND_TO_MILLISECOND=1e3,e.NO_TWEEN=100,e.VERSION="4.7.1",e.DEBUG=!0,e._armatures=[],e}();e.DragonBones=t,egret.registerClass(t,"dragonBones.DragonBones")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this)}__extends(t,e);var a=__define,n=t,r=n.prototype;return t.toString=function(){return"[Class dragonBones.EventObject]"},r._onClear=function(){this.type=null,this.name=null,this.data=null,this.armature=null,this.bone=null,this.slot=null,this.animationState=null,this.userData=null},a(r,"animationName",function(){return this.animationState.name}),t.START="start",t.LOOP_COMPLETE="loopComplete",t.COMPLETE="complete",t.FADE_IN="fadeIn",t.FADE_IN_COMPLETE="fadeInComplete",t.FADE_OUT="fadeOut",t.FADE_OUT_COMPLETE="fadeOutComplete",t.FRAME_EVENT="frameEvent",t.SOUND_EVENT="soundEvent",t}(e.BaseObject);e.EventObject=t,egret.registerClass(t,"dragonBones.EventObject")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this),this.textures={}}__extends(t,e);var a=(__define,t),n=a.prototype;return n._onClear=function(){var e=this;e.autoSearch=!1,e.scale=1,e.name=null,e.imagePath=null;for(var t in e.textures)e.textures[t].returnToPool(),delete e.textures[t]},n.dispose=function(){this.returnToPool()},n.addTextureData=function(e){if(!e||!e.name||this.textures[e.name])throw new Error;this.textures[e.name]=e,e.parent=this},n.getTextureData=function(e){return this.textures[e]},t}(e.BaseObject);e.TextureAtlasData=t,egret.registerClass(t,"dragonBones.TextureAtlasData");var a=function(t){function a(){t.call(this),this.region=new e.Rectangle}__extends(a,t);var n=(__define,a),r=n.prototype;return a.generateRectangle=function(){return new e.Rectangle},r._onClear=function(){var e=this;e.rotated=!1,e.name=null,e.frame=null,e.parent=null,e.region.clear()},a}(e.BaseObject);e.TextureData=a,egret.registerClass(a,"dragonBones.TextureData")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function n(){t.call(this)}__extends(n,t);var r=(__define,n),i=r.prototype;return n.toString=function(){return"[Class dragonBones.EgretTextureAtlasData]"},i._onClear=function(){t.prototype._onClear.call(this),this.texture&&(this.texture=null)},i.generateTextureData=function(){return e.BaseObject.borrowObject(a)},n}(e.TextureAtlasData);e.EgretTextureAtlasData=t,egret.registerClass(t,"dragonBones.EgretTextureAtlasData");var a=function(e){function t(){e.call(this)}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.EgretTextureData]"},n._onClear=function(){e.prototype._onClear.call(this),this.texture&&(this.texture.dispose(),this.texture=null)},t}(e.TextureData);e.EgretTextureData=a,egret.registerClass(a,"dragonBones.EgretTextureData")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(e,a,n,r){t.call(this,e,a,n,r)}__extends(a,t);var n=__define,r=a,i=r.prototype;return n(i,"eventObject",function(){return this.data}),n(i,"frameLabel",function(){return this.eventObject.name}),n(i,"sound",function(){return this.eventObject.name}),n(i,"animationName",function(){return this.eventObject.animationState.name}),n(i,"armature",function(){return this.eventObject.armature}),n(i,"bone",function(){return this.eventObject.bone}),n(i,"slot",function(){return this.eventObject.slot}),n(i,"animationState",function(){return this.eventObject.animationState}),n(i,"movementID",function(){return this.animationName}),a.START=e.EventObject.START,a.LOOP_COMPLETE=e.EventObject.LOOP_COMPLETE,a.COMPLETE=e.EventObject.COMPLETE,a.FADE_IN=e.EventObject.FADE_IN,a.FADE_IN_COMPLETE=e.EventObject.FADE_IN_COMPLETE,a.FADE_OUT=e.EventObject.FADE_OUT,a.FADE_OUT_COMPLETE=e.EventObject.FADE_OUT_COMPLETE,a.FRAME_EVENT=e.EventObject.FRAME_EVENT,a.SOUND_EVENT=e.EventObject.SOUND_EVENT,a.ANIMATION_FRAME_EVENT=e.EventObject.FRAME_EVENT,a.BONE_FRAME_EVENT=e.EventObject.FRAME_EVENT,a.MOVEMENT_FRAME_EVENT=e.EventObject.FRAME_EVENT,a}(egret.Event);e.EgretEvent=t,egret.registerClass(t,"dragonBones.EgretEvent");var a=function(a){function n(){a.call(this),n._clock||(n._clock=new e.WorldClock,n._clock.time=egret.getTimer(),egret.startTick(n._clockHandler,n))}__extends(n,a);var r=__define,i=n,o=i.prototype;return n._clockHandler=function(e){var t=e-n._clock.time;return n._clock.advanceTime(.001*t),n._clock.time=e,!1},o._onClear=function(){this.advanceTimeBySelf(!1),this._armature=null},o._dispatchEvent=function(e){var a=egret.Event.create(t,e.type);a.data=e,this.dispatchEvent(a),egret.Event.release(a)},o.advanceTime=function(e){this._armature.advanceTime(e)},o.hasEvent=function(e){return this.hasEventListener(e)},o.addEvent=function(e,t,a){this.addEventListener(e,t,a)},o.removeEvent=function(e,t,a){this.removeEventListener(e,t,a)},o.advanceTimeBySelf=function(e){e?n._clock.add(this._armature):n._clock.remove(this._armature)},o.dispose=function(){this._armature&&this._armature.dispose()},r(o,"armature",function(){return this._armature}),r(o,"animation",function(){return this._armature.animation}),n._clock=null,n}(egret.DisplayObjectContainer);e.EgretArmatureDisplay=a,egret.registerClass(a,"dragonBones.EgretArmatureDisplay",["dragonBones.IArmatureDisplay","dragonBones.IEventDispatcher"]);var n=function(e){function t(){e.apply(this,arguments)}__extends(t,e);var a=(__define,t);a.prototype;return t}(t);e.AnimationEvent=n,egret.registerClass(n,"dragonBones.AnimationEvent");var r=function(e){function t(){e.apply(this,arguments)}__extends(t,e);var a=(__define,t);a.prototype;return t}(t);e.FrameEvent=r,egret.registerClass(r,"dragonBones.FrameEvent");var i=function(e){function t(){e.apply(this,arguments)}__extends(t,e);var a=(__define,t);a.prototype;return t}(t);e.SoundEvent=i,egret.registerClass(i,"dragonBones.SoundEvent");var o=function(t){function a(a,n,r){void 0===r&&(r=1),t.call(this),this._onClear(),this.texture=a,e.ObjectDataParser.getInstance().parseTextureAtlasData(n,this,r)}__extends(a,t);var n=(__define,a);n.prototype;return a.toString=function(){return"[Class dragonBones.EgretTextureAtlas]"},a}(e.EgretTextureAtlasData);e.EgretTextureAtlas=o,egret.registerClass(o,"dragonBones.EgretTextureAtlas");var s=function(e){function t(){e.apply(this,arguments)}__extends(t,e);var a=(__define,t);a.prototype;return t}(o);e.EgretSheetAtlas=s,egret.registerClass(s,"dragonBones.EgretSheetAtlas");var l=function(){function t(){}var a=(__define,t);a.prototype;return t.getInstance=function(){return e.Armature._soundEventManager},t}();e.SoundEventManager=l,egret.registerClass(l,"dragonBones.SoundEventManager");var _=function(){function e(){}var t=(__define,e);t.prototype;return e}();e.AnimationCacheManager=_,egret.registerClass(_,"dragonBones.AnimationCacheManager")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function e(e,t,a,n,r,i,o,s){void 0===e&&(e=1),void 0===t&&(t=1),void 0===a&&(a=1),void 0===n&&(n=1),void 0===r&&(r=0),void 0===i&&(i=0),void 0===o&&(o=0),void 0===s&&(s=0),this.alphaMultiplier=e,this.redMultiplier=t,this.greenMultiplier=a,this.blueMultiplier=n,this.alphaOffset=r,this.redOffset=i,this.greenOffset=o,this.blueOffset=s -}var t=(__define,e),a=t.prototype;return a.copyFrom=function(e){var t=this;t.alphaMultiplier=e.alphaMultiplier,t.redMultiplier=e.redMultiplier,t.greenMultiplier=e.greenMultiplier,t.blueMultiplier=e.blueMultiplier,t.alphaOffset=e.alphaOffset,t.redOffset=e.redOffset,t.redOffset=e.redOffset,t.greenOffset=e.blueOffset},a.identity=function(){var e=this;e.alphaMultiplier=e.redMultiplier=e.greenMultiplier=e.blueMultiplier=1,e.alphaOffset=e.redOffset=e.greenOffset=e.blueOffset=0},e}();e.ColorTransform=t,egret.registerClass(t,"dragonBones.ColorTransform")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function t(){this.autoSearch=!1,this._objectDataParser=new e.ObjectDataParser,this._dragonBonesDataMap={},this._textureAtlasDataMap={}}var a=(__define,t),n=a.prototype;return n._getTextureData=function(e,t){var a=this._textureAtlasDataMap[e];if(a)for(var n=0,r=a.length;r>n;++n){var i=a[n].getTextureData(t);if(i)return i}if(this.autoSearch)for(var n in this._textureAtlasDataMap){a=this._textureAtlasDataMap[n];for(var o=0,s=a.length;s>o;++o){var l=a[o];if(l.autoSearch){var i=l.getTextureData(t);if(i)return i}}}return null},n._fillBuildArmaturePackage=function(e,t,a,n){if(e){var r=this._dragonBonesDataMap[e];if(r){var i=r.getArmature(t);if(i)return n.dataName=e,n.data=r,n.armature=i,n.skin=i.getSkin(a),n.skin||(n.skin=i.defaultSkin),!0}}if(!e||this.autoSearch)for(var o in this._dragonBonesDataMap){var r=this._dragonBonesDataMap[o];if(!e||r.autoSearch){var i=r.getArmature(t);if(i)return n.dataName=o,n.data=r,n.armature=i,n.skin=i.getSkin(a),n.skin||(n.skin=i.defaultSkin),!0}}return!1},n._buildBones=function(t,a){for(var n=t.armature.sortedBones,r=0,i=n.length;i>r;++r){var o=n[r],s=e.BaseObject.borrowObject(e.Bone);s.name=o.name,s.inheritTranslation=o.inheritTranslation,s.inheritRotation=o.inheritRotation,s.inheritScale=o.inheritScale,s.length=o.length,s.origin.copyFrom(o.transform),o.parent?a.addBone(s,o.parent.name):a.addBone(s),o.ik&&(s.ikBendPositive=o.bendPositive,s.ikWeight=o.weight,s._setIK(a.getBone(o.ik.name),o.chain,o.chainIndex))}},n._buildSlots=function(e,t){var a=e.skin,n=e.armature.defaultSkin,r={};for(var i in n.slots){var o=n.slots[i];r[o.slot.name]=o}if(a!=n)for(var i in a.slots){var o=a.slots[i];r[o.slot.name]=o}for(var s=e.armature.sortedSlots,i=0,l=s.length;l>i;++i){var _=s[i],o=r[_.name];if(o){var u=this._generateSlot(e,o);u._displayDataSet=o,u._setDisplayIndex(_.displayIndex),u._setBlendMode(_.blendMode),u._setColor(_.color),u._replacedDisplayDataSet.length=u._displayDataSet.displays.length,t.addSlot(u,_.parent.name)}}},n._replaceSlotDisplay=function(e,t,a,n){if(0>n&&(n=a.displayIndex),n>=0){var r=a.displayList;if(r.length<=n&&(r.length=n+1),t.textureData||(t.textureData=this._getTextureData(e.dataName,t.name)),1==t.type){var i=this.buildArmature(t.name,e.dataName);r[n]=i}else a._replacedDisplayDataSet.length<=n&&(a._replacedDisplayDataSet.length=n+1),a._replacedDisplayDataSet[n]=t,t.meshData?r[n]=a.MeshDisplay:r[n]=a.rawDisplay;a.displayList=r,a.invalidUpdate()}},n.parseDragonBonesData=function(e,t){void 0===t&&(t=null);var a=this._objectDataParser.parseDragonBonesData(e);return this.addDragonBonesData(a,t),a},n.parseTextureAtlasData=function(e,t,a,n){void 0===a&&(a=null),void 0===n&&(n=0);var r=this._generateTextureAtlasData(null,null);return this._objectDataParser.parseTextureAtlasData(e,r,n),this._generateTextureAtlasData(r,t),this.addTextureAtlasData(r,a),r},n.getDragonBonesData=function(e){return this._dragonBonesDataMap[e]},n.addDragonBonesData=function(e,t){if(void 0===t&&(t=null),!e)throw new Error;t=t||e.name,t?this._dragonBonesDataMap[t]?console.warn("Same name data."):this._dragonBonesDataMap[t]=e:console.warn("Unnamed data.")},n.removeDragonBonesData=function(t,a){void 0===a&&(a=!0);var n=this._dragonBonesDataMap[t];if(n){if(a){if(e.DragonBones.DEBUG)for(var r=0,i=e.DragonBones._armatures.length;i>r;++r){var o=e.DragonBones._armatures[r];if(o.armatureData.parent==n)throw new Error("ArmatureData: "+o.armatureData.name+" DragonBonesData: "+t)}n.returnToPool()}delete this._dragonBonesDataMap[t]}},n.getTextureAtlasData=function(e){return this._textureAtlasDataMap[e]},n.addTextureAtlasData=function(e,t){if(void 0===t&&(t=null),!e)throw new Error;if(t=t||e.name){var a=this._textureAtlasDataMap[t]=this._textureAtlasDataMap[t]||[];a.indexOf(e)<0&&a.push(e)}else console.warn("Unnamed data.")},n.removeTextureAtlasData=function(e,t){void 0===t&&(t=!0);var a=this._textureAtlasDataMap[e];if(a){if(t)for(var n=0,r=a.length;r>n;++n)a[n].returnToPool();delete this._textureAtlasDataMap[e]}},n.clear=function(e){void 0===e&&(e=!0);var t=this;for(var a in t._dragonBonesDataMap)e&&t._dragonBonesDataMap[a].returnToPool(),delete t._dragonBonesDataMap[a];for(var a in t._textureAtlasDataMap){if(e)for(var n=t._textureAtlasDataMap[a],r=0,i=n.length;i>r;++r)n[r].returnToPool();delete t._textureAtlasDataMap[a]}},n.buildArmature=function(e,t,a){void 0===t&&(t=null),void 0===a&&(a=null);var n={};if(this._fillBuildArmaturePackage(t,e,a,n)){var r=this._generateArmature(n);return this._buildBones(n,r),this._buildSlots(n,r),r.armatureData.actions.length>0&&(r._action=r.armatureData.actions[r.armatureData.actions.length-1]),r.advanceTime(0),r}return null},n.copyAnimationsToArmature=function(t,a,n,r,i){void 0===n&&(n=null),void 0===r&&(r=null),void 0===i&&(i=!0);var o={};if(this._fillBuildArmaturePackage(r,a,n,o)){var s=o.armature;if(i)t.animation.animations=s.animations;else{var l={};for(var _ in t.animation.animations)l[_]=t.animation.animations[_];for(var _ in s.animations)l[_]=s.animations[_];t.animation.animations=l}if(o.skin){for(var u=t.getSlots(),f=0,m=u.length;m>f;++f)for(var h=u[f],c=h.displayList,d=0,g=c.length;g>d;++d){var p=c[d];if(p instanceof e.Armature){var v=o.skin.getSlot(h.name).displays;if(dl;++l){var u=s.displays[l];if(u.name==n){this._replaceSlotDisplay(o,u,r,i);break}}}},n.replaceSlotDisplayList=function(e,t,a,n){var r={};if(this._fillBuildArmaturePackage(e,t,null,r)){var i=r.skin.getSlot(a);if(i)for(var o=0,s=0,l=i.displays.length;l>s;++s){var _=i.displays[s];this._replaceSlotDisplay(r,_,n,o++)}}},n.dispose=function(){this.clear()},t}();e.BaseFactory=t,egret.registerClass(t,"dragonBones.BaseFactory")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this),e.Armature._soundEventManager||(e.Armature._soundEventManager=new e.EgretArmatureDisplay)}__extends(a,t);var n=__define,r=a,i=r.prototype;return i._generateTextureAtlasData=function(t,a){return t?t.texture=a:t=e.BaseObject.borrowObject(e.EgretTextureAtlasData),t},i._generateArmature=function(t){var a=e.BaseObject.borrowObject(e.Armature),n=new e.EgretArmatureDisplay;return a._armatureData=t.armature,a._skinData=t.skin,a._animation=e.BaseObject.borrowObject(e.Animation),a._display=n,n._armature=a,a._animation._armature=a,a.animation.animations=t.armature.animations,a},i._generateSlot=function(t,a){var n=e.BaseObject.borrowObject(e.EgretSlot),r=a.slot,i=[];n.name=r.name,n._rawDisplay=new egret.Bitmap;for(var o=0,s=a.displays.length;s>o;++o){var l=a.displays[o];switch(l.type){case 0:l.textureData||(l.textureData=this._getTextureData(t.dataName,l.name)),i.push(n._rawDisplay);break;case 2:l.textureData||(l.textureData=this._getTextureData(t.dataName,l.name)),"webgl"==egret.Capabilities.renderMode?(n._meshDisplay||(n._meshDisplay=new egret.Mesh),i.push(n._meshDisplay)):i.push(n._rawDisplay);break;case 1:var _=this.buildArmature(l.name,t.dataName);_&&(r.actions.length>0?_._action=r.actions[r.actions.length-1]:_.animation.play()),i.push(_);break;default:i.push(null)}}return n._setDisplayList(i),n},i.buildArmatureDisplay=function(e,t,a){void 0===t&&(t=null),void 0===a&&(a=null);var n=this.buildArmature(e,t,a),r=n?n._display:null;return r&&r.advanceTimeBySelf(!0),r},i.getTextureDisplay=function(e,t){void 0===t&&(t=null);var a=this._getTextureData(t,e);return a?new egret.Bitmap(a.texture):null},n(i,"soundEventManater",function(){return e.Armature._soundEventManager}),i.addSkeletonData=function(e,t){void 0===t&&(t=null),this.addDragonBonesData(e,t)},i.getSkeletonData=function(e){return this.getDragonBonesData(e)},i.removeSkeletonData=function(e){this.removeDragonBonesData(e)},i.addTextureAtlas=function(e,t){void 0===t&&(t=null),this.addTextureAtlasData(e,t)},i.getTextureAtlas=function(e){return this.getTextureAtlasData(e)},i.removeTextureAtlas=function(e){this.removeTextureAtlasData(e)},i.buildFastArmature=function(e,t,a){return void 0===t&&(t=null),void 0===a&&(a=null),this.buildArmature(e,t,a)},a}(e.BaseFactory);e.EgretFactory=t,egret.registerClass(t,"dragonBones.EgretFactory")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this)}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.EgretSlot]"},n._onClear=function(){e.prototype._onClear.call(this),this.transformUpdateEnabled=!1,this._renderDisplay=null,this._colorFilter=null},n._onUpdateDisplay=function(){var e=this;e._rawDisplay||(e._rawDisplay=new egret.Bitmap),e._renderDisplay=e._display||e._rawDisplay},n._initDisplay=function(e){},n._addDisplay=function(){var e=this._armature._display;e.addChild(this._renderDisplay)},n._replaceDisplay=function(e){var t=this._armature._display,a=e;t.addChild(this._renderDisplay),t.swapChildren(this._renderDisplay,a),t.removeChild(a)},n._removeDisplay=function(){this._renderDisplay.parent.removeChild(this._renderDisplay)},n._disposeDisplay=function(e){},n._updateVisible=function(){this._renderDisplay.visible=this._parent.visible},n._updateBlendMode=function(){if(this._blendMode=0){var a=e._displayIndexu;++u)_.uvs[u]=e._meshData.uvs[u],_.vertices[u]=e._meshData.vertices[u];for(var u=0,f=e._meshData.vertexIndices.length;f>u;++u)_.indices[u]=e._meshData.vertexIndices[u];l.$setBitmapData(s),l.$updateVertices(),l.$invalidateTransform()}else{var m=i.frame||i.region,h=m.width,c=m.height;i.rotated&&(h=m.height,c=m.width);var d=r.pivot.x,g=r.pivot.y;r.isRelativePivot&&(d=h*d,g=c*g),i.frame&&(d+=i.frame.x,g+=i.frame.y),a&&n&&(d+=a.transform.x-n.transform.x,g+=a.transform.y-n.transform.y),t.$setBitmapData(s),t.$setAnchorOffsetX(d),t.$setAnchorOffsetY(g)}return void e._updateVisible()}}}t.visible=!1,t.$setBitmapData(null),t.$setAnchorOffsetX(0),t.$setAnchorOffsetY(0),t.x=0,t.y=0},n._updateMesh=function(){var e=this,t=e._meshDisplay,a=t.$renderNode,n=e._ffdVertices.length>0;if(e._meshData.skinned){for(var r=0,i=0,o=e._meshData.vertices.length;o>r;r+=2){for(var s=r/2,l=e._meshData.boneIndices[s],_=e._meshData.boneVertices[s],u=e._meshData.weights[s],f=0,m=0,h=0,c=l.length;c>h;++h){var d=e._meshBones[l[h]],g=d.globalTransformMatrix,p=u[h],v=0,T=0;n?(v=_[2*h]+e._ffdVertices[i],T=_[2*h+1]+e._ffdVertices[i+1]):(v=_[2*h],T=_[2*h+1]),f+=(g.a*v+g.c*T+g.tx)*p,m+=(g.b*v+g.d*T+g.ty)*p,i+=2}a.vertices[r]=f,a.vertices[r+1]=m}t.$updateVertices(),t.$invalidateTransform()}else if(n){for(var y=e._meshData.vertices,r=0,o=e._meshData.vertices.length;o>r;r+=2){var f=y[r]+e._ffdVertices[r],m=y[r+1]+e._ffdVertices[r+1];a.vertices[r]=f,a.vertices[r+1]=m}t.$updateVertices(),t.$invalidateTransform()}},n._updateTransform=function(){var e=this;e._renderDisplay.$setMatrix(e.globalTransformMatrix,e.transformUpdateEnabled)},t.BLEND_MODE_LIST=[egret.BlendMode.NORMAL,egret.BlendMode.ADD,null,null,null,egret.BlendMode.ERASE,null,null,null,null,null,null,null,null],t}(e.Slot);e.EgretSlot=t,egret.registerClass(t,"dragonBones.EgretSlot")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function e(e,t,a,n,r,i){void 0===e&&(e=1),void 0===t&&(t=0),void 0===a&&(a=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===i&&(i=0),this.a=e,this.b=t,this.c=a,this.d=n,this.tx=r,this.ty=i}var t=(__define,e),a=t.prototype;return a.copyFrom=function(e){var t=this;t.a=e.a,t.b=e.b,t.c=e.c,t.d=e.d,t.tx=e.tx,t.ty=e.ty},a.identity=function(){var e=this;e.a=e.d=1,e.b=e.c=0,e.tx=e.ty=0},a.concat=function(e){var t=this,a=t.a,n=t.b,r=t.c,i=t.d,o=t.tx,s=t.ty,l=e.a,_=e.b,u=e.c,f=e.d,m=e.tx,h=e.ty;t.a=a*l+n*u,t.b=a*_+n*f,t.c=r*l+i*u,t.d=r*_+i*f,t.tx=l*o+u*s+m,t.ty=f*s+_*o+h},a.invert=function(){var e=this,t=e.a,a=e.b,n=e.c,r=e.d,i=e.tx,o=e.ty,s=t*r-a*n;e.a=r/s,e.b=-a/s,e.c=-n/s,e.d=t/s,e.tx=(n*o-r*i)/s,e.ty=-(t*o-a*i)/s},a.transformPoint=function(e,t,a,n){void 0===n&&(n=!1);var r=this;a.x=r.a*e+r.c*t,a.y=r.b*e+r.d*t,n||(a.x+=r.tx,a.y+=r.ty)},e}();e.Matrix=t,egret.registerClass(t,"dragonBones.Matrix")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function e(e,t){void 0===e&&(e=0),void 0===t&&(t=0),this.x=e,this.y=t}var t=(__define,e),a=t.prototype;return a.copyFrom=function(e){this.x=e.x,this.y=e.y},a.clear=function(){this.x=this.y=0},e}();e.Point=t,egret.registerClass(t,"dragonBones.Point")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function e(e,t,a,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===a&&(a=0),void 0===n&&(n=0),this.x=e,this.y=t,this.width=a,this.height=n}var t=(__define,e),a=t.prototype;return a.copyFrom=function(e){this.x=e.x,this.y=e.y,this.width=e.width,this.height=e.height},a.clear=function(){this.x=this.y=0,this.width=this.height=0},e}();e.Rectangle=t,egret.registerClass(t,"dragonBones.Rectangle")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function e(e,t,a,n,r,i){void 0===e&&(e=0),void 0===t&&(t=0),void 0===a&&(a=0),void 0===n&&(n=0),void 0===r&&(r=1),void 0===i&&(i=1),this.x=e,this.y=t,this.skewX=a,this.skewY=n,this.scaleX=r,this.scaleY=i}var t=__define,a=e,n=a.prototype;return e.normalizeRadian=function(e){return e=(e+Math.PI)%(2*Math.PI),e+=e>0?-Math.PI:Math.PI},n.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+180*this.skewX/Math.PI+" skewY:"+180*this.skewY/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY},n.copyFrom=function(e){var t=this;return t.x=e.x,t.y=e.y,t.skewX=e.skewX,t.skewY=e.skewY,t.scaleX=e.scaleX,t.scaleY=e.scaleY,this},n.clone=function(){var t=new e;return t.copyFrom(this),t},n.identity=function(){var e=this;return e.x=e.y=e.skewX=e.skewY=0,e.scaleX=e.scaleY=1,this},n.add=function(e){var t=this;return t.x+=e.x,t.y+=e.y,t.skewX+=e.skewX,t.skewY+=e.skewY,t.scaleX*=e.scaleX,t.scaleY*=e.scaleY,this},n.minus=function(t){var a=this;return a.x-=t.x,a.y-=t.y,a.skewX=e.normalizeRadian(a.skewX-t.skewX),a.skewY=e.normalizeRadian(a.skewY-t.skewY),a.scaleX/=t.scaleX,a.scaleY/=t.scaleY,this},n.fromMatrix=function(e){var t=this,a=.25*Math.PI,n=t.scaleX,r=t.scaleY;return t.x=e.tx,t.y=e.ty,t.skewX=Math.atan(-e.c/e.d),t.skewY=Math.atan(e.b/e.a),t.skewX!=t.skewX&&(t.skewX=0),t.skewY!=t.skewY&&(t.skewY=0),t.scaleY=t.skewX>-a&&t.skewX-a&&t.skewY=0&&t.scaleX<0&&(t.scaleX=-t.scaleX,t.skewY=t.skewY-Math.PI),r>=0&&t.scaleY<0&&(t.scaleY=-t.scaleY,t.skewX=t.skewX-Math.PI),this},n.toMatrix=function(e){var t=this;e.a=t.scaleX*Math.cos(t.skewY),e.b=t.scaleX*Math.sin(t.skewY),e.c=-t.scaleY*Math.sin(t.skewX),e.d=t.scaleY*Math.cos(t.skewX),e.tx=t.x,e.ty=t.y},t(n,"rotation",function(){return this.skewY},function(e){var t=e-this.skewY;this.skewX+=t,this.skewY+=t}),e}();e.Transform=t,egret.registerClass(t,"dragonBones.Transform")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this),this.frames=[]}__extends(t,e);var a=(__define,t),n=a.prototype;return n._onClear=function(){var e=this;if(e.scale=1,e.offset=0,e.frames.length){for(var t=null,a=0,n=e.frames.length;n>a;++a){var r=e.frames[a];t&&r!=t&&t.returnToPool(),t=r}e.frames.length=0}},t}(e.BaseObject);e.TimelineData=t,egret.registerClass(t,"dragonBones.TimelineData");var a=function(t){function a(){t.call(this),this.bone=null,this.originTransform=new e.Transform,this.cachedFrames=[]}__extends(a,t);var n=(__define,a),r=n.prototype;return a.cacheFrame=function(t,a,n){var r=t[a]=new e.Matrix;return r.copyFrom(n),r},a.toString=function(){return"[Class dragonBones.BoneTimelineData]"},r._onClear=function(){var e=this;t.prototype._onClear.call(this),e.bone=null,e.originTransform.identity(),e.cachedFrames.length&&(e.cachedFrames.length=0)},r.cacheFrames=function(e){this.cachedFrames.length=0,this.cachedFrames.length=e},a}(t);e.BoneTimelineData=a,egret.registerClass(a,"dragonBones.BoneTimelineData");var n=function(t){function a(){t.call(this),this.slot=null,this.cachedFrames=[]}__extends(a,t);var n=(__define,a),r=n.prototype;return a.cacheFrame=function(t,a,n){var r=t[a]=new e.Matrix;return r.copyFrom(n),r},a.toString=function(){return"[Class dragonBones.SlotTimelineData]"},r._onClear=function(){var e=this;t.prototype._onClear.call(this),e.slot=null,e.cachedFrames.length&&(e.cachedFrames.length=0)},r.cacheFrames=function(e){this.cachedFrames.length=0,this.cachedFrames.length=e},a}(t);e.SlotTimelineData=n,egret.registerClass(n,"dragonBones.SlotTimelineData");var r=function(e){function t(){e.call(this),this.displayIndex=0,this.skin=null,this.slot=null}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.FFDTimelineData]"},n._onClear=function(){var t=this;e.prototype._onClear.call(this),t.displayIndex=0,t.skin=null,t.slot=null},t}(t);e.FFDTimelineData=r,egret.registerClass(r,"dragonBones.FFDTimelineData")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this),this.boneTimelines={},this.slotTimelines={},this.ffdTimelines={},this.cachedFrames=[]}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.AnimationData]"},n._onClear=function(){var t=this;e.prototype._onClear.call(this),t.hasAsynchronyTimeline=!1,t.cacheTimeToFrameScale=0,t.position=0,t.duration=0,t.playTimes=0,t.fadeInTime=0,t.name=null,t.animation=null;for(var a in t.boneTimelines)t.boneTimelines[a].returnToPool(),delete t.boneTimelines[a];for(var a in t.slotTimelines)t.slotTimelines[a].returnToPool(),delete t.slotTimelines[a];for(var a in t.ffdTimelines){for(var n in t.ffdTimelines[a])for(var r in t.ffdTimelines[a][n])t.ffdTimelines[a][n][r].returnToPool();delete t.ffdTimelines[a]}t.cachedFrames.length&&(t.cachedFrames.length=0)},n.cacheFrames=function(e){var t=this;if(!t.animation){var a=Math.max(Math.floor(t.frameCount*t.scale*e),1);t.cacheTimeToFrameScale=a/(t.duration+1e-6),t.cachedFrames.length=0,t.cachedFrames.length=a;for(var n in t.boneTimelines)t.boneTimelines[n].cacheFrames(a);for(var n in t.slotTimelines)t.slotTimelines[n].cacheFrames(a)}},n.addBoneTimeline=function(e){if(!e||!e.bone||this.boneTimelines[e.bone.name])throw new Error;this.boneTimelines[e.bone.name]=e},n.addSlotTimeline=function(e){if(!e||!e.slot||this.slotTimelines[e.slot.name])throw new Error;this.slotTimelines[e.slot.name]=e},n.addFFDTimeline=function(e){if(!(e&&e.skin&&e.slot))throw new Error;var t=this.ffdTimelines[e.skin.name]=this.ffdTimelines[e.skin.name]||{},a=t[e.slot.slot.name]=t[e.slot.slot.name]||{};if(a[e.displayIndex])throw new Error;a[e.displayIndex]=e},n.getBoneTimeline=function(e){return this.boneTimelines[e]},n.getSlotTimeline=function(e){return this.slotTimelines[e]},n.getFFDTimeline=function(e,t,a){var n=this.ffdTimelines[e];if(n){var r=n[t];if(r)return r[a]}return null},t}(e.TimelineData);e.AnimationData=t,egret.registerClass(t,"dragonBones.AnimationData")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this),this.parent=null,this.bones={},this.slots={},this.skins={},this.animations={},this.actions=[],this._sortedBones=[],this._sortedSlots=[],this._bonesChildren={}}__extends(t,e);var a=__define,n=t,r=n.prototype;return t._onSortSlots=function(e,t){return e.zOrder>t.zOrder?1:-1},t.toString=function(){return"[Class dragonBones.ArmatureData]"},r._onClear=function(){var e=this;e.frameRate=0,e.cacheFrameRate=0,e.type=0,e.name=null,e.parent=null;for(var t in e.bones)e.bones[t].returnToPool(),delete e.bones[t];for(var t in e.slots)e.slots[t].returnToPool(),delete e.slots[t];for(var t in e.skins)e.skins[t].returnToPool(),delete e.skins[t];for(var t in e.animations)e.animations[t].returnToPool(),delete e.animations[t];if(e.actions.length){for(var t=0,a=e.actions.length;a>t;++t)e.actions[t].returnToPool();e.actions.length=0}e._boneDirty=!1,e._slotDirty=!1,e._defaultSkin=null,e._defaultAnimation=null,e._sortedBones.length&&(e._sortedBones.length=0),e._sortedSlots.length&&(e._sortedSlots.length=0);for(var t in e._bonesChildren)delete e._bonesChildren[t]},r._sortBones=function(){var e=this,t=e._sortedBones.length;if(t){var a=e._sortedBones.concat(),n=0,r=0;for(e._sortedBones.length=0;t>r;){var i=a[n++];n>=t&&(n=0),e._sortedBones.indexOf(i)>=0||i.parent&&e._sortedBones.indexOf(i.parent)<0||i.ik&&e._sortedBones.indexOf(i.ik)<0||(i.ik&&i.chain>0&&i.chainIndex==i.chain?e._sortedBones.splice(e._sortedBones.indexOf(i.parent)+1,0,i):e._sortedBones.push(i),r++)}}},r._sortSlots=function(){this._sortedSlots.sort(t._onSortSlots)},r.cacheFrames=function(e){var t=this;if(t.cacheFrameRate!=e){t.cacheFrameRate=e;var a=t.cacheFrameRate/t.frameRate;for(var n in t.animations)t.animations[n].cacheFrames(a)}},r.addBone=function(e,t){var a=this;if(!e||!e.name||a.bones[e.name])throw new Error;if(t){var n=a.getBone(t);n?e.parent=n:(a._bonesChildren[t]=a._bonesChildren[t]||[]).push(e)}var r=a._bonesChildren[e.name];if(r){for(var i=0,o=r.length;o>i;++i)r[i].parent=e;delete a._bonesChildren[e.name]}a.bones[e.name]=e,a._sortedBones.push(e),a._boneDirty=!0},r.addSlot=function(e){if(!e||!e.name||this.slots[e.name])throw new Error;this.slots[e.name]=e,this._sortedSlots.push(e),this._slotDirty=!0},r.addSkin=function(e){if(!e||!e.name||this.skins[e.name])throw new Error;this.skins[e.name]=e,this._defaultSkin||(this._defaultSkin=e)},r.addAnimation=function(e){if(!e||!e.name||this.animations[e.name])throw new Error;this.animations[e.name]=e,this._defaultAnimation||(this._defaultAnimation=e)},r.getBone=function(e){return this.bones[e]},r.getSlot=function(e){return this.slots[e]},r.getSkin=function(e){return e?this.skins[e]:this._defaultSkin},r.getAnimation=function(e){return e?this.animations[e]:this._defaultAnimation},a(r,"sortedBones",function(){return this._boneDirty&&(this._boneDirty=!1,this._sortBones()),this._sortedBones}),a(r,"sortedSlots",function(){return this._slotDirty&&(this._slotDirty=!1,this._sortSlots()),this._sortedSlots}),a(r,"defaultSkin",function(){return this._defaultSkin}),a(r,"defaultAnimation",function(){return this._defaultAnimation}),t}(e.BaseObject);e.ArmatureData=t,egret.registerClass(t,"dragonBones.ArmatureData");var a=function(t){function a(){t.call(this),this.transform=new e.Transform}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.BoneData]"},r._onClear=function(){var e=this;e.inheritTranslation=!1,e.inheritRotation=!1,e.inheritScale=!1,e.bendPositive=!1,e.chain=0,e.chainIndex=0,e.weight=0,e.length=0,e.name=null,e.parent=null,e.ik=null,e.transform.identity()},a}(e.BaseObject);e.BoneData=a,egret.registerClass(a,"dragonBones.BoneData");var n=function(t){function a(){t.call(this),this.actions=[]}__extends(a,t);var n=(__define,a),r=n.prototype;return a.generateColor=function(){return new e.ColorTransform},a.toString=function(){return"[Class dragonBones.SlotData]"},r._onClear=function(){var e=this;if(e.displayIndex=0,e.zOrder=0,e.blendMode=0,e.name=null,e.parent=null,e.color=null,e.actions.length){for(var t=0,a=e.actions.length;a>t;++t)e.actions[t].returnToPool();e.actions.length=0}},a.DEFAULT_COLOR=new e.ColorTransform,a}(e.BaseObject);e.SlotData=n,egret.registerClass(n,"dragonBones.SlotData");var r=function(e){function t(){e.call(this),this.name=null,this.slots={}}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.SkinData]"},n._onClear=function(){var e=this;e.name=null;for(var t in e.slots)e.slots[t].returnToPool(),delete e.slots[t]},n.addSlot=function(e){if(!e||!e.slot||this.slots[e.slot.name])throw new Error;this.slots[e.slot.name]=e},n.getSlot=function(e){return this.slots[e]},t}(e.BaseObject);e.SkinData=r,egret.registerClass(r,"dragonBones.SkinData");var i=function(e){function t(){e.call(this),this.displays=[]}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.SlotDisplayDataSet]"},n._onClear=function(){if(this.slot=null,this.displays.length){for(var e=0,t=this.displays.length;t>e;++e)this.displays[e].returnToPool();this.displays.length=0}},t}(e.BaseObject);e.SlotDisplayDataSet=i,egret.registerClass(i,"dragonBones.SlotDisplayDataSet");var o=function(t){function a(){t.call(this),this.pivot=new e.Point,this.transform=new e.Transform}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.DisplayData]"},r._onClear=function(){var e=this;e.isRelativePivot=!1,e.type=0,e.name=null,e.textureData=null,e.armatureData=null,e.meshData&&(e.meshData.returnToPool(),e.meshData=null),e.pivot.clear(),e.transform.identity()},a}(e.BaseObject);e.DisplayData=o,egret.registerClass(o,"dragonBones.DisplayData");var s=function(t){function a(){t.call(this),this.slotPose=new e.Matrix,this.uvs=[],this.vertices=[],this.vertexIndices=[],this.boneIndices=[],this.weights=[],this.boneVertices=[],this.bones=[],this.inverseBindPose=[]}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.MeshData]"},r._onClear=function(){var e=this;e.skinned=!1,e.slotPose.identity(),e.uvs.length&&(e.uvs.length=0),e.vertices.length&&(e.vertices.length=0),e.vertexIndices.length&&(e.vertexIndices.length=0),e.boneIndices.length&&(e.boneIndices.length=0),e.weights.length&&(e.weights.length=0),e.boneVertices.length&&(e.boneVertices.length=0),e.bones.length&&(e.bones.length=0),e.inverseBindPose.length&&(e.inverseBindPose.length=0)},a}(e.BaseObject);e.MeshData=s,egret.registerClass(s,"dragonBones.MeshData")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this),this.armatures={},this._armatureNames=[]}__extends(t,e);var a=__define,n=t,r=n.prototype;return t.toString=function(){return"[Class dragonBones.DragonBonesData]"},r._onClear=function(){var e=this;e.autoSearch=!1,e.frameRate=0,e.name=null;for(var t in e.armatures)e.armatures[t].returnToPool(),delete e.armatures[t];e._armatureNames.length&&(e._armatureNames.length=0)},r.getArmature=function(e){return this.armatures[e]},r.addArmature=function(e){if(!e||!e.name||this.armatures[e.name])throw new Error;this.armatures[e.name]=e,this._armatureNames.push(e.name),e.parent=this},a(r,"armatureNames",function(){return this._armatureNames}),r.dispose=function(){this.returnToPool()},t}(e.BaseObject);e.DragonBonesData=t,egret.registerClass(t,"dragonBones.DragonBonesData")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(e){function t(){e.call(this)}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.ActionData]"},n._onClear=function(){var e=this;e.type=0,e.data=null,e.bone=null,e.slot=null},t}(e.BaseObject);e.ActionData=t,egret.registerClass(t,"dragonBones.ActionData");var a=function(e){function t(){e.call(this)}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.EventData]"},n._onClear=function(){var e=this;e.type=0,e.name=null,e.data=null,e.bone=null,e.slot=null},t}(e.BaseObject);e.EventData=a,egret.registerClass(a,"dragonBones.EventData");var n=function(e){function t(){e.call(this)}__extends(t,e);var a=(__define,t),n=a.prototype;return n._onClear=function(){var e=this;e.position=0,e.duration=0,e.prev=null,e.next=null},t}(e.BaseObject);e.FrameData=n,egret.registerClass(n,"dragonBones.FrameData");var r=function(e){function t(){e.call(this)}__extends(t,e);var a=(__define,t),n=a.prototype;return t.samplingCurve=function(e,t){if(0==e.length||0==t)return null;var a=t+2,n=1/a,r=new Array(2*(a-1));e.unshift(0,0),e.push(1,1);for(var i=0,o=0;a-1>o;++o){for(var s=n*(o+1);e[i+6]a;++a)t.actions[a].returnToPool();t.actions.length=0}if(t.events.length){for(var a=0,n=t.events.length;n>a;++a)t.events[a].returnToPool();t.events.length=0}},t}(n);e.AnimationFrameData=i,egret.registerClass(i,"dragonBones.AnimationFrameData");var o=function(t){function a(){t.call(this),this.transform=new e.Transform}__extends(a,t);var n=(__define,a),r=n.prototype;return a.toString=function(){return"[Class dragonBones.BoneFrameData]"},r._onClear=function(){var e=this;t.prototype._onClear.call(this),e.tweenScale=!1,e.tweenRotate=0,e.transform.identity()},a}(r);e.BoneFrameData=o,egret.registerClass(o,"dragonBones.BoneFrameData");var s=function(t){function a(){t.call(this)}__extends(a,t);var n=(__define,a),r=n.prototype;return a.generateColor=function(){return new e.ColorTransform},a.toString=function(){return"[Class dragonBones.SlotFrameData]"},r._onClear=function(){var e=this;t.prototype._onClear.call(this),e.displayIndex=0,e.zOrder=0,e.color=null},a.DEFAULT_COLOR=new e.ColorTransform,a}(r);e.SlotFrameData=s,egret.registerClass(s,"dragonBones.SlotFrameData");var l=function(e){function t(){e.call(this),this.tweens=[],this.keys=[] -}__extends(t,e);var a=(__define,t),n=a.prototype;return t.toString=function(){return"[Class dragonBones.ExtensionFrameData]"},n._onClear=function(){var t=this;e.prototype._onClear.call(this),t.type=0,t.tweens.length&&(t.tweens.length=0),t.keys.length&&(t.keys.length=0)},t}(r);e.ExtensionFrameData=l,egret.registerClass(l,"dragonBones.ExtensionFrameData")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(){function t(){this._data=null,this._armature=null,this._skin=null,this._slotDisplayDataSet=null,this._mesh=null,this._animation=null,this._timeline=null,this._isParentCooriinate=!1,this._isAutoTween=!1,this._animationTweenEasing=0,this._armatureScale=1,this._helpPoint=new e.Point,this._helpTransform=new e.Transform,this._helpMatrix=new e.Matrix,this._rawBones=[]}var a=(__define,t),n=a.prototype;return t._getArmatureType=function(e){switch(e.toLowerCase()){case"stage":return 0;case"armature":return 0;case"movieClip":return 1;default:return 0}},t._getDisplayType=function(e){switch(e.toLowerCase()){case"image":return 0;case"armature":return 1;case"mesh":return 2;default:return 0}},t._getBlendMode=function(e){switch(e.toLowerCase()){case"normal":return 0;case"add":return 1;case"alpha":return 2;case"darken":return 3;case"difference":return 4;case"erase":return 5;case"hardlight":return 6;case"invert":return 7;case"layer":return 8;case"lighten":return 9;case"multiply":return 10;case"overlay":return 11;case"screen":return 12;case"subtract":return 13;default:return 0}},t._getActionType=function(e){switch(e.toLowerCase()){case"play":return 0;case"stop":return 1;case"gotoandplay":return 2;case"gotoandstop":return 3;case"fadein":return 4;case"fadeout":return 5;default:return 4}},n._getTimelineFrameMatrix=function(t,a,n,r){var i=Math.floor(n*t.frameCount/t.duration);if(1==a.frames.length||i>=a.frames.length)r.copyFrom(a.frames[0].transform);else{var o=a.frames[i],s=0;o.duration>0&&o.tweenEasing!=e.DragonBones.NO_TWEEN?(s=(n-o.position)/o.duration,0!=o.tweenEasing&&(s=e.TweenTimelineState._getEasingValue(s,o.tweenEasing))):o.curve&&(s=(n-o.position)/o.duration,s=e.TweenTimelineState._getCurveEasingValue(s,o.curve)),r.x=o.next.transform.x-o.transform.x,r.y=o.next.transform.y-o.transform.y,r.skewX=e.Transform.normalizeRadian(o.next.transform.skewX-o.transform.skewX),r.skewY=e.Transform.normalizeRadian(o.next.transform.skewY-o.transform.skewY),r.scaleX=o.next.transform.scaleX-o.transform.scaleX,r.scaleY=o.next.transform.scaleY-o.transform.scaleY,r.x=o.transform.x+r.x*s,r.y=o.transform.y+r.y*s,r.skewX=o.transform.skewX+r.skewX*s,r.skewY=o.transform.skewY+r.skewY*s,r.scaleX=o.transform.scaleX+r.scaleX*s,r.scaleY=o.transform.scaleY+r.scaleY*s}r.add(a.originTransform)},n._mergeFrameToAnimationTimeline=function(t,a,n){var r=Math.floor(t.position*this._armature.frameRate),i=this._animation.frames;if(0==i.length){var o=e.BaseObject.borrowObject(e.AnimationFrameData);if(o.position=0,this._animation.frameCount>1){i.length=this._animation.frameCount+1;var s=e.BaseObject.borrowObject(e.AnimationFrameData);s.position=this._animation.frameCount/this._armature.frameRate,i[0]=o,i[this._animation.frameCount]=s}}var l=null,_=i[r];if(!_||0!=r&&i[r-1]!=_.prev){l=e.BaseObject.borrowObject(e.AnimationFrameData),l.position=r/this._armature.frameRate,i[r]=l;for(var u=r+1,f=i.length;f>u;++u)_&&i[u]==_&&(i[u]=null)}else l=_;if(a)for(var u=0,f=a.length;f>u;++u)l.actions.push(a[u]);if(n)for(var u=0,f=n.length;f>u;++u)l.events.push(n[u]);for(var m=null,h=null,u=0,f=i.length;f>u;++u){var c=i[u];c&&h!=c?(h=c,m&&(h.prev=m,m.next=h,m.duration=h.position-m.position),m=h):i[u]=m}h.duration=this._animation.duration-h.position,h=i[0],m.next=h,h.prev=m},n._globalToLocal=function(e){for(var t=[],a=e.sortedBones.concat().reverse(),n=0,r=a.length;r>n;++n){var i=a[n];i.parent&&(i.parent.transform.toMatrix(this._helpMatrix),this._helpMatrix.invert(),this._helpMatrix.transformPoint(i.transform.x,i.transform.y,i.transform),i.transform.rotation-=i.parent.transform.rotation);for(var o in e.animations){var s=e.animations[o],l=s.getBoneTimeline(i.name);if(l){var _=l.bone.parent?s.getBoneTimeline(l.bone.parent.name):null;t.length=0;for(var u=0,f=l.frames.length;f>u;++u){var m=l.frames[u];t.indexOf(m)>=0||(t.push(m),_?(this._getTimelineFrameMatrix(s,_,m.position,this._helpTransform),m.transform.add(l.originTransform),this._helpTransform.toMatrix(this._helpMatrix),this._helpMatrix.invert(),this._helpMatrix.transformPoint(m.transform.x,m.transform.y,m.transform),m.transform.rotation-=this._helpTransform.rotation):m.transform.add(l.originTransform))}t.length=0;for(var h=0,c=l.frames.length;c>h;++h){var m=l.frames[h];t.indexOf(m)>=0||(t.push(m),m.transform.minus(l.bone.transform),0==h?(l.originTransform.copyFrom(m.transform),m.transform.identity()):m.transform.minus(l.originTransform))}}}}},t.parseDragonBonesData=function(t){return e.ObjectDataParser.getInstance().parseDragonBonesData(t)},t.parseTextureAtlasData=function(a,n){void 0===n&&(n=1);for(var r={},i=a[t.SUB_TEXTURE],o=0,s=i.length;s>o;o++){var l=i[o],_=l[t.NAME],u=new e.Rectangle,f=null;u.x=l[t.X]/n,u.y=l[t.Y]/n,u.width=l[t.WIDTH]/n,u.height=l[t.HEIGHT]/n,t.FRAME_WIDTH in l&&(f=new e.Rectangle,f.x=l[t.FRAME_X]/n,f.y=l[t.FRAME_Y]/n,f.width=l[t.FRAME_WIDTH]/n,f.height=l[t.FRAME_HEIGHT]/n),r[_]={region:u,frame:f,rotated:!1}}return r},t.DATA_VERSION_2_3="2.3",t.DATA_VERSION_3_0="3.0",t.DATA_VERSION_4_0="4.0",t.DATA_VERSION="4.5",t.TEXTURE_ATLAS="TextureAtlas",t.SUB_TEXTURE="SubTexture",t.FORMAT="format",t.IMAGE_PATH="imagePath",t.WIDTH="width",t.HEIGHT="height",t.ROTATED="rotated",t.FRAME_X="frameX",t.FRAME_Y="frameY",t.FRAME_WIDTH="frameWidth",t.FRAME_HEIGHT="frameHeight",t.DRADON_BONES="dragonBones",t.ARMATURE="armature",t.BONE="bone",t.IK="ik",t.SLOT="slot",t.SKIN="skin",t.DISPLAY="display",t.ANIMATION="animation",t.FFD="ffd",t.FRAME="frame",t.PIVOT="pivot",t.TRANSFORM="transform",t.COLOR="color",t.FILTER="filter",t.VERSION="version",t.IS_GLOBAL="isGlobal",t.FRAME_RATE="frameRate",t.TYPE="type",t.NAME="name",t.PARENT="parent",t.LENGTH="length",t.DATA="data",t.DISPLAY_INDEX="displayIndex",t.Z_ORDER="z",t.BLEND_MODE="blendMode",t.INHERIT_TRANSLATION="inheritTranslation",t.INHERIT_ROTATION="inheritRotation",t.INHERIT_SCALE="inheritScale",t.TARGET="target",t.BEND_POSITIVE="bendPositive",t.CHAIN="chain",t.WEIGHT="weight",t.FADE_IN_TIME="fadeInTime",t.PLAY_TIMES="playTimes",t.SCALE="scale",t.OFFSET="offset",t.POSITION="position",t.DURATION="duration",t.TWEEN_EASING="tweenEasing",t.TWEEN_ROTATE="tweenRotate",t.TWEEN_SCALE="tweenScale",t.CURVE="curve",t.EVENT="event",t.SOUND="sound",t.ACTION="action",t.ACTIONS="actions",t.DEFAULT_ACTIONS="defaultActions",t.X="x",t.Y="y",t.SKEW_X="skX",t.SKEW_Y="skY",t.SCALE_X="scX",t.SCALE_Y="scY",t.ALPHA_OFFSET="aO",t.RED_OFFSET="rO",t.GREEN_OFFSET="gO",t.BLUE_OFFSET="bO",t.ALPHA_MULTIPLIER="aM",t.RED_MULTIPLIER="rM",t.GREEN_MULTIPLIER="gM",t.BLUE_MULTIPLIER="bM",t.UVS="uvs",t.VERTICES="vertices",t.TRIANGLES="triangles",t.WEIGHTS="weights",t.SLOT_POSE="slotPose",t.BONE_POSE="bonePose",t.TWEEN="tween",t.KEY="key",t.COLOR_TRANSFORM="colorTransform",t.TIMELINE="timeline",t.PIVOT_X="pX",t.PIVOT_Y="pY",t.LOOP="loop",t.AUTO_TWEEN="autoTween",t.HIDE="hide",t.RECTANGLE="rectangle",t.ELLIPSE="ellipse",t}();e.DataParser=t,egret.registerClass(t,"dragonBones.DataParser")}(dragonBones||(dragonBones={}));var dragonBones;!function(e){var t=function(t){function a(){t.call(this)}__extends(a,t);var n=(__define,a),r=n.prototype;return a._getBoolean=function(e,t,a){if(t in e){var n=e[t],r=typeof n;if("boolean"==r)return n;if("string"!=r)return Boolean(n);switch(n){case"0":case"NaN":case"":case"false":case"null":case"undefined":return!1;default:return!0}}return a},a._getNumber=function(e,t,a){if(t in e){var n=e[t];return null==n||"NaN"==n?a:Number(n)}return a},a._getString=function(e,t,a){return t in e?String(e[t]):a},a._getParameter=function(e,t,a){return e&&e.length>t?e[t]:a},r._parseArmature=function(t){var n=e.BaseObject.borrowObject(e.ArmatureData);if(n.name=a._getString(t,a.NAME,null),n.frameRate=a._getNumber(t,a.FRAME_RATE,this._data.frameRate)||this._data.frameRate,a.TYPE in t&&"string"==typeof t[a.TYPE]?n.type=a._getArmatureType(t[a.TYPE]):n.type=a._getNumber(t,a.TYPE,0),this._armature=n,this._rawBones.length=0,a.BONE in t)for(var r=t[a.BONE],i=0,o=r.length;o>i;++i){var s=r[i],l=this._parseBone(s);n.addBone(l,a._getString(s,a.PARENT,null)),this._rawBones.push(l)}if(a.IK in t)for(var _=t[a.IK],i=0,o=_.length;o>i;++i)this._parseIK(_[i]);if(a.SLOT in t)for(var u=t[a.SLOT],i=0,o=u.length;o>i;++i)n.addSlot(this._parseSlot(u[i]));if(a.SKIN in t)for(var f=t[a.SKIN],i=0,o=f.length;o>i;++i)n.addSkin(this._parseSkin(f[i]));if(a.ANIMATION in t)for(var m=t[a.ANIMATION],i=0,o=m.length;o>i;++i)n.addAnimation(this._parseAnimation(m[i]));return(a.ACTIONS in t||a.DEFAULT_ACTIONS in t)&&this._parseActionData(t,n.actions,null,null),this._isParentCooriinate&&a._getBoolean(t,a.IS_GLOBAL,!0)&&this._globalToLocal(n),this._armature=null,this._rawBones.length=0,n},r._parseBone=function(t){var n=e.BaseObject.borrowObject(e.BoneData);return n.name=a._getString(t,a.NAME,null),n.inheritTranslation=a._getBoolean(t,a.INHERIT_TRANSLATION,!0),n.inheritRotation=a._getBoolean(t,a.INHERIT_ROTATION,!0),n.inheritScale=a._getBoolean(t,a.INHERIT_SCALE,!0),n.length=a._getNumber(t,a.LENGTH,0)*this._armatureScale,a.TRANSFORM in t&&this._parseTransform(t[a.TRANSFORM],n.transform),this._isParentCooriinate&&(n.inheritRotation=!0,n.inheritScale=!1),n},r._parseIK=function(e){var t=this._armature.getBone(a._getString(e,a.BONE in e?a.BONE:a.NAME,null));t&&(t.ik=this._armature.getBone(a._getString(e,a.TARGET,null)),t.bendPositive=a._getBoolean(e,a.BEND_POSITIVE,!0),t.chain=a._getNumber(e,a.CHAIN,0),t.weight=a._getNumber(e,a.WEIGHT,1),t.chain>0&&t.parent&&!t.parent.ik?(t.parent.ik=t.ik,t.parent.chainIndex=0,t.parent.chain=0,t.chainIndex=1):(t.chain=0,t.chainIndex=0))},r._parseSlot=function(t){var n=e.BaseObject.borrowObject(e.SlotData);return n.name=a._getString(t,a.NAME,null),n.parent=this._armature.getBone(a._getString(t,a.PARENT,null)),n.displayIndex=a._getNumber(t,a.DISPLAY_INDEX,0),n.zOrder=a._getNumber(t,a.Z_ORDER,this._armature.sortedSlots.length),a.COLOR in t?(n.color=e.SlotData.generateColor(),this._parseColorTransform(t[a.COLOR],n.color)):n.color=e.SlotData.DEFAULT_COLOR,a.BLEND_MODE in t&&"string"==typeof t[a.BLEND_MODE]?n.blendMode=a._getBlendMode(t[a.BLEND_MODE]):n.blendMode=a._getNumber(t,a.BLEND_MODE,0),(a.ACTIONS in t||a.DEFAULT_ACTIONS in t)&&this._parseActionData(t,n.actions,null,null),this._isParentCooriinate&&(a.COLOR_TRANSFORM in t?(n.color=e.SlotData.generateColor(),this._parseColorTransform(t[a.COLOR_TRANSFORM],n.color)):n.color=e.SlotData.DEFAULT_COLOR),n},r._parseSkin=function(t){var n=e.BaseObject.borrowObject(e.SkinData);if(n.name=a._getString(t,a.NAME,"__default")||"__default",a.SLOT in t){this._skin=n;for(var r=t[a.SLOT],i=0,o=r.length;o>i;++i)this._isParentCooriinate&&this._armature.addSlot(this._parseSlot(r[i])),n.addSlot(this._parseSlotDisplaySet(r[i]));this._skin=null}return n},r._parseSlotDisplaySet=function(t){var n=e.BaseObject.borrowObject(e.SlotDisplayDataSet);if(n.slot=this._armature.getSlot(a._getString(t,a.NAME,null)),a.DISPLAY in t){var r=t[a.DISPLAY],i=n.displays;this._slotDisplayDataSet=n;for(var o=0,s=r.length;s>o;++o)i.push(this._parseDisplay(r[o]));this._slotDisplayDataSet=null}return n},r._parseDisplay=function(t){var n=e.BaseObject.borrowObject(e.DisplayData);if(n.name=a._getString(t,a.NAME,null),a.TYPE in t&&"string"==typeof t[a.TYPE]?n.type=a._getDisplayType(t[a.TYPE]):n.type=a._getNumber(t,a.TYPE,0),n.isRelativePivot=!0,a.PIVOT in t){var r=t[a.PIVOT];n.pivot.x=a._getNumber(r,a.X,0),n.pivot.y=a._getNumber(r,a.Y,0)}else if(this._isParentCooriinate){var i=t[a.TRANSFORM];n.isRelativePivot=!1,n.pivot.x=a._getNumber(i,a.PIVOT_X,0)*this._armatureScale,n.pivot.y=a._getNumber(i,a.PIVOT_Y,0)*this._armatureScale}else n.pivot.x=.5,n.pivot.y=.5;switch(a.TRANSFORM in t&&this._parseTransform(t[a.TRANSFORM],n.transform),n.type){case 0:break;case 1:break;case 2:n.meshData=this._parseMesh(t)}return n},r._parseMesh=function(t){var n=e.BaseObject.borrowObject(e.MeshData),r=t[a.VERTICES],i=t[a.UVS],o=t[a.TRIANGLES],s=Math.floor(r.length/2),l=Math.floor(o.length/3),_=new Array(this._armature.sortedBones.length);if(n.skinned=a.WEIGHTS in t&&t[a.WEIGHTS].length>0,n.uvs.length=2*s,n.vertices.length=2*s,n.vertexIndices.length=3*l,n.skinned){if(n.boneIndices.length=s,n.weights.length=s,n.boneVertices.length=s,a.SLOT_POSE in t){var u=t[a.SLOT_POSE];n.slotPose.a=u[0],n.slotPose.b=u[1],n.slotPose.c=u[2],n.slotPose.d=u[3],n.slotPose.tx=u[4],n.slotPose.ty=u[5]}if(a.BONE_POSE in t)for(var f=t[a.BONE_POSE],m=0,h=f.length;h>m;m+=7){var c=f[m],d=_[c]=new e.Matrix;d.a=f[m+1],d.b=f[m+2],d.c=f[m+3],d.d=f[m+4],d.tx=f[m+5],d.ty=f[m+6],d.invert()}}for(var m=0,g=0,h=r.length;h>m;m+=2){var p=m+1,v=m/2,T=n.vertices[m]=r[m]*this._armatureScale,y=n.vertices[p]=r[p]*this._armatureScale;if(n.uvs[m]=i[m],n.uvs[p]=i[p],n.skinned){var D=t[a.WEIGHTS],b=D[g],E=n.boneIndices[v]=new Array(b),S=n.weights[v]=new Array(b),O=n.boneVertices[v]=new Array(2*b);n.slotPose.transformPoint(T,y,this._helpPoint),T=n.vertices[m]=this._helpPoint.x,y=n.vertices[p]=this._helpPoint.y;for(var B=0;b>B;++B){var A=g+1+2*B,c=D[A],w=this._rawBones[c],x=n.bones.indexOf(w);0>x&&(x=n.bones.length,n.bones[x]=w,n.inverseBindPose[x]=_[c]),n.inverseBindPose[x].transformPoint(T,y,this._helpPoint),E[B]=x,S[B]=D[A+1],O[2*B]=this._helpPoint.x,O[2*B+1]=this._helpPoint.y}g+=2*b+1}}for(var m=0,h=o.length;h>m;++m)n.vertexIndices[m]=o[m];return n},r._parseAnimation=function(t){var n=e.BaseObject.borrowObject(e.AnimationData);n.name=a._getString(t,a.NAME,"__default")||"__default",n.frameCount=Math.max(a._getNumber(t,a.DURATION,1),1),n.position=a._getNumber(t,a.POSITION,0)/this._armature.frameRate,n.duration=n.frameCount/this._armature.frameRate,n.playTimes=a._getNumber(t,a.PLAY_TIMES,1),n.fadeInTime=a._getNumber(t,a.FADE_IN_TIME,0),this._animation=n;var r=a._getString(t,a.ANIMATION,null);if(r)return n.animation=this._armature.getAnimation(r),!n.animation,n;if(this._parseTimeline(t,n,this._parseAnimationFrame),a.BONE in t)for(var i=t[a.BONE],o=0,s=i.length;s>o;++o)n.addBoneTimeline(this._parseBoneTimeline(i[o]));if(a.SLOT in t)for(var l=t[a.SLOT],o=0,s=l.length;s>o;++o)n.addSlotTimeline(this._parseSlotTimeline(l[o]));if(a.FFD in t)for(var _=t[a.FFD],o=0,s=_.length;s>o;++o)n.addFFDTimeline(this._parseFFDTimeline(_[o]));if(this._isParentCooriinate){if(this._isAutoTween=a._getBoolean(t,a.AUTO_TWEEN,!0),this._animationTweenEasing=a._getNumber(t,a.TWEEN_EASING,0)||0,n.playTimes=a._getNumber(t,a.LOOP,1),a.TIMELINE in t){for(var u=t[a.TIMELINE],o=0,s=u.length;s>o;++o)n.addBoneTimeline(this._parseBoneTimeline(u[o]));for(var o=0,s=u.length;s>o;++o)n.addSlotTimeline(this._parseSlotTimeline(u[o]))}}else this._isAutoTween=!1,this._animationTweenEasing=0;for(var o in this._armature.bones){var f=this._armature.bones[o];if(!n.getBoneTimeline(f.name)){var m=e.BaseObject.borrowObject(e.BoneTimelineData),h=e.BaseObject.borrowObject(e.BoneFrameData);m.bone=f,m.frames[0]=h,n.addBoneTimeline(m)}}for(var o in this._armature.slots){var c=this._armature.slots[o];if(!n.getSlotTimeline(c.name)){var d=e.BaseObject.borrowObject(e.SlotTimelineData),g=e.BaseObject.borrowObject(e.SlotFrameData);d.slot=c,g.displayIndex=c.displayIndex,c.color==e.SlotData.DEFAULT_COLOR?g.color=e.SlotFrameData.DEFAULT_COLOR:(g.color=e.SlotFrameData.generateColor(),g.color.copyFrom(c.color)),d.frames[0]=g,n.addSlotTimeline(d),this._isParentCooriinate&&(g.displayIndex=-1)}}return this._animation=null,n},r._parseBoneTimeline=function(t){var n=e.BaseObject.borrowObject(e.BoneTimelineData);n.bone=this._armature.getBone(a._getString(t,a.NAME,null)),this._parseTimeline(t,n,this._parseBoneFrame);for(var r=n.originTransform,i=null,o=0,s=n.frames.length;s>o;++o){var l=n.frames[o];i?i!=l&&l.transform.minus(r):(r.copyFrom(l.transform),l.transform.identity(),0==r.scaleX&&(r.scaleX=.001),0==r.scaleY&&(r.scaleY=.001)),i=l}return(1!=n.scale||0!=n.offset)&&(this._animation.hasAsynchronyTimeline=!0),n},r._parseSlotTimeline=function(t){var n=e.BaseObject.borrowObject(e.SlotTimelineData);return n.slot=this._armature.getSlot(a._getString(t,a.NAME,null)),this._parseTimeline(t,n,this._parseSlotFrame),(1!=n.scale||0!=n.offset)&&(this._animation.hasAsynchronyTimeline=!0),n},r._parseFFDTimeline=function(t){var n=e.BaseObject.borrowObject(e.FFDTimelineData);n.skin=this._armature.getSkin(a._getString(t,a.SKIN,null)),n.slot=n.skin.getSlot(a._getString(t,a.SLOT,null));for(var r=a._getString(t,a.NAME,null),i=0,o=n.slot.displays.length;o>i;++i){var s=n.slot.displays[i];if(s.meshData&&s.name==r){n.displayIndex=i,this._mesh=s.meshData;break}}return this._parseTimeline(t,n,this._parseFFDFrame),this._mesh=null,n},r._parseAnimationFrame=function(t,n,r){var i=e.BaseObject.borrowObject(e.AnimationFrameData);return this._parseFrame(t,i,n,r),(a.ACTION in t||a.ACTIONS in t)&&this._parseActionData(t,i.actions,null,null),(a.EVENT in t||a.SOUND in t)&&this._parseEventData(t,i.events,null,null),i},r._parseBoneFrame=function(t,n,r){var i=e.BaseObject.borrowObject(e.BoneFrameData);if(i.tweenRotate=a._getNumber(t,a.TWEEN_ROTATE,0),i.tweenScale=a._getBoolean(t,a.TWEEN_SCALE,!0),this._parseTweenFrame(t,i,n,r),a.TRANSFORM in t){var o=t[a.TRANSFORM];this._parseTransform(o,i.transform),this._isParentCooriinate&&(this._helpPoint.x=a._getNumber(o,a.PIVOT_X,0),this._helpPoint.y=a._getNumber(o,a.PIVOT_Y,0),i.transform.toMatrix(this._helpMatrix),this._helpMatrix.transformPoint(this._helpPoint.x,this._helpPoint.y,this._helpPoint,!0),i.transform.x+=this._helpPoint.x,i.transform.y+=this._helpPoint.y)}var s=this._timeline.bone;if(a.ACTION in t||a.ACTIONS in t){var l=this._armature.getSlot(s.name),_=[];this._parseActionData(t,_,s,l),this._mergeFrameToAnimationTimeline(i,_,null)}if(a.EVENT in t||a.SOUND in t){var u=[];this._parseEventData(t,u,s,null),this._mergeFrameToAnimationTimeline(i,null,u)}return i},r._parseSlotFrame=function(t,n,r){var i=e.BaseObject.borrowObject(e.SlotFrameData);if(i.displayIndex=a._getNumber(t,a.DISPLAY_INDEX,0),this._parseTweenFrame(t,i,n,r),a.COLOR in t||a.COLOR_TRANSFORM in t?(i.color=e.SlotFrameData.generateColor(),this._parseColorTransform(t[a.COLOR]||t[a.COLOR_TRANSFORM],i.color)):i.color=e.SlotFrameData.DEFAULT_COLOR,this._isParentCooriinate)a._getBoolean(t,a.HIDE,!1)&&(i.displayIndex=-1);else if(a.ACTION in t||a.ACTIONS in t){var o=this._timeline.slot,s=[];this._parseActionData(t,s,o.parent,o),this._mergeFrameToAnimationTimeline(i,s,null)}return i},r._parseFFDFrame=function(t,n,r){var i=e.BaseObject.borrowObject(e.ExtensionFrameData);i.type=a._getNumber(t,a.TYPE,0),this._parseTweenFrame(t,i,n,r);for(var o=t[a.VERTICES],s=a._getNumber(t,a.OFFSET,0),l=0,_=0,u=0,f=this._mesh.vertices.length;f>u;u+=2)if(!o||s>u||u-s>=o.length?(l=0,_=0):(l=o[u-s]*this._armatureScale,_=o[u+1-s]*this._armatureScale),this._mesh.skinned){this._mesh.slotPose.transformPoint(l,_,this._helpPoint,!0),l=this._helpPoint.x,_=this._helpPoint.y;for(var m=this._mesh.boneIndices[u/2],h=0,c=m.length;c>h;++h){var d=m[h];this._mesh.inverseBindPose[d].transformPoint(l,_,this._helpPoint,!0),i.tweens.push(this._helpPoint.x,this._helpPoint.y)}}else i.tweens.push(l,_);return i},r._parseTweenFrame=function(t,n,r,i){this._parseFrame(t,n,r,i),a.TWEEN_EASING in t?n.tweenEasing=a._getNumber(t,a.TWEEN_EASING,e.DragonBones.NO_TWEEN):this._isParentCooriinate&&(n.tweenEasing=this._isAutoTween?this._animationTweenEasing:e.DragonBones.NO_TWEEN),this._isParentCooriinate&&1==this._animation.scale&&1==this._timeline.scale&&n.duration*this._armature.frameRate<2&&(n.tweenEasing=e.DragonBones.NO_TWEEN),a.CURVE in t&&(n.curve=e.TweenFrameData.samplingCurve(t[a.CURVE],i))},r._parseFrame=function(e,t,a,n){t.position=a/this._armature.frameRate,t.duration=n/this._armature.frameRate},r._parseTimeline=function(t,n,r){if(n.scale=a._getNumber(t,a.SCALE,1),n.offset=a._getNumber(t,a.OFFSET,0),this._timeline=n,a.FRAME in t){var i=t[a.FRAME];if(i.length)if(1==i.length)n.frames.length=1,n.frames[0]=r.call(this,i[0],0,a._getNumber(i[0],a.DURATION,1));else{n.frames.length=this._animation.frameCount+1;for(var o=0,s=0,l=null,_=null,u=0,f=0,m=this._animation.frameCount+1;m>u;++u){if(u>=o+s&&fl;++l){var u=o[l]instanceof Array?o[l]:null,s=e.BaseObject.borrowObject(e.ActionData),f=u?null:o[l].gotoAndPlay;if(u){var m=u[0];"string"==typeof m?s.type=a._getActionType(m):s.type=a._getParameter(u,0,4)}else s.type=2;switch(s.type){case 0:s.data=[u?a._getParameter(u,1,null):f,a._getParameter(u,2,-1)];break;case 1:s.data=[u?a._getParameter(u,1,null):f];break;case 2:s.data=[u?a._getParameter(u,1,null):f,a._getParameter(u,2,0),a._getParameter(u,3,-1)];break;case 3:s.data=[u?a._getParameter(u,1,null):f,a._getParameter(u,2,0)];break;case 4:s.data=[u?a._getParameter(u,1,null):f,a._getParameter(u,2,-1),a._getParameter(u,3,-1)];break;case 5:s.data=[u?a._getParameter(u,1,null):f,a._getParameter(u,2,0)]}s.bone=r,s.slot=i,n.push(s)}},r._parseEventData=function(t,n,r,i){if(a.SOUND in t){var o=e.BaseObject.borrowObject(e.EventData);o.type=1,o.name=t[a.SOUND],o.bone=r,o.slot=i,n.push(o)}if(a.EVENT in t){var s=e.BaseObject.borrowObject(e.EventData);s.type=0,s.name=t[a.EVENT],s.bone=r,s.slot=i,a.DATA in t&&(s.data=t[a.DATA]),n.push(s)}},r._parseTransform=function(t,n){n.x=a._getNumber(t,a.X,0)*this._armatureScale,n.y=a._getNumber(t,a.Y,0)*this._armatureScale,n.skewX=a._getNumber(t,a.SKEW_X,0)*e.DragonBones.ANGLE_TO_RADIAN,n.skewY=a._getNumber(t,a.SKEW_Y,0)*e.DragonBones.ANGLE_TO_RADIAN,n.scaleX=a._getNumber(t,a.SCALE_X,1),n.scaleY=a._getNumber(t,a.SCALE_Y,1)},r._parseColorTransform=function(e,t){t.alphaMultiplier=.01*a._getNumber(e,a.ALPHA_MULTIPLIER,100),t.redMultiplier=.01*a._getNumber(e,a.RED_MULTIPLIER,100),t.greenMultiplier=.01*a._getNumber(e,a.GREEN_MULTIPLIER,100),t.blueMultiplier=.01*a._getNumber(e,a.BLUE_MULTIPLIER,100),t.alphaOffset=a._getNumber(e,a.ALPHA_OFFSET,0),t.redOffset=a._getNumber(e,a.RED_OFFSET,0),t.greenOffset=a._getNumber(e,a.GREEN_OFFSET,0),t.blueOffset=a._getNumber(e,a.BLUE_OFFSET,0)},r.parseDragonBonesData=function(t,n){if(void 0===n&&(n=1),t){var r=a._getString(t,a.VERSION,null);if(this._isParentCooriinate=r==a.DATA_VERSION_2_3||r==a.DATA_VERSION_3_0,this._armatureScale=n,r==a.DATA_VERSION||r==a.DATA_VERSION_4_0||this._isParentCooriinate){var i=e.BaseObject.borrowObject(e.DragonBonesData);if(i.name=a._getString(t,a.NAME,null),i.frameRate=a._getNumber(t,a.FRAME_RATE,24)||24,a.ARMATURE in t){this._data=i;for(var o=t[a.ARMATURE],s=0,l=o.length;l>s;++s)i.addArmature(this._parseArmature(o[s]));this._data=null}return i}throw new Error("Nonsupport data version.")}throw new Error},r.parseTextureAtlasData=function(t,n,r){if(void 0===r&&(r=0),t){if(n.name=a._getString(t,a.NAME,null),n.imagePath=a._getString(t,a.IMAGE_PATH,null),r>0?n.scale=r:r=n.scale=a._getNumber(t,a.SCALE,n.scale),r=1/r,a.SUB_TEXTURE in t)for(var i=t[a.SUB_TEXTURE],o=0,s=i.length;s>o;++o){var l=i[o],_=n.generateTextureData();_.name=a._getString(l,a.NAME,null),_.rotated=a._getBoolean(l,a.ROTATED,!1),_.region.x=a._getNumber(l,a.X,0)*r,_.region.y=a._getNumber(l,a.Y,0)*r,_.region.width=a._getNumber(l,a.WIDTH,0)*r,_.region.height=a._getNumber(l,a.HEIGHT,0)*r;var u=a._getNumber(l,a.FRAME_WIDTH,-1),f=a._getNumber(l,a.FRAME_HEIGHT,-1);u>0&&f>0&&(_.frame=e.TextureData.generateRectangle(),_.frame.x=a._getNumber(l,a.FRAME_X,0)*r,_.frame.y=a._getNumber(l,a.FRAME_Y,0)*r,_.frame.width=u*r,_.frame.height=f*r),n.addTextureData(_)}return n}throw new Error},a.getInstance=function(){return a._instance||(a._instance=new a),a._instance},a._instance=null,a}(e.DataParser);e.ObjectDataParser=t,egret.registerClass(t,"dragonBones.ObjectDataParser")}(dragonBones||(dragonBones={})); \ No newline at end of file +var __extends=this&&this.__extends||function(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)},dragonBones;!function(t){var e=function(){function t(){this.hashCode=t._hashCode++}return t._returnObject=function(e){var i=e.constructor,n=String(i),a=null==t._maxCountMap[n]?t._defaultMaxCount:t._maxCountMap[n],r=t._poolsMap[n]=t._poolsMap[n]||[];if(r.lengthi&&(a.length=i)}else{t._defaultMaxCount=i;for(var n in t._poolsMap)if(null!=t._maxCountMap[n]){var a=t._poolsMap[n];a.length>i&&(a.length=i)}}},t.clearPool=function(e){if(void 0===e&&(e=null),e){var i=t._poolsMap[String(e)];i&&i.length&&(i.length=0)}else for(var n in t._poolsMap){var i=t._poolsMap[n];i.length=0}},t.borrowObject=function(e){var i=t._poolsMap[String(e)];if(i&&i.length)return i.pop();var n=new e;return n._onClear(),n},t.prototype.returnToPool=function(){this._onClear(),t._returnObject(this)},t._hashCode=0,t._defaultMaxCount=5e3,t._maxCountMap={},t._poolsMap={},t}();t.BaseObject=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(){function t(){}return t.hasArmature=function(e){return t._armatures.indexOf(e)>=0},t.addArmature=function(e){e&&t._armatures.indexOf(e)<0&&t._armatures.push(e)},t.removeArmature=function(e){if(e){var i=t._armatures.indexOf(e);i>=0&&t._armatures.splice(i,1)}},t.PI_D=2*Math.PI,t.PI_H=Math.PI/2,t.PI_Q=Math.PI/4,t.ANGLE_TO_RADIAN=Math.PI/180,t.RADIAN_TO_ANGLE=180/Math.PI,t.SECOND_TO_MILLISECOND=1e3,t.NO_TWEEN=100,t.VERSION="4.7.2",t.DEBUG=!1,t.DEBUG_DRAW=!1,t._armatures=[],t}();t.DragonBones=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(t){function e(){t.call(this)}return __extends(e,t),e.toString=function(){return"[class dragonBones.EventObject]"},e.prototype._onClear=function(){this.type=null,this.name=null,this.data=null,this.armature=null,this.bone=null,this.slot=null,this.animationState=null,this.userData=null},Object.defineProperty(e.prototype,"animationName",{get:function(){return this.animationState.name},enumerable:!0,configurable:!0}),e.START="start",e.LOOP_COMPLETE="loopComplete",e.COMPLETE="complete",e.FADE_IN="fadeIn",e.FADE_IN_COMPLETE="fadeInComplete",e.FADE_OUT="fadeOut",e.FADE_OUT_COMPLETE="fadeOutComplete",e.FRAME_EVENT="frameEvent",e.SOUND_EVENT="soundEvent",e._soundEventManager=null,e}(t.BaseObject);t.EventObject=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(){function t(t,e){void 0===t&&(t=0),void 0===e&&(e=0),this.x=t,this.y=e}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y},t.prototype.clear=function(){this.x=this.y=0},t}();t.Point=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(){function t(t,e,i,n){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),this.x=t,this.y=e,this.width=i,this.height=n}return t.prototype.copyFrom=function(t){this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height},t.prototype.clear=function(){this.x=this.y=0,this.width=this.height=0},t}();t.Rectangle=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(){function t(t,e,i,n,a,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=0),void 0===a&&(a=1),void 0===r&&(r=1),this.x=t,this.y=e,this.skewX=i,this.skewY=n,this.scaleX=a,this.scaleY=r}return t.normalizeRadian=function(t){return t=(t+Math.PI)%(2*Math.PI),t+=t>0?-Math.PI:Math.PI},t.prototype.toString=function(){return"[object dragonBones.Transform] x:"+this.x+" y:"+this.y+" skewX:"+180*this.skewX/Math.PI+" skewY:"+180*this.skewY/Math.PI+" scaleX:"+this.scaleX+" scaleY:"+this.scaleY},t.prototype.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.skewX=t.skewX,this.skewY=t.skewY,this.scaleX=t.scaleX,this.scaleY=t.scaleY,this},t.prototype.clone=function(){var e=new t;return e.copyFrom(this),e},t.prototype.identity=function(){return this.x=this.y=this.skewX=this.skewY=0,this.scaleX=this.scaleY=1,this},t.prototype.add=function(t){return this.x+=t.x,this.y+=t.y,this.skewX+=t.skewX,this.skewY+=t.skewY,this.scaleX*=t.scaleX,this.scaleY*=t.scaleY,this},t.prototype.minus=function(e){return this.x-=e.x,this.y-=e.y,this.skewX=t.normalizeRadian(this.skewX-e.skewX),this.skewY=t.normalizeRadian(this.skewY-e.skewY),this.scaleX/=e.scaleX,this.scaleY/=e.scaleY,this},t.prototype.fromMatrix=function(t){var e=.25*Math.PI,i=this.scaleX,n=this.scaleY;return this.x=t.tx,this.y=t.ty,this.skewX=Math.atan(-t.c/t.d),this.skewY=Math.atan(t.b/t.a),this.skewX!=this.skewX&&(this.skewX=0),this.skewY!=this.skewY&&(this.skewY=0),this.scaleY=this.skewX>-e&&this.skewX-e&&this.skewY=0&&this.scaleX<0&&(this.scaleX=-this.scaleX,this.skewY=this.skewY-Math.PI),n>=0&&this.scaleY<0&&(this.scaleY=-this.scaleY,this.skewX=this.skewX-Math.PI),this},t.prototype.toMatrix=function(t){return t.a=this.scaleX*Math.cos(this.skewY),t.b=this.scaleX*Math.sin(this.skewY),t.c=-this.scaleY*Math.sin(this.skewX),t.d=this.scaleY*Math.cos(this.skewX),t.tx=this.x,t.ty=this.y,this},Object.defineProperty(t.prototype,"rotation",{get:function(){return this.skewY},set:function(t){var e=t-this.skewY;this.skewX+=e,this.skewY+=e},enumerable:!0,configurable:!0}),t}();t.Transform=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(){function t(t,e,i,n,a,r,s,o){void 0===t&&(t=1),void 0===e&&(e=1),void 0===i&&(i=1),void 0===n&&(n=1),void 0===a&&(a=0),void 0===r&&(r=0),void 0===s&&(s=0),void 0===o&&(o=0),this.alphaMultiplier=t,this.redMultiplier=e,this.greenMultiplier=i,this.blueMultiplier=n,this.alphaOffset=a,this.redOffset=r,this.greenOffset=s,this.blueOffset=o}return t.prototype.copyFrom=function(t){this.alphaMultiplier=t.alphaMultiplier,this.redMultiplier=t.redMultiplier,this.greenMultiplier=t.greenMultiplier,this.blueMultiplier=t.blueMultiplier,this.alphaOffset=t.alphaOffset,this.redOffset=t.redOffset,this.redOffset=t.redOffset,this.greenOffset=t.blueOffset},t.prototype.identity=function(){this.alphaMultiplier=this.redMultiplier=this.greenMultiplier=this.blueMultiplier=1,this.alphaOffset=this.redOffset=this.greenOffset=this.blueOffset=0},t}();t.ColorTransform=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(){function t(t,e,i,n,a,r){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===a&&(a=0),void 0===r&&(r=0),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=a,this.ty=r}return t.prototype.copyFrom=function(t){this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty},t.prototype.identity=function(){this.a=this.d=1,this.b=this.c=0,this.tx=this.ty=0},t.prototype.concat=function(t){var e=this.a,i=this.b,n=this.c,a=this.d,r=this.tx,s=this.ty,o=t.a,l=t.b,h=t.c,_=t.d,u=t.tx,f=t.ty;this.a=e*o+i*h,this.b=e*l+i*_,this.c=n*o+a*h,this.d=n*l+a*_,this.tx=o*r+h*s+u,this.ty=_*s+l*r+f},t.prototype.invert=function(){var t=this.a,e=this.b,i=this.c,n=this.d,a=this.tx,r=this.ty,s=t*n-e*i;this.a=n/s,this.b=-e/s,this.c=-i/s,this.d=t/s,this.tx=(i*r-n*a)/s,this.ty=-(t*r-e*a)/s},t.prototype.transformPoint=function(t,e,i,n){void 0===n&&(n=!1),i.x=this.a*t+this.c*e,i.y=this.b*t+this.d*e,n||(i.x+=this.tx,i.y+=this.ty)},t}();t.Matrix=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(t){function e(){t.call(this),this.armatures={},this._armatureNames=[]}return __extends(e,t),e.toString=function(){return"[class dragonBones.DragonBonesData]"},e.prototype._onClear=function(){this.autoSearch=!1,this.frameRate=0,this.name=null,this.userData=null;for(var t in this.armatures)this.armatures[t].returnToPool(),delete this.armatures[t];this._armatureNames.length&&(this._armatureNames.length=0)},e.prototype.getArmature=function(t){return this.armatures[t]},e.prototype.addArmature=function(t){if(!t||!t.name||this.armatures[t.name])throw new Error;this.armatures[t.name]=t,this._armatureNames.push(t.name),t.parent=this},Object.defineProperty(e.prototype,"armatureNames",{get:function(){return this._armatureNames},enumerable:!0,configurable:!0}),e.prototype.dispose=function(){this.returnToPool()},e}(t.BaseObject);t.DragonBonesData=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(t){function e(){t.call(this)}return __extends(e,t),e.toString=function(){return"[class dragonBones.ActionData]"},e.prototype._onClear=function(){this.type=0,this.data=null,this.bone=null,this.slot=null},e}(t.BaseObject);t.ActionData=e;var i=function(t){function e(){t.call(this)}return __extends(e,t),e.toString=function(){return"[class dragonBones.EventData]"},e.prototype._onClear=function(){this.type=0,this.name=null,this.data=null,this.bone=null,this.slot=null},e}(t.BaseObject);t.EventData=i;var n=function(t){function e(){t.call(this)}return __extends(e,t),e.prototype._onClear=function(){this.position=0,this.duration=0,this.prev=null,this.next=null},e}(t.BaseObject);t.FrameData=n;var a=function(t){function e(){t.call(this)}return __extends(e,t),e.samplingCurve=function(t,e){if(0==t.length||0==e)return null;var i=e+2,n=1/i,a=new Array(2*(i-1));t.unshift(0,0),t.push(1,1);for(var r=0,s=0;se.zOrder?1:-1},i.toString=function(){return"[class dragonBones.ArmatureData]"},i.prototype._onClear=function(){this.frameRate=0,this.cacheFrameRate=0,this.type=0,this.name=null,this.parent=null,this.userData=null,this.aabb.clear();for(var t in this.bones)this.bones[t].returnToPool(),delete this.bones[t];for(var t in this.slots)this.slots[t].returnToPool(),delete this.slots[t];for(var t in this.skins)this.skins[t].returnToPool(),delete this.skins[t];for(var t in this.animations)this.animations[t].returnToPool(),delete this.animations[t];if(this.actions.length){for(var t=0,e=this.actions.length;t=t&&(i=0),this._sortedBones.indexOf(a)>=0||a.parent&&this._sortedBones.indexOf(a.parent)<0||a.ik&&this._sortedBones.indexOf(a.ik)<0||(a.ik&&a.chain>0&&a.chainIndex==a.chain?this._sortedBones.splice(this._sortedBones.indexOf(a.parent)+1,0,a):this._sortedBones.push(a),n++)}}},i.prototype._sortSlots=function(){this._sortedSlots.sort(i._onSortSlots)},i.prototype.cacheFrames=function(t){if(this.cacheFrameRate!=t){this.cacheFrameRate=t;var e=this.cacheFrameRate/this.frameRate;for(var i in this.animations)this.animations[i].cacheFrames(e)}},i.prototype.addBone=function(t,e){if(!t||!t.name||this.bones[t.name])throw new Error;if(e){var i=this.getBone(e);i?t.parent=i:(this._bonesChildren[e]=this._bonesChildren[e]||[]).push(t)}var n=this._bonesChildren[t.name];if(n){for(var a=0,r=n.length;ae.layer?1:-1},i.toString=function(){return"[class dragonBones.Animation]"},i.prototype._onClear=function(){this.timeScale=1,this._animationStateDirty=!1,this._timelineStateDirty=!1,this._armature=null,this._isPlaying=!1,this._time=0,this._lastAnimationState=null;for(var t in this._animations)delete this._animations[t];this._animationNames.length&&(this._animationNames.length=0);for(var t=0,e=this._animationStates.length;t1)for(var a=e._animationStates[0]._layer,r=1,s=0,o=1,l=0,h=0;l=0?e._lastAnimationState=e._animationStates[l-h]:e._lastAnimationState=null)):(h>0&&(e._animationStates[l-h]=n),a!=n._layer&&(a=n._layer,s>=r?r=0:r-=s,s=0),e._timelineStateDirty&&n._updateTimelineStates(),n._advanceTime(t,r,o),0!=n._weightResult&&(s+=n._weightResult,o++)),l==i-1&&h>0&&(e._animationStates.length-=h)}e._timelineStateDirty=!1}},i.prototype.reset=function(){this._isPlaying=!1,this._lastAnimationState=null;for(var t=0,e=this._animationStates.length;t1&&this._animationStates.sort(i._sortAnimationState);for(var m=this._armature.getSlots(),c=0,p=m.length;c0&&(h.timeScale=h.totalTime/i),h},i.prototype.gotoAndStop=function(t,e){return void 0===e&&(e=0),this.gotoAndStopByTime(t,e)},Object.defineProperty(i.prototype,"animationList",{get:function(){return this._animationNames},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationDataList",{get:function(){for(var t=[],e=0,i=this._animationNames.length;e=i.fadeTotalTime?i._isFadeOut?0:1:i._fadeTime>0?i._isFadeOut?1-i._fadeTime/i.fadeTotalTime:i._fadeTime/i.fadeTotalTime:i._isFadeOut?1:0,i._fadeProgress!=n){i._fadeProgress=n;var a=i._armature._display;if(i._fadeTime<=e)if(i._isFadeOut){if(a.hasEvent(t.EventObject.FADE_OUT)){var r=t.BaseObject.borrowObject(t.EventObject);r.animationState=this,i._armature._bufferEvent(r,t.EventObject.FADE_OUT)}}else if(a.hasEvent(t.EventObject.FADE_IN)){var s=t.BaseObject.borrowObject(t.EventObject);s.animationState=this,i._armature._bufferEvent(s,t.EventObject.FADE_IN)}if(i._fadeTime>=i.fadeTotalTime)if(i._isFadeOut){if(i._isFadeOutComplete=!0,a.hasEvent(t.EventObject.FADE_OUT_COMPLETE)){var o=t.BaseObject.borrowObject(t.EventObject);o.animationState=this,i._armature._bufferEvent(o,t.EventObject.FADE_OUT_COMPLETE)}}else if(i._isPausePlayhead=!1,a.hasEvent(t.EventObject.FADE_IN_COMPLETE)){var l=t.BaseObject.borrowObject(t.EventObject);l.animationState=this,i._armature._bufferEvent(l,t.EventObject.FADE_IN_COMPLETE)}}},i.prototype._isDisabled=function(t){return!(this.displayControl&&(!t.displayController||t.displayController==this._name||t.displayController==this._group))},i.prototype._fadeIn=function(e,i,n,a,r,s,o,l,h,_){this._armature=e,this._animationData=i,this._name=n,this.playTimes=a,this.timeScale=l,this.fadeTotalTime=h,this._position=r,this._duration=s,this._time=o,this._isPausePlayhead=_,0==this.fadeTotalTime&&(this._fadeProgress=.999999),this._timeline=t.BaseObject.borrowObject(t.AnimationTimelineState), +this._timeline.fadeIn(this._armature,this,this._animationData,this._time),this._updateTimelineStates()},i.prototype._updateTimelineStates=function(){var e=this._time;this._animationData.hasAsynchronyTimeline||(e=this._timeline._currentTime);for(var i={},n={},a=0,r=this._boneTimelines.length;a=1&&0==i&&n._armature.cacheFrameRate>0,r=n._animationData.cacheTimeToFrameScale,s=!0,o=!0,l=a?Math.floor(n._time*r)/r:n._time;if(n._timeline.update(l),n._animationData.hasAsynchronyTimeline||(l=n._timeline._currentTime),a){var h=Math.floor(n._timeline._currentTime*r);if(n._armature._cacheFrameIndex==h)s=!1,o=!1;else{if(n._armature._cacheFrameIndex=h,n._armature._animation._animationStateDirty){n._armature._animation._animationStateDirty=!1;for(var _=0,u=n._boneTimelines.length;_=0&&n._fadeProgress>=1&&n._timeline._isCompleted&&n.fadeOut(n.autoFadeOutTime)},i.prototype.play=function(){this._isPlaying=!0},i.prototype.stop=function(){this._isPlaying=!1},i.prototype.fadeOut=function(t,e){if(void 0===e&&(e=!0),(t<0||t!=t)&&(t=0),this._isPausePlayhead=e,this._isFadeOut){if(t>t-this._fadeTime)return}else{this._isFadeOut=!0,(0==t||this._fadeProgress<=0)&&(this._fadeProgress=1e-6);for(var i=0,n=this._boneTimelines.length;i1e-6?t/this._fadeProgress:0,this._fadeTime=this.fadeTotalTime*(1-this._fadeProgress)},i.prototype.containsBoneMask=function(t){return!this._boneMask.length||this._boneMask.indexOf(t)>=0},i.prototype.addBoneMask=function(t,e){void 0===e&&(e=!0);var i=this._armature.getBone(t);if(i){if(this._boneMask.indexOf(t)<0&&this._animationData.getBoneTimeline(t)&&this._boneMask.push(t),e)for(var n=this._armature.getBones(),a=0,r=n.length;a=0&&this._boneMask.splice(i,1),e){var n=this._armature.getBone(t);if(n)for(var a=this._armature.getBones(),r=0,s=a.length;r=0&&n.contains(o)&&this._boneMask.splice(h,1)}}this._updateTimelineStates()},i.prototype.removeAllBoneMask=function(){this._boneMask.length=0,this._updateTimelineStates()},Object.defineProperty(i.prototype,"layer",{get:function(){return this._layer},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"group",{get:function(){return this._group},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"name",{get:function(){return this._name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationData",{get:function(){return this._animationData},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isCompleted",{get:function(){return this._timeline._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"isPlaying",{get:function(){return this._isPlaying&&!this._timeline._isCompleted},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentPlayTimes",{get:function(){return this._currentPlayTimes},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"totalTime",{get:function(){return this._duration},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"currentTime",{get:function(){return this._timeline._currentTime},set:function(t){if((t<0||t!=t)&&(t=0),this._time=t,this._timeline.setCurrentTime(this._time),0!=this._weightResult){var e=this._time;this._animationData.hasAsynchronyTimeline||(e=this._timeline._currentTime);for(var i=0,n=this._boneTimelines.length;i0&&(t>=a||t<=-a)?(e._isCompleted=!0,i=n,t=t<0?0:e._duration):(e._isCompleted=!1,t<0?(i=Math.floor(-t/e._duration),t=e._duration- -t%e._duration):(i=Math.floor(t/e._duration),t%=e._duration),n>0&&i>n&&(i=n)),t+=e._position}else e._isCompleted=e._animationState._timeline._isCompleted,i=e._animationState._timeline._currentPlayTimes;return e._currentTime!=t&&(1==e._keyFrameCount&&t>e._position&&this!=e._animationState._timeline&&(e._isCompleted=!0),e._isReverse=e._currentTime>t&&e._currentPlayTimes==i,e._currentTime=t,e._currentPlayTimes=i,!0)},e.prototype.setCurrentTime=function(t){switch(this._setCurrentTime(t),this._keyFrameCount){case 0:break;case 1:this._currentFrame=this._timeline.frames[0],this._onArriveAtFrame(!1),this._onUpdateFrame(!1);break;default:this._currentFrame=this._timeline.frames[Math.floor(this._currentTime*this._frameRate)],this._onArriveAtFrame(!1),this._onUpdateFrame(!1)}this._currentFrame=null},e.prototype.fadeIn=function(t,e,i,n){this._armature=t,this._animationState=e,this._timeline=i;var a=this==this._animationState._timeline;this._hasAsynchronyTimeline=a||this._animationState.animationData.hasAsynchronyTimeline,this._frameRate=this._armature.armatureData.frameRate,this._keyFrameCount=this._timeline.frames.length,this._frameCount=this._animationState.animationData.frameCount,this._position=this._animationState._position,this._duration=this._animationState._duration,this._animationDutation=this._animationState.animationData.duration,this._timeScale=a?1:1/this._timeline.scale,this._timeOffset=a?0:this._timeline.offset,this._onFadeIn(),this.setCurrentTime(n)},e.prototype.fadeOut=function(){},e.prototype.update=function(t){var e=this;if(!e._isCompleted&&e._setCurrentTime(t)&&e._keyFrameCount){var i=e._keyFrameCount>1?Math.floor(e._currentTime*e._frameRate):0,n=e._timeline.frames[i];e._currentFrame!=n&&(e._currentFrame=n,e._onArriveAtFrame(!0)),e._onUpdateFrame(!0)}},e}(t.BaseObject);t.TimelineState=e;var i=function(e){function i(){e.call(this)}return __extends(i,e),i._getEasingValue=function(t,e){var i=1;if(e>2)return t;if(e>1)i=.5*(1-Math.cos(t*Math.PI)),e-=1;else if(e>0)i=1-Math.pow(1-t,2);else if(e>=-1)e*=-1,i=Math.pow(t,2);else{if(!(e>=-2))return t;e*=-1,i=Math.acos(1-2*t)/Math.PI,e-=1}return(i-t)*e+t},i._getCurveEasingValue=function(t,e){for(var i=0,n=0,a=0,r=e.length;a=t){if(0==a)return n*t/i;var s=e[a-2],o=e[a-1];return o+(n-o)*(t-s)/(i-s)}return n+(1-n)*(t-i)/(1-i)},i.prototype._onClear=function(){e.prototype._onClear.call(this),this._tweenProgress=0,this._tweenEasing=t.DragonBones.NO_TWEEN,this._curve=null},i.prototype._onArriveAtFrame=function(e){var i=this;i._tweenEasing=i._currentFrame.tweenEasing,i._curve=i._currentFrame.curve,(i._keyFrameCount<=1||i._currentFrame.next==i._timeline.frames[0]&&(i._tweenEasing!=t.DragonBones.NO_TWEEN||i._curve)&&i._animationState.playTimes>0&&i._animationState.currentPlayTimes==i._animationState.playTimes-1)&&(i._tweenEasing=t.DragonBones.NO_TWEEN,i._curve=null)},i.prototype._onUpdateFrame=function(e){var n=this;n._tweenEasing!=t.DragonBones.NO_TWEEN?(n._tweenProgress=(n._currentTime-n._currentFrame.position+n._position)/n._currentFrame.duration,0!=n._tweenEasing&&(n._tweenProgress=i._getEasingValue(n._tweenProgress,n._tweenEasing))):n._curve?(n._tweenProgress=(n._currentTime-n._currentFrame.position+n._position)/n._currentFrame.duration,n._tweenProgress=i._getCurveEasingValue(n._tweenProgress,n._curve)):n._tweenProgress=0},i.prototype._updateExtensionKeyFrame=function(t,e,i){var n=0;if(t.type==e.type)for(var a=0,r=t.tweens.length;a1?Math.floor(i._currentTime*i._frameRate):0,l=i._timeline.frames[o];if(i._currentFrame!=l)if(i._keyFrameCount>1){var h=i._currentFrame;if(i._currentFrame=l,!h){var _=Math.floor(n*i._frameRate);h=i._timeline.frames[_],i._isReverse||(n<=h.position||a!=i._currentPlayTimes)&&(h=h.prev)}if(i._isReverse)for(;h!=l;)i._onCrossFrame(h),h=h.prev;else for(;h!=l;)h=h.next,i._onCrossFrame(h)}else i._currentFrame=l,i._onCrossFrame(i._currentFrame)}if(a!=i._currentPlayTimes){var u=i._isCompleted?t.EventObject.COMPLETE:t.EventObject.LOOP_COMPLETE;if(r.hasEvent(u)){var s=t.BaseObject.borrowObject(t.EventObject);s.animationState=i._animationState,i._armature._bufferEvent(s,u)}}}},i}(t.TimelineState);t.AnimationTimelineState=e;var i=function(e){function i(){e.call(this),this._transform=new t.Transform,this._currentTransform=new t.Transform,this._durationTransform=new t.Transform}return __extends(i,e),i.toString=function(){return"[class dragonBones.BoneTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.bone=null,this._tweenTransform=0,this._tweenRotate=0,this._tweenScale=0,this._boneTransform=null,this._originTransform=null,this._transform.identity(),this._currentTransform.identity(),this._durationTransform.identity()},i.prototype._onFadeIn=function(){this._originTransform=this._timeline.originTransform,this._boneTransform=this.bone._animationPose},i.prototype._onArriveAtFrame=function(i){var n=this;if(e.prototype._onArriveAtFrame.call(this,i),n._currentTransform.copyFrom(n._currentFrame.transform),n._tweenTransform=1,n._tweenRotate=1,n._tweenScale=1,n._keyFrameCount>1&&(n._tweenEasing!=t.DragonBones.NO_TWEEN||n._curve)){var a=n._currentFrame.next,r=a.transform;n._durationTransform.x=r.x-n._currentTransform.x,n._durationTransform.y=r.y-n._currentTransform.y,0==n._durationTransform.x&&0==n._durationTransform.y||(n._tweenTransform=2);var s=n._currentFrame.tweenRotate;if(s==s){if(s)if(s>0?r.skewY>=n._currentTransform.skewY:r.skewY<=n._currentTransform.skewY){var o=s>0?s-1:s+1;n._durationTransform.skewX=r.skewX-n._currentTransform.skewX+t.DragonBones.PI_D*o,n._durationTransform.skewY=r.skewY-n._currentTransform.skewY+t.DragonBones.PI_D*o}else n._durationTransform.skewX=r.skewX-n._currentTransform.skewX+t.DragonBones.PI_D*s,n._durationTransform.skewY=r.skewY-n._currentTransform.skewY+t.DragonBones.PI_D*s;else n._durationTransform.skewX=t.Transform.normalizeRadian(r.skewX-n._currentTransform.skewX),n._durationTransform.skewY=t.Transform.normalizeRadian(r.skewY-n._currentTransform.skewY);0==n._durationTransform.skewX&&0==n._durationTransform.skewY||(n._tweenRotate=2)}else n._durationTransform.skewX=0,n._durationTransform.skewY=0;n._currentFrame.tweenScale?(n._durationTransform.scaleX=r.scaleX-n._currentTransform.scaleX,n._durationTransform.scaleY=r.scaleY-n._currentTransform.scaleY,0==n._durationTransform.scaleX&&0==n._durationTransform.scaleY||(n._tweenScale=2)):(n._durationTransform.scaleX=0,n._durationTransform.scaleY=0)}else n._durationTransform.x=0,n._durationTransform.y=0,n._durationTransform.skewX=0,n._durationTransform.skewY=0,n._durationTransform.scaleX=0,n._durationTransform.scaleY=0},i.prototype._onUpdateFrame=function(t){var i=this;if(i._tweenTransform||i._tweenRotate||i._tweenScale){e.prototype._onUpdateFrame.call(this,t);var n=0;i._tweenTransform&&(1==i._tweenTransform?(i._tweenTransform=0,n=0):n=i._tweenProgress,i._animationState.additiveBlending?(i._transform.x=i._currentTransform.x+i._durationTransform.x*n,i._transform.y=i._currentTransform.y+i._durationTransform.y*n):(i._transform.x=i._originTransform.x+i._currentTransform.x+i._durationTransform.x*n,i._transform.y=i._originTransform.y+i._currentTransform.y+i._durationTransform.y*n)),i._tweenRotate&&(1==i._tweenRotate?(i._tweenRotate=0,n=0):n=i._tweenProgress,i._animationState.additiveBlending?(i._transform.skewX=i._currentTransform.skewX+i._durationTransform.skewX*n,i._transform.skewY=i._currentTransform.skewY+i._durationTransform.skewY*n):(i._transform.skewX=i._originTransform.skewX+i._currentTransform.skewX+i._durationTransform.skewX*n,i._transform.skewY=i._originTransform.skewY+i._currentTransform.skewY+i._durationTransform.skewY*n)),i._tweenScale&&(1==i._tweenScale?(i._tweenScale=0,n=0):n=i._tweenProgress,i._animationState.additiveBlending?(i._transform.scaleX=i._currentTransform.scaleX+i._durationTransform.scaleX*n,i._transform.scaleY=i._currentTransform.scaleY+i._durationTransform.scaleY*n):(i._transform.scaleX=i._originTransform.scaleX*(i._currentTransform.scaleX+i._durationTransform.scaleX*n),i._transform.scaleY=i._originTransform.scaleY*(i._currentTransform.scaleY+i._durationTransform.scaleY*n))),i.bone.invalidUpdate()}},i.prototype.fadeOut=function(){this._transform.skewX=t.Transform.normalizeRadian(this._transform.skewX),this._transform.skewY=t.Transform.normalizeRadian(this._transform.skewY)},i.prototype.update=function(t){var i=this;e.prototype.update.call(this,t);var n=i._animationState._weightResult;if(n>0){0==i.bone._blendIndex?(i._boneTransform.x=i._transform.x*n,i._boneTransform.y=i._transform.y*n,i._boneTransform.skewX=i._transform.skewX*n,i._boneTransform.skewY=i._transform.skewY*n,i._boneTransform.scaleX=(i._transform.scaleX-1)*n+1,i._boneTransform.scaleY=(i._transform.scaleY-1)*n+1):(i._boneTransform.x+=i._transform.x*n,i._boneTransform.y+=i._transform.y*n,i._boneTransform.skewX+=i._transform.skewX*n,i._boneTransform.skewY+=i._transform.skewY*n,i._boneTransform.scaleX+=(i._transform.scaleX-1)*n,i._boneTransform.scaleY+=(i._transform.scaleY-1)*n),i.bone._blendIndex++;var a=i._animationState._fadeProgress;a<1&&i.bone.invalidUpdate()}},i}(t.TweenTimelineState);t.BoneTimelineState=i;var n=function(e){function i(){e.call(this),this._color=new t.ColorTransform,this._durationColor=new t.ColorTransform}return __extends(i,e),i.toString=function(){return"[class dragonBones.SlotTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.slot=null,this._colorDirty=!1,this._tweenColor=0,this._slotColor=null,this._color.identity(),this._durationColor.identity()},i.prototype._onFadeIn=function(){this._slotColor=this.slot._colorTransform},i.prototype._onArriveAtFrame=function(i){var n=this;if(e.prototype._onArriveAtFrame.call(this,i),n._animationState._isDisabled(n.slot))return n._tweenEasing=t.DragonBones.NO_TWEEN,n._curve=null,void(n._tweenColor=0);if(n.slot._displayDataSet){var a=n._currentFrame.displayIndex;n.slot.displayIndex>=0&&a>=0?n.slot._displayDataSet.displays.length>1&&n.slot._setDisplayIndex(a):n.slot._setDisplayIndex(a),n.slot._updateMeshData(!0)}if(n._currentFrame.displayIndex>=0){n._tweenColor=0;var r=n._currentFrame.color;if(n._keyFrameCount>1&&(n._tweenEasing!=t.DragonBones.NO_TWEEN||n._curve)){var s=n._currentFrame.next,o=s.color;r!=o&&s.displayIndex>=0&&(n._durationColor.alphaMultiplier=o.alphaMultiplier-r.alphaMultiplier,n._durationColor.redMultiplier=o.redMultiplier-r.redMultiplier,n._durationColor.greenMultiplier=o.greenMultiplier-r.greenMultiplier,n._durationColor.blueMultiplier=o.blueMultiplier-r.blueMultiplier,n._durationColor.alphaOffset=o.alphaOffset-r.alphaOffset,n._durationColor.redOffset=o.redOffset-r.redOffset,n._durationColor.greenOffset=o.greenOffset-r.greenOffset,n._durationColor.blueOffset=o.blueOffset-r.blueOffset,0==n._durationColor.alphaMultiplier&&0==n._durationColor.redMultiplier&&0==n._durationColor.greenMultiplier&&0==n._durationColor.blueMultiplier&&0==n._durationColor.alphaOffset&&0==n._durationColor.redOffset&&0==n._durationColor.greenOffset&&0==n._durationColor.blueOffset||(n._tweenColor=2))}0==n._tweenColor&&(n._slotColor.alphaMultiplier==r.alphaMultiplier&&n._slotColor.redMultiplier==r.redMultiplier&&n._slotColor.greenMultiplier==r.greenMultiplier&&n._slotColor.blueMultiplier==r.blueMultiplier&&n._slotColor.alphaOffset==r.alphaOffset&&n._slotColor.redOffset==r.redOffset&&n._slotColor.greenOffset==r.greenOffset&&n._slotColor.blueOffset==r.blueOffset||(n._tweenColor=1))}else n._tweenEasing=t.DragonBones.NO_TWEEN,n._curve=null,n._tweenColor=0},i.prototype._onUpdateFrame=function(t){var i=this;e.prototype._onUpdateFrame.call(this,t);var n=0;if(i._tweenColor){1==i._tweenColor?(i._tweenColor=0,n=0):n=i._tweenProgress;var a=i._currentFrame.color;i._color.alphaMultiplier=a.alphaMultiplier+i._durationColor.alphaMultiplier*n,i._color.redMultiplier=a.redMultiplier+i._durationColor.redMultiplier*n,i._color.greenMultiplier=a.greenMultiplier+i._durationColor.greenMultiplier*n,i._color.blueMultiplier=a.blueMultiplier+i._durationColor.blueMultiplier*n,i._color.alphaOffset=a.alphaOffset+i._durationColor.alphaOffset*n,i._color.redOffset=a.redOffset+i._durationColor.redOffset*n,i._color.greenOffset=a.greenOffset+i._durationColor.greenOffset*n,i._color.blueOffset=a.blueOffset+i._durationColor.blueOffset*n,i._colorDirty=!0}},i.prototype.fadeOut=function(){this._tweenColor=0},i.prototype.update=function(t){var i=this;if(e.prototype.update.call(this,t),0!=i._tweenColor||i._colorDirty){var n=i._animationState._weightResult;if(n>0){var a=i._animationState._fadeProgress;a<1?(i._slotColor.alphaMultiplier+=(i._color.alphaMultiplier-i._slotColor.alphaMultiplier)*a,i._slotColor.redMultiplier+=(i._color.redMultiplier-i._slotColor.redMultiplier)*a,i._slotColor.greenMultiplier+=(i._color.greenMultiplier-i._slotColor.greenMultiplier)*a,i._slotColor.blueMultiplier+=(i._color.blueMultiplier-i._slotColor.blueMultiplier)*a,i._slotColor.alphaOffset+=(i._color.alphaOffset-i._slotColor.alphaOffset)*a,i._slotColor.redOffset+=(i._color.redOffset-i._slotColor.redOffset)*a,i._slotColor.greenOffset+=(i._color.greenOffset-i._slotColor.greenOffset)*a,i._slotColor.blueOffset+=(i._color.blueOffset-i._slotColor.blueOffset)*a,i.slot._colorDirty=!0):i._colorDirty&&(i._colorDirty=!1,i._slotColor.alphaMultiplier=i._color.alphaMultiplier,i._slotColor.redMultiplier=i._color.redMultiplier,i._slotColor.greenMultiplier=i._color.greenMultiplier,i._slotColor.blueMultiplier=i._color.blueMultiplier,i._slotColor.alphaOffset=i._color.alphaOffset,i._slotColor.redOffset=i._color.redOffset,i._slotColor.greenOffset=i._color.greenOffset,i._slotColor.blueOffset=i._color.blueOffset,i.slot._colorDirty=!0)}}},i}(t.TweenTimelineState);t.SlotTimelineState=n;var a=function(e){function i(){e.call(this),this._ffdVertices=[]}return __extends(i,e),i.toString=function(){return"[class dragonBones.FFDTimelineState]"},i.prototype._onClear=function(){e.prototype._onClear.call(this),this.slot=null,this._tweenFFD=0,this._slotFFDVertices=null,this._durationFFDFrame&&(this._durationFFDFrame.returnToPool(),this._durationFFDFrame=null),this._ffdVertices.length&&(this._ffdVertices.length=0)},i.prototype._onFadeIn=function(){this._slotFFDVertices=this.slot._ffdVertices,this._durationFFDFrame=t.BaseObject.borrowObject(t.ExtensionFrameData),this._durationFFDFrame.tweens.length=this._slotFFDVertices.length,this._ffdVertices.length=this._slotFFDVertices.length;for(var e=0,i=this._durationFFDFrame.tweens.length;e0){if(0==i.slot._blendIndex)for(var a=0,r=i._ffdVertices.length;a0&&(this._animatebles[i-n]=r,this._animatebles[i]=null),r.advanceTime(e)):n++}if(n>0){for(a=this._animatebles.length;i=0},e.prototype.add=function(e){e&&this._animatebles.indexOf(e)<0&&(this._animatebles.push(e),t.DragonBones.DEBUG&&e instanceof t.Armature&&t.DragonBones.addArmature(e))},e.prototype.remove=function(e){var i=this._animatebles.indexOf(e);i>=0&&(this._animatebles[i]=null,t.DragonBones.DEBUG&&e instanceof t.Armature&&t.DragonBones.removeArmature(e))},e.prototype.clear=function(){for(var t=0,e=this._animatebles.length;t=t&&(i=0),this._bones.indexOf(a)>=0||a.parent&&this._bones.indexOf(a.parent)<0||a.ik&&this._bones.indexOf(a.ik)<0||(a.ik&&a.ikChain>0&&a.ikChainIndex==a.ikChain?this._bones.splice(this._bones.indexOf(a.parent)+1,0,a):this._bones.push(a),n++)}}},i.prototype._sortSlots=function(){},i.prototype._doAction=function(t){switch(t.type){case 0:this._animation.play(t.data[0],t.data[1]);break;case 1:this._animation.stop(t.data[0]);break;case 2:this._animation.gotoAndPlayByTime(t.data[0],t.data[1],t.data[2]);break;case 3:this._animation.gotoAndStopByTime(t.data[0],t.data[1]);break;case 4:this._animation.fadeIn(t.data[0],t.data[1],t.data[2]);break;case 5:}},i.prototype._addBoneToBoneList=function(t){this._bones.indexOf(t)<0&&(this._bonesDirty=!0,this._bones[this._bones.length]=t,this._animation._timelineStateDirty=!0)},i.prototype._removeBoneFromBoneList=function(t){var e=this._bones.indexOf(t);e>=0&&(this._bones.splice(e,1),this._animation._timelineStateDirty=!0)},i.prototype._addSlotToSlotList=function(t){this._slots.indexOf(t)<0&&(this._slotsDirty=!0,this._slots[this._slots.length]=t,this._animation._timelineStateDirty=!0)},i.prototype._removeSlotFromSlotList=function(t){var e=this._slots.indexOf(t);e>=0&&(this._slots.splice(e,1),this._animation._timelineStateDirty=!0)},i.prototype._bufferAction=function(t){this._actions.push(t)},i.prototype._bufferEvent=function(t,e){t.type=e,t.armature=this,this._events.push(t)},i.prototype.dispose=function(){this._delayDispose=!0,this._lockDispose||this.returnToPool()},i.prototype.advanceTime=function(e){var i=this;if(!i._lockDispose){i._lockDispose=!0;var n=e*i._animation.timeScale;i._animation._advanceTime(n),i._bonesDirty&&(i._bonesDirty=!1,i._sortBones()),i._slotsDirty&&(i._slotsDirty=!1,i._sortSlots());for(var a=0,r=i._bones.length;a0){for(var a=0,r=i._events.length;a0){for(var a=0,r=i._actions.length;a=0){var n=i._cacheFrames[e];i.globalTransformMatrix==n?i._transformDirty=0:n?(i._transformDirty=2,i.globalTransformMatrix=n):2==i._transformDirty||i._parent&&0!=i._parent._transformDirty||i._ik&&i.ikWeight>0&&0!=i._ik._transformDirty?(i._transformDirty=2,i.globalTransformMatrix=i._globalTransformMatrix):i.globalTransformMatrix!=i._globalTransformMatrix?(i._transformDirty=0,i._cacheFrames[e]=i.globalTransformMatrix):(i._transformDirty=2,i.globalTransformMatrix=i._globalTransformMatrix)}else(2==i._transformDirty||i._parent&&0!=i._parent._transformDirty||i._ik&&i.ikWeight>0&&0!=i._ik._transformDirty)&&(i._transformDirty=2,i.globalTransformMatrix=i._globalTransformMatrix);0!=i._transformDirty&&(2==i._transformDirty?(i._transformDirty=1,i.globalTransformMatrix==i._globalTransformMatrix&&(i.global.x=i.origin.x+i.offset.x+i._animationPose.x,i.global.y=i.origin.y+i.offset.y+i._animationPose.y,i.global.skewX=i.origin.skewX+i.offset.skewX+i._animationPose.skewX,i.global.skewY=i.origin.skewY+i.offset.skewY+i._animationPose.skewY,i.global.scaleX=i.origin.scaleX*i.offset.scaleX*i._animationPose.scaleX,i.global.scaleY=i.origin.scaleY*i.offset.scaleY*i._animationPose.scaleY,i._updateGlobalTransformMatrix(),i._ik&&i._ikChainIndex==i._ikChain&&i.ikWeight>0&&(i.inheritTranslation&&i._ikChain>0&&i._parent?i._computeIKB():i._computeIKA()),e>=0&&(i.globalTransformMatrix=t.BoneTimelineData.cacheFrame(i._cacheFrames,e,i._globalTransformMatrix)))):i._transformDirty=0)},i.prototype.invalidUpdate=function(){this._transformDirty=2},i.prototype.contains=function(t){if(t){if(t==this)return!1;for(var e=t;e!=this&&e;)e=e.parent;return e==this}return!1},i.prototype.getBones=function(){this._bones.length=0;for(var t=this._armature.getBones(),e=0,i=t.length;e=0&&this._displayIndex=0&&this._displayIndex0)for(var s=0,o=r.actions.length;s=0&&this._displayIndex=0){var n=i._cacheFrames[e];i.globalTransformMatrix==n?i._transformDirty=!1:n?(i._transformDirty=!0,i.globalTransformMatrix=n):i._transformDirty||0!=i._parent._transformDirty?(i._transformDirty=!0,i.globalTransformMatrix=i._globalTransformMatrix):i.globalTransformMatrix!=i._globalTransformMatrix?(i._transformDirty=!1,i._cacheFrames[e]=i.globalTransformMatrix):(i._transformDirty=!0,i.globalTransformMatrix=i._globalTransformMatrix)}else(i._transformDirty||0!=i._parent._transformDirty)&&(i._transformDirty=!0,i.globalTransformMatrix=i._globalTransformMatrix);i._transformDirty&&(i._transformDirty=!1,i.globalTransformMatrix==i._globalTransformMatrix&&(i._updateGlobalTransformMatrix(),e>=0&&(i.globalTransformMatrix=t.SlotTimelineData.cacheFrame(i._cacheFrames,e,i._globalTransformMatrix))),i._updateTransform())}},i.prototype._setDisplayList=function(e){if(e&&e.length){this._displayList.length!=e.length&&(this._displayList.length=e.length);for(var i=0,n=this._displayList.length;i=0&&this._displayIndex=0){var a=i.displayList;if(a.length<=n&&(a.length=n+1),e.texture||(e.texture=this._getTextureData(t.dataName,e.name)),1==e.type){var r=this.buildArmature(e.name,t.dataName);a[n]=r}else i._replacedDisplayDataSet.length<=n&&(i._replacedDisplayDataSet.length=n+1),i._replacedDisplayDataSet[n]=e,e.mesh?a[n]=i.MeshDisplay:a[n]=i.rawDisplay;i.displayList=a,i.invalidUpdate()}},e.prototype.parseDragonBonesData=function(t,e){void 0===e&&(e=null);var i=this._dataParser.parseDragonBonesData(t,1);return this.addDragonBonesData(i,e),i},e.prototype.parseTextureAtlasData=function(t,e,i,n){void 0===i&&(i=null),void 0===n&&(n=0);var a=this._generateTextureAtlasData(null,null);return this._dataParser.parseTextureAtlasData(t,a,n),this._generateTextureAtlasData(a,e),this.addTextureAtlasData(a,i),a},e.prototype.getDragonBonesData=function(t){return this._dragonBonesDataMap[t]},e.prototype.addDragonBonesData=function(t,e){if(void 0===e&&(e=null),!t)throw new Error;e=e||t.name,e?this._dragonBonesDataMap[e]?console.warn("Same name data."):this._dragonBonesDataMap[e]=t:console.warn("Unnamed data.")},e.prototype.removeDragonBonesData=function(e,i){void 0===i&&(i=!0);var n=this._dragonBonesDataMap[e];if(n){if(i){if(t.DragonBones.DEBUG)for(var a=0,r=t.DragonBones._armatures.length;a0)for(var r=0,s=a.armatureData.actions.length;r=i.frames.length)a.copyFrom(i.frames[0].transform);else{var s=i.frames[r],o=0;s.tweenEasing!=t.DragonBones.NO_TWEEN?(o=(n-s.position)/s.duration,0!=s.tweenEasing&&(o=t.TweenTimelineState._getEasingValue(o,s.tweenEasing))):s.curve&&(o=(n-s.position)/s.duration,o=t.TweenTimelineState._getCurveEasingValue(o,s.curve));var l=s.next;a.x=l.transform.x-s.transform.x,a.y=l.transform.y-s.transform.y,a.skewX=t.Transform.normalizeRadian(l.transform.skewX-s.transform.skewX),a.skewY=t.Transform.normalizeRadian(l.transform.skewY-s.transform.skewY),a.scaleX=l.transform.scaleX-s.transform.scaleX,a.scaleY=l.transform.scaleY-s.transform.scaleY,a.x=s.transform.x+a.x*o,a.y=s.transform.y+a.y*o,a.skewX=s.transform.skewX+a.skewX*o,a.skewY=s.transform.skewY+a.skewY*o,a.scaleX=s.transform.scaleX+a.scaleX*o,a.scaleY=s.transform.scaleY+a.scaleY*o}a.add(i.originTransform)},e.prototype._globalToLocal=function(t){for(var e=[],i=t.sortedBones.concat().reverse(),n=0,a=i.length;n=0||(e.push(f),h?(this._getTimelineFrameMatrix(o,h,f.position,this._helpTransformA),f.transform.add(this._helpTransformB),this._helpTransformA.toMatrix(this._helpMatrix),this._helpMatrix.invert(),this._helpMatrix.transformPoint(f.transform.x,f.transform.y,f.transform),f.transform.rotation-=this._helpTransformA.rotation):f.transform.add(this._helpTransformB),f.transform.minus(r.transform),0==_?(l.originTransform.copyFrom(f.transform),f.transform.identity()):f.transform.minus(l.originTransform))}}}}},e.prototype._mergeFrameToAnimationTimeline=function(e,i,n){var a=Math.floor(e.position*this._armature.frameRate),r=this._animation.frames;if(0==r.length){var s=t.BaseObject.borrowObject(t.AnimationFrameData);if(s.position=0,this._animation.frameCount>1){r.length=this._animation.frameCount+1;var o=t.BaseObject.borrowObject(t.AnimationFrameData);o.position=this._animation.frameCount/this._armature.frameRate,r[0]=s,r[this._animation.frameCount]=o}}var l=null,h=r[a];if(!h||0!=a&&r[a-1]!=h.prev){l=t.BaseObject.borrowObject(t.AnimationFrameData),l.position=a/this._armature.frameRate,r[a]=l;for(var _=a+1,u=r.length;_e?t[e]:i},i.prototype._parseArmature=function(e){var n=t.BaseObject.borrowObject(t.ArmatureData);if(n.name=i._getString(e,i.NAME,null),n.frameRate=i._getNumber(e,i.FRAME_RATE,this._data.frameRate)||this._data.frameRate,i.TYPE in e&&"string"==typeof e[i.TYPE]?n.type=i._getArmatureType(e[i.TYPE]):n.type=i._getNumber(e,i.TYPE,0),this._armature=n,this._rawBones.length=0,i.AABB in e){var a=e[i.AABB];n.aabb.x=i._getNumber(a,i.X,0),n.aabb.y=i._getNumber(a,i.Y,0),n.aabb.width=i._getNumber(a,i.WIDTH,0),n.aabb.height=i._getNumber(a,i.HEIGHT,0)}if(i.BONE in e)for(var r=e[i.BONE],s=0,o=r.length;s0&&e.parent&&!e.parent.ik?(e.parent.ik=e.ik,e.parent.chainIndex=0,e.parent.chain=0,e.chainIndex=1):(e.chain=0,e.chainIndex=0))},i.prototype._parseSlot=function(e){var n=t.BaseObject.borrowObject(t.SlotData);return n.name=i._getString(e,i.NAME,null),n.parent=this._armature.getBone(i._getString(e,i.PARENT,null)),n.displayIndex=i._getNumber(e,i.DISPLAY_INDEX,0),n.zOrder=i._getNumber(e,i.Z_ORDER,this._armature.sortedSlots.length),i.COLOR in e?(n.color=t.SlotData.generateColor(),this._parseColorTransform(e[i.COLOR],n.color)):n.color=t.SlotData.DEFAULT_COLOR,i.BLEND_MODE in e&&"string"==typeof e[i.BLEND_MODE]?n.blendMode=i._getBlendMode(e[i.BLEND_MODE]):n.blendMode=i._getNumber(e,i.BLEND_MODE,0),(i.ACTIONS in e||i.DEFAULT_ACTIONS in e)&&this._parseActionData(e,n.actions,null,null),this._isOldData&&(i.COLOR_TRANSFORM in e?(n.color=t.SlotData.generateColor(),this._parseColorTransform(e[i.COLOR_TRANSFORM],n.color)):n.color=t.SlotData.DEFAULT_COLOR),n},i.prototype._parseSkin=function(e){var n=t.BaseObject.borrowObject(t.SkinData);if(n.name=i._getString(e,i.NAME,"__default")||"__default",i.SLOT in e){this._skin=n;for(var a=e[i.SLOT],r=0,s=a.length;r0,n.uvs.length=2*o,n.vertices.length=2*o,n.vertexIndices.length=3*l,n.skinned){if(n.boneIndices.length=o,n.weights.length=o,n.boneVertices.length=o,i.SLOT_POSE in e){var _=e[i.SLOT_POSE];n.slotPose.a=_[0],n.slotPose.b=_[1],n.slotPose.c=_[2],n.slotPose.d=_[3],n.slotPose.tx=_[4],n.slotPose.ty=_[5]}if(i.BONE_POSE in e)for(var u=e[i.BONE_POSE],f=0,m=u.length;f=s.length?(l=0,h=0):(l=s[_-o]*this._armatureScale,h=s[_+1-o]*this._armatureScale),this._mesh.skinned){this._mesh.slotPose.transformPoint(l,h,this._helpPoint,!0),l=this._helpPoint.x,h=this._helpPoint.y;for(var f=this._mesh.boneIndices[_/2],m=0,c=f.length;m0?(i.TWEEN_EASING in e?n.tweenEasing=i._getNumber(e,i.TWEEN_EASING,t.DragonBones.NO_TWEEN):this._isOldData?n.tweenEasing=this._isAutoTween?this._animationTweenEasing:t.DragonBones.NO_TWEEN:n.tweenEasing=t.DragonBones.NO_TWEEN,this._isOldData&&1==this._animation.scale&&1==this._timeline.scale&&n.duration*this._armature.frameRate<2&&(n.tweenEasing=t.DragonBones.NO_TWEEN),i.CURVE in e&&(n.curve=t.TweenFrameData.samplingCurve(e[i.CURVE],r))):(n.tweenEasing=t.DragonBones.NO_TWEEN,n.curve=null)},i.prototype._parseFrame=function(t,e,i,n){e.position=i/this._armature.frameRate,e.duration=n/this._armature.frameRate},i.prototype._parseTimeline=function(e,n,a){if(n.scale=i._getNumber(e,i.SCALE,1),n.offset=i._getNumber(e,i.OFFSET,0),this._timeline=n,i.FRAME in e){var r=e[i.FRAME];if(r.length)if(1==r.length)n.frames.length=1,n.frames[0]=a.call(this,r[0],0,i._getNumber(r[0],i.DURATION,1));else{n.frames.length=this._animation.frameCount+1;for(var s=0,o=0,l=null,h=null,_=0,u=0,f=this._animation.frameCount+1;_0?n.scale=a:a=n.scale=i._getNumber(e,i.SCALE,n.scale),a=1/a,i.SUB_TEXTURE in e)for(var r=e[i.SUB_TEXTURE],s=0,o=r.length;s0&&u>0&&(h.frame=t.TextureData.generateRectangle(),h.frame.x=i._getNumber(l,i.FRAME_X,0)*a,h.frame.y=i._getNumber(l,i.FRAME_Y,0)*a,h.frame.width=_*a,h.frame.height=u*a),n.addTextureData(h)}return n}throw new Error},i.getInstance=function(){return i._instance||(i._instance=new i),i._instance},i._instance=null,i}(t.DataParser);t.ObjectDataParser=e}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(t){function e(){t.call(this),this.textures={}}return __extends(e,t),e.prototype._onClear=function(){this.autoSearch=!1,this.scale=1,this.name=null,this.imagePath=null;for(var t in this.textures)this.textures[t].returnToPool(),delete this.textures[t]},e.prototype.dispose=function(){this.returnToPool()},e.prototype.addTextureData=function(t){t&&t.name&&!this.textures[t.name]&&(this.textures[t.name]=t,t.parent=this)},e.prototype.getTextureData=function(t){return this.textures[t]},e}(t.BaseObject);t.TextureAtlasData=e;var i=function(e){function i(){e.call(this),this.region=new t.Rectangle}return __extends(i,e),i.generateRectangle=function(){return new t.Rectangle},i.prototype._onClear=function(){this.rotated=!1,this.name=null,this.frame=null,this.parent=null,this.region.clear()},i}(t.BaseObject);t.TextureData=i}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(e){function n(){e.call(this)}return __extends(n,e),n.toString=function(){return"[class dragonBones.EgretTextureAtlasData]"},n.prototype._onClear=function(){e.prototype._onClear.call(this),this.texture&&(this.texture=null)},n.prototype.generateTextureData=function(){return t.BaseObject.borrowObject(i)},n}(t.TextureAtlasData);t.EgretTextureAtlasData=e;var i=function(t){function e(){t.call(this)}return __extends(e,t),e.toString=function(){return"[class dragonBones.EgretTextureData]"},e.prototype._onClear=function(){t.prototype._onClear.call(this),this.texture&&(this.texture.dispose(),this.texture=null)},e}(t.TextureData);t.EgretTextureData=i}(dragonBones||(dragonBones={}));var dragonBones;!function(t){var e=function(e){function i(t,i,n,a){e.call(this,t,i,n,a)}return __extends(i,e),Object.defineProperty(i.prototype,"eventObject",{get:function(){return this.data},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"frameLabel",{get:function(){return this.eventObject.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"sound",{get:function(){return this.eventObject.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationName",{get:function(){return this.eventObject.animationState.name},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"armature",{get:function(){return this.eventObject.armature},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"bone",{get:function(){return this.eventObject.bone},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"slot",{get:function(){return this.eventObject.slot},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"animationState",{get:function(){return this.eventObject.animationState},enumerable:!0,configurable:!0}),Object.defineProperty(i.prototype,"movementID",{get:function(){return this.animationName},enumerable:!0,configurable:!0}),i.START=t.EventObject.START,i.LOOP_COMPLETE=t.EventObject.LOOP_COMPLETE,i.COMPLETE=t.EventObject.COMPLETE,i.FADE_IN=t.EventObject.FADE_IN,i.FADE_IN_COMPLETE=t.EventObject.FADE_IN_COMPLETE,i.FADE_OUT=t.EventObject.FADE_OUT,i.FADE_OUT_COMPLETE=t.EventObject.FADE_OUT_COMPLETE,i.FRAME_EVENT=t.EventObject.FRAME_EVENT,i.SOUND_EVENT=t.EventObject.SOUND_EVENT,i.ANIMATION_FRAME_EVENT=t.EventObject.FRAME_EVENT,i.BONE_FRAME_EVENT=t.EventObject.FRAME_EVENT,i.MOVEMENT_FRAME_EVENT=t.EventObject.FRAME_EVENT,i.SOUND=t.EventObject.SOUND_EVENT,i}(egret.Event);t.EgretEvent=e;var i=function(i){function n(){i.call(this),n._clock||(n._clock=new t.WorldClock,n._clock.time=.001*egret.getTimer(),egret.startTick(n._clockHandler,n))}return __extends(n,i),n._clockHandler=function(t){t*=.001;var e=n.passTime>0?n.passTime:t-n._clock.time;return n._clock.advanceTime(e),n._clock.time=t,!1},n.prototype._onClear=function(){this._armature=null,this._debugDrawer=null},n.prototype._dispatchEvent=function(t){var i=egret.Event.create(e,t.type);i.data=t,this.dispatchEvent(i),egret.Event.release(i)},n.prototype._debugDraw=function(){this._debugDrawer||(this._debugDrawer=new egret.Shape),this.addChild(this._debugDrawer),this._debugDrawer.graphics.clear();for(var t=this._armature.getBones(),e=0,i=t.length;e0)for(var _=0,u=a.actions.length;_=0){var e=this._displayIndex0;if(this._meshData.skinned){for(var n=0,a=0,r=this._meshData.vertices.length;n void; + protected renderCount: number; /** - * @private + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 */ - private showFPS; + cleanBeforeRender(): void; + $getRenderCount(): number; + } +} +declare module egret.sys { + /** + * @private + * 位图渲染节点 + */ + class BitmapNode extends RenderNode { + constructor(); /** - * @private + * 要绘制的位图 */ - private showLog; + image: BitmapData; /** - * @private + * 控制在缩放时是否对位图进行平滑处理。 */ - private fpsDisplay; + smoothing: boolean; /** - * @private - * 是否显示脏矩形重绘区。 + * 相对偏移矩阵。 */ - showPaintRect: (value: boolean) => void; + matrix: egret.Matrix; /** - * @private + * 图片宽度。WebGL渲染使用 */ - private drawDirtyRect; + imageWidth: number; /** - * @private + * 图片高度。WebGL渲染使用 */ - private _showPaintRect; + imageHeight: number; /** - * @private + * 使用的混合模式 */ - private stageDisplayList; + blendMode: number; /** - * @private + * 绘制一次位图 */ - private paintList; + drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; + /** + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 + */ + cleanBeforeRender(): void; + static $updateTextureData(node: sys.BitmapNode, image: any, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, scale9Grid: egret.Rectangle, fillMode: string, smoothing: boolean): void; /** * @private + * 绘制九宫格位图 */ - private drawPaintRect; + private static $updateTextureDataWithScale9Grid(node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH); + /** + * @private + */ + private static drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX?, startY?); } - /** - * @private - */ - var $logToFPS: (info: string) => void; -} -/** - * @private - */ -interface PlayerOption { - /** - * 入口类完整类名 - */ - entryClassName?: string; - /** - * 默认帧率 - */ - frameRate?: number; - /** - * 屏幕适配模式 - */ - scaleMode?: string; - /** - * 初始内容宽度 - */ - contentWidth?: number; - /** - * 初始内容高度 - */ - contentHeight?: number; - /** - * 屏幕方向 - */ - orientation?: string; - /** - * 是否显示重绘区域 - */ - showPaintRect?: boolean; - /** - * 显示FPS - */ - showFPS?: boolean; - /** - * - */ - fpsStyles?: Object; - /** - * 显示日志 - */ - showLog?: boolean; - /** - * 过滤日志的正则表达式 - */ - logFilter?: string; - /** - * - */ - maxTouches?: number; - /** - * - */ - textureScaleFactor?: number; } declare module egret.sys { /** * @private + * 矢量渲染节点 */ - class Region { + class GraphicsNode extends RenderNode { + constructor(); /** - * @private - * 释放一个Region实例到对象池 + * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 + * @param color 填充的颜色 + * @param alpha 填充的 Alpha 值 + * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 */ - static release(region: Region): void; + beginFill(color: number, alpha?: number, beforePath?: Path2D): Path2D; /** - * @private - * 从对象池中取出或创建一个新的Region对象。 - * 建议对于一次性使用的对象,均使用此方法创建,而不是直接new一个。 - * 使用完后调用对应的release()静态方法回收对象,能有效减少对象创建数量造成的性能开销。 + * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 + * 调用 clear() 方法会清除填充。 + * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 + * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 + * @param alphas colors 数组中对应颜色的 alpha 值数组。 + * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 + * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 + * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 */ - static create(): Region; + beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix, beforePath?: Path2D): Path2D; /** - * @private + * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 + * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 + * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 + * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 + * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND + * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND + * @param miterLimit 用于表示剪切斜接的极限值的数字。 */ - minX: number; + lineStyle(thickness?: number, color?: number, alpha?: number, caps?: string, joints?: string, miterLimit?: number): Path2D; /** - * @private + * 清空所有缓存的绘制数据 */ - minY: number; + clear(): void; /** - * @private + * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 */ - maxX: number; + cleanBeforeRender(): void; /** - * @private + * 绘制x偏移 */ - maxY: number; + x: number; /** - * @private + * 绘制y偏移 + */ + y: number; + /** + * 绘制宽度 */ width: number; /** - * @private + * 绘制高度 */ height: number; /** - * @private + * 脏渲染标记 + * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D */ - area: number; + dirtyRender: boolean; + $texture: any; + $textureWidth: any; + $textureHeight: any; + } +} +declare module egret.sys { + /** + * @private + * 组渲染节点,用于组合多个渲染节点 + */ + class GroupNode extends RenderNode { + constructor(); + addNode(node: RenderNode): void; /** - * @private - * 是否发生移动 + * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 + * 这里只是想清空绘制命令,因此不调用super */ - moved: boolean; + cleanBeforeRender(): void; + $getRenderCount(): number; + } +} +declare module egret.sys { + /** + * @private + * Mesh 渲染节点 + */ + class MeshNode extends RenderNode { + constructor(); /** - * @private + * 要绘制的位图 */ - setTo(minX: number, minY: number, maxX: number, maxY: number): Region; + image: BitmapData; /** - * @private - * 把所有值都取整 + * 控制在缩放时是否对位图进行平滑处理。 */ - intValues(): void; + smoothing: boolean; /** - * @private + * 图片宽度。WebGL渲染使用 */ - updateArea(): void; + imageWidth: number; /** - * @private - * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 + * 图片高度。WebGL渲染使用 */ - union(target: Region): void; + imageHeight: number; /** - * @private - * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 + * 相对偏移矩阵。 */ - intersect(target: Region): void; + matrix: egret.Matrix; /** - * @private + * UV 坐标。 */ - private setEmpty(); + uvs: number[]; /** - * @private - * 确定此 Region 对象是否为空。 + * 顶点坐标。 */ - isEmpty(): boolean; + vertices: number[]; /** - * @private + * 顶点索引。 */ - intersects(target: Region): boolean; + indices: number[]; /** - * @private + * 顶点索引。 */ - updateRegion(bounds: Rectangle, matrix: Matrix): void; + bounds: Rectangle; + /** + * 绘制一次位图 + */ + drawMesh(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; + /** + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 + */ + cleanBeforeRender(): void; } } declare module egret.sys { /** - * 共享的用于碰撞检测的渲染缓冲 + * @private + * 位图渲染节点 */ - var hitTestBuffer: sys.RenderBuffer; + class SetAlphaNode extends RenderNode { + constructor(); + /** + * 绘制一次位图 + */ + setAlpha(alpha: number): void; + } +} +declare module egret.sys { /** * @private - * 渲染缓冲 + * 文本格式 */ - interface RenderBuffer { + interface TextFormat { /** - * 呈现最终绘图结果的画布。 - * @readOnly + * 颜色值 */ - surface: any; + textColor?: number; /** - * 渲染上下文。 - * @readOnly + * 描边颜色值 */ - context: any; + strokeColor?: number; /** - * 渲染缓冲的宽度,以像素为单位。 - * @readOnly + * 字号 */ - width: number; + size?: number; /** - * 渲染缓冲的高度,以像素为单位。 - * @readOnly + * 描边大小 */ - height: number; + stroke?: number; /** - * 改变渲染缓冲的大小并清空缓冲区 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 + * 是否加粗 */ - resize(width: number, height: number, useMaxSize?: boolean): void; + bold?: boolean; /** - * 改变渲染缓冲为指定大小,但保留原始图像数据 - * @param width 改变后的宽 - * @param height 改变后的高 - * @param offsetX 原始图像数据在改变后缓冲区的绘制起始位置x - * @param offsetY 原始图像数据在改变后缓冲区的绘制起始位置y + * 是否倾斜 */ - resizeTo(width: number, height: number, offsetX: number, offsetY: number): void; + italic?: boolean; /** - * 清空并设置裁切区域 - * @param regions 矩形列表 - * @param offsetX 矩形偏移量x - * @param offsetY 矩形偏移量y + * 字体名称 */ - beginClip(regions: sys.Region[], offsetX?: number, offsetY?: number): void; + fontFamily?: string; + } +} +declare module egret.sys { + /** + * @private + * 文本渲染节点 + */ + class TextNode extends RenderNode { + constructor(); /** - * 取消上一次设置的clip。 + * 颜色值 */ - endClip(): void; + textColor: number; /** - * 获取指定坐标的像素 + * 描边颜色值 */ - getPixel(x: number, y: number): number[]; + strokeColor: number; /** - * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null - * @param type 转换的类型,如: "image/png","image/jpeg" + * 字号 */ - toDataURL(type?: string, ...args: any[]): string; + size: number; /** - * 清空缓冲区数据 + * 描边大小 */ - clear(): void; + stroke: number; /** - * 销毁渲染缓冲 + * 是否加粗 */ - destroy(): void; + bold: boolean; /** - * 设置脏矩形策略 + * 是否倾斜 */ - setDirtyRegionPolicy(state: string): void; - } - var RenderBuffer: { + italic: boolean; /** - * 创建一个RenderTarget。 - * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 - * @param width 渲染缓冲的初始宽 - * @param height 渲染缓冲的初始高 + * 字体名称 */ - new (width?: number, height?: number): RenderBuffer; - }; -} -declare module egret.sys { - /** - * @private - */ - interface Renderable extends HashObject { + fontFamily: string; /** - * 获取渲染节点 + * 绘制一行文本 */ - $getRenderNode(): RenderNode; + drawText(x: number, y: number, text: string, format: TextFormat): void; /** - * @private - * 更新对象在舞台上的显示区域和透明度,返回显示区域是否发生改变。 - * 注意:此方法必须在$getRenderNode()被调用之后执行。 + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 */ - $update(dirtyRegionPolicy: string, bounds?: Rectangle): boolean; + cleanBeforeRender(): void; + /** + * 绘制x偏移 + */ + x: number; + /** + * 绘制y偏移 + */ + y: number; + /** + * 绘制宽度 + */ + width: number; + /** + * 绘制高度 + */ + height: number; + /** + * 脏渲染标记 + */ + dirtyRender: boolean; + $texture: any; + $textureWidth: any; + $textureHeight: any; } } declare module egret.sys { /** - * @private - * 设备屏幕 + * 路径类型 */ - interface Screen { + const enum PathType { /** - * @private - * 更新屏幕视口尺寸 + * 纯色填充路径 */ - updateScreenSize(): any; + Fill = 1, /** - * @private - * 更新触摸数量 + * 渐变填充路径 */ - updateMaxTouches(): any; + GradientFill = 2, /** - * @private - * 设置分辨率尺寸 + * 线条路径 */ - setContentSize(width: number, height: number): any; + Stroke = 3, } -} -declare module egret.sys { /** * @private - * 屏幕适配器接口,当播放器视口尺寸改变时,屏幕适配器将被用于计算当前对应的舞台显示尺寸。 + * 2D路径命令 */ - interface IScreenAdapter { - /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; + const enum PathCommand { + MoveTo = 1, + LineTo = 2, + CurveTo = 3, + CubicCurveTo = 4, } /** * @private - * 舞台显示尺寸数据 + * 2D路径 */ - interface StageDisplaySize { + class Path2D { /** - * @private - * 舞台宽度 + * 路径类型 */ - stageWidth: number; + type: number; + $commands: number[]; + $data: number[]; + private commandPosition; + private dataPosition; /** - * @private - * 舞台高度 + * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 + * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 + * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 */ - stageHeight: number; + moveTo(x: number, y: number): void; /** - * @private - * 显示宽度,若跟舞台宽度不同,将会产生缩放。 + * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 + * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 + * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 */ - displayWidth: number; + lineTo(x: number, y: number): void; /** - * @private - * 显示高度,若跟舞台高度不同,将会产生缩放。 + * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 + * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 + * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 + * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 + * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 + * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 + * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 */ - displayHeight: number; + curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; + /** + * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 + * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 + * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 + * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 + * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 + * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 + * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 + */ + cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; + /** + * 绘制一个矩形 + * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 + * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 + * @param width 矩形的宽度(以像素为单位)。 + * @param height 矩形的高度(以像素为单位)。 + */ + drawRect(x: number, y: number, width: number, height: number): void; + /** + * 绘制一个圆角矩形。 + * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 + * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 + * @param width 矩形的宽度(以像素为单位)。 + * @param height 矩形的高度(以像素为单位)。 + * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 + * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 + */ + drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; + /** + * 绘制一个圆。 + * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 + * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 + * @param radius 圆的半径(以像素为单位)。 + */ + drawCircle(x: number, y: number, radius: number): void; + /** + * 绘制一个椭圆。 + * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 + * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 + * @param width 矩形的宽度(以像素为单位)。 + * @param height 矩形的高度(以像素为单位)。 + */ + drawEllipse(x: number, y: number, width: number, height: number): void; + /** + * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 + * @param x 圆弧中心(圆心)的 x 轴坐标。 + * @param y 圆弧中心(圆心)的 y 轴坐标。 + * @param radius 圆弧的半径。 + * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 + * 注意,必须在0~2π之间。 + * @param endAngle 圆弧的终点, 单位以弧度表示。 + * 注意,必须在0~2π之间。 + * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 + */ + drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): void; + /** + * 绘制一段圆弧路径 + * @param x 圆弧中心(圆心)的 x 轴坐标。 + * @param y 圆弧中心(圆心)的 y 轴坐标。 + * @param radiusX 圆弧的半径 x。 + * @param radiusY 圆弧的半径 y。 + * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 + * 注意:必须为正数。 + * @param endAngle 圆弧的终点, 单位以弧度表示。 + * 注意:与startAngle差值必须在0~2π之间。 + * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 + * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 + */ + private arcToBezier(x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise?); } +} +declare module egret.sys { /** * @private - * 屏幕适配器实例,开发者可以通过给这个变量赋值实现了IScreenAdapter接口的实例,从而注入自定义的屏幕适配器。 - */ - var screenAdapter: IScreenAdapter; - /** - * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 + * 填充路径 */ - class DefaultScreenAdapter extends HashObject implements IScreenAdapter { + class FillPath extends Path2D { + constructor(); /** - * @private + * 填充颜色 */ - constructor(); + fillColor: number; /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 + * 填充透明度 */ - calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; + fillAlpha: number; } } -declare module egret { +declare module egret.sys { /** - * @language en_US - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts + * @private + * 渐变填充路径 */ + class GradientFillPath extends Path2D { + constructor(); + gradientType: string; + colors: number[]; + alphas: number[]; + ratios: number[]; + matrix: Matrix; + } +} +declare module egret.sys { /** - * @language zh_CN - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts + * @private + * 线条路径。 + * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 */ - class StageScaleMode { + class StrokePath extends Path2D { + constructor(); /** - * @language en_US - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. + * 线条宽度。 + * 注意:绘制时对1像素和3像素要特殊处理,整体向右下角偏移0.5像素,以显示清晰锐利的线条。 */ + lineWidth: number; /** - * @language zh_CN - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 + * 线条颜色 */ - static NO_SCALE: string; + lineColor: number; /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. + * 线条透明度 */ + lineAlpha: number; /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 + * 端点样式,"none":无端点,"round":圆头端点,"square":方头端点 */ - static SHOW_ALL: string; + caps: string; /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. + * 联接点样式,"bevel":斜角连接,"miter":尖角连接,"round":圆角连接 */ + joints: string; /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 + * 用于表示剪切斜接的极限值的数字。 */ - static NO_BORDER: string; + miterLimit: number; + } +} +declare module egret.sys { + var $TempStage: egret.Stage; + /** + * @private + * Egret播放器 + */ + class Player extends HashObject { /** - * @language en_US - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
- * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. + * @private + * 实例化一个播放器对象。 */ + constructor(buffer: RenderBuffer, stage: Stage, entryClassName: string); /** - * @language zh_CN - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
- * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 + * @private */ - static EXACT_FIT: string; + private createDisplayList(stage, buffer); /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
- * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. + * @private */ + private screenDisplayList; /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
- * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 + * @private + * 入口类的完整类名 */ - static FIXED_WIDTH: string; + private entryClassName; /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
- * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. + * @private + * 舞台引用 */ + stage: Stage; /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
- * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 + * @private + * 入口类实例 */ - static FIXED_HEIGHT: string; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - */ - static FIXED_NARROW: string; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
- * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
- * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - */ - static FIXED_WIDE: string; - } -} -declare module egret.sys { - /** - * @private - */ - var systemRenderer: SystemRenderer; - /** - * @private - * 用于碰撞检测绘制 - */ - var canvasRenderer: SystemRenderer; - /** - * @private - * 显示渲染器接口 - */ - interface SystemRenderer { - /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要对显示对象整体叠加的变换矩阵 - * @param dirtyList 脏矩形列表 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 - */ - render(displayObject: DisplayObject, buffer: RenderBuffer, matrix: Matrix, dirtyList?: Region[], forRenderTexture?: boolean): number; - /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 - */ - drawNodeToBuffer(node: sys.RenderNode, buffer: RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; - } -} -declare module egret.sys { - /** - * @private - */ - var $START_TIME: number; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - var $invalidateRenderFlag: boolean; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - var $requestRenderingFlag: boolean; - /** - * @private - * Egret心跳计时器 - */ - class SystemTicker { + private root; /** * @private */ - constructor(); + private isPlaying; /** * @private + * 启动播放器 */ - private playerList; + start(): void; /** * @private - * 注册一个播放器实例并运行 + * */ - $addPlayer(player: Player): void; + private initialize(); /** * @private - * 停止一个播放器实例的运行。 + * 停止播放器,停止后将不能重新启动。 */ - $removePlayer(player: Player): void; + stop(): void; /** * @private + * 暂停播放器,后续可以通过调用start()重新启动播放器。 */ - private callBackList; + pause(): void; /** * @private + * 渲染屏幕 */ - private thisObjectList; + $render(triggerByFrame: boolean, costTicker: number): void; /** * @private + * */ - $startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; + private callLaters(); /** * @private + * */ - $stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; + private callLaterAsyncs(); /** * @private + * 更新舞台尺寸 + * @param stageWidth 舞台宽度(以像素为单位) + * @param stageHeight 舞台高度(以像素为单位) */ - private getTickIndex(callBack, thisObject); + updateStageSize(stageWidth: number, stageHeight: number): void; /** * @private - * + * 显示FPS。 */ - private concatTick(); + displayFPS: (showFPS: boolean, showLog: boolean, logFilter: string, fpsStyles: Object) => void; /** * @private - * 全局帧率 */ - $frameRate: number; + private showFPS; /** * @private */ - private frameInterval; + private showLog; /** * @private - * 设置全局帧率 */ - $setFrameRate(value: number): boolean; + private fpsDisplay; /** * @private + * 是否显示脏矩形重绘区。 */ - private lastCount; + showPaintRect: (value: boolean) => void; /** * @private - * ticker 花销的时间 */ - private costEnterFrame; + private drawDirtyRect; /** * @private - * 执行一次刷新 */ - update(): void; + private _showPaintRect; /** * @private - * 执行一次屏幕渲染 */ - private render(triggerByFrame, costTicker); + private stageDisplayList; /** * @private - * 广播EnterFrame事件。 */ - private broadcastEnterFrame(); + private paintList; /** * @private - * 广播Render事件。 */ - private broadcastRender(); + private drawPaintRect; } /** * @private - * 心跳计时器单例 */ - var $ticker: SystemTicker; + var $logToFPS: (info: string) => void; +} +/** + * @private + */ +interface PlayerOption { + /** + * 入口类完整类名 + */ + entryClassName?: string; + /** + * 默认帧率 + */ + frameRate?: number; + /** + * 屏幕适配模式 + */ + scaleMode?: string; + /** + * 初始内容宽度 + */ + contentWidth?: number; + /** + * 初始内容高度 + */ + contentHeight?: number; + /** + * 屏幕方向 + */ + orientation?: string; + /** + * 是否显示重绘区域 + */ + showPaintRect?: boolean; + /** + * 显示FPS + */ + showFPS?: boolean; + /** + * + */ + fpsStyles?: Object; + /** + * 显示日志 + */ + showLog?: boolean; + /** + * 过滤日志的正则表达式 + */ + logFilter?: string; + /** + * + */ + maxTouches?: number; + /** + * + */ + textureScaleFactor?: number; } declare module egret.sys { /** * @private - * 用户交互操作管理器 */ - class TouchHandler extends HashObject { - private maxTouches; - private useTouchesCount; + class Region { /** * @private + * 释放一个Region实例到对象池 */ - constructor(stage: Stage); + static release(region: Region): void; /** * @private - * 设置同时触摸数量 + * 从对象池中取出或创建一个新的Region对象。 + * 建议对于一次性使用的对象,均使用此方法创建,而不是直接new一个。 + * 使用完后调用对应的release()静态方法回收对象,能有效减少对象创建数量造成的性能开销。 */ - $initMaxTouches(): void; + static create(): Region; /** * @private */ - private stage; + minX: number; /** * @private */ - private touchDownTarget; + minY: number; /** * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 */ - onTouchBegin(x: number, y: number, touchPointID: number): void; + maxX: number; /** * @private */ - private lastTouchX; + maxY: number; /** * @private */ - private lastTouchY; + width: number; /** * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 */ - onTouchMove(x: number, y: number, touchPointID: number): void; + height: number; /** * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 */ - onTouchEnd(x: number, y: number, touchPointID: number): void; + area: number; /** * @private - * 获取舞台坐标下的触摸对象 + * 是否发生移动 */ - private findTarget(stageX, stageY); - } -} -declare module egret.sys { - /** - * @private - * 渲染节点类型 - */ - const enum RenderNodeType { + moved: boolean; /** - * 位图渲染节点 + * @private */ - BitmapNode = 1, + setTo(minX: number, minY: number, maxX: number, maxY: number): Region; /** - * 文本渲染节点 - */ - TextNode = 2, - /** - * 矢量渲染节点 + * @private + * 把所有值都取整 */ - GraphicsNode = 3, + intValues(): void; /** - * 组渲染节点 + * @private */ - GroupNode = 4, + updateArea(): void; /** - * 设置矩阵节点 + * @private + * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 */ - SetTransformNode = 5, + union(target: Region): void; /** - * 设置透明度节点 + * @private + * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 */ - SetAlphaNode = 6, + intersect(target: Region): void; /** - * Mesh 节点 + * @private */ - MeshNode = 7, - } - /** - * @private - * 渲染节点基类 - */ - class RenderNode { + private setEmpty(); /** - * 节点类型.. + * @private + * 确定此 Region 对象是否为空。 */ - type: number; + isEmpty(): boolean; /** - * 是否需要重绘的标志。 + * @private */ - needRedraw: boolean; + intersects(target: Region): boolean; /** - * 这个对象在舞台上的整体透明度 + * @private */ - renderAlpha: number; + updateRegion(bounds: Rectangle, matrix: Matrix): void; + } +} +declare module egret.sys { + /** + * @private + */ + interface Renderable extends HashObject { /** - * 这个对象在舞台上的透明度 + * 获取渲染节点 */ - renderVisible: boolean; + $getRenderNode(): RenderNode; /** - * 相对于显示列表根节点或位图缓存根节点上的矩阵对象 + * @private + * 更新对象在舞台上的显示区域和透明度,返回显示区域是否发生改变。 + * 注意:此方法必须在$getRenderNode()被调用之后执行。 */ - renderMatrix: Matrix; + $update(dirtyRegionPolicy: string, bounds?: Rectangle): boolean; + } +} +declare module egret.sys { + /** + * 共享的用于碰撞检测的渲染缓冲 + */ + var hitTestBuffer: sys.RenderBuffer; + /** + * @private + * 渲染缓冲 + */ + interface RenderBuffer { /** - * 此显示对象自身(不包括子项)在显示列表根节点或位图缓存根节点上的显示尺寸。 + * 呈现最终绘图结果的画布。 + * @readOnly */ - renderRegion: sys.Region; + surface: any; /** - * 是否发生移动 + * 渲染上下文。 + * @readOnly */ - moved: boolean; + context: any; /** - * 绘制数据 + * 渲染缓冲的宽度,以像素为单位。 + * @readOnly */ - drawData: any[]; + width: number; /** - * 绘制次数 + * 渲染缓冲的高度,以像素为单位。 + * @readOnly */ - protected renderCount: number; + height: number; /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 + * 改变渲染缓冲的大小并清空缓冲区 + * @param width 改变后的宽 + * @param height 改变后的高 + * @param useMaxSize 若传入true,则将改变后的尺寸与已有尺寸对比,保留较大的尺寸。 */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare module egret.sys { - /** - * @private - * 位图渲染节点 - */ - class BitmapNode extends RenderNode { - constructor(); + resize(width: number, height: number, useMaxSize?: boolean): void; /** - * 要绘制的位图 + * 改变渲染缓冲为指定大小,但保留原始图像数据 + * @param width 改变后的宽 + * @param height 改变后的高 + * @param offsetX 原始图像数据在改变后缓冲区的绘制起始位置x + * @param offsetY 原始图像数据在改变后缓冲区的绘制起始位置y */ - image: BitmapData; + resizeTo(width: number, height: number, offsetX: number, offsetY: number): void; /** - * 控制在缩放时是否对位图进行平滑处理。 + * 清空并设置裁切区域 + * @param regions 矩形列表 + * @param offsetX 矩形偏移量x + * @param offsetY 矩形偏移量y */ - smoothing: boolean; + beginClip(regions: sys.Region[], offsetX?: number, offsetY?: number): void; /** - * 相对偏移矩阵。 + * 取消上一次设置的clip。 */ - matrix: egret.Matrix; + endClip(): void; /** - * 图片宽度。WebGL渲染使用 + * 获取指定坐标的像素 */ - imageWidth: number; + getPixel(x: number, y: number): number[]; /** - * 图片高度。WebGL渲染使用 + * 转换成base64字符串,如果图片(或者包含的图片)跨域,则返回null + * @param type 转换的类型,如: "image/png","image/jpeg" */ - imageHeight: number; + toDataURL(type?: string, ...args: any[]): string; /** - * 使用的混合模式 + * 清空缓冲区数据 */ - blendMode: number; + clear(): void; /** - * 绘制一次位图 + * 销毁渲染缓冲 */ - drawImage(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; + destroy(): void; /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 + * 设置脏矩形策略 */ - cleanBeforeRender(): void; - static $updateTextureData(node: sys.BitmapNode, image: any, bitmapX: number, bitmapY: number, bitmapWidth: number, bitmapHeight: number, offsetX: number, offsetY: number, textureWidth: number, textureHeight: number, destW: number, destH: number, sourceWidth: number, sourceHeight: number, scale9Grid: egret.Rectangle, fillMode: string, smoothing: boolean): void; + setDirtyRegionPolicy(state: string): void; + } + var RenderBuffer: { /** - * @private - * 绘制九宫格位图 + * 创建一个RenderTarget。 + * 注意:若内存不足或创建缓冲区失败,将会抛出错误异常。 + * @param width 渲染缓冲的初始宽 + * @param height 渲染缓冲的初始高 */ - private static $updateTextureDataWithScale9Grid(node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH); - /** - * @private - */ - private static drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX?, startY?); - } + new (width?: number, height?: number): RenderBuffer; + }; } -declare module egret.sys { +declare module egret { /** * @private - * 矢量渲染节点 + * Canvas渲染器 */ - class GraphicsNode extends RenderNode { + class CanvasRenderer implements sys.SystemRenderer { constructor(); + private nestLevel; /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 + * 渲染一个显示对象 + * @param displayObject 要渲染的显示对象 + * @param buffer 渲染缓冲 + * @param matrix 要对显示对象整体叠加的变换矩阵 + * @param dirtyList 脏矩形列表 + * @param forRenderTexture 绘制目标是RenderTexture的标志 + * @returns drawCall触发绘制的次数 */ - beginFill(color: number, alpha?: number, beforePath?: Path2D): Path2D; + render(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix, dirtyList?: egret.sys.Region[], forRenderTexture?: boolean): number; /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 + * @private + * 绘制一个显示对象 */ - beginGradientFill(type: string, colors: number[], alphas: number[], ratios: number[], matrix?: egret.Matrix, beforePath?: Path2D): Path2D; + private drawDisplayObject(displayObject, context, dirtyList, matrix, displayList, clipRegion, root); /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 + * @private */ - lineStyle(thickness?: number, color?: number, alpha?: number, caps?: string, joints?: string, miterLimit?: number): Path2D; + private drawWithFilter(displayObject, context, dirtyList, matrix, clipRegion, root); + private renderingMask; /** - * 清空所有缓存的绘制数据 + * @private */ - clear(): void; + private drawWithClip(displayObject, context, dirtyList, matrix, clipRegion, root); /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 + * @private */ - cleanBeforeRender(): void; + private drawWithScrollRect(displayObject, context, dirtyList, matrix, clipRegion, root); /** - * 绘制x偏移 + * 将一个RenderNode对象绘制到渲染缓冲 + * @param node 要绘制的节点 + * @param buffer 渲染缓冲 + * @param matrix 要叠加的矩阵 + * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 */ - x: number; + drawNodeToBuffer(node: sys.RenderNode, buffer: sys.RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; /** - * 绘制y偏移 + * @private */ - y: number; + private renderNode(node, context, forHitTest?); /** - * 绘制宽度 + * @private */ - width: number; + private renderBitmap(node, context); /** - * 绘制高度 + * @private */ - height: number; + private renderText(node, context); /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D + * @private */ - dirtyRender: boolean; - $texture: any; - $textureWidth: any; - $textureHeight: any; + private renderGraphics(node, context, forHitTest?); + private renderPath(path, context); + private renderGroup(groupNode, context); + /** + * @private + */ + private createRenderBuffer(width, height); } } declare module egret.sys { /** * @private - * 组渲染节点,用于组合多个渲染节点 + * 设备屏幕 */ - class GroupNode extends RenderNode { - constructor(); - addNode(node: RenderNode): void; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - cleanBeforeRender(): void; - $getRenderCount(): number; - } -} -declare module egret.sys { - /** - * @private - * Mesh 渲染节点 - */ - class MeshNode extends RenderNode { - constructor(); - /** - * 要绘制的位图 - */ - image: BitmapData; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - smoothing: boolean; - /** - * 图片宽度。WebGL渲染使用 - */ - imageWidth: number; - /** - * 图片高度。WebGL渲染使用 - */ - imageHeight: number; - /** - * 相对偏移矩阵。 - */ - matrix: egret.Matrix; - /** - * UV 坐标。 - */ - uvs: number[]; - /** - * 顶点坐标。 - */ - vertices: number[]; - /** - * 顶点索引。 - */ - indices: number[]; + interface Screen { /** - * 顶点索引。 + * @private + * 更新屏幕视口尺寸 */ - bounds: Rectangle; + updateScreenSize(): any; /** - * 绘制一次位图 + * @private + * 更新触摸数量 */ - drawMesh(sourceX: number, sourceY: number, sourceW: number, sourceH: number, drawX: number, drawY: number, drawW: number, drawH: number): void; + updateMaxTouches(): any; /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 + * @private + * 设置分辨率尺寸 */ - cleanBeforeRender(): void; + setContentSize(width: number, height: number): any; } } declare module egret.sys { /** * @private - * 位图渲染节点 + * 屏幕适配器接口,当播放器视口尺寸改变时,屏幕适配器将被用于计算当前对应的舞台显示尺寸。 */ - class SetAlphaNode extends RenderNode { - constructor(); + interface IScreenAdapter { /** - * 绘制一次位图 + * @private + * 计算舞台显示尺寸 + * @param scaleMode 当前的缩放模式 + * @param screenWidth 播放器视口宽度 + * @param screenHeight 播放器视口高度 + * @param contentWidth 初始化内容宽度 + * @param contentHeight 初始化内容高度 */ - setAlpha(alpha: number): void; + calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; } -} -declare module egret.sys { /** * @private - * 文本格式 + * 舞台显示尺寸数据 */ - interface TextFormat { - /** - * 颜色值 - */ - textColor?: number; + interface StageDisplaySize { /** - * 描边颜色值 + * @private + * 舞台宽度 */ - strokeColor?: number; + stageWidth: number; /** - * 字号 + * @private + * 舞台高度 */ - size?: number; + stageHeight: number; /** - * 描边大小 + * @private + * 显示宽度,若跟舞台宽度不同,将会产生缩放。 */ - stroke?: number; + displayWidth: number; /** - * 是否加粗 + * @private + * 显示高度,若跟舞台高度不同,将会产生缩放。 */ - bold?: boolean; + displayHeight: number; + } + /** + * @private + * 屏幕适配器实例,开发者可以通过给这个变量赋值实现了IScreenAdapter接口的实例,从而注入自定义的屏幕适配器。 + */ + var screenAdapter: IScreenAdapter; + /** + * @private + * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 + */ + class DefaultScreenAdapter extends HashObject implements IScreenAdapter { /** - * 是否倾斜 + * @private */ - italic?: boolean; + constructor(); /** - * 字体名称 + * @private + * 计算舞台显示尺寸 + * @param scaleMode 当前的缩放模式 + * @param screenWidth 播放器视口宽度 + * @param screenHeight 播放器视口高度 + * @param contentWidth 初始化内容宽度 + * @param contentHeight 初始化内容高度 */ - fontFamily?: string; + calculateStageSize(scaleMode: string, screenWidth: number, screenHeight: number, contentWidth: number, contentHeight: number): StageDisplaySize; } } -declare module egret.sys { +declare module egret { /** - * @private - * 文本渲染节点 + * @language en_US + * StageScaleMode class provides values for the stage zoom mode. + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/player/StageScaleMode.ts */ - class TextNode extends RenderNode { - constructor(); - /** - * 颜色值 - */ - textColor: number; + /** + * @language zh_CN + * StageScaleMode 类为舞台缩放模式提供值。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/player/StageScaleMode.ts + */ + class StageScaleMode { /** - * 描边颜色值 + * @language en_US + * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
+ * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. */ - strokeColor: number; /** - * 字号 + * @language zh_CN + * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
+ * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 */ - size: number; + static NO_SCALE: string; /** - * 描边大小 + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
+ * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. */ - stroke: number; /** - * 是否加粗 + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
+ * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 */ - bold: boolean; + static SHOW_ALL: string; /** - * 是否倾斜 + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
+ * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. */ - italic: boolean; /** - * 字体名称 + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
+ * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 */ - fontFamily: string; + static NO_BORDER: string; /** - * 绘制一行文本 + * @language en_US + * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
+ * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. */ - drawText(x: number, y: number, text: string, format: TextFormat): void; /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 + * @language zh_CN + * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
+ * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 */ - cleanBeforeRender(): void; + static EXACT_FIT: string; /** - * 绘制x偏移 + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
+ * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. */ - x: number; /** - * 绘制y偏移 + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
+ * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 */ - y: number; + static FIXED_WIDTH: string; /** - * 绘制宽度 + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
+ * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. */ - width: number; /** - * 绘制高度 + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
+ * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 */ - height: number; + static FIXED_HEIGHT: string; /** - * 脏渲染标记 + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
+ * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. */ - dirtyRender: boolean; - $texture: any; - $textureWidth: any; - $textureHeight: any; - } -} -declare module egret.sys { - /** - * 路径类型 - */ - const enum PathType { /** - * 纯色填充路径 + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
+ * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 */ - Fill = 1, + static FIXED_NARROW: string; /** - * 渐变填充路径 + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
+ * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. */ - GradientFill = 2, /** - * 线条路径 + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
+ * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 */ - Stroke = 3, + static FIXED_WIDE: string; } +} +declare module egret.sys { /** * @private - * 2D路径命令 */ - const enum PathCommand { - MoveTo = 1, - LineTo = 2, - CurveTo = 3, - CubicCurveTo = 4, - } + var systemRenderer: SystemRenderer; /** * @private - * 2D路径 + * 用于碰撞检测绘制 */ - class Path2D { - /** - * 路径类型 - */ - type: number; - $commands: number[]; - $data: number[]; - private commandPosition; - private dataPosition; - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - moveTo(x: number, y: number): void; - /** - * 使用当前线条样式绘制一条从当前绘图位置开始到 (x, y) 结束的直线;当前绘图位置随后会设置为 (x, y)。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - */ - lineTo(x: number, y: number): void; - /** - * 使用当前线条样式和由 (controlX, controlY) 指定的控制点绘制一条从当前绘图位置开始到 (anchorX, anchorY) 结束的二次贝塞尔曲线。当前绘图位置随后设置为 (anchorX, anchorY)。 - * 如果在调用 moveTo() 方法之前调用了 curveTo() 方法,则当前绘图位置的默认值为 (0, 0)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * 绘制的曲线是二次贝塞尔曲线。二次贝塞尔曲线包含两个锚点和一个控制点。该曲线内插这两个锚点,并向控制点弯曲。 - * @param controlX 一个数字,指定控制点相对于父显示对象注册点的水平位置。 - * @param controlY 一个数字,指定控制点相对于父显示对象注册点的垂直位置。 - * @param anchorX 一个数字,指定下一个锚点相对于父显示对象注册点的水平位置。 - * @param anchorY 一个数字,指定下一个锚点相对于父显示对象注册点的垂直位置。 - */ - curveTo(controlX: number, controlY: number, anchorX: number, anchorY: number): void; - /** - * 从当前绘图位置到指定的锚点绘制一条三次贝塞尔曲线。三次贝塞尔曲线由两个锚点和两个控制点组成。该曲线内插这两个锚点,并向两个控制点弯曲。 - * @param controlX1 指定首个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY1 指定首个控制点相对于父显示对象的注册点的垂直位置。 - * @param controlX2 指定第二个控制点相对于父显示对象的注册点的水平位置。 - * @param controlY2 指定第二个控制点相对于父显示对象的注册点的垂直位置。 - * @param anchorX 指定锚点相对于父显示对象的注册点的水平位置。 - * @param anchorY 指定锚点相对于父显示对象的注册点的垂直位置。 - */ - cubicCurveTo(controlX1: number, controlY1: number, controlX2: number, controlY2: number, anchorX: number, anchorY: number): void; - /** - * 绘制一个矩形 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawRect(x: number, y: number, width: number, height: number): void; - /** - * 绘制一个圆角矩形。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - * @param ellipseWidth 用于绘制圆角的椭圆的宽度(以像素为单位)。 - * @param ellipseHeight 用于绘制圆角的椭圆的高度(以像素为单位)。 (可选)如果未指定值,则默认值与为 ellipseWidth 参数提供的值相匹配。 - */ - drawRoundRect(x: number, y: number, width: number, height: number, ellipseWidth: number, ellipseHeight?: number): void; - /** - * 绘制一个圆。 - * @param x 圆心相对于父显示对象注册点的 x 位置(以像素为单位)。 - * @param y 相对于父显示对象注册点的圆心的 y 位置(以像素为单位)。 - * @param radius 圆的半径(以像素为单位)。 - */ - drawCircle(x: number, y: number, radius: number): void; - /** - * 绘制一个椭圆。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 - * @param width 矩形的宽度(以像素为单位)。 - * @param height 矩形的高度(以像素为单位)。 - */ - drawEllipse(x: number, y: number, width: number, height: number): void; - /** - * 绘制一段圆弧路径。圆弧路径的圆心在 (x, y) 位置,半径为 r ,根据anticlockwise (默认为顺时针)指定的方向从 startAngle 开始绘制,到 endAngle 结束。 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radius 圆弧的半径。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意,必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - */ - drawArc(x: number, y: number, radius: number, startAngle: number, endAngle: number, anticlockwise: boolean): void; - /** - * 绘制一段圆弧路径 - * @param x 圆弧中心(圆心)的 x 轴坐标。 - * @param y 圆弧中心(圆心)的 y 轴坐标。 - * @param radiusX 圆弧的半径 x。 - * @param radiusY 圆弧的半径 y。 - * @param startAngle 圆弧的起始点, x轴方向开始计算,单位以弧度表示。 - * 注意:必须为正数。 - * @param endAngle 圆弧的终点, 单位以弧度表示。 - * 注意:与startAngle差值必须在0~2π之间。 - * @param anticlockwise 如果为 true,逆时针绘制圆弧,反之,顺时针绘制。 - * 注意:如果为true,endAngle必须小于startAngle,反之必须大于。 - */ - private arcToBezier(x, y, radiusX, radiusY, startAngle, endAngle, anticlockwise?); - } -} -declare module egret.sys { + var canvasRenderer: SystemRenderer; /** * @private - * 填充路径 + * 显示渲染器接口 */ - class FillPath extends Path2D { - constructor(); + interface SystemRenderer { /** - * 填充颜色 + * 渲染一个显示对象 + * @param displayObject 要渲染的显示对象 + * @param buffer 渲染缓冲 + * @param matrix 要对显示对象整体叠加的变换矩阵 + * @param dirtyList 脏矩形列表 + * @param forRenderTexture 绘制目标是RenderTexture的标志 + * @returns drawCall触发绘制的次数 */ - fillColor: number; + render(displayObject: DisplayObject, buffer: RenderBuffer, matrix: Matrix, dirtyList?: Region[], forRenderTexture?: boolean): number; /** - * 填充透明度 + * 将一个RenderNode对象绘制到渲染缓冲 + * @param node 要绘制的节点 + * @param buffer 渲染缓冲 + * @param matrix 要叠加的矩阵 + * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 */ - fillAlpha: number; + drawNodeToBuffer(node: sys.RenderNode, buffer: RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; } } declare module egret.sys { /** * @private - * 渐变填充路径 */ - class GradientFillPath extends Path2D { - constructor(); - gradientType: string; - colors: number[]; - alphas: number[]; - ratios: number[]; - matrix: Matrix; - } -} -declare module egret.sys { + var $START_TIME: number; /** * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 + * 是否要广播Event.RENDER事件的标志。 */ - class StrokePath extends Path2D { + var $invalidateRenderFlag: boolean; + /** + * @private + * 需要立即刷新屏幕的标志 + */ + var $requestRenderingFlag: boolean; + /** + * @private + * Egret心跳计时器 + */ + class SystemTicker { + /** + * @private + */ constructor(); /** - * 线条宽度。 - * 注意:绘制时对1像素和3像素要特殊处理,整体向右下角偏移0.5像素,以显示清晰锐利的线条。 + * @private */ - lineWidth: number; + private playerList; /** - * 线条颜色 + * @private + * 注册一个播放器实例并运行 */ - lineColor: number; + $addPlayer(player: Player): void; /** - * 线条透明度 + * @private + * 停止一个播放器实例的运行。 */ - lineAlpha: number; + $removePlayer(player: Player): void; /** - * 端点样式,"none":无端点,"round":圆头端点,"square":方头端点 + * @private */ - caps: string; + private callBackList; /** - * 联接点样式,"bevel":斜角连接,"miter":尖角连接,"round":圆角连接 + * @private */ - joints: string; + private thisObjectList; /** - * 用于表示剪切斜接的极限值的数字。 + * @private */ - miterLimit: number; - } -} -declare module egret { - /** - * @private - * Canvas渲染器 - */ - class CanvasRenderer implements sys.SystemRenderer { - constructor(); - private nestLevel; + $startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要对显示对象整体叠加的变换矩阵 - * @param dirtyList 脏矩形列表 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 + * @private */ - render(displayObject: DisplayObject, buffer: sys.RenderBuffer, matrix: Matrix, dirtyList?: egret.sys.Region[], forRenderTexture?: boolean): number; + $stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; /** * @private - * 绘制一个显示对象 */ - private drawDisplayObject(displayObject, context, dirtyList, matrix, displayList, clipRegion, root); - private renderingMask; + private getTickIndex(callBack, thisObject); /** * @private + * */ - private drawWithClip(displayObject, context, dirtyList, matrix, clipRegion, root); + private concatTick(); /** * @private + * 全局帧率 */ - private drawWithScrollRect(displayObject, context, dirtyList, matrix, clipRegion, root); + $frameRate: number; /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 + * @private */ - drawNodeToBuffer(node: sys.RenderNode, buffer: sys.RenderBuffer, matrix: Matrix, forHitTest?: boolean): void; + private frameInterval; + private frameDeltaTime; + private lastTimeStamp; /** * @private + * 设置全局帧率 */ - private renderNode(node, context, forHitTest?); + $setFrameRate(value: number): boolean; /** * @private */ - private renderBitmap(node, context); + private lastCount; /** * @private + * ticker 花销的时间 */ - private renderText(node, context); + private costEnterFrame; /** * @private + * 执行一次刷新 */ - private renderGraphics(node, context, forHitTest?); - private renderPath(path, context); - private renderGroup(groupNode, context); + update(): void; /** * @private + * 执行一次屏幕渲染 */ - private createRenderBuffer(width, height); - } -} -declare module egret { - /** - * @language en_US - * Orientation monitor the orientation of the device, send CHANGE event when the orientation is changed - * + private render(triggerByFrame, costTicker); + /** + * @private + * 广播EnterFrame事件。 + */ + private broadcastEnterFrame(); + /** + * @private + * 广播Render事件。 + */ + private broadcastRender(); + } + /** + * @private + * 心跳计时器单例 + */ + var $ticker: SystemTicker; +} +declare module egret.sys { + /** + * @private + * 用户交互操作管理器 + */ + class TouchHandler extends HashObject { + private maxTouches; + private useTouchesCount; + /** + * @private + */ + constructor(stage: Stage); + /** + * @private + * 设置同时触摸数量 + */ + $initMaxTouches(): void; + /** + * @private + */ + private stage; + /** + * @private + */ + private touchDownTarget; + /** + * @private + * 触摸开始(按下) + * @param x 事件发生处相对于舞台的坐标x + * @param y 事件发生处相对于舞台的坐标y + * @param touchPointID 分配给触摸点的唯一标识号 + */ + onTouchBegin(x: number, y: number, touchPointID: number): void; + /** + * @private + */ + private lastTouchX; + /** + * @private + */ + private lastTouchY; + /** + * @private + * 触摸移动 + * @param x 事件发生处相对于舞台的坐标x + * @param y 事件发生处相对于舞台的坐标y + * @param touchPointID 分配给触摸点的唯一标识号 + */ + onTouchMove(x: number, y: number, touchPointID: number): void; + /** + * @private + * 触摸结束(弹起) + * @param x 事件发生处相对于舞台的坐标x + * @param y 事件发生处相对于舞台的坐标y + * @param touchPointID 分配给触摸点的唯一标识号 + */ + onTouchEnd(x: number, y: number, touchPointID: number): void; + /** + * @private + * 获取舞台坐标下的触摸对象 + */ + private findTarget(stageX, stageY); + } +} +declare module egret { + /** + * @language en_US + * Orientation monitor the orientation of the device, send CHANGE event when the orientation is changed + * * @event egret.Event.CHANGE device's orientation is changed * @version Egret 2.4 * @platform Web,Native @@ -11898,6 +11904,107 @@ declare module egret { private addToArray(infoStr); } } +declare module egret { + /** + * @private + * @version Egret 2.4 + * @platform Web,Native + */ + class InputController extends HashObject { + /** + * @private + */ + private stageText; + /** + * @private + */ + private _text; + /** + * @private + */ + private _isFocus; + /** + * @version Egret 2.4 + * @platform Web,Native + */ + constructor(); + /** + * + * @param text + * @version Egret 2.4 + * @platform Web,Native + */ + init(text: TextField): void; + /** + * @private + * + */ + _addStageText(): void; + /** + * @private + * + */ + _removeStageText(): void; + /** + * @private + * + * @returns + */ + _getText(): string; + /** + * @private + * + * @param value + */ + _setText(value: string): void; + /** + * @private + */ + _setColor(value: number): void; + /** + * @private + * + * @param event + */ + private focusHandler(event); + /** + * @private + * + * @param event + */ + private blurHandler(event); + private tempStage; + private onMouseDownHandler(event); + $onFocus(): void; + private onStageDownHandler(event); + /** + * @private + * + * @param event + */ + private updateTextHandler(event); + /** + * @private + * + */ + private resetText(); + /** + * @private + * + */ + _hideInput(): void; + /** + * @private + * + */ + private updateInput(); + /** + * @private + * + */ + _updateProperties(): void; + } +} declare module egret { /** * @private @@ -12161,166 +12268,65 @@ declare module egret { * @version Egret 2.4 * @platform Web,Native */ - class InputController extends HashObject { - /** - * @private - */ - private stageText; - /** - * @private - */ - private _text; + interface StageText extends EventDispatcher { /** * @private */ - private _isFocus; - /** - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(); - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - init(text: TextField): void; + $textfield: egret.TextField; /** * @private * + * @param textfield */ - _addStageText(): void; + $setTextField(textfield: egret.TextField): boolean; /** * @private * */ - _removeStageText(): void; + $resetStageText(): void; /** * @private * * @returns */ - _getText(): string; + $getText(): string; /** * @private * * @param value */ - _setText(value: string): void; - /** - * @private - */ - _setColor(value: number): void; - /** - * @private - * - * @param event - */ - private focusHandler(event); + $setText(value: string): boolean; /** * @private * - * @param event + * @param value */ - private blurHandler(event); - private tempStage; - private onMouseDownHandler(event); - $onFocus(): void; - private onStageDownHandler(event); + $setColor(value: number): boolean; /** * @private * - * @param event */ - private updateTextHandler(event); + $show(): void; /** * @private * */ - private resetText(); + $hide(): void; /** * @private * */ - _hideInput(): void; + $addToStage(): void; /** * @private * */ - private updateInput(); + $removeFromStage(): void; /** * @private * */ - _updateProperties(): void; - } -} -declare module egret { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - interface StageText extends EventDispatcher { - /** - * @private - */ - $textfield: egret.TextField; - /** - * @private - * - * @param textfield - */ - $setTextField(textfield: egret.TextField): boolean; - /** - * @private - * - */ - $resetStageText(): void; - /** - * @private - * - * @returns - */ - $getText(): string; - /** - * @private - * - * @param value - */ - $setText(value: string): boolean; - /** - * @private - * - * @param value - */ - $setColor(value: number): boolean; - /** - * @private - * - */ - $show(): void; - /** - * @private - * - */ - $hide(): void; - /** - * @private - * - */ - $addToStage(): void; - /** - * @private - * - */ - $removeFromStage(): void; - /** - * @private - * - */ - $onBlur(): void; + $onBlur(): void; } /** * @version Egret 2.4 @@ -14154,6 +14160,7 @@ declare module egret { /** * @private */ +<<<<<<< HEAD interface MapLike { [key: string]: T; [key: number]: T; @@ -14164,912 +14171,915 @@ declare module egret { function createMap(): MapLike; } declare module egret { +======= + var $callLaterFunctionList: Array; + /** + * @private + */ + var $callLaterThisList: Array; + /** + * @private + */ + var $callLaterArgsList: Array; +>>>>>>> 4b8c5c4a241e7d9bd1c1bd245f7622d16a8879b6 /** * @language en_US - * Logger is an entrance for the log processing module of the engine + * Delay the function to run unless screen is redrawn. + * @param method {Function} The function to be delayed to run + * @param thisObject {any} this reference of callback function + * @param ...args {any} Function parameter list * @version Egret 2.4 * @platform Web,Native + * @includeExample egret/utils/callLater.ts */ /** * @language zh_CN - * Logger是引擎的日志处理模块入口 + * 延迟函数到屏幕重绘前执行。 + * @param method {Function} 要延迟执行的函数 + * @param thisObject {any} 回调函数的this引用 + * @param ...args {any} 函数参数列表 * @version Egret 2.4 * @platform Web,Native + * @includeExample egret/utils/callLater.ts */ - class Logger { - /** - * @language en_US - * open all - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 全开 - * @version Egret 2.4 - * @platform Web,Native - */ - static ALL: string; - /** - * @language en_US - * level: DEBUG - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 等级为 DEBUG - * @version Egret 2.4 - * @platform Web,Native - */ - static DEBUG: string; - /** - * @language en_US - * level: INFO - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 等级为 INFO - * @version Egret 2.4 - * @platform Web,Native - */ - static INFO: string; - /** - * @language en_US - * level: WARN - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 等级为 WARN - * @version Egret 2.4 - * @platform Web,Native - */ - static WARN: string; - /** - * @language en_US - * level: ERROR - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 等级为 ERROR - * @version Egret 2.4 - * @platform Web,Native - */ - static ERROR: string; - /** - * @language en_US - * close all - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 全关 - * @version Egret 2.4 - * @platform Web,Native - */ - static OFF: string; - /** - * @language en_US - * Set the current need to open the log level. Grade level are: ALL - * This feature is only in DEBUG mode to take effect.
- *
    - *
  • Logger.ALL - all levels of log can be printed out. - *
  • Logger.DEBUG - print debug, info, log, warn, error. - *
  • Logger.INFO - print info, log, warn, error. - *
  • Logger.WARN - can print warn, error. - *
  • Logger.ERROR - You can print error. - *
  • Logger.OFF - all closed. - * - *param LogType from this level to start printing. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
    - * 此功能只在 DEBUG 模式下才生效。
    - *
      - *
    • Logger.ALL -- 所有等级的log都可以打印出来。
    • - *
    • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
    • - *
    • Logger.INFO -- 可以打印info、log、warn、error。
    • - *
    • Logger.WARN -- 可以打印warn、error。
    • - *
    • Logger.ERROR -- 可以打印error。
    • - *
    • Logger.OFF -- 全部关闭。
    • - *
    - * @param logType 从这个等级开始打印。 - * @version Egret 2.4 - * @platform Web,Native - */ - static logLevel: string; - } + function callLater(method: Function, thisObject: any, ...args: any[]): void; + /** + * @private + */ + var $callAsyncFunctionList: Array; + /** + * @private + */ + var $callAsyncThisList: Array; + /** + * @private + */ + var $callAsyncArgsList: Array; + /** + * 异步调用函数 + * @param method {Function} 要异步调用的函数 + * @param thisObject {any} 函数的this引用 + * @param ...args {any} 函数参数列表 + * @private + */ + function $callAsync(method: Function, thisObject: any, ...args: any[]): void; } declare module egret { /** - * @version Egret 2.4 - * @platform Web,Native + * @language en_US + * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1; + * @param currentClass The current class class name, non-string + * @param thisObj The current object. Always this + * @param type Setter property names need to call + * @param values Value passed to the parent class + * + * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); */ - class NumberUtils { - /** - * @language en_US - * Judge whether it is a numerical value - * @param value Parameter that needs to be judged - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 判断是否是数值 - * @param value 需要判断的参数 - * @returns - * @version Egret 2.4 - * @platform Web,Native - */ - static isNumber(value: any): boolean; - /** - * @language en_US - * Obtain the approximate sin value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} sin value - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 得到对应角度值的sin近似值 - * @param value {number} 角度值 - * @returns {number} sin值 - * @version Egret 2.4 - * @platform Web,Native - */ - static sin(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static sinInt(value); - /** - * @language en_US - * Obtain the approximate cos value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} cos value - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 得到对应角度值的cos近似值 - * @param value {number} 角度值 - * @returns {number} cos值 - * @version Egret 2.4 - * @platform Web,Native - */ - static cos(value: number): number; - /** - * @private - * - * @param value - * @returns - */ - private static cosInt(value); - } + /** + * @language zh_CN + * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1; + * @param thisObj 当前对象。永远都this + * @param currentClass 当前 class 类名,非字符串 + * @param type 需要调用的setter属性名称 + * @param values 传给父类的值 + * + * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); + */ + function superSetter(currentClass: any, thisObj: any, type: string, ...values: any[]): any; + /** + * @language en_US + * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha; + * @param currentClass The current class class name, non-string + * @param thisObj The current object. Always this + * @param type Setter property names need to call + * @returns {any} The value returned by the parent + * + * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); + */ + /** + * @language zh_CN + * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha; + * @param thisObj 当前对象。永远都this + * @param currentClass 当前 class 类名,非字符串 + * @param type 需要调用的setter属性名称 + * @returns {any} 父类返回的值 + * + * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); + */ + function superGetter(currentClass: any, thisObj: any, type: string): any; } -declare var egret_sin_map: {}; -declare var egret_cos_map: {}; -declare var DEG_TO_RAD: number; declare module egret { /** * @language en_US - * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() - * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
    - * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending - * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at - * slightly offset intervals. - * @see egret.TimerEvent + * Returns a reference to the class object of the class specified by the name parameter. + * @param name The name of a class. * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/Timer.ts + * @includeExample egret/utils/getDefinitionByName.ts */ /** * @language zh_CN - * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 - * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 - * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 - * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 - * @see egret.TimerEvent + * 返回 name 参数指定的类的类对象引用。 + * @param name 类的名称。 * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/Timer.ts + * @includeExample egret/utils/getDefinitionByName.ts */ - class Timer extends EventDispatcher { - /** - * @language en_US - * Constructs a new Timer object with the specified delay and repeatCount states. - * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. - * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, - * the timer runs the specified number of times and then stops. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 - * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 - * @version Egret 2.4 - * @platform Web,Native - */ - constructor(delay: number, repeatCount?: number); - /** - * @private - */ - private _delay; - /** - * @language en_US - * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
    - * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
    - * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @version Egret 2.4 - * @platform Web,Native - */ - delay: number; - /** - * @language en_US - * The total number of times the timer is set to run. If the repeat count is set to 0, the timer continues indefinitely, - * until the stop() method is invoked or the program stops. If the repeat count is nonzero, the timer runs the specified - * number of times. If repeatCount is set to a total that is the same or less then currentCount the timer stops and will not fire again. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 设置的计时器运行总次数。如果重复计数设置为 0,则计时器将持续不断运行,或直至调用了 stop() 方法或节目停止。 - * 如果重复计数不为 0,则将运行计时器,运行次数为指定的次数。如果设置的 repeatCount 总数等于或小于 currentCount,则计时器将停止并且不会再次触发。 - * @version Egret 2.4 - * @platform Web,Native - */ - repeatCount: number; - /** - * @private - */ - private _currentCount; - /** - * @language en_US - * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 - * @version Egret 2.4 - * @platform Web,Native - */ - currentCount: number; - /** - * @private - */ - private _running; - /** - * @language en_US - * The timer's current state; true if the timer is running, otherwise false. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - */ - running: boolean; - /** - * @language en_US - * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. - * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 - * @version Egret 2.4 - * @platform Web,Native - */ - reset(): void; - /** - * @language en_US - * Starts the timer, if it is not already running. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 如果计时器尚未运行,则启动计时器。 - * @version Egret 2.4 - * @platform Web,Native - */ - start(): void; - /** - * @language en_US - * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of - * repetitions, as set by the repeatCount property. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 - * @version Egret 2.4 - * @platform Web,Native - */ - stop(): void; - /** - * @private - */ - private updateInterval; - /** - * @private - */ - private lastCount; - /** - * @private - * Ticker以60FPS频率刷新此方法 - */ - $update(timeStamp: number): boolean; - } + function getDefinitionByName(name: string): any; } +declare var __global: any; declare module egret { /** * @language en_US - * The XMLNode class is the base class for all xml node. + * Get browser or Runtime parameters, returns an empty string if not set + * Get the url parameter corresponds to the browser, access to the corresponding parameter in the Runtime setOption + * @method egret.getOption + * @param key {string} Parameters key * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * XML节点基类 + * 获取浏览器或者Runtime参数,如果没有设置返回空字符串 + * 在浏览器中相当于获取url中参数,在Runtime获取对应setOption参数 + * @method egret.getOption + * @param key {string} 参数key * @version Egret 2.4 * @platform Web,Native */ - interface XMLNode { - /** - * @language en_US - * a integer representing the type of the node, 1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 节点类型,1:XML,2:XMLAttribute,3:XMLText - * @version Egret 2.4 - * @platform Web,Native - */ - nodeType: number; - /** - * @language en_US - * the parent node of this xml node. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 节点所属的父级节点 - * @version Egret 2.4 - * @platform Web,Native - */ - parent: XML; - } + var getOption: (key: string) => string; +} +declare module egret { + /** + * @language en_US + * Return the fully qualified class name of an object + * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to + * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. + * @returns A string containing the fully qualified class name. + * @example + *
    +     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
    +     * 
    + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedClassName.ts + */ + /** + * @language zh_CN + * 返回对象的完全限定类名。 + * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 + * (如number)和类对象 + * @returns 包含完全限定类名称的字符串。 + * @example + *
    +     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
    +     * 
    + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedClassName.ts + */ + function getQualifiedClassName(value: any): string; +} +declare module egret { + /** @language en_US + * Returns the fully qualified class name of the base class of the object specified by the value parameter. + * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including + * all available JavaScript types, object instances, primitive types such as number, and class objects. + * @returns A fully qualified base class name, or null if none exists. + * @example + *
    +     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
    +     * 
    + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedSuperclassName.ts + */ + /** + * @language zh_CN + * 返回 value 参数指定的对象的基类的完全限定类名。 + * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 + * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 + * @example + *
    +     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
    +     * 
    + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedSuperclassName.ts + */ + function getQualifiedSuperclassName(value: any): string; +} +declare module egret { + /** + * @language en_US + * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized + * @returns The number of milliseconds since the Egret framework was initialized + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getTimer.ts + */ + /** + * @language zh_CN + * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 + * @returns 启动 Egret 框架以来经过的毫秒数。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getTimer.ts + */ + function getTimer(): number; +} +declare module egret { + /** + * @language en_US + * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. + * @param name {string} Name of the definition. + * @returns {boolean} Whether the public definition exists + * @example + * egret.hasDefinition("egret.DisplayObject") //return true + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/hasDefinition.ts + */ + /** + * @language zh_CN + * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 + * @param name {string} 定义的名称。 + * @returns {boolean} 公共定义是否存在 + * @example + * egret.hasDefinition("egret.DisplayObject") //返回 true + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/hasDefinition.ts + */ + function hasDefinition(name: string): boolean; +} +declare module egret { + /** + * @language en_US + * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance + * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. + * @param instance the instance to be checked. + * @param typeName the string value representing a specific class or interface. + * @returns A value of true if the object is a instance of the class or interface specified as the parameter. + * @example + *
    +     *     var instance = new egret.Sprite();
    +     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    +     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    +     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    +     * 
    + * @see egret.registerClass() + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 + * @param instance 要判断的实例。 + * @param typeName 类或接口的完全名称. + * @returns 返回true表示当前对象是指定类或接口的实例。 + * @example + *
    +     *     var instance = new egret.Sprite();
    +     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
    +     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
    +     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
    +     * 
    + * @see egret.registerClass() + * @version Egret 2.4 + * @platform Web,Native + */ + function is(instance: any, typeName: string): boolean; +} +declare module egret { /** * @language en_US - * The XML class contains properties for working with XML objects. + * Logger is an entrance for the log processing module of the engine * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/XML.ts */ /** * @language zh_CN - * XML 类包含用于处理 XML 对象的属性。 + * Logger是引擎的日志处理模块入口 * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/XML.ts */ - interface XML extends XMLNode { + class Logger { /** * @language en_US - * the attributes of this xml node. + * open all * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 当前节点上的属性列表 + * 全开 * @version Egret 2.4 * @platform Web,Native */ - attributes: any; + static ALL: string; /** * @language en_US - * the children of the xml node. + * level: DEBUG * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 当前节点的子节点列表 + * 等级为 DEBUG * @version Egret 2.4 * @platform Web,Native */ - children: XMLNode[]; + static DEBUG: string; /** * @language en_US - * the full name of this xml node. For example,the name of is "s:Button". + * level: INFO * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 节点完整名称。例如节点 的 name 为:"s:Button" + * 等级为 INFO * @version Egret 2.4 * @platform Web,Native */ - name: string; + static INFO: string; /** * @language en_US - * thie namesapce prefix of this xml node.For example,the prefix of is "s". + * level: WARN * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 节点的命名空间前缀。例如节点 的 prefix 为:s + * 等级为 WARN * @version Egret 2.4 * @platform Web,Native */ - prefix: string; + static WARN: string; /** * @language en_US - * the local name of this xml node. For example,the local name of is "Button". + * level: ERROR * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 节点的本地名称。例如节点 的 localName 为:Button + * 等级为 ERROR * @version Egret 2.4 * @platform Web,Native */ - localName: string; + static ERROR: string; /** * @language en_US - * the namesapce uri of this xml node.For example,the namespace uri of is "http://ns.egret.com/eui". + * close all * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 节点的命名空间地址。例如节点 的 namespace 为: http://ns.egret.com/eui + * 全关 * @version Egret 2.4 * @platform Web,Native */ - namespace: string; - } - /** - * @language en_US - * The XMLText class represents a string node in the XML. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * XMLText 类表示在XML中的文本节点 - * @version Egret 2.4 - * @platform Web,Native - */ - interface XMLText extends XMLNode { + static OFF: string; /** * @language en_US - * the text content + * Set the current need to open the log level. Grade level are: ALL + * This feature is only in DEBUG mode to take effect.
    + *
      + *
    • Logger.ALL - all levels of log can be printed out. + *
    • Logger.DEBUG - print debug, info, log, warn, error. + *
    • Logger.INFO - print info, log, warn, error. + *
    • Logger.WARN - can print warn, error. + *
    • Logger.ERROR - You can print error. + *
    • Logger.OFF - all closed. + * + *param LogType from this level to start printing. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 文本内容 + * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
      + * 此功能只在 DEBUG 模式下才生效。
      + *
        + *
      • Logger.ALL -- 所有等级的log都可以打印出来。
      • + *
      • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
      • + *
      • Logger.INFO -- 可以打印info、log、warn、error。
      • + *
      • Logger.WARN -- 可以打印warn、error。
      • + *
      • Logger.ERROR -- 可以打印error。
      • + *
      • Logger.OFF -- 全部关闭。
      • + *
      + * @param logType 从这个等级开始打印。 * @version Egret 2.4 * @platform Web,Native */ - text: string; + static logLevel: string; } +} +declare module egret { /** - * @language en_US - * The XML class contains properties for working with XML objects. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * XML 类包含用于处理 XML 对象的属性。 * @version Egret 2.4 * @platform Web,Native */ - var XML: { + class NumberUtils { /** * @language en_US - * parses a text to XML instance. - * @param text the text to be parsed. + * Judge whether it is a numerical value + * @param value Parameter that needs to be judged + * @returns + * @version Egret 2.4 + * @platform Web,Native */ /** * @language zh_CN - * 解析字符串为XML对象 - * @param text 要解析的XML对象。 + * 判断是否是数值 + * @param value 需要判断的参数 + * @returns + * @version Egret 2.4 + * @platform Web,Native */ - parse(text: string): XML; - }; -} -declare module egret { - /** - * @private - */ - var $callLaterFunctionList: Array; - /** - * @private - */ - var $callLaterThisList: Array; - /** - * @private - */ - var $callLaterArgsList: Array; - /** - * @language en_US - * Delay the function to run unless screen is redrawn. - * @param method {Function} The function to be delayed to run - * @param thisObject {any} this reference of callback function - * @param ...args {any} Function parameter list - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - */ - /** - * @language zh_CN - * 延迟函数到屏幕重绘前执行。 - * @param method {Function} 要延迟执行的函数 - * @param thisObject {any} 回调函数的this引用 - * @param ...args {any} 函数参数列表 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/callLater.ts - */ - function callLater(method: Function, thisObject: any, ...args: any[]): void; - /** - * @private - */ - var $callAsyncFunctionList: Array; - /** - * @private - */ - var $callAsyncThisList: Array; - /** - * @private - */ - var $callAsyncArgsList: Array; - /** - * 异步调用函数 - * @param method {Function} 要异步调用的函数 - * @param thisObject {any} 函数的this引用 - * @param ...args {any} 函数参数列表 - * @private - */ - function $callAsync(method: Function, thisObject: any, ...args: any[]): void; -} -declare module egret { - /** - * @language en_US - * Call setter properties of the parent class, instead of the other writing languages, such as super.alpha = 1; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @param values Value passed to the parent class - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - */ - /** - * @language zh_CN - * 调用父类的setter属性,代替其他语言的写法,如 super.alpha = 1; - * @param thisObj 当前对象。永远都this - * @param currentClass 当前 class 类名,非字符串 - * @param type 需要调用的setter属性名称 - * @param values 传给父类的值 - * - * @exmaple egret.superSetter(egret.Sprite, this, "alpha", 1); - */ - function superSetter(currentClass: any, thisObj: any, type: string, ...values: any[]): any; - /** - * @language en_US - * Get getter property value of the parent class. Instead of writing in other languages, such as super.alpha; - * @param currentClass The current class class name, non-string - * @param thisObj The current object. Always this - * @param type Setter property names need to call - * @returns {any} The value returned by the parent - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - */ - /** - * @language zh_CN - * 获取父类的getter属性值。代替其他语言的写法,如 super.alpha; - * @param thisObj 当前对象。永远都this - * @param currentClass 当前 class 类名,非字符串 - * @param type 需要调用的setter属性名称 - * @returns {any} 父类返回的值 - * - * @exmaple egret.superGetter(egret.Sprite, this, "alpha"); - */ - function superGetter(currentClass: any, thisObj: any, type: string): any; -} -declare module egret { - /** - * @language en_US - * Returns a reference to the class object of the class specified by the name parameter. - * @param name The name of a class. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - */ - /** - * @language zh_CN - * 返回 name 参数指定的类的类对象引用。 - * @param name 类的名称。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getDefinitionByName.ts - */ - function getDefinitionByName(name: string): any; + static isNumber(value: any): boolean; + /** + * @language en_US + * Obtain the approximate sin value of the corresponding angle value + * @param value {number} Angle value + * @returns {number} sin value + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 得到对应角度值的sin近似值 + * @param value {number} 角度值 + * @returns {number} sin值 + * @version Egret 2.4 + * @platform Web,Native + */ + static sin(value: number): number; + /** + * @private + * + * @param value + * @returns + */ + private static sinInt(value); + /** + * @language en_US + * Obtain the approximate cos value of the corresponding angle value + * @param value {number} Angle value + * @returns {number} cos value + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 得到对应角度值的cos近似值 + * @param value {number} 角度值 + * @returns {number} cos值 + * @version Egret 2.4 + * @platform Web,Native + */ + static cos(value: number): number; + /** + * @private + * + * @param value + * @returns + */ + private static cosInt(value); + } } -declare var __global: any; +declare var egret_sin_map: {}; +declare var egret_cos_map: {}; +declare var DEG_TO_RAD: number; declare module egret { /** * @language en_US - * Get browser or Runtime parameters, returns an empty string if not set - * Get the url parameter corresponds to the browser, access to the corresponding parameter in the Runtime setOption - * @method egret.getOption - * @param key {string} Parameters key + * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
      + * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. + * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds + * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime + * to render after processing of this method completes. + * @param thisObject the call back method's "this" * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 获取浏览器或者Runtime参数,如果没有设置返回空字符串 - * 在浏览器中相当于获取url中参数,在Runtime获取对应setOption参数 - * @method egret.getOption - * @param key {string} 参数key + * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 + * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 + * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 + * @param thisObject 回调方法的this对象引用。 * @version Egret 2.4 * @platform Web,Native */ - var getOption: (key: string) => string; + function startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; } declare module egret { /** * @language en_US - * Return the fully qualified class name of an object - * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to - * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A string containing the fully qualified class name. - * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - */ - /** - * @language zh_CN - * 返回对象的完全限定类名。 - * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 - * (如number)和类对象 - * @returns 包含完全限定类名称的字符串。 - * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
      -     * 
      - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts - */ - function getQualifiedClassName(value: any): string; -} -declare module egret { - /** @language en_US - * Returns the fully qualified class name of the base class of the object specified by the value parameter. - * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including - * all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A fully qualified base class name, or null if none exists. - * @example - *
      -     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
      -     * 
      + * Stops the timer started by the egret.startTick() method. + * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds + * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime + * to render after processing of this method completes. + * @param thisObject the call back method's "this" * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts */ /** * @language zh_CN - * 返回 value 参数指定的对象的基类的完全限定类名。 - * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 - * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 - * @example - *
      -     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
      -     * 
      + * 停止之前用 startTick() 方法启动的计时器。 + * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 + * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 + * @param thisObject 回调方法的this对象引用。 * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts */ - function getQualifiedSuperclassName(value: any): string; + function stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; } declare module egret { /** * @language en_US - * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized - * @returns The number of milliseconds since the Egret framework was initialized + * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() + * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
      + * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending + * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at + * slightly offset intervals. + * @see egret.TimerEvent * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getTimer.ts + * @includeExample egret/utils/Timer.ts */ /** * @language zh_CN - * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 - * @returns 启动 Egret 框架以来经过的毫秒数。 + * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 + * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 + * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 + * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 + * @see egret.TimerEvent * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getTimer.ts + * @includeExample egret/utils/Timer.ts */ - function getTimer(): number; + class Timer extends EventDispatcher { + /** + * @language en_US + * Constructs a new Timer object with the specified delay and repeatCount states. + * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. + * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. + * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, + * the timer runs the specified number of times and then stops. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 + * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 + * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 + * @version Egret 2.4 + * @platform Web,Native + */ + constructor(delay: number, repeatCount?: number); + /** + * @private + */ + private _delay; + /** + * @language en_US + * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
      + * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
      + * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 + * @version Egret 2.4 + * @platform Web,Native + */ + delay: number; + /** + * @language en_US + * The total number of times the timer is set to run. If the repeat count is set to 0, the timer continues indefinitely, + * until the stop() method is invoked or the program stops. If the repeat count is nonzero, the timer runs the specified + * number of times. If repeatCount is set to a total that is the same or less then currentCount the timer stops and will not fire again. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 设置的计时器运行总次数。如果重复计数设置为 0,则计时器将持续不断运行,或直至调用了 stop() 方法或节目停止。 + * 如果重复计数不为 0,则将运行计时器,运行次数为指定的次数。如果设置的 repeatCount 总数等于或小于 currentCount,则计时器将停止并且不会再次触发。 + * @version Egret 2.4 + * @platform Web,Native + */ + repeatCount: number; + /** + * @private + */ + private _currentCount; + /** + * @language en_US + * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 + * @version Egret 2.4 + * @platform Web,Native + */ + currentCount: number; + /** + * @private + */ + private _running; + /** + * @language en_US + * The timer's current state; true if the timer is running, otherwise false. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 + * @version Egret 2.4 + * @platform Web,Native + */ + running: boolean; + /** + * @language en_US + * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. + * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 + * @version Egret 2.4 + * @platform Web,Native + */ + reset(): void; + /** + * @language en_US + * Starts the timer, if it is not already running. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 如果计时器尚未运行,则启动计时器。 + * @version Egret 2.4 + * @platform Web,Native + */ + start(): void; + /** + * @language en_US + * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of + * repetitions, as set by the repeatCount property. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 + * @version Egret 2.4 + * @platform Web,Native + */ + stop(): void; + /** + * @private + */ + private updateInterval; + /** + * @private + */ + private lastCount; + /** + * @private + */ + private lastTimeStamp; + /** + * @private + * Ticker以60FPS频率刷新此方法 + */ + $update(timeStamp: number): boolean; + } } declare module egret { /** * @language en_US - * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. - * @param name {string} Name of the definition. - * @returns {boolean} Whether the public definition exists - * @example - * egret.hasDefinition("egret.DisplayObject") //return true + * Transfer number to color character string + * @param value {number} color value ,such as 0xffffff + * @returns {string} Color character string, for example, #ffffff. * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts + * @includeExample egret/utils/toColorString.ts */ /** * @language zh_CN - * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 - * @param name {string} 定义的名称。 - * @returns {boolean} 公共定义是否存在 - * @example - * egret.hasDefinition("egret.DisplayObject") //返回 true + * 转换数字为颜色字符串 + * @param value {number} 颜色值,例如 0xffffff + * @returns {string} 颜色字符串,例如"#ffffff"。 * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts + * @includeExample egret/utils/toColorString.ts */ - function hasDefinition(name: string): boolean; + function toColorString(value: number): string; } declare module egret { /** * @language en_US - * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance - * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. - * @param instance the instance to be checked. - * @param typeName the string value representing a specific class or interface. - * @returns A value of true if the object is a instance of the class or interface specified as the parameter. - * @example - *
      -     *     var instance = new egret.Sprite();
      -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
      -     * 
      - * @see egret.registerClass() + * The XMLNode class is the base class for all xml node. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 - * @param instance 要判断的实例。 - * @param typeName 类或接口的完全名称. - * @returns 返回true表示当前对象是指定类或接口的实例。 - * @example - *
      -     *     var instance = new egret.Sprite();
      -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
      -     * 
      - * @see egret.registerClass() + * XML节点基类 * @version Egret 2.4 * @platform Web,Native */ - function is(instance: any, typeName: string): boolean; -} -declare module egret { + interface XMLNode { + /** + * @language en_US + * a integer representing the type of the node, 1:XML,2:XMLAttribute,3:XMLText + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 节点类型,1:XML,2:XMLAttribute,3:XMLText + * @version Egret 2.4 + * @platform Web,Native + */ + nodeType: number; + /** + * @language en_US + * the parent node of this xml node. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 节点所属的父级节点 + * @version Egret 2.4 + * @platform Web,Native + */ + parent: XML; + } /** * @language en_US - * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
      - * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" + * The XML class contains properties for working with XML objects. * @version Egret 2.4 * @platform Web,Native + * @includeExample egret/utils/XML.ts */ /** * @language zh_CN - * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 + * XML 类包含用于处理 XML 对象的属性。 * @version Egret 2.4 * @platform Web,Native + * @includeExample egret/utils/XML.ts */ - function startTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare module egret { + interface XML extends XMLNode { + /** + * @language en_US + * the attributes of this xml node. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 当前节点上的属性列表 + * @version Egret 2.4 + * @platform Web,Native + */ + attributes: any; + /** + * @language en_US + * the children of the xml node. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 当前节点的子节点列表 + * @version Egret 2.4 + * @platform Web,Native + */ + children: XMLNode[]; + /** + * @language en_US + * the full name of this xml node. For example,the name of is "s:Button". + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 节点完整名称。例如节点 的 name 为:"s:Button" + * @version Egret 2.4 + * @platform Web,Native + */ + name: string; + /** + * @language en_US + * thie namesapce prefix of this xml node.For example,the prefix of is "s". + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 节点的命名空间前缀。例如节点 的 prefix 为:s + * @version Egret 2.4 + * @platform Web,Native + */ + prefix: string; + /** + * @language en_US + * the local name of this xml node. For example,the local name of is "Button". + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 节点的本地名称。例如节点 的 localName 为:Button + * @version Egret 2.4 + * @platform Web,Native + */ + localName: string; + /** + * @language en_US + * the namesapce uri of this xml node.For example,the namespace uri of is "http://ns.egret.com/eui". + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 节点的命名空间地址。例如节点 的 namespace 为: http://ns.egret.com/eui + * @version Egret 2.4 + * @platform Web,Native + */ + namespace: string; + } /** * @language en_US - * Stops the timer started by the egret.startTick() method. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" + * The XMLText class represents a string node in the XML. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 停止之前用 startTick() 方法启动的计时器。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 + * XMLText 类表示在XML中的文本节点 * @version Egret 2.4 * @platform Web,Native */ - function stopTick(callBack: (timeStamp: number) => boolean, thisObject: any): void; -} -declare module egret { + interface XMLText extends XMLNode { + /** + * @language en_US + * the text content + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 文本内容 + * @version Egret 2.4 + * @platform Web,Native + */ + text: string; + } /** * @language en_US - * Transfer number to color character string - * @param value {number} color value ,such as 0xffffff - * @returns {string} Color character string, for example, #ffffff. + * The XML class contains properties for working with XML objects. * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/toColorString.ts */ /** * @language zh_CN - * 转换数字为颜色字符串 - * @param value {number} 颜色值,例如 0xffffff - * @returns {string} 颜色字符串,例如"#ffffff"。 + * XML 类包含用于处理 XML 对象的属性。 * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/toColorString.ts */ - function toColorString(value: number): string; + var XML: { + /** + * @language en_US + * parses a text to XML instance. + * @param text the text to be parsed. + */ + /** + * @language zh_CN + * 解析字符串为XML对象 + * @param text 要解析的XML对象。 + */ + parse(text: string): XML; + }; } declare module egret { /** diff --git a/build/egret/egret.js b/build/egret/egret.js index 88a6cb98b2..5db8776350 100644 --- a/build/egret/egret.js +++ b/build/egret/egret.js @@ -1542,15 +1542,15 @@ var egret; * @private * 标记矩阵失效 */ - p.invalidateMatrix = function () { + p.$invalidateMatrix = function () { this.$setFlags(8 /* InvalidMatrix */); - this.invalidatePosition(); + this.$invalidatePosition(); }; /** * @private * 标记这个显示对象在父级容器的位置发生了改变。 */ - p.invalidatePosition = function () { + p.$invalidatePosition = function () { var self = this; self.$invalidateTransform(); self.$propagateFlagsDown(16 /* InvalidConcatenatedMatrix */ | @@ -1720,7 +1720,7 @@ var egret; values[4 /* rotation */] = clampRotation(values[3 /* skewY */] * 180 / Math.PI); } self.$removeFlags(8 /* InvalidMatrix */); - self.invalidatePosition(); + self.$invalidatePosition(); return true; }; /** @@ -1815,7 +1815,7 @@ var egret; return false; } m.tx = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; }; d(p, "y" @@ -1865,7 +1865,7 @@ var egret; return false; } m.ty = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; }; d(p, "scaleX" @@ -1911,7 +1911,7 @@ var egret; return false; } values[0 /* scaleX */] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; }; d(p, "scaleY" @@ -1955,7 +1955,7 @@ var egret; return false; } this.$DisplayObject[1 /* scaleY */] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; }; d(p, "rotation" @@ -2005,7 +2005,7 @@ var egret; values[2 /* skewX */] += angle; values[3 /* skewY */] += angle; values[4 /* rotation */] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; }; d(p, "skewX" @@ -2038,7 +2038,7 @@ var egret; value = clampRotation(value); value = value / 180 * Math.PI; values[2 /* skewX */] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; }; d(p, "skewY" @@ -2071,7 +2071,7 @@ var egret; value = clampRotation(value); value = value / 180 * Math.PI; values[3 /* skewY */] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; }; d(p, "width" @@ -2134,7 +2134,7 @@ var egret; // values[Keys.scaleY] = bounds.height / baseHeight; // values[Keys.scaleX] = value / baseWidth; // } - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; }; d(p, "height" @@ -2197,7 +2197,7 @@ var egret; // values[Keys.scaleY] = value / baseHeight; // values[Keys.scaleX] = bounds.width / baseWidth; // } - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; }; d(p, "measuredWidth" @@ -2264,7 +2264,7 @@ var egret; return false; } this.$DisplayObject[12 /* anchorOffsetX */] = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; }; d(p, "anchorOffsetY" @@ -2307,7 +2307,7 @@ var egret; return false; } this.$DisplayObject[13 /* anchorOffsetY */] = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; }; d(p, "visible" @@ -2592,7 +2592,7 @@ var egret; else { this.$scrollRect = null; } - this.invalidatePosition(); + this.$invalidatePosition(); return true; }; d(p, "blendMode" @@ -2710,7 +2710,7 @@ var egret; else { this.$maskRect = null; } - this.invalidatePosition(); + this.$invalidatePosition(); return true; }; d(p, "filters" @@ -13386,417 +13386,441 @@ var egret; // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// -/// var egret; (function (egret) { var sys; (function (sys) { /** * @private - * Egret播放器 + * 渲染节点基类 */ - var Player = (function (_super) { - __extends(Player, _super); - /** - * @private - * 实例化一个播放器对象。 - */ - function Player(buffer, stage, entryClassName) { - _super.call(this); + var RenderNode = (function () { + function RenderNode() { /** - * @private + * 节点类型.. */ - this.isPlaying = false; - if (DEBUG && !buffer) { - egret.$error(1003, "buffer"); - } - this.entryClassName = entryClassName; - this.stage = stage; - this.screenDisplayList = this.createDisplayList(stage, buffer); - this.showFPS = false; - this.showLog = false; - this._showPaintRect = false; - this.stageDisplayList = null; - this.paintList = []; - this.displayFPS = displayFPS; - this.showPaintRect = showPaintRect; - this.drawPaintRect = drawPaintRect; - this.drawDirtyRect = drawDirtyRect; + this.type = 0; + /** + * 是否需要重绘的标志。 + */ + this.needRedraw = false; + /** + * 这个对象在舞台上的整体透明度 + */ + this.renderAlpha = 1; + /** + * 这个对象在舞台上的透明度 + */ + this.renderVisible = true; + /** + * 相对于显示列表根节点或位图缓存根节点上的矩阵对象 + */ + this.renderMatrix = new egret.Matrix(); + /** + * 此显示对象自身(不包括子项)在显示列表根节点或位图缓存根节点上的显示尺寸。 + */ + this.renderRegion = new sys.Region(); + /** + * 是否发生移动 + */ + this.moved = false; + /** + * 绘制数据 + */ + this.drawData = []; + /** + * 绘制次数 + */ + this.renderCount = 0; } - var d = __define,c=Player,p=c.prototype; + var d = __define,c=RenderNode,p=c.prototype; /** - * @private + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 */ - p.createDisplayList = function (stage, buffer) { - var displayList = new sys.DisplayList(stage); - displayList.renderBuffer = buffer; - stage.$displayList = displayList; - //displayList.setClipRect(stage.$stageWidth, stage.$stageHeight); - return displayList; + p.cleanBeforeRender = function () { + this.drawData.length = 0; + this.renderCount = 0; }; - /** - * @private - * 启动播放器 - */ - p.start = function () { - if (this.isPlaying || !this.stage) { - return; - } - sys.$TempStage = sys.$TempStage || this.stage; - this.isPlaying = true; - if (!this.root) { - this.initialize(); - } - sys.$ticker.$addPlayer(this); + p.$getRenderCount = function () { + return this.renderCount; }; + return RenderNode; + }()); + sys.RenderNode = RenderNode; + egret.registerClass(RenderNode,'egret.sys.RenderNode'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var sys; + (function (sys) { + /** + * @private + * 位图渲染节点 + */ + var BitmapNode = (function (_super) { + __extends(BitmapNode, _super); + function BitmapNode() { + _super.call(this); + /** + * 要绘制的位图 + */ + this.image = null; + /** + * 控制在缩放时是否对位图进行平滑处理。 + */ + this.smoothing = true; + /** + * 使用的混合模式 + */ + this.blendMode = null; + this.type = 1 /* BitmapNode */; + } + var d = __define,c=BitmapNode,p=c.prototype; /** - * @private - * + * 绘制一次位图 */ - p.initialize = function () { - var rootClass; - if (this.entryClassName) { - rootClass = egret.getDefinitionByName(this.entryClassName); - } - if (rootClass) { - var rootContainer = new rootClass(); - this.root = rootContainer; - if (rootContainer instanceof egret.DisplayObject) { - this.stage.addChild(rootContainer); - } - else { - DEBUG && egret.$error(1002, this.entryClassName); - } - } - else { - DEBUG && egret.$error(1001, this.entryClassName); - } + p.drawImage = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { + this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); + this.renderCount++; }; /** - * @private - * 停止播放器,停止后将不能重新启动。 + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 */ - p.stop = function () { - this.pause(); - this.stage = null; + p.cleanBeforeRender = function () { + _super.prototype.cleanBeforeRender.call(this); + this.image = null; + this.matrix = null; }; - /** - * @private - * 暂停播放器,后续可以通过调用start()重新启动播放器。 - */ - p.pause = function () { - if (!this.isPlaying) { + BitmapNode.$updateTextureData = function (node, image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, scale9Grid, fillMode, smoothing) { + if (!image) { return; } - this.isPlaying = false; - sys.$ticker.$removePlayer(this); - }; - /** - * @private - * 渲染屏幕 - */ - p.$render = function (triggerByFrame, costTicker) { - if (this.showFPS || this.showLog) { - this.stage.addChild(this.fpsDisplay); + var scale = egret.$TextureScaleFactor; + node.smoothing = smoothing; + node.image = image; + node.imageWidth = sourceWidth; + node.imageHeight = sourceHeight; + if (scale9Grid) { + BitmapNode.$updateTextureDataWithScale9Grid(node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH); } - this.callLaters(); - this.callLaterAsyncs(); - var stage = this.stage; - var t = egret.getTimer(); - var dirtyList = stage.$displayList.updateDirtyRegions(); - var t1 = egret.getTimer(); - dirtyList = dirtyList.concat(); - var drawCalls = stage.$displayList.drawToSurface(); - if (this._showPaintRect) { - this.drawPaintRect(dirtyList); + else if (fillMode == egret.BitmapFillMode.SCALE) { + var tsX = destW / textureWidth; + var tsY = destH / textureHeight; + node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX * tsX, offsetY * tsY, tsX * bitmapWidth, tsY * bitmapHeight); } - var t2 = egret.getTimer(); - if (triggerByFrame && this.showFPS) { - var dirtyRatio = 0; - if (drawCalls > 0) { - var length = dirtyList.length; - var dirtyArea = 0; - for (var i = 0; i < length; i++) { - dirtyArea += dirtyList[i].area; + else if (fillMode == egret.BitmapFillMode.CLIP) { + var displayW = Math.min(textureWidth, destW); + var displayH = Math.min(textureHeight, destH); + var scaledBitmapW = bitmapWidth * scale; + var scaledBitmapH = bitmapHeight * scale; + BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH); + } + else { + var scaledBitmapW = bitmapWidth * scale; + var scaledBitmapH = bitmapHeight * scale; + for (var startX = 0; startX < destW; startX += textureWidth) { + for (var startY = 0; startY < destH; startY += textureHeight) { + var displayW = Math.min(destW - startX, textureWidth); + var displayH = Math.min(destH - startY, textureHeight); + BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH, startX, startY); } - dirtyRatio = Math.ceil(dirtyArea * 1000 / (stage.stageWidth * stage.stageHeight)) / 10; } - this.fpsDisplay.update(drawCalls, dirtyRatio, t1 - t, t2 - t1, costTicker); } }; /** * @private - * + * 绘制九宫格位图 */ - p.callLaters = function () { - if (egret.$callLaterFunctionList.length > 0) { - var functionList = egret.$callLaterFunctionList; - egret.$callLaterFunctionList = []; - var thisList = egret.$callLaterThisList; - egret.$callLaterThisList = []; - var argsList = egret.$callLaterArgsList; - egret.$callLaterArgsList = []; + BitmapNode.$updateTextureDataWithScale9Grid = function (node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH) { + var imageWidth = bitmapWidth; + var imageHeight = bitmapHeight; + destW = destW - (textureWidth - bitmapWidth * egret.$TextureScaleFactor); + destH = destH - (textureHeight - bitmapHeight * egret.$TextureScaleFactor); + var targetW0 = scale9Grid.x - offsetX; + var targetH0 = scale9Grid.y - offsetY; + var sourceW0 = targetW0 / egret.$TextureScaleFactor; + var sourceH0 = targetH0 / egret.$TextureScaleFactor; + var sourceW1 = scale9Grid.width / egret.$TextureScaleFactor; + var sourceH1 = scale9Grid.height / egret.$TextureScaleFactor; + //防止空心的情况出现。 + if (sourceH1 == 0) { + sourceH1 = 1; + if (sourceH0 >= imageHeight) { + sourceH0--; + } } - if (functionList) { - var length = functionList.length; - for (var i = 0; i < length; i++) { - var func = functionList[i]; - if (func != null) { - func.apply(thisList[i], argsList[i]); - } + if (sourceW1 == 0) { + sourceW1 = 1; + if (sourceW0 >= imageWidth) { + sourceW0--; } } + var sourceX0 = bitmapX; + var sourceX1 = sourceX0 + sourceW0; + var sourceX2 = sourceX1 + sourceW1; + var sourceW2 = imageWidth - sourceW0 - sourceW1; + var sourceY0 = bitmapY; + var sourceY1 = sourceY0 + sourceH0; + var sourceY2 = sourceY1 + sourceH1; + var sourceH2 = imageHeight - sourceH0 - sourceH1; + var targetW2 = sourceW2 * egret.$TextureScaleFactor; + var targetH2 = sourceH2 * egret.$TextureScaleFactor; + if ((sourceW0 + sourceW2) * egret.$TextureScaleFactor > destW || (sourceH0 + sourceH2) * egret.$TextureScaleFactor > destH) { + node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, destW, destH); + return; + } + var targetX0 = offsetX; + var targetX1 = targetX0 + targetW0; + var targetX2 = targetX0 + (destW - targetW2); + var targetW1 = destW - targetW0 - targetW2; + var targetY0 = offsetY; + var targetY1 = targetY0 + targetH0; + var targetY2 = targetY0 + destH - targetH2; + var targetH1 = destH - targetH0 - targetH2; + // + // x0 x1 x2 + // y0 +------+------+------+ + // | | | | h0 + // | | | | + // y1 +------+------+------+ + // | | | | h1 + // | | | | + // y2 +------+------+------+ + // | | | | h2 + // | | | | + // +------+------+------+ + // w0 w1 w2 + // + if (sourceH0 > 0) { + if (sourceW0 > 0) + node.drawImage(sourceX0, sourceY0, sourceW0, sourceH0, targetX0, targetY0, targetW0, targetH0); + if (sourceW1 > 0) + node.drawImage(sourceX1, sourceY0, sourceW1, sourceH0, targetX1, targetY0, targetW1, targetH0); + if (sourceW2 > 0) + node.drawImage(sourceX2, sourceY0, sourceW2, sourceH0, targetX2, targetY0, targetW2, targetH0); + } + if (sourceH1 > 0) { + if (sourceW0 > 0) + node.drawImage(sourceX0, sourceY1, sourceW0, sourceH1, targetX0, targetY1, targetW0, targetH1); + if (sourceW1 > 0) + node.drawImage(sourceX1, sourceY1, sourceW1, sourceH1, targetX1, targetY1, targetW1, targetH1); + if (sourceW2 > 0) + node.drawImage(sourceX2, sourceY1, sourceW2, sourceH1, targetX2, targetY1, targetW2, targetH1); + } + if (sourceH2 > 0) { + if (sourceW0 > 0) + node.drawImage(sourceX0, sourceY2, sourceW0, sourceH2, targetX0, targetY2, targetW0, targetH2); + if (sourceW1 > 0) + node.drawImage(sourceX1, sourceY2, sourceW1, sourceH2, targetX1, targetY2, targetW1, targetH2); + if (sourceW2 > 0) + node.drawImage(sourceX2, sourceY2, sourceW2, sourceH2, targetX2, targetY2, targetW2, targetH2); + } }; /** - * @private - * + * @private + */ + BitmapNode.drawClipImage = function (node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX, startY) { + if (startX === void 0) { startX = 0; } + if (startY === void 0) { startY = 0; } + var offset = offsetX + scaledBitmapW - destW; + if (offset > 0) { + scaledBitmapW -= offset; + } + offset = offsetY + scaledBitmapH - destH; + if (offset > 0) { + scaledBitmapH -= offset; + } + node.drawImage(bitmapX, bitmapY, scaledBitmapW / scale, scaledBitmapH / scale, startX + offsetX, startY + offsetY, scaledBitmapW, scaledBitmapH); + }; + return BitmapNode; + }(sys.RenderNode)); + sys.BitmapNode = BitmapNode; + egret.registerClass(BitmapNode,'egret.sys.BitmapNode'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var sys; + (function (sys) { + var CAPS_STYLES = ["none", "round", "square"]; + var JOINT_STYLES = ["bevel", "miter", "round"]; + /** + * @private + * 矢量渲染节点 + */ + var GraphicsNode = (function (_super) { + __extends(GraphicsNode, _super); + function GraphicsNode() { + _super.call(this); + /** + * 脏渲染标记 + * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D + */ + this.dirtyRender = true; + this.type = 3 /* GraphicsNode */; + } + var d = __define,c=GraphicsNode,p=c.prototype; + /** + * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 + * @param color 填充的颜色 + * @param alpha 填充的 Alpha 值 + * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 */ - p.callLaterAsyncs = function () { - if (egret.$callAsyncFunctionList.length > 0) { - var locCallAsyncFunctionList = egret.$callAsyncFunctionList; - var locCallAsyncThisList = egret.$callAsyncThisList; - var locCallAsyncArgsList = egret.$callAsyncArgsList; - egret.$callAsyncFunctionList = []; - egret.$callAsyncThisList = []; - egret.$callAsyncArgsList = []; - for (var i = 0; i < locCallAsyncFunctionList.length; i++) { - var func = locCallAsyncFunctionList[i]; - if (func != null) { - func.apply(locCallAsyncThisList[i], locCallAsyncArgsList[i]); - } - } + p.beginFill = function (color, alpha, beforePath) { + if (alpha === void 0) { alpha = 1; } + var path = new sys.FillPath(); + path.fillColor = color; + path.fillAlpha = alpha; + if (beforePath) { + var index = this.drawData.lastIndexOf(beforePath); + this.drawData.splice(index, 0, path); + } + else { + this.drawData.push(path); } + return path; }; /** - * @private - * 更新舞台尺寸 - * @param stageWidth 舞台宽度(以像素为单位) - * @param stageHeight 舞台高度(以像素为单位) + * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 + * 调用 clear() 方法会清除填充。 + * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 + * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 + * @param alphas colors 数组中对应颜色的 alpha 值数组。 + * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 + * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 + * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 */ - p.updateStageSize = function (stageWidth, stageHeight) { - var stage = this.stage; - //if (stageWidth !== stage.$stageWidth || stageHeight !== stage.$stageHeight) { - stage.$stageWidth = stageWidth; - stage.$stageHeight = stageHeight; - this.screenDisplayList.setClipRect(stageWidth, stageHeight); - if (this.stageDisplayList) { - this.stageDisplayList.setClipRect(stageWidth, stageHeight); + p.beginGradientFill = function (type, colors, alphas, ratios, matrix, beforePath) { + var m = new egret.Matrix(); + if (matrix) { + m.a = matrix.a * 819.2; + m.b = matrix.b * 819.2; + m.c = matrix.c * 819.2; + m.d = matrix.d * 819.2; + m.tx = matrix.tx; + m.ty = matrix.ty; } - stage.dispatchEventWith(egret.Event.RESIZE); - stage.$invalidate(true); - //} + else { + //默认值 + m.a = 100; + m.d = 100; + } + var path = new sys.GradientFillPath(); + path.gradientType = type; + path.colors = colors; + path.alphas = alphas; + path.ratios = ratios; + path.matrix = m; + if (beforePath) { + var index = this.drawData.lastIndexOf(beforePath); + this.drawData.splice(index, 0, path); + } + else { + this.drawData.push(path); + } + return path; }; - return Player; - }(egret.HashObject)); - sys.Player = Player; - egret.registerClass(Player,'egret.sys.Player'); - var infoLines = []; - var fpsDisplay; - var fpsStyle; - sys.$logToFPS = function (info) { - if (!fpsDisplay) { - infoLines.push(info); - return; - } - fpsDisplay.updateInfo(info); - }; - function displayFPS(showFPS, showLog, logFilter, styles) { - if (showLog) { - egret.log = function () { - var length = arguments.length; - var info = ""; - for (var i = 0; i < length; i++) { - info += arguments[i] + " "; - } - sys.$logToFPS(info); - console.log.apply(console, toArray(arguments)); - }; - } - fpsStyle = styles ? {} : styles; - showLog = !!showLog; - this.showFPS = !!showFPS; - this.showLog = showLog; - if (!this.fpsDisplay) { - var x = styles["x"] === undefined ? 0 : styles["x"]; - var y = styles["y"] === undefined ? 0 : styles["y"]; - fpsDisplay = this.fpsDisplay = new FPS(this.stage, showFPS, showLog, logFilter, styles); - fpsDisplay.x = x; - fpsDisplay.y = y; - var length = infoLines.length; - for (var i = 0; i < length; i++) { - fpsDisplay.updateInfo(infoLines[i]); - } - infoLines = null; - } - } - function showPaintRect(value) { - value = !!value; - if (this._showPaintRect == value) { - return; - } - this._showPaintRect = value; - if (value) { - if (!this.stageDisplayList) { - this.stageDisplayList = sys.DisplayList.create(this.stage); - } - this.stage.$displayList = this.stageDisplayList; - } - else { - this.stage.$displayList = this.screenDisplayList; - } - } - function drawPaintRect(dirtyList) { - var length = dirtyList.length; - var list = []; - for (var i = 0; i < length; i++) { - var region = dirtyList[i]; - list[i] = [region.minX, region.minY, region.width, region.height]; - region.width -= 1; - region.height -= 1; - } - var repaintList = this.paintList; - repaintList.push(list); - if (repaintList.length > 1) { - repaintList.shift(); - } - var renderBuffer = this.screenDisplayList.renderBuffer; - var context = renderBuffer.context; - context.setTransform(1, 0, 0, 1, 0, 0); - context.clearRect(0, 0, renderBuffer.surface.width, renderBuffer.surface.height); - context.drawImage(this.stageDisplayList.renderBuffer.surface, 0, 0); - length = repaintList.length; - for (i = 0; i < length; i++) { - list = repaintList[i]; - for (var j = list.length - 1; j >= 0; j--) { - var r = list[j]; - this.drawDirtyRect(r[0], r[1], r[2], r[3], context); - } - } - context.save(); - context.beginPath(); - var length = dirtyList.length; - for (var i = 0; i < length; i++) { - var region = dirtyList[i]; - context.clearRect(region.minX, region.minY, region.width, region.height); - context.rect(region.minX, region.minY, region.width, region.height); - } - context.clip(); - context.drawImage(this.stageDisplayList.renderBuffer.surface, 0, 0); - context.restore(); - } - /** - * 绘制一个脏矩形显示区域,在显示重绘区功能开启时调用。 - */ - function drawDirtyRect(x, y, width, height, context) { - context.strokeStyle = 'rgb(255,0,0)'; - context.lineWidth = 5; - context.strokeRect(x - 0.5, y - 0.5, width, height); - } - /** - * FPS显示对象 - */ - FPS = (function (_super) { - __extends(FPSImpl, _super); - function FPSImpl(stage, showFPS, showLog, logFilter, styles) { - _super.call(this); - this["isFPS"] = true; - this.infoLines = []; - this.totalTime = 0; - this.totalTick = 0; - this.lastTime = 0; - this.drawCalls = 0; - this.dirtyRatio = 0; - this.costDirty = 0; - this.costRender = 0; - this.costTicker = 0; - this._stage = stage; - this.showFPS = showFPS; - this.showLog = showLog; - this.logFilter = logFilter; - this.touchChildren = false; - this.touchEnabled = false; - this.styles = styles; - this.fpsDisplay = new egret.FPSDisplay(stage, showFPS, showLog, logFilter, styles); - this.addChild(this.fpsDisplay); - try { - var logFilterRegExp = logFilter ? new RegExp(logFilter) : null; - } - catch (e) { - egret.log(e); + /** + * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 + * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 + * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 + * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 + * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND + * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND + * @param miterLimit 用于表示剪切斜接的极限值的数字。 + */ + p.lineStyle = function (thickness, color, alpha, caps, joints, miterLimit) { + if (alpha === void 0) { alpha = 1; } + if (miterLimit === void 0) { miterLimit = 3; } + if (CAPS_STYLES.indexOf(caps) == -1) { + caps = "round"; } - this.filter = function (message) { - if (logFilterRegExp) - return logFilterRegExp.test(message); - return !logFilter || message.indexOf(logFilter) == 0; - }; - } - FPSImpl.prototype.update = function (drawCalls, dirtyRatio, costDirty, costRender, costTicker) { - var current = egret.getTimer(); - this.totalTime += current - this.lastTime; - this.lastTime = current; - this.totalTick++; - this.drawCalls += drawCalls; - this.dirtyRatio += dirtyRatio; - this.costDirty += costDirty; - this.costRender += costRender; - this.costTicker += costTicker; - if (this.totalTime >= 1000) { - var lastFPS = Math.min(Math.ceil(this.totalTick * 1000 / this.totalTime), sys.$ticker.$frameRate); - var lastDrawCalls = Math.round(this.drawCalls / this.totalTick); - var lastDirtyRatio = Math.round(this.dirtyRatio / this.totalTick); - var lastCostDirty = Math.round(this.costDirty / this.totalTick); - var lastCostRender = Math.round(this.costRender / this.totalTick); - var lastCostTicker = Math.round(this.costTicker / this.totalTick); - this.fpsDisplay.update({ - fps: lastFPS, - draw: lastDrawCalls, - dirty: lastDirtyRatio, - costTicker: lastCostTicker, - costDirty: lastCostDirty, - costRender: lastCostRender - }); - this.totalTick = 0; - this.totalTime = this.totalTime % 500; - this.drawCalls = 0; - this.dirtyRatio = 0; - this.costDirty = 0; - this.costRender = 0; - this.costTicker = 0; + if (JOINT_STYLES.indexOf(joints) == -1) { + joints = "round"; } + var path = new sys.StrokePath(); + path.lineWidth = thickness; + path.lineColor = color; + path.lineAlpha = alpha; + path.caps = caps || egret.CapsStyle.ROUND; + path.joints = joints; + path.miterLimit = miterLimit; + this.drawData.push(path); + return path; }; - FPSImpl.prototype.updateInfo = function (info) { - if (!info) { - return; - } - if (!this.showLog) { - return; - } - if (!this.filter(info)) { - return; - } - this.fpsDisplay.updateInfo(info); + /** + * 清空所有缓存的绘制数据 + */ + p.clear = function () { + this.drawData.length = 0; + this.dirtyRender = true; }; - return FPSImpl; - })(egret.Sprite); - function toArray(argument) { - var args = []; - for (var i = 0; i < argument.length; i++) { - args.push(argument[i]); - } - return args; - } - egret.warn = function () { - console.warn.apply(console, toArray(arguments)); - }; - egret.error = function () { - console.error.apply(console, toArray(arguments)); - }; - egret.assert = function () { - console.assert.apply(console, toArray(arguments)); - }; - egret.log = function () { - console.log.apply(console, toArray(arguments)); - }; + /** + * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 + */ + p.cleanBeforeRender = function () { + }; + return GraphicsNode; + }(sys.RenderNode)); + sys.GraphicsNode = GraphicsNode; + egret.registerClass(GraphicsNode,'egret.sys.GraphicsNode'); })(sys = egret.sys || (egret.sys = {})); })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// @@ -13827,23 +13851,65 @@ var egret; // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +var egret; +(function (egret) { + var sys; + (function (sys) { + /** + * @private + * 组渲染节点,用于组合多个渲染节点 + */ + var GroupNode = (function (_super) { + __extends(GroupNode, _super); + function GroupNode() { + _super.call(this); + this.type = 4 /* GroupNode */; + } + var d = __define,c=GroupNode,p=c.prototype; + p.addNode = function (node) { + this.drawData.push(node); + }; + /** + * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 + * 这里只是想清空绘制命令,因此不调用super + */ + p.cleanBeforeRender = function () { + var data = this.drawData; + for (var i = data.length - 1; i >= 0; i--) { + data[i].cleanBeforeRender(); + } + }; + p.$getRenderCount = function () { + var result = 0; + var data = this.drawData; + for (var i = data.length - 1; i >= 0; i--) { + result += data[i].$getRenderCount(); + } + return result; + }; + return GroupNode; + }(sys.RenderNode)); + sys.GroupNode = GroupNode; + egret.registerClass(GroupNode,'egret.sys.GroupNode'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. // IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, @@ -13859,287 +13925,111 @@ var egret; (function (egret) { var sys; (function (sys) { - var regionPool = []; /** * @private + * Mesh 渲染节点 */ - var Region = (function () { - function Region() { - /** - * @private - */ - this.minX = 0; - /** - * @private - */ - this.minY = 0; - /** - * @private - */ - this.maxX = 0; - /** - * @private - */ - this.maxY = 0; - /** - * @private - */ - this.width = 0; + var MeshNode = (function (_super) { + __extends(MeshNode, _super); + function MeshNode() { + _super.call(this); /** - * @private + * 要绘制的位图 */ - this.height = 0; + this.image = null; /** - * @private + * 控制在缩放时是否对位图进行平滑处理。 */ - this.area = 0; + this.smoothing = true; /** - * @private - * 是否发生移动 + * 顶点索引。 */ - this.moved = false; + this.bounds = new egret.Rectangle(); + this.type = 7 /* MeshNode */; + this.vertices = []; + this.uvs = []; + this.indices = []; } - var d = __define,c=Region,p=c.prototype; - /** - * @private - * 释放一个Region实例到对象池 - */ - Region.release = function (region) { - regionPool.push(region); - }; - /** - * @private - * 从对象池中取出或创建一个新的Region对象。 - * 建议对于一次性使用的对象,均使用此方法创建,而不是直接new一个。 - * 使用完后调用对应的release()静态方法回收对象,能有效减少对象创建数量造成的性能开销。 - */ - Region.create = function () { - var region = regionPool.pop(); - if (!region) { - region = new Region(); - } - return region; - }; - /** - * @private - */ - p.setTo = function (minX, minY, maxX, maxY) { - this.minX = minX; - this.minY = minY; - this.maxX = maxX; - this.maxY = maxY; - this.updateArea(); - return this; - }; + var d = __define,c=MeshNode,p=c.prototype; + ; /** - * @private - * 把所有值都取整 + * 绘制一次位图 */ - p.intValues = function () { - this.minX = Math.floor(this.minX); - this.minY = Math.floor(this.minY); - this.maxX = Math.ceil(this.maxX); - this.maxY = Math.ceil(this.maxY); - this.updateArea(); + p.drawMesh = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { + this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); + this.renderCount++; }; /** - * @private + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 */ - p.updateArea = function () { - this.width = this.maxX - this.minX; - this.height = this.maxY - this.minY; - this.area = this.width * this.height; + p.cleanBeforeRender = function () { + _super.prototype.cleanBeforeRender.call(this); + this.image = null; + this.matrix = null; }; + return MeshNode; + }(sys.RenderNode)); + sys.MeshNode = MeshNode; + egret.registerClass(MeshNode,'egret.sys.MeshNode'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var sys; + (function (sys) { + /** + * @private + * 位图渲染节点 + */ + var SetAlphaNode = (function (_super) { + __extends(SetAlphaNode, _super); + function SetAlphaNode() { + _super.call(this); + this.type = 6 /* SetAlphaNode */; + } + var d = __define,c=SetAlphaNode,p=c.prototype; /** - * @private - * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 + * 绘制一次位图 */ - p.union = function (target) { - if (this.minX > target.minX) { - this.minX = target.minX; - } - if (this.minY > target.minY) { - this.minY = target.minY; - } - if (this.maxX < target.maxX) { - this.maxX = target.maxX; - } - if (this.maxY < target.maxY) { - this.maxY = target.maxY; + p.setAlpha = function (alpha) { + if (this.drawData.length != 0) { + this.drawData.length = 0; } - this.updateArea(); + this.drawData.push(alpha); + this.renderCount++; }; - /** - * @private - * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 - */ - p.intersect = function (target) { - if (this.minX < target.minX) { - this.minX = target.minX; - } - if (this.maxX > target.maxX) { - this.maxX = target.maxX; - } - if (this.minX >= this.maxX) { - this.setEmpty(); - return; - } - if (this.minY < target.minY) { - this.minY = target.minY; - } - if (this.maxY > target.maxY) { - this.maxY = target.maxY; - } - if (this.minY >= this.maxY) { - this.setEmpty(); - return; - } - this.updateArea(); - }; - /** - * @private - */ - p.setEmpty = function () { - this.minX = 0; - this.minY = 0; - this.maxX = 0; - this.maxY = 0; - this.width = 0; - this.height = 0; - this.area = 0; - }; - /** - * @private - * 确定此 Region 对象是否为空。 - */ - p.isEmpty = function () { - return this.width <= 0 || this.height <= 0; - }; - /** - * @private - */ - p.intersects = function (target) { - if (this.isEmpty()) { - return false; - } - var max = this.minX > target.minX ? this.minX : target.minX; - var min = this.maxX < target.maxX ? this.maxX : target.maxX; - if (max > min) { - return false; - } - max = this.minY > target.minY ? this.minY : target.minY; - min = this.maxY < target.maxY ? this.maxY : target.maxY; - return max <= min; - }; - /** - * @private - */ - p.updateRegion = function (bounds, matrix) { - if (bounds.width == 0 || bounds.height == 0) { - //todo 理论上应该是空 - this.setEmpty(); - return; - } - var m = matrix; - var a = m.a; - var b = m.b; - var c = m.c; - var d = m.d; - var tx = m.tx; - var ty = m.ty; - var x = bounds.x; - var y = bounds.y; - var xMax = x + bounds.width; - var yMax = y + bounds.height; - var minX, minY, maxX, maxY; - //优化,通常情况下不缩放旋转的对象占多数,直接加上偏移量即可。 - if (a == 1.0 && b == 0.0 && c == 0.0 && d == 1.0) { - minX = x + tx - 1; - minY = y + ty - 1; - maxX = xMax + tx + 1; - maxY = yMax + ty + 1; - } - else { - var x0 = a * x + c * y + tx; - var y0 = b * x + d * y + ty; - var x1 = a * xMax + c * y + tx; - var y1 = b * xMax + d * y + ty; - var x2 = a * xMax + c * yMax + tx; - var y2 = b * xMax + d * yMax + ty; - var x3 = a * x + c * yMax + tx; - var y3 = b * x + d * yMax + ty; - var tmp = 0; - if (x0 > x1) { - tmp = x0; - x0 = x1; - x1 = tmp; - } - if (x2 > x3) { - tmp = x2; - x2 = x3; - x3 = tmp; - } - minX = (x0 < x2 ? x0 : x2) - 1; - maxX = (x1 > x3 ? x1 : x3) + 1; - if (y0 > y1) { - tmp = y0; - y0 = y1; - y1 = tmp; - } - if (y2 > y3) { - tmp = y2; - y2 = y3; - y3 = tmp; - } - minY = (y0 < y2 ? y0 : y2) - 1; - maxY = (y1 > y3 ? y1 : y3) + 1; - } - this.minX = minX; - this.minY = minY; - this.maxX = maxX; - this.maxY = maxY; - this.width = maxX - minX; - this.height = maxY - minY; - this.area = this.width * this.height; - }; - return Region; - }()); - sys.Region = Region; - egret.registerClass(Region,'egret.sys.Region'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { + return SetAlphaNode; + }(sys.RenderNode)); + sys.SetAlphaNode = SetAlphaNode; + egret.registerClass(SetAlphaNode,'egret.sys.SetAlphaNode'); })(sys = egret.sys || (egret.sys = {})); })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// @@ -14198,6 +14088,73 @@ var egret; // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var sys; + (function (sys) { + /** + * @private + * 文本渲染节点 + */ + var TextNode = (function (_super) { + __extends(TextNode, _super); + function TextNode() { + _super.call(this); + /** + * 颜色值 + */ + this.textColor = 0xFFFFFF; + /** + * 描边颜色值 + */ + this.strokeColor = 0x000000; + /** + * 字号 + */ + this.size = 30; + /** + * 描边大小 + */ + this.stroke = 0; + /** + * 是否加粗 + */ + this.bold = false; + /** + * 是否倾斜 + */ + this.italic = false; + /** + * 字体名称 + */ + this.fontFamily = "Arial"; + /** + * 脏渲染标记 + */ + this.dirtyRender = true; + this.type = 2 /* TextNode */; + } + var d = __define,c=TextNode,p=c.prototype; + /** + * 绘制一行文本 + */ + p.drawText = function (x, y, text, format) { + this.drawData.push(x, y, text, format); + this.renderCount++; + this.dirtyRender = true; + }; + /** + * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 + */ + p.cleanBeforeRender = function () { + _super.prototype.cleanBeforeRender.call(this); + }; + return TextNode; + }(sys.RenderNode)); + sys.TextNode = TextNode; + egret.registerClass(TextNode,'egret.sys.TextNode'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. @@ -14232,1554 +14189,24 @@ var egret; (function (sys) { /** * @private - * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 + * 2D路径 */ - var DefaultScreenAdapter = (function (_super) { - __extends(DefaultScreenAdapter, _super); - /** - * @private - */ - function DefaultScreenAdapter() { - _super.call(this); + var Path2D = (function () { + function Path2D() { + /** + * 路径类型 + */ + this.type = 0; + this.$commands = []; + this.$data = []; + this.commandPosition = 0; + this.dataPosition = 0; } - var d = __define,c=DefaultScreenAdapter,p=c.prototype; + var d = __define,c=Path2D,p=c.prototype; /** - * @private - * 计算舞台显示尺寸 - * @param scaleMode 当前的缩放模式 - * @param screenWidth 播放器视口宽度 - * @param screenHeight 播放器视口高度 - * @param contentWidth 初始化内容宽度 - * @param contentHeight 初始化内容高度 - */ - p.calculateStageSize = function (scaleMode, screenWidth, screenHeight, contentWidth, contentHeight) { - var displayWidth = screenWidth; - var displayHeight = screenHeight; - var stageWidth = contentWidth; - var stageHeight = contentHeight; - var scaleX = (screenWidth / stageWidth) || 0; - var scaleY = (screenHeight / stageHeight) || 0; - switch (scaleMode) { - case egret.StageScaleMode.EXACT_FIT: - break; - case egret.StageScaleMode.FIXED_HEIGHT: - stageWidth = Math.round(screenWidth / scaleY); - break; - case egret.StageScaleMode.FIXED_WIDTH: - stageHeight = Math.round(screenHeight / scaleX); - break; - case egret.StageScaleMode.NO_BORDER: - if (scaleX > scaleY) { - displayHeight = Math.round(stageHeight * scaleX); - } - else { - displayWidth = Math.round(stageWidth * scaleY); - } - break; - case egret.StageScaleMode.SHOW_ALL: - if (scaleX > scaleY) { - displayWidth = Math.round(stageWidth * scaleY); - } - else { - displayHeight = Math.round(stageHeight * scaleX); - } - break; - case egret.StageScaleMode.FIXED_NARROW: - if (scaleX > scaleY) { - stageWidth = Math.round(screenWidth / scaleY); - } - else { - stageHeight = Math.round(screenHeight / scaleX); - } - break; - case egret.StageScaleMode.FIXED_WIDE: - if (scaleX > scaleY) { - stageHeight = Math.round(screenHeight / scaleX); - } - else { - stageWidth = Math.round(screenWidth / scaleY); - } - break; - default: - stageWidth = screenWidth; - stageHeight = screenHeight; - break; - } - //宽高不是2的整数倍会导致图片绘制出现问题 - if (displayWidth % 2 != 0) { - displayWidth += 1; - } - if (displayHeight % 2 != 0) { - displayHeight += 1; - } - return { - stageWidth: stageWidth, - stageHeight: stageHeight, - displayWidth: displayWidth, - displayHeight: displayHeight - }; - }; - return DefaultScreenAdapter; - }(egret.HashObject)); - sys.DefaultScreenAdapter = DefaultScreenAdapter; - egret.registerClass(DefaultScreenAdapter,'egret.sys.DefaultScreenAdapter',["egret.sys.IScreenAdapter"]); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * StageScaleMode class provides values for the stage zoom mode. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - */ - /** - * @language zh_CN - * StageScaleMode 类为舞台缩放模式提供值。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/player/StageScaleMode.ts - */ - var StageScaleMode = (function () { - function StageScaleMode() { - } - var d = __define,c=StageScaleMode,p=c.prototype; - /** - * @language en_US - * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
      - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. - */ - /** - * @language zh_CN - * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
      - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 - */ - StageScaleMode.NO_SCALE = "noScale"; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
      - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
      - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - */ - StageScaleMode.SHOW_ALL = "showAll"; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
      - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
      - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - */ - StageScaleMode.NO_BORDER = "noBorder"; - /** - * @language en_US - * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
      - * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. - */ - /** - * @language zh_CN - * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
      - * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 - */ - StageScaleMode.EXACT_FIT = "exactFit"; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
      - * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
      - * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 - */ - StageScaleMode.FIXED_WIDTH = "fixedWidth"; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
      - * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
      - * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 - */ - StageScaleMode.FIXED_HEIGHT = "fixedHeight"; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
      - * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
      - * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - */ - StageScaleMode.FIXED_NARROW = "fixedNarrow"; - /** - * @language en_US - * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
      - * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. - */ - /** - * @language zh_CN - * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
      - * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 - */ - StageScaleMode.FIXED_WIDE = "fixedWide"; - return StageScaleMode; - }()); - egret.StageScaleMode = StageScaleMode; - egret.registerClass(StageScaleMode,'egret.StageScaleMode'); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - */ - sys.$START_TIME = 0; - /** - * @private - * 是否要广播Event.RENDER事件的标志。 - */ - sys.$invalidateRenderFlag = false; - /** - * @private - * 需要立即刷新屏幕的标志 - */ - sys.$requestRenderingFlag = false; - /** - * @private - * Egret心跳计时器 - */ - var SystemTicker = (function () { - /** - * @private - */ - function SystemTicker() { - /** - * @private - */ - this.playerList = []; - /** - * @private - */ - this.callBackList = []; - /** - * @private - */ - this.thisObjectList = []; - /** - * @private - * 全局帧率 - */ - this.$frameRate = 30; - /** - * @private - */ - this.frameInterval = 2000; - /** - * @private - */ - this.lastCount = 2000; - /** - * @private - * ticker 花销的时间 - */ - this.costEnterFrame = 0; - if (DEBUG && sys.$ticker) { - egret.$error(1008, "egret.sys.SystemTicker"); - } - sys.$START_TIME = Date.now(); - } - var d = __define,c=SystemTicker,p=c.prototype; - /** - * @private - * 注册一个播放器实例并运行 - */ - p.$addPlayer = function (player) { - if (this.playerList.indexOf(player) != -1) { - return; - } - if (DEBUG) { - egret_stages.push(player.stage); - } - this.playerList = this.playerList.concat(); - this.playerList.push(player); - }; - /** - * @private - * 停止一个播放器实例的运行。 - */ - p.$removePlayer = function (player) { - var index = this.playerList.indexOf(player); - if (index !== -1) { - if (DEBUG) { - var i = egret_stages.indexOf(player.stage); - egret_stages.splice(i, 1); - } - this.playerList = this.playerList.concat(); - this.playerList.splice(index, 1); - } - }; - /** - * @private - */ - p.$startTick = function (callBack, thisObject) { - var index = this.getTickIndex(callBack, thisObject); - if (index != -1) { - return; - } - this.concatTick(); - this.callBackList.push(callBack); - this.thisObjectList.push(thisObject); - }; - /** - * @private - */ - p.$stopTick = function (callBack, thisObject) { - var index = this.getTickIndex(callBack, thisObject); - if (index == -1) { - return; - } - this.concatTick(); - this.callBackList.splice(index, 1); - this.thisObjectList.splice(index, 1); - }; - /** - * @private - */ - p.getTickIndex = function (callBack, thisObject) { - var callBackList = this.callBackList; - var thisObjectList = this.thisObjectList; - for (var i = callBackList.length - 1; i >= 0; i--) { - if (callBackList[i] == callBack && - thisObjectList[i] == thisObject) { - return i; - } - } - return -1; - }; - /** - * @private - * - */ - p.concatTick = function () { - this.callBackList = this.callBackList.concat(); - this.thisObjectList = this.thisObjectList.concat(); - }; - /** - * @private - * 设置全局帧率 - */ - p.$setFrameRate = function (value) { - value = +value || 0; - if (value <= 0) { - return false; - } - if (this.$frameRate == value) { - return false; - } - this.$frameRate = value; - if (value > 60) { - value = 60; - } - //todo - if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) { - egret_native.setFrameRate(value); - value = 60; - } - //这里用60*1000来避免浮点数计算不准确的问题。 - this.lastCount = this.frameInterval = Math.round(60000 / value); - return true; - }; - /** - * @private - * 执行一次刷新 - */ - p.update = function () { - var t1 = egret.getTimer(); - var callBackList = this.callBackList; - var thisObjectList = this.thisObjectList; - var length = callBackList.length; - var requestRenderingFlag = sys.$requestRenderingFlag; - var timeStamp = egret.getTimer(); - for (var i = 0; i < length; i++) { - if (callBackList[i].call(thisObjectList[i], timeStamp)) { - requestRenderingFlag = true; - } - } - this.lastCount -= 1000; - var t2 = egret.getTimer(); - if (this.lastCount > 0) { - if (requestRenderingFlag) { - this.render(false, this.costEnterFrame + t2 - t1); - } - return; - } - this.lastCount += this.frameInterval; - this.render(true, this.costEnterFrame + t2 - t1); - var t3 = egret.getTimer(); - this.broadcastEnterFrame(); - var t4 = egret.getTimer(); - this.costEnterFrame = t4 - t3; - }; - /** - * @private - * 执行一次屏幕渲染 - */ - p.render = function (triggerByFrame, costTicker) { - var playerList = this.playerList; - var length = playerList.length; - if (length == 0) { - return; - } - if (sys.$invalidateRenderFlag) { - this.broadcastRender(); - sys.$invalidateRenderFlag = false; - } - for (var i = 0; i < length; i++) { - playerList[i].$render(triggerByFrame, costTicker); - } - sys.$requestRenderingFlag = false; - }; - /** - * @private - * 广播EnterFrame事件。 - */ - p.broadcastEnterFrame = function () { - var list = egret.DisplayObject.$enterFrameCallBackList; - var length = list.length; - if (length == 0) { - return; - } - list = list.concat(); - for (var i = 0; i < length; i++) { - list[i].dispatchEventWith(egret.Event.ENTER_FRAME); - } - }; - /** - * @private - * 广播Render事件。 - */ - p.broadcastRender = function () { - var list = egret.DisplayObject.$renderCallBackList; - var length = list.length; - if (length == 0) { - return; - } - list = list.concat(); - for (var i = 0; i < length; i++) { - list[i].dispatchEventWith(egret.Event.RENDER); - } - }; - return SystemTicker; - }()); - sys.SystemTicker = SystemTicker; - egret.registerClass(SystemTicker,'egret.sys.SystemTicker'); - /** - * @private - * 心跳计时器单例 - */ - sys.$ticker = new sys.SystemTicker(); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -if (DEBUG) { - var egret_stages = []; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 用户交互操作管理器 - */ - var TouchHandler = (function (_super) { - __extends(TouchHandler, _super); - /** - * @private - */ - function TouchHandler(stage) { - _super.call(this); - this.maxTouches = 0; - this.useTouchesCount = 0; - /** - * @private - */ - this.touchDownTarget = {}; - /** - * @private - */ - this.lastTouchX = -1; - /** - * @private - */ - this.lastTouchY = -1; - this.stage = stage; - } - var d = __define,c=TouchHandler,p=c.prototype; - /** - * @private - * 设置同时触摸数量 - */ - p.$initMaxTouches = function () { - this.maxTouches = this.stage.$maxTouches; - }; - /** - * @private - * 触摸开始(按下) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - p.onTouchBegin = function (x, y, touchPointID) { - if (this.useTouchesCount >= this.maxTouches) { - return; - } - this.lastTouchX = x; - this.lastTouchY = y; - var target = this.findTarget(x, y); - if (this.touchDownTarget[touchPointID] == null) { - this.touchDownTarget[touchPointID] = target; - this.useTouchesCount++; - } - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_BEGIN, true, true, x, y, touchPointID, true); - }; - /** - * @private - * 触摸移动 - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - p.onTouchMove = function (x, y, touchPointID) { - if (this.touchDownTarget[touchPointID] == null) { - return; - } - if (this.lastTouchX == x && this.lastTouchY == y) { - return; - } - this.lastTouchX = x; - this.lastTouchY = y; - var target = this.findTarget(x, y); - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_MOVE, true, true, x, y, touchPointID, true); - }; - /** - * @private - * 触摸结束(弹起) - * @param x 事件发生处相对于舞台的坐标x - * @param y 事件发生处相对于舞台的坐标y - * @param touchPointID 分配给触摸点的唯一标识号 - */ - p.onTouchEnd = function (x, y, touchPointID) { - if (this.touchDownTarget[touchPointID] == null) { - return; - } - var target = this.findTarget(x, y); - var oldTarget = this.touchDownTarget[touchPointID]; - delete this.touchDownTarget[touchPointID]; - this.useTouchesCount--; - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_END, true, true, x, y, touchPointID, false); - if (oldTarget == target) { - egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_TAP, true, true, x, y, touchPointID, false); - } - else { - egret.TouchEvent.dispatchTouchEvent(oldTarget, egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, true, true, x, y, touchPointID, false); - } - }; - /** - * @private - * 获取舞台坐标下的触摸对象 - */ - p.findTarget = function (stageX, stageY) { - var target = this.stage.$hitTest(stageX, stageY); - if (!target) { - target = this.stage; - } - return target; - }; - return TouchHandler; - }(egret.HashObject)); - sys.TouchHandler = TouchHandler; - egret.registerClass(TouchHandler,'egret.sys.TouchHandler'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 渲染节点基类 - */ - var RenderNode = (function () { - function RenderNode() { - /** - * 节点类型.. - */ - this.type = 0; - /** - * 是否需要重绘的标志。 - */ - this.needRedraw = false; - /** - * 这个对象在舞台上的整体透明度 - */ - this.renderAlpha = 1; - /** - * 这个对象在舞台上的透明度 - */ - this.renderVisible = true; - /** - * 相对于显示列表根节点或位图缓存根节点上的矩阵对象 - */ - this.renderMatrix = new egret.Matrix(); - /** - * 此显示对象自身(不包括子项)在显示列表根节点或位图缓存根节点上的显示尺寸。 - */ - this.renderRegion = new sys.Region(); - /** - * 是否发生移动 - */ - this.moved = false; - /** - * 绘制数据 - */ - this.drawData = []; - /** - * 绘制次数 - */ - this.renderCount = 0; - } - var d = __define,c=RenderNode,p=c.prototype; - /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 - */ - p.cleanBeforeRender = function () { - this.drawData.length = 0; - this.renderCount = 0; - }; - p.$getRenderCount = function () { - return this.renderCount; - }; - return RenderNode; - }()); - sys.RenderNode = RenderNode; - egret.registerClass(RenderNode,'egret.sys.RenderNode'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 位图渲染节点 - */ - var BitmapNode = (function (_super) { - __extends(BitmapNode, _super); - function BitmapNode() { - _super.call(this); - /** - * 要绘制的位图 - */ - this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - this.smoothing = true; - /** - * 使用的混合模式 - */ - this.blendMode = null; - this.type = 1 /* BitmapNode */; - } - var d = __define,c=BitmapNode,p=c.prototype; - /** - * 绘制一次位图 - */ - p.drawImage = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); - this.renderCount++; - }; - /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 - */ - p.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - this.matrix = null; - }; - BitmapNode.$updateTextureData = function (node, image, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH, sourceWidth, sourceHeight, scale9Grid, fillMode, smoothing) { - if (!image) { - return; - } - var scale = egret.$TextureScaleFactor; - node.smoothing = smoothing; - node.image = image; - node.imageWidth = sourceWidth; - node.imageHeight = sourceHeight; - if (scale9Grid) { - BitmapNode.$updateTextureDataWithScale9Grid(node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH); - } - else if (fillMode == egret.BitmapFillMode.SCALE) { - var tsX = destW / textureWidth; - var tsY = destH / textureHeight; - node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX * tsX, offsetY * tsY, tsX * bitmapWidth, tsY * bitmapHeight); - } - else if (fillMode == egret.BitmapFillMode.CLIP) { - var displayW = Math.min(textureWidth, destW); - var displayH = Math.min(textureHeight, destH); - var scaledBitmapW = bitmapWidth * scale; - var scaledBitmapH = bitmapHeight * scale; - BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH); - } - else { - var scaledBitmapW = bitmapWidth * scale; - var scaledBitmapH = bitmapHeight * scale; - for (var startX = 0; startX < destW; startX += textureWidth) { - for (var startY = 0; startY < destH; startY += textureHeight) { - var displayW = Math.min(destW - startX, textureWidth); - var displayH = Math.min(destH - startY, textureHeight); - BitmapNode.drawClipImage(node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, displayW, displayH, startX, startY); - } - } - } - }; - /** - * @private - * 绘制九宫格位图 - */ - BitmapNode.$updateTextureDataWithScale9Grid = function (node, scale9Grid, bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, textureWidth, textureHeight, destW, destH) { - var imageWidth = bitmapWidth; - var imageHeight = bitmapHeight; - destW = destW - (textureWidth - bitmapWidth * egret.$TextureScaleFactor); - destH = destH - (textureHeight - bitmapHeight * egret.$TextureScaleFactor); - var targetW0 = scale9Grid.x - offsetX; - var targetH0 = scale9Grid.y - offsetY; - var sourceW0 = targetW0 / egret.$TextureScaleFactor; - var sourceH0 = targetH0 / egret.$TextureScaleFactor; - var sourceW1 = scale9Grid.width / egret.$TextureScaleFactor; - var sourceH1 = scale9Grid.height / egret.$TextureScaleFactor; - //防止空心的情况出现。 - if (sourceH1 == 0) { - sourceH1 = 1; - if (sourceH0 >= imageHeight) { - sourceH0--; - } - } - if (sourceW1 == 0) { - sourceW1 = 1; - if (sourceW0 >= imageWidth) { - sourceW0--; - } - } - var sourceX0 = bitmapX; - var sourceX1 = sourceX0 + sourceW0; - var sourceX2 = sourceX1 + sourceW1; - var sourceW2 = imageWidth - sourceW0 - sourceW1; - var sourceY0 = bitmapY; - var sourceY1 = sourceY0 + sourceH0; - var sourceY2 = sourceY1 + sourceH1; - var sourceH2 = imageHeight - sourceH0 - sourceH1; - var targetW2 = sourceW2 * egret.$TextureScaleFactor; - var targetH2 = sourceH2 * egret.$TextureScaleFactor; - if ((sourceW0 + sourceW2) * egret.$TextureScaleFactor > destW || (sourceH0 + sourceH2) * egret.$TextureScaleFactor > destH) { - node.drawImage(bitmapX, bitmapY, bitmapWidth, bitmapHeight, offsetX, offsetY, destW, destH); - return; - } - var targetX0 = offsetX; - var targetX1 = targetX0 + targetW0; - var targetX2 = targetX0 + (destW - targetW2); - var targetW1 = destW - targetW0 - targetW2; - var targetY0 = offsetY; - var targetY1 = targetY0 + targetH0; - var targetY2 = targetY0 + destH - targetH2; - var targetH1 = destH - targetH0 - targetH2; - // - // x0 x1 x2 - // y0 +------+------+------+ - // | | | | h0 - // | | | | - // y1 +------+------+------+ - // | | | | h1 - // | | | | - // y2 +------+------+------+ - // | | | | h2 - // | | | | - // +------+------+------+ - // w0 w1 w2 - // - if (sourceH0 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY0, sourceW0, sourceH0, targetX0, targetY0, targetW0, targetH0); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY0, sourceW1, sourceH0, targetX1, targetY0, targetW1, targetH0); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY0, sourceW2, sourceH0, targetX2, targetY0, targetW2, targetH0); - } - if (sourceH1 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY1, sourceW0, sourceH1, targetX0, targetY1, targetW0, targetH1); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY1, sourceW1, sourceH1, targetX1, targetY1, targetW1, targetH1); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY1, sourceW2, sourceH1, targetX2, targetY1, targetW2, targetH1); - } - if (sourceH2 > 0) { - if (sourceW0 > 0) - node.drawImage(sourceX0, sourceY2, sourceW0, sourceH2, targetX0, targetY2, targetW0, targetH2); - if (sourceW1 > 0) - node.drawImage(sourceX1, sourceY2, sourceW1, sourceH2, targetX1, targetY2, targetW1, targetH2); - if (sourceW2 > 0) - node.drawImage(sourceX2, sourceY2, sourceW2, sourceH2, targetX2, targetY2, targetW2, targetH2); - } - }; - /** - * @private - */ - BitmapNode.drawClipImage = function (node, scale, bitmapX, bitmapY, scaledBitmapW, scaledBitmapH, offsetX, offsetY, destW, destH, startX, startY) { - if (startX === void 0) { startX = 0; } - if (startY === void 0) { startY = 0; } - var offset = offsetX + scaledBitmapW - destW; - if (offset > 0) { - scaledBitmapW -= offset; - } - offset = offsetY + scaledBitmapH - destH; - if (offset > 0) { - scaledBitmapH -= offset; - } - node.drawImage(bitmapX, bitmapY, scaledBitmapW / scale, scaledBitmapH / scale, startX + offsetX, startY + offsetY, scaledBitmapW, scaledBitmapH); - }; - return BitmapNode; - }(sys.RenderNode)); - sys.BitmapNode = BitmapNode; - egret.registerClass(BitmapNode,'egret.sys.BitmapNode'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - var CAPS_STYLES = ["none", "round", "square"]; - var JOINT_STYLES = ["bevel", "miter", "round"]; - /** - * @private - * 矢量渲染节点 - */ - var GraphicsNode = (function (_super) { - __extends(GraphicsNode, _super); - function GraphicsNode() { - _super.call(this); - /** - * 脏渲染标记 - * 暂时调用lineStyle,beginFill,beginGradientFill标记,实际应该draw时候标记在Path2D - */ - this.dirtyRender = true; - this.type = 3 /* GraphicsNode */; - } - var d = __define,c=GraphicsNode,p=c.prototype; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * @param color 填充的颜色 - * @param alpha 填充的 Alpha 值 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - p.beginFill = function (color, alpha, beforePath) { - if (alpha === void 0) { alpha = 1; } - var path = new sys.FillPath(); - path.fillColor = color; - path.fillAlpha = alpha; - if (beforePath) { - var index = this.drawData.lastIndexOf(beforePath); - this.drawData.splice(index, 0, path); - } - else { - this.drawData.push(path); - } - return path; - }; - /** - * 指定一种简单的单一颜色填充,在绘制时该填充将在随后对其他 Graphics 方法(如 lineTo() 或 drawCircle())的调用中使用。 - * 调用 clear() 方法会清除填充。 - * @param type 用于指定要使用哪种渐变类型的 GradientType 类的值:GradientType.LINEAR 或 GradientType.RADIAL。 - * @param colors 渐变中使用的 RGB 十六进制颜色值的数组(例如,红色为 0xFF0000,蓝色为 0x0000FF,等等)。对于每种颜色,请在 alphas 和 ratios 参数中指定对应值。 - * @param alphas colors 数组中对应颜色的 alpha 值数组。 - * @param ratios 颜色分布比率的数组。有效值为 0 到 255。 - * @param matrix 一个由 egret.Matrix 类定义的转换矩阵。egret.Matrix 类包括 createGradientBox() 方法,通过该方法可以方便地设置矩阵,以便与 beginGradientFill() 方法一起使用 - * @param beforePath 插入在指定的路径命令之前绘制,通常是插入到当前正在绘制的线条路径之前,以确保线条总在填充的上方。 - */ - p.beginGradientFill = function (type, colors, alphas, ratios, matrix, beforePath) { - var m = new egret.Matrix(); - if (matrix) { - m.a = matrix.a * 819.2; - m.b = matrix.b * 819.2; - m.c = matrix.c * 819.2; - m.d = matrix.d * 819.2; - m.tx = matrix.tx; - m.ty = matrix.ty; - } - else { - //默认值 - m.a = 100; - m.d = 100; - } - var path = new sys.GradientFillPath(); - path.gradientType = type; - path.colors = colors; - path.alphas = alphas; - path.ratios = ratios; - path.matrix = m; - if (beforePath) { - var index = this.drawData.lastIndexOf(beforePath); - this.drawData.splice(index, 0, path); - } - else { - this.drawData.push(path); - } - return path; - }; - /** - * 指定一种线条样式以用于随后对 lineTo() 或 drawCircle() 等 Graphics 方法的调用。 - * @param thickness 一个整数,以点为单位表示线条的粗细,有效值为 0 到 255。如果未指定数字,或者未定义该参数,则不绘制线条。如果传递的值小于 0,则默认值为 0。值 0 表示极细的粗细;最大粗细为 255。如果传递的值大于 255,则默认值为 255。 - * @param color 线条的十六进制颜色值(例如,红色为 0xFF0000,蓝色为 0x0000FF 等)。如果未指明值,则默认值为 0x000000(黑色)。可选。 - * @param alpha 表示线条颜色的 Alpha 值的数字;有效值为 0 到 1。如果未指明值,则默认值为 1(纯色)。如果值小于 0,则默认值为 0。如果值大于 1,则默认值为 1。 - * @param caps 用于指定线条末端处端点类型的 CapsStyle 类的值。默认值:CapsStyle.ROUND - * @param joints 指定用于拐角的连接外观的类型。默认值:JointStyle.ROUND - * @param miterLimit 用于表示剪切斜接的极限值的数字。 - */ - p.lineStyle = function (thickness, color, alpha, caps, joints, miterLimit) { - if (alpha === void 0) { alpha = 1; } - if (miterLimit === void 0) { miterLimit = 3; } - if (CAPS_STYLES.indexOf(caps) == -1) { - caps = "round"; - } - if (JOINT_STYLES.indexOf(joints) == -1) { - joints = "round"; - } - var path = new sys.StrokePath(); - path.lineWidth = thickness; - path.lineColor = color; - path.lineAlpha = alpha; - path.caps = caps || egret.CapsStyle.ROUND; - path.joints = joints; - path.miterLimit = miterLimit; - this.drawData.push(path); - return path; - }; - /** - * 清空所有缓存的绘制数据 - */ - p.clear = function () { - this.drawData.length = 0; - this.dirtyRender = true; - }; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - */ - p.cleanBeforeRender = function () { - }; - return GraphicsNode; - }(sys.RenderNode)); - sys.GraphicsNode = GraphicsNode; - egret.registerClass(GraphicsNode,'egret.sys.GraphicsNode'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 组渲染节点,用于组合多个渲染节点 - */ - var GroupNode = (function (_super) { - __extends(GroupNode, _super); - function GroupNode() { - _super.call(this); - this.type = 4 /* GroupNode */; - } - var d = __define,c=GroupNode,p=c.prototype; - p.addNode = function (node) { - this.drawData.push(node); - }; - /** - * 覆盖父类方法,不自动清空缓存的绘图数据,改为手动调用clear()方法清空。 - * 这里只是想清空绘制命令,因此不调用super - */ - p.cleanBeforeRender = function () { - var data = this.drawData; - for (var i = data.length - 1; i >= 0; i--) { - data[i].cleanBeforeRender(); - } - }; - p.$getRenderCount = function () { - var result = 0; - var data = this.drawData; - for (var i = data.length - 1; i >= 0; i--) { - result += data[i].$getRenderCount(); - } - return result; - }; - return GroupNode; - }(sys.RenderNode)); - sys.GroupNode = GroupNode; - egret.registerClass(GroupNode,'egret.sys.GroupNode'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * Mesh 渲染节点 - */ - var MeshNode = (function (_super) { - __extends(MeshNode, _super); - function MeshNode() { - _super.call(this); - /** - * 要绘制的位图 - */ - this.image = null; - /** - * 控制在缩放时是否对位图进行平滑处理。 - */ - this.smoothing = true; - /** - * 顶点索引。 - */ - this.bounds = new egret.Rectangle(); - this.type = 7 /* MeshNode */; - this.vertices = []; - this.uvs = []; - this.indices = []; - } - var d = __define,c=MeshNode,p=c.prototype; - ; - /** - * 绘制一次位图 - */ - p.drawMesh = function (sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH) { - this.drawData.push(sourceX, sourceY, sourceW, sourceH, drawX, drawY, drawW, drawH); - this.renderCount++; - }; - /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 - */ - p.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - this.image = null; - this.matrix = null; - }; - return MeshNode; - }(sys.RenderNode)); - sys.MeshNode = MeshNode; - egret.registerClass(MeshNode,'egret.sys.MeshNode'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 位图渲染节点 - */ - var SetAlphaNode = (function (_super) { - __extends(SetAlphaNode, _super); - function SetAlphaNode() { - _super.call(this); - this.type = 6 /* SetAlphaNode */; - } - var d = __define,c=SetAlphaNode,p=c.prototype; - /** - * 绘制一次位图 - */ - p.setAlpha = function (alpha) { - if (this.drawData.length != 0) { - this.drawData.length = 0; - } - this.drawData.push(alpha); - this.renderCount++; - }; - return SetAlphaNode; - }(sys.RenderNode)); - sys.SetAlphaNode = SetAlphaNode; - egret.registerClass(SetAlphaNode,'egret.sys.SetAlphaNode'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 文本渲染节点 - */ - var TextNode = (function (_super) { - __extends(TextNode, _super); - function TextNode() { - _super.call(this); - /** - * 颜色值 - */ - this.textColor = 0xFFFFFF; - /** - * 描边颜色值 - */ - this.strokeColor = 0x000000; - /** - * 字号 - */ - this.size = 30; - /** - * 描边大小 - */ - this.stroke = 0; - /** - * 是否加粗 - */ - this.bold = false; - /** - * 是否倾斜 - */ - this.italic = false; - /** - * 字体名称 - */ - this.fontFamily = "Arial"; - /** - * 脏渲染标记 - */ - this.dirtyRender = true; - this.type = 2 /* TextNode */; - } - var d = __define,c=TextNode,p=c.prototype; - /** - * 绘制一行文本 - */ - p.drawText = function (x, y, text, format) { - this.drawData.push(x, y, text, format); - this.renderCount++; - this.dirtyRender = true; - }; - /** - * 在显示对象的$render()方法被调用前,自动清空自身的drawData数据。 - */ - p.cleanBeforeRender = function () { - _super.prototype.cleanBeforeRender.call(this); - }; - return TextNode; - }(sys.RenderNode)); - sys.TextNode = TextNode; - egret.registerClass(TextNode,'egret.sys.TextNode'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 2D路径 - */ - var Path2D = (function () { - function Path2D() { - /** - * 路径类型 - */ - this.type = 0; - this.$commands = []; - this.$data = []; - this.commandPosition = 0; - this.dataPosition = 0; - } - var d = __define,c=Path2D,p=c.prototype; - /** - * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 - * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 - * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 + * 将当前绘图位置移动到 (x, y)。如果缺少任何一个参数,则此方法将失败,并且当前绘图位置不改变。 + * @param x 一个表示相对于父显示对象注册点的水平位置的数字(以像素为单位)。 + * @param y 一个表示相对于父显示对象注册点的垂直位置的数字(以像素为单位)。 */ p.moveTo = function (x, y) { this.$commands[this.commandPosition++] = 1 /* MoveTo */; @@ -16109,772 +14536,511 @@ var egret; (function (sys) { /** * @private - * 渐变填充路径 - */ - var GradientFillPath = (function (_super) { - __extends(GradientFillPath, _super); - function GradientFillPath() { - _super.call(this); - this.type = 2 /* GradientFill */; - } - var d = __define,c=GradientFillPath,p=c.prototype; - return GradientFillPath; - }(sys.Path2D)); - sys.GradientFillPath = GradientFillPath; - egret.registerClass(GradientFillPath,'egret.sys.GradientFillPath'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - /** - * @private - * 线条路径。 - * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 - */ - var StrokePath = (function (_super) { - __extends(StrokePath, _super); - function StrokePath() { - _super.call(this); - this.type = 3 /* Stroke */; - } - var d = __define,c=StrokePath,p=c.prototype; - return StrokePath; - }(sys.Path2D)); - sys.StrokePath = StrokePath; - egret.registerClass(StrokePath,'egret.sys.StrokePath'); - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var blendModes = ["source-over", "lighter", "destination-out"]; - var defaultCompositeOp = "source-over"; - var BLACK_COLOR = "#000000"; - var CAPS_STYLES = { none: 'butt', square: 'square', round: 'round' }; - var renderBufferPool = []; //渲染缓冲区对象池 - /** - * @private - * Canvas渲染器 - */ - var CanvasRenderer = (function () { - function CanvasRenderer() { - this.nestLevel = 0; //渲染的嵌套层次,0表示在调用堆栈的最外层。 - this.renderingMask = false; - } - var d = __define,c=CanvasRenderer,p=c.prototype; - /** - * 渲染一个显示对象 - * @param displayObject 要渲染的显示对象 - * @param buffer 渲染缓冲 - * @param matrix 要对显示对象整体叠加的变换矩阵 - * @param dirtyList 脏矩形列表 - * @param forRenderTexture 绘制目标是RenderTexture的标志 - * @returns drawCall触发绘制的次数 - */ - p.render = function (displayObject, buffer, matrix, dirtyList, forRenderTexture) { - this.nestLevel++; - var context = buffer.context; - var root = forRenderTexture ? displayObject : null; - //绘制显示对象 - var drawCall = this.drawDisplayObject(displayObject, context, dirtyList, matrix, null, null, root); - this.nestLevel--; - if (this.nestLevel === 0) { - //最大缓存6个渲染缓冲 - if (renderBufferPool.length > 6) { - renderBufferPool.length = 6; - } - var length = renderBufferPool.length; - for (var i = 0; i < length; i++) { - renderBufferPool[i].resize(0, 0); - } - } - return drawCall; - }; - /** - * @private - * 绘制一个显示对象 - */ - p.drawDisplayObject = function (displayObject, context, dirtyList, matrix, displayList, clipRegion, root) { - var drawCalls = 0; - var node; - if (displayList && !root) { - if (displayList.isDirty) { - drawCalls += displayList.drawToSurface(); - } - node = displayList.$renderNode; - } - else { - node = displayObject.$getRenderNode(); - } - if (node) { - if (dirtyList) { - var renderRegion = node.renderRegion; - if (clipRegion && !clipRegion.intersects(renderRegion)) { - node.needRedraw = false; - } - else if (!node.needRedraw) { - var l = dirtyList.length; - for (var j = 0; j < l; j++) { - if (renderRegion.intersects(dirtyList[j])) { - node.needRedraw = true; - break; - } - } - } - } - else { - node.needRedraw = true; - } - if (node.needRedraw) { - var renderAlpha; - var m; - if (root) { - renderAlpha = displayObject.$getConcatenatedAlphaAt(root, displayObject.$getConcatenatedAlpha()); - m = egret.Matrix.create().copyFrom(displayObject.$getConcatenatedMatrix()); - displayObject.$getConcatenatedMatrixAt(root, m); - matrix.$preMultiplyInto(m, m); - context.setTransform(m.a, m.b, m.c, m.d, m.tx, m.ty); - egret.Matrix.release(m); - } - else { - renderAlpha = node.renderAlpha; - m = node.renderMatrix; - context.setTransform(m.a, m.b, m.c, m.d, m.tx + matrix.tx, m.ty + matrix.ty); - } - context.globalAlpha = renderAlpha; - drawCalls += this.renderNode(node, context); - node.needRedraw = false; - } - } - if (displayList && !root) { - return drawCalls; - } - var children = displayObject.$children; - if (children) { - var length = children.length; - for (var i = 0; i < length; i++) { - var child = children[i]; - if (!child.$visible || child.$alpha <= 0 || child.$maskedObject) { - continue; - } - if ((child.$blendMode !== 0 || - (child.$mask && (child.$mask.$parentDisplayList || root)))) { - drawCalls += this.drawWithClip(child, context, dirtyList, matrix, clipRegion, root); - } - else if (child.$scrollRect || child.$maskRect) { - drawCalls += this.drawWithScrollRect(child, context, dirtyList, matrix, clipRegion, root); - } - else { - if (child["isFPS"]) { - this.drawDisplayObject(child, context, dirtyList, matrix, child.$displayList, clipRegion, root); - } - else { - drawCalls += this.drawDisplayObject(child, context, dirtyList, matrix, child.$displayList, clipRegion, root); - } - } - } + * 渐变填充路径 + */ + var GradientFillPath = (function (_super) { + __extends(GradientFillPath, _super); + function GradientFillPath() { + _super.call(this); + this.type = 2 /* GradientFill */; } - return drawCalls; - }; + var d = __define,c=GradientFillPath,p=c.prototype; + return GradientFillPath; + }(sys.Path2D)); + sys.GradientFillPath = GradientFillPath; + egret.registerClass(GradientFillPath,'egret.sys.GradientFillPath'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var sys; + (function (sys) { /** * @private + * 线条路径。 + * 注意:当线条宽度(lineWidth)为1或3像素时,需要特殊处理,往右下角偏移0.5像素,以显示清晰锐利的线条。 */ - p.drawWithClip = function (displayObject, context, dirtyList, matrix, clipRegion, root) { - var drawCalls = 0; - var hasBlendMode = (displayObject.$blendMode !== 0); - if (hasBlendMode) { - var compositeOp = blendModes[displayObject.$blendMode]; - if (!compositeOp) { - compositeOp = defaultCompositeOp; - } + var StrokePath = (function (_super) { + __extends(StrokePath, _super); + function StrokePath() { + _super.call(this); + this.type = 3 /* Stroke */; } - var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; - var mask = displayObject.$mask; - if (mask) { - var maskRenderNode = mask.$getRenderNode(); - if (maskRenderNode) { - var maskRenderMatrix = maskRenderNode.renderMatrix; - //遮罩scaleX或scaleY为0,放弃绘制 - if ((maskRenderMatrix.a == 0 && maskRenderMatrix.b == 0) || (maskRenderMatrix.c == 0 && maskRenderMatrix.d == 0)) { - return drawCalls; - } + var d = __define,c=StrokePath,p=c.prototype; + return StrokePath; + }(sys.Path2D)); + sys.StrokePath = StrokePath; + egret.registerClass(StrokePath,'egret.sys.StrokePath'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +/// +var egret; +(function (egret) { + var sys; + (function (sys) { + /** + * @private + * Egret播放器 + */ + var Player = (function (_super) { + __extends(Player, _super); + /** + * @private + * 实例化一个播放器对象。 + */ + function Player(buffer, stage, entryClassName) { + _super.call(this); + /** + * @private + */ + this.isPlaying = false; + if (DEBUG && !buffer) { + egret.$error(1003, "buffer"); } + this.entryClassName = entryClassName; + this.stage = stage; + this.screenDisplayList = this.createDisplayList(stage, buffer); + this.showFPS = false; + this.showLog = false; + this._showPaintRect = false; + this.stageDisplayList = null; + this.paintList = []; + this.displayFPS = displayFPS; + this.showPaintRect = showPaintRect; + this.drawPaintRect = drawPaintRect; + this.drawDirtyRect = drawDirtyRect; } - //if (mask && !mask.$parentDisplayList) { - // mask = null; //如果遮罩不在显示列表中,放弃绘制遮罩。 - //} - //计算scrollRect和mask的clip区域是否需要绘制,不需要就直接返回,跳过所有子项的遍历。 - var maskRegion; - var displayMatrix = egret.Matrix.create(); - displayMatrix.copyFrom(displayObject.$getConcatenatedMatrix()); - if (displayObject.$parentDisplayList) { - var displayRoot = displayObject.$parentDisplayList.root; - var invertedMatrix; - if (displayRoot !== displayObject.$stage) { - displayObject.$getConcatenatedMatrixAt(displayRoot, displayMatrix); + var d = __define,c=Player,p=c.prototype; + /** + * @private + */ + p.createDisplayList = function (stage, buffer) { + var displayList = new sys.DisplayList(stage); + displayList.renderBuffer = buffer; + stage.$displayList = displayList; + //displayList.setClipRect(stage.$stageWidth, stage.$stageHeight); + return displayList; + }; + /** + * @private + * 启动播放器 + */ + p.start = function () { + if (this.isPlaying || !this.stage) { + return; } - } - if (mask) { - var bounds = mask.$getOriginalBounds(); - maskRegion = egret.sys.Region.create(); - var m = egret.Matrix.create(); - m.copyFrom(mask.$getConcatenatedMatrix()); - if (invertedMatrix) { - invertedMatrix.$preMultiplyInto(m, m); + sys.$TempStage = sys.$TempStage || this.stage; + this.isPlaying = true; + if (!this.root) { + this.initialize(); } - maskRegion.updateRegion(bounds, m); - egret.Matrix.release(m); - } - var region; - if (scrollRect) { - region = egret.sys.Region.create(); - region.updateRegion(scrollRect, displayMatrix); - } - if (region && maskRegion) { - region.intersect(maskRegion); - egret.sys.Region.release(maskRegion); - } - else if (!region && maskRegion) { - region = maskRegion; - } - if (region) { - if (region.isEmpty() || (clipRegion && !clipRegion.intersects(region))) { - egret.sys.Region.release(region); - egret.Matrix.release(displayMatrix); - return drawCalls; + sys.$ticker.$addPlayer(this); + }; + /** + * @private + * + */ + p.initialize = function () { + var rootClass; + if (this.entryClassName) { + rootClass = egret.getDefinitionByName(this.entryClassName); } - } - else { - region = egret.sys.Region.create(); - bounds = displayObject.$getOriginalBounds(); - region.updateRegion(bounds, displayMatrix); - } - var found = false; - if (!dirtyList) { - found = true; - } - else { - var l = dirtyList.length; - for (var j = 0; j < l; j++) { - if (region.intersects(dirtyList[j])) { - found = true; - break; + if (rootClass) { + var rootContainer = new rootClass(); + this.root = rootContainer; + if (rootContainer instanceof egret.DisplayObject) { + this.stage.addChild(rootContainer); + } + else { + DEBUG && egret.$error(1002, this.entryClassName); } } - } - if (!found) { - egret.sys.Region.release(region); - egret.Matrix.release(displayMatrix); - return drawCalls; - } - //没有遮罩,同时显示对象没有子项 - if (!mask && (!displayObject.$children || displayObject.$children.length == 0)) { - if (scrollRect) { - var m = displayMatrix; - context.save(); - context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY); - context.beginPath(); - context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); - context.clip(); - } - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; - } - drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; + else { + DEBUG && egret.$error(1001, this.entryClassName); } - if (scrollRect) { - context.restore(); + }; + /** + * @private + * 停止播放器,停止后将不能重新启动。 + */ + p.stop = function () { + this.pause(); + this.stage = null; + }; + /** + * @private + * 暂停播放器,后续可以通过调用start()重新启动播放器。 + */ + p.pause = function () { + if (!this.isPlaying) { + return; } - return drawCalls; - } - //遮罩是单纯的填充图形,且alpha为1,性能优化 - //todo 平台差异 - if (mask && egret.Capabilities.$runtimeType == egret.RuntimeType.WEB && (!mask.$children || mask.$children.length == 0) && - maskRenderNode && maskRenderNode.type == 3 /* GraphicsNode */ && - maskRenderNode.drawData.length == 1 && - maskRenderNode.drawData[0].type == 1 /* Fill */ && - maskRenderNode.drawData[0].fillAlpha == 1) { - this.renderingMask = true; - context.save(); - var calls = this.drawDisplayObject(mask, context, dirtyList, matrix, mask.$displayList, clipRegion, root); - this.renderingMask = false; - if (scrollRect) { - var m = displayMatrix; - context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY); - context.beginPath(); - context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); - context.clip(); + this.isPlaying = false; + sys.$ticker.$removePlayer(this); + }; + /** + * @private + * 渲染屏幕 + */ + p.$render = function (triggerByFrame, costTicker) { + if (this.showFPS || this.showLog) { + this.stage.addChild(this.fpsDisplay); } - calls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); - context.restore(); - return calls; - } - //todo 若显示对象是容器,同时子项有混合模式,则需要先绘制背景到displayBuffer并清除背景区域 - //绘制显示对象自身,若有scrollRect,应用clip - var displayBuffer = this.createRenderBuffer(region.width, region.height); - var displayContext = displayBuffer.context; - if (!displayContext) { - drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); - egret.sys.Region.release(region); - egret.Matrix.release(displayMatrix); - return drawCalls; - } - displayContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY); - var offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY); - drawCalls += this.drawDisplayObject(displayObject, displayContext, dirtyList, offsetM, displayObject.$displayList, region, root); - //绘制遮罩 - if (mask) { - //如果只有一次绘制或是已经被cache直接绘制到displayContext - if (egret.Capabilities.$runtimeType == egret.RuntimeType.WEB && maskRenderNode && maskRenderNode.$getRenderCount() == 1 || mask.$displayList) { - displayContext.globalCompositeOperation = "destination-in"; - drawCalls += this.drawDisplayObject(mask, displayContext, dirtyList, offsetM, mask.$displayList, region, root); + this.callLaters(); + this.callLaterAsyncs(); + var stage = this.stage; + var t = egret.getTimer(); + var dirtyList = stage.$displayList.updateDirtyRegions(); + var t1 = egret.getTimer(); + dirtyList = dirtyList.concat(); + var drawCalls = stage.$displayList.drawToSurface(); + if (this._showPaintRect) { + this.drawPaintRect(dirtyList); } - else { - var maskBuffer = this.createRenderBuffer(region.width, region.height); - var maskContext = maskBuffer.context; - if (!maskContext) { - drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); - renderBufferPool.push(displayBuffer); - egret.sys.Region.release(region); - egret.Matrix.release(displayMatrix); - return drawCalls; - } - maskContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY); - offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY); - var calls = this.drawDisplayObject(mask, maskContext, dirtyList, offsetM, mask.$displayList, region, root); - if (calls > 0) { - drawCalls += calls; - displayContext.globalCompositeOperation = "destination-in"; - displayContext.setTransform(1, 0, 0, 1, 0, 0); - displayContext.globalAlpha = 1; - displayContext.drawImage(maskBuffer.surface, 0, 0); + var t2 = egret.getTimer(); + if (triggerByFrame && this.showFPS) { + var dirtyRatio = 0; + if (drawCalls > 0) { + var length = dirtyList.length; + var dirtyArea = 0; + for (var i = 0; i < length; i++) { + dirtyArea += dirtyList[i].area; + } + dirtyRatio = Math.ceil(dirtyArea * 1000 / (stage.stageWidth * stage.stageHeight)) / 10; } - renderBufferPool.push(maskBuffer); + this.fpsDisplay.update(drawCalls, dirtyRatio, t1 - t, t2 - t1, costTicker); } - } - egret.Matrix.release(offsetM); - //绘制结果到屏幕 - if (drawCalls > 0) { - drawCalls++; - if (hasBlendMode) { - context.globalCompositeOperation = compositeOp; + }; + /** + * @private + * + */ + p.callLaters = function () { + if (egret.$callLaterFunctionList.length > 0) { + var functionList = egret.$callLaterFunctionList; + egret.$callLaterFunctionList = []; + var thisList = egret.$callLaterThisList; + egret.$callLaterThisList = []; + var argsList = egret.$callLaterArgsList; + egret.$callLaterArgsList = []; } - if (scrollRect) { - var m = displayMatrix; - context.save(); - context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY); - context.beginPath(); - context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); - context.clip(); + if (functionList) { + var length = functionList.length; + for (var i = 0; i < length; i++) { + var func = functionList[i]; + if (func != null) { + func.apply(thisList[i], argsList[i]); + } + } } - context.globalAlpha = 1; - context.setTransform(1, 0, 0, 1, region.minX + matrix.tx, region.minY + matrix.ty); - context.drawImage(displayBuffer.surface, 0, 0); - if (scrollRect) { - context.restore(); + }; + /** + * @private + * + */ + p.callLaterAsyncs = function () { + if (egret.$callAsyncFunctionList.length > 0) { + var locCallAsyncFunctionList = egret.$callAsyncFunctionList; + var locCallAsyncThisList = egret.$callAsyncThisList; + var locCallAsyncArgsList = egret.$callAsyncArgsList; + egret.$callAsyncFunctionList = []; + egret.$callAsyncThisList = []; + egret.$callAsyncArgsList = []; + for (var i = 0; i < locCallAsyncFunctionList.length; i++) { + var func = locCallAsyncFunctionList[i]; + if (func != null) { + func.apply(locCallAsyncThisList[i], locCallAsyncArgsList[i]); + } + } } - if (hasBlendMode) { - context.globalCompositeOperation = defaultCompositeOp; + }; + /** + * @private + * 更新舞台尺寸 + * @param stageWidth 舞台宽度(以像素为单位) + * @param stageHeight 舞台高度(以像素为单位) + */ + p.updateStageSize = function (stageWidth, stageHeight) { + var stage = this.stage; + //if (stageWidth !== stage.$stageWidth || stageHeight !== stage.$stageHeight) { + stage.$stageWidth = stageWidth; + stage.$stageHeight = stageHeight; + this.screenDisplayList.setClipRect(stageWidth, stageHeight); + if (this.stageDisplayList) { + this.stageDisplayList.setClipRect(stageWidth, stageHeight); } + stage.dispatchEventWith(egret.Event.RESIZE); + stage.$invalidate(true); + //} + }; + return Player; + }(egret.HashObject)); + sys.Player = Player; + egret.registerClass(Player,'egret.sys.Player'); + var infoLines = []; + var fpsDisplay; + var fpsStyle; + sys.$logToFPS = function (info) { + if (!fpsDisplay) { + infoLines.push(info); + return; } - renderBufferPool.push(displayBuffer); - egret.sys.Region.release(region); - egret.Matrix.release(displayMatrix); - return drawCalls; + fpsDisplay.updateInfo(info); }; - /** - * @private - */ - p.drawWithScrollRect = function (displayObject, context, dirtyList, matrix, clipRegion, root) { - var drawCalls = 0; - var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; - if (scrollRect.width == 0 || scrollRect.height == 0) { - return drawCalls; + function displayFPS(showFPS, showLog, logFilter, styles) { + if (showLog) { + egret.log = function () { + var length = arguments.length; + var info = ""; + for (var i = 0; i < length; i++) { + info += arguments[i] + " "; + } + sys.$logToFPS(info); + console.log.apply(console, toArray(arguments)); + }; } - var m = egret.Matrix.create(); - m.copyFrom(displayObject.$getConcatenatedMatrix()); - if (root) { - displayObject.$getConcatenatedMatrixAt(root, m); + fpsStyle = styles ? {} : styles; + showLog = !!showLog; + this.showFPS = !!showFPS; + this.showLog = showLog; + if (!this.fpsDisplay) { + var x = styles["x"] === undefined ? 0 : styles["x"]; + var y = styles["y"] === undefined ? 0 : styles["y"]; + fpsDisplay = this.fpsDisplay = new FPS(this.stage, showFPS, showLog, logFilter, styles); + fpsDisplay.x = x; + fpsDisplay.y = y; + var length = infoLines.length; + for (var i = 0; i < length; i++) { + fpsDisplay.updateInfo(infoLines[i]); + } + infoLines = null; + } + } + function showPaintRect(value) { + value = !!value; + if (this._showPaintRect == value) { + return; } - else if (displayObject.$parentDisplayList) { - var displayRoot = displayObject.$parentDisplayList.root; - if (displayRoot !== displayObject.$stage) { - displayObject.$getConcatenatedMatrixAt(displayRoot, m); + this._showPaintRect = value; + if (value) { + if (!this.stageDisplayList) { + this.stageDisplayList = sys.DisplayList.create(this.stage); } + this.stage.$displayList = this.stageDisplayList; } - var region = egret.sys.Region.create(); - if (!scrollRect.isEmpty()) { - region.updateRegion(scrollRect, m); + else { + this.stage.$displayList = this.screenDisplayList; } - if (region.isEmpty() || (clipRegion && !clipRegion.intersects(region))) { - egret.sys.Region.release(region); - egret.Matrix.release(m); - return drawCalls; + } + function drawPaintRect(dirtyList) { + var length = dirtyList.length; + var list = []; + for (var i = 0; i < length; i++) { + var region = dirtyList[i]; + list[i] = [region.minX, region.minY, region.width, region.height]; + region.width -= 1; + region.height -= 1; } - var found = false; - if (!dirtyList) { - found = true; + var repaintList = this.paintList; + repaintList.push(list); + if (repaintList.length > 1) { + repaintList.shift(); } - else { - var l = dirtyList.length; - for (var j = 0; j < l; j++) { - if (region.intersects(dirtyList[j])) { - found = true; - break; - } + var renderBuffer = this.screenDisplayList.renderBuffer; + var context = renderBuffer.context; + context.setTransform(1, 0, 0, 1, 0, 0); + context.clearRect(0, 0, renderBuffer.surface.width, renderBuffer.surface.height); + context.drawImage(this.stageDisplayList.renderBuffer.surface, 0, 0); + length = repaintList.length; + for (i = 0; i < length; i++) { + list = repaintList[i]; + for (var j = list.length - 1; j >= 0; j--) { + var r = list[j]; + this.drawDirtyRect(r[0], r[1], r[2], r[3], context); } } - if (!found) { - egret.sys.Region.release(region); - egret.Matrix.release(m); - return drawCalls; - } - //绘制显示对象自身 context.save(); - context.setTransform(m.a, m.b, m.c, m.d, m.tx + matrix.tx, m.ty + matrix.ty); context.beginPath(); - context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); + var length = dirtyList.length; + for (var i = 0; i < length; i++) { + var region = dirtyList[i]; + context.clearRect(region.minX, region.minY, region.width, region.height); + context.rect(region.minX, region.minY, region.width, region.height); + } context.clip(); - drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, region, root); + context.drawImage(this.stageDisplayList.renderBuffer.surface, 0, 0); context.restore(); - egret.sys.Region.release(region); - egret.Matrix.release(m); - return drawCalls; - }; - /** - * 将一个RenderNode对象绘制到渲染缓冲 - * @param node 要绘制的节点 - * @param buffer 渲染缓冲 - * @param matrix 要叠加的矩阵 - * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 - */ - p.drawNodeToBuffer = function (node, buffer, matrix, forHitTest) { - var context = buffer.context; - context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); - this.renderNode(node, context, forHitTest); - }; - /** - * @private - */ - p.renderNode = function (node, context, forHitTest) { - var drawCalls = 0; - switch (node.type) { - case 1 /* BitmapNode */: - drawCalls = this.renderBitmap(node, context); - break; - case 2 /* TextNode */: - drawCalls = 1; - this.renderText(node, context); - break; - case 3 /* GraphicsNode */: - drawCalls = 1; - this.renderGraphics(node, context, forHitTest); - break; - case 4 /* GroupNode */: - drawCalls = this.renderGroup(node, context); - break; - case 6 /* SetAlphaNode */: - context.globalAlpha = node.drawData[0]; - break; - } - return drawCalls; - }; - /** - * @private - */ - p.renderBitmap = function (node, context) { - var image = node.image; - if (context.$imageSmoothingEnabled != node.smoothing) { - context.imageSmoothingEnabled = node.smoothing; - context.$imageSmoothingEnabled = node.smoothing; - } - var data = node.drawData; - var length = data.length; - var pos = 0; - var m = node.matrix; - var blendMode = node.blendMode; - var saved = false; - if (m) { - if (context.saveTransform) { - context.saveTransform(); - } - else { - context.save(); - } - saved = true; - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - } - if (blendMode) { - context.globalCompositeOperation = blendModes[blendMode]; - } - var drawCalls = 0; - while (pos < length) { - drawCalls++; - context.drawImage(image, data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++]); - } - if (saved) { - if (context.restoreTransform) { - context.restoreTransform(); - if (blendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - } - else { - context.restore(); - } - } - else if (blendMode) { - context.globalCompositeOperation = defaultCompositeOp; - } - return drawCalls; - }; + } /** - * @private + * 绘制一个脏矩形显示区域,在显示重绘区功能开启时调用。 */ - p.renderText = function (node, context) { - context.textAlign = "left"; - context.textBaseline = "middle"; - context.lineJoin = "round"; //确保描边样式是圆角 - var drawData = node.drawData; - var length = drawData.length; - var pos = 0; - while (pos < length) { - var x = drawData[pos++]; - var y = drawData[pos++]; - var text = drawData[pos++]; - var format = drawData[pos++]; - context.font = getFontString(node, format); - var textColor = format.textColor == null ? node.textColor : format.textColor; - var strokeColor = format.strokeColor == null ? node.strokeColor : format.strokeColor; - var stroke = format.stroke == null ? node.stroke : format.stroke; - context.fillStyle = egret.toColorString(textColor); - context.strokeStyle = egret.toColorString(strokeColor); - if (stroke) { - context.lineWidth = stroke * 2; - context.strokeText(text, x, y); - } - context.fillText(text, x, y); - } - }; + function drawDirtyRect(x, y, width, height, context) { + context.strokeStyle = 'rgb(255,0,0)'; + context.lineWidth = 5; + context.strokeRect(x - 0.5, y - 0.5, width, height); + } /** - * @private + * FPS显示对象 */ - p.renderGraphics = function (node, context, forHitTest) { - var drawData = node.drawData; - var length = drawData.length; - forHitTest = !!forHitTest; - for (var i = 0; i < length; i++) { - var path = drawData[i]; - switch (path.type) { - case 1 /* Fill */: - var fillPath = path; - context.fillStyle = forHitTest ? BLACK_COLOR : getRGBAString(fillPath.fillColor, fillPath.fillAlpha); - this.renderPath(path, context); - if (this.renderingMask) { - context.clip(); - } - else { - context.fill(); - } - break; - case 2 /* GradientFill */: - var g = path; - context.fillStyle = forHitTest ? BLACK_COLOR : getGradient(context, g.gradientType, g.colors, g.alphas, g.ratios, g.matrix); - context.save(); - var m = g.matrix; - this.renderPath(path, context); - context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); - context.fill(); - context.restore(); - break; - case 3 /* Stroke */: - var strokeFill = path; - var lineWidth = strokeFill.lineWidth; - context.lineWidth = lineWidth; - context.strokeStyle = forHitTest ? BLACK_COLOR : getRGBAString(strokeFill.lineColor, strokeFill.lineAlpha); - context.lineCap = CAPS_STYLES[strokeFill.caps]; - context.lineJoin = strokeFill.joints; - context.miterLimit = strokeFill.miterLimit; - //对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 - var isSpecialCaseWidth = lineWidth === 1 || lineWidth === 3; - if (isSpecialCaseWidth) { - context.translate(0.5, 0.5); - } - this.renderPath(path, context); - context.stroke(); - if (isSpecialCaseWidth) { - context.translate(-0.5, -0.5); - } - break; + FPS = (function (_super) { + __extends(FPSImpl, _super); + function FPSImpl(stage, showFPS, showLog, logFilter, styles) { + _super.call(this); + this["isFPS"] = true; + this.infoLines = []; + this.totalTime = 0; + this.totalTick = 0; + this.lastTime = 0; + this.drawCalls = 0; + this.dirtyRatio = 0; + this.costDirty = 0; + this.costRender = 0; + this.costTicker = 0; + this._stage = stage; + this.showFPS = showFPS; + this.showLog = showLog; + this.logFilter = logFilter; + this.touchChildren = false; + this.touchEnabled = false; + this.styles = styles; + this.fpsDisplay = new egret.FPSDisplay(stage, showFPS, showLog, logFilter, styles); + this.addChild(this.fpsDisplay); + try { + var logFilterRegExp = logFilter ? new RegExp(logFilter) : null; } + catch (e) { + egret.log(e); + } + this.filter = function (message) { + if (logFilterRegExp) + return logFilterRegExp.test(message); + return !logFilter || message.indexOf(logFilter) == 0; + }; } - }; - p.renderPath = function (path, context) { - context.beginPath(); - var data = path.$data; - var commands = path.$commands; - var commandCount = commands.length; - var pos = 0; - for (var commandIndex = 0; commandIndex < commandCount; commandIndex++) { - var command = commands[commandIndex]; - switch (command) { - case 4 /* CubicCurveTo */: - context.bezierCurveTo(data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++]); - break; - case 3 /* CurveTo */: - context.quadraticCurveTo(data[pos++], data[pos++], data[pos++], data[pos++]); - break; - case 2 /* LineTo */: - context.lineTo(data[pos++], data[pos++]); - break; - case 1 /* MoveTo */: - context.moveTo(data[pos++], data[pos++]); - break; + FPSImpl.prototype.update = function (drawCalls, dirtyRatio, costDirty, costRender, costTicker) { + var current = egret.getTimer(); + this.totalTime += current - this.lastTime; + this.lastTime = current; + this.totalTick++; + this.drawCalls += drawCalls; + this.dirtyRatio += dirtyRatio; + this.costDirty += costDirty; + this.costRender += costRender; + this.costTicker += costTicker; + if (this.totalTime >= 1000) { + var lastFPS = Math.min(Math.ceil(this.totalTick * 1000 / this.totalTime), sys.$ticker.$frameRate); + var lastDrawCalls = Math.round(this.drawCalls / this.totalTick); + var lastDirtyRatio = Math.round(this.dirtyRatio / this.totalTick); + var lastCostDirty = Math.round(this.costDirty / this.totalTick); + var lastCostRender = Math.round(this.costRender / this.totalTick); + var lastCostTicker = Math.round(this.costTicker / this.totalTick); + this.fpsDisplay.update({ + fps: lastFPS, + draw: lastDrawCalls, + dirty: lastDirtyRatio, + costTicker: lastCostTicker, + costDirty: lastCostDirty, + costRender: lastCostRender + }); + this.totalTick = 0; + this.totalTime = this.totalTime % 1000; + this.drawCalls = 0; + this.dirtyRatio = 0; + this.costDirty = 0; + this.costRender = 0; + this.costTicker = 0; + } + }; + FPSImpl.prototype.updateInfo = function (info) { + if (!info) { + return; + } + if (!this.showLog) { + return; + } + if (!this.filter(info)) { + return; } + this.fpsDisplay.updateInfo(info); + }; + return FPSImpl; + })(egret.Sprite); + function toArray(argument) { + var args = []; + for (var i = 0; i < argument.length; i++) { + args.push(argument[i]); } + return args; + } + egret.warn = function () { + console.warn.apply(console, toArray(arguments)); }; - p.renderGroup = function (groupNode, context) { - var drawCalls = 0; - var children = groupNode.drawData; - var length = children.length; - for (var i = 0; i < length; i++) { - var node = children[i]; - drawCalls += this.renderNode(node, context); - } - return drawCalls; + egret.error = function () { + console.error.apply(console, toArray(arguments)); }; - /** - * @private - */ - p.createRenderBuffer = function (width, height) { - var buffer = renderBufferPool.pop(); - if (buffer) { - buffer.resize(width, height, true); - } - else { - buffer = new egret.sys.RenderBuffer(width, height); - } - return buffer; + egret.assert = function () { + console.assert.apply(console, toArray(arguments)); }; - return CanvasRenderer; - }()); - egret.CanvasRenderer = CanvasRenderer; - egret.registerClass(CanvasRenderer,'egret.CanvasRenderer',["egret.sys.SystemRenderer"]); - /** - * @private - * 获取字体字符串 - */ - function getFontString(node, format) { - var italic = format.italic == null ? node.italic : format.italic; - var bold = format.bold == null ? node.bold : format.bold; - var size = format.size == null ? node.size : format.size; - var fontFamily = format.fontFamily || node.fontFamily; - var font = italic ? "italic " : "normal "; - font += bold ? "bold " : "normal "; - font += size + "px " + fontFamily; - return font; - } - /** - * @private - * 获取RGBA字符串 - */ - function getRGBAString(color, alpha) { - var red = color >> 16; - var green = (color >> 8) & 0xFF; - var blue = color & 0xFF; - return "rgba(" + red + "," + green + "," + blue + "," + alpha + ")"; - } - /** - * @private - * 获取渐变填充样式对象 - */ - function getGradient(context, type, colors, alphas, ratios, matrix) { - var gradient; - if (type == egret.GradientType.LINEAR) { - gradient = context.createLinearGradient(-1, 0, 1, 0); - } - else { - gradient = context.createRadialGradient(0, 0, 0, 0, 0, 1); - } - //todo colors alphas ratios数量不一致情况处理 - var l = colors.length; - for (var i = 0; i < l; i++) { - gradient.addColorStop(ratios[i] / 255, getRGBAString(colors[i], alphas[i])); - } - return gradient; - } -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @copy egret.Orientation - */ - egret.DeviceOrientation = null; -})(egret || (egret = {})); -var egret; -(function (egret) { -})(egret || (egret = {})); -var egret; -(function (egret) { + egret.log = function () { + console.log.apply(console, toArray(arguments)); + }; + })(sys = egret.sys || (egret.sys = {})); })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -16904,330 +15070,287 @@ var egret; // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// var egret; (function (egret) { - /** - * @language en_US - * Type of operation. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 运行类型的类型。 - * @version Egret 2.4 - * @platform Web,Native - */ - var RuntimeType = (function () { - function RuntimeType() { - } - var d = __define,c=RuntimeType,p=c.prototype; - /** - * @language en_US - * Running on Web - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 运行在Web上 - * @version Egret 2.4 - * @platform Web,Native - */ - RuntimeType.WEB = "web"; - /** - * @language en_US - * Running on NATIVE - * @version Egret 2.4 - * @platform Web,Native - */ + var sys; + (function (sys) { + var regionPool = []; /** - * @language zh_CN - * 运行在NATIVE上 - * @version Egret 2.4 - * @platform Web,Native + * @private */ - RuntimeType.NATIVE = "native"; - return RuntimeType; - }()); - egret.RuntimeType = RuntimeType; - egret.registerClass(RuntimeType,'egret.RuntimeType'); - /** - * @language en_US - * The Capabilities class provides properties that describe the system and runtime that are hosting the application. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - */ - /** - * @language zh_CN - * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/system/Capabilities.ts - */ - var Capabilities = (function () { - function Capabilities() { - } - var d = __define,c=Capabilities,p=c.prototype; - d(Capabilities, "language" - /** - * @language en_US - * Specifies the language code of the system on which the content is running. The language is specified as a lowercase - * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 - * distinguishes between Simplified and Traditional Chinese.
      - * The following table lists the possible values,but not limited to them: - *
        - *
      • Simplified Chinese zh-CN
      • - *
      • Traditional Chinese zh-TW
      • - *
      • English en
      • - *
      • Japanese ja
      • - *
      • Korean ko
      • - *
      - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 - * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
      - * 以下是可能但不限于的语言和值: - *
        - *
      • 简体中文 zh-CN
      • - *
      • 繁体中文 zh-TW
      • - *
      • 英语 en
      • - *
      • 日语 ja
      • - *
      • 韩语 ko
      • - *
      - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return Capabilities.$language; + var Region = (function () { + function Region() { + /** + * @private + */ + this.minX = 0; + /** + * @private + */ + this.minY = 0; + /** + * @private + */ + this.maxX = 0; + /** + * @private + */ + this.maxY = 0; + /** + * @private + */ + this.width = 0; + /** + * @private + */ + this.height = 0; + /** + * @private + */ + this.area = 0; + /** + * @private + * 是否发生移动 + */ + this.moved = false; } - ); - d(Capabilities, "isMobile" + var d = __define,c=Region,p=c.prototype; /** - * @language en_US - * Specifies whether the system is running in a mobile device.(such as a mobile phone or tablet) - * @version Egret 2.4 - * @platform Web,Native + * @private + * 释放一个Region实例到对象池 */ + Region.release = function (region) { + regionPool.push(region); + }; /** - * @language zh_CN - * 表示程序内容是否运行在移动设备中(例如移动电话或平板电脑)。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * 从对象池中取出或创建一个新的Region对象。 + * 建议对于一次性使用的对象,均使用此方法创建,而不是直接new一个。 + * 使用完后调用对应的release()静态方法回收对象,能有效减少对象创建数量造成的性能开销。 */ - ,function () { - return Capabilities.$isMobile; - } - ); - d(Capabilities, "os" + Region.create = function () { + var region = regionPool.pop(); + if (!region) { + region = new Region(); + } + return region; + }; /** - * @language en_US - * Specifies the current operating system. The os property can return the following strings: - *
        - *
      • iPhone "iOS"
      • - *
      • Android Phone "Android"
      • - *
      • Windows Phone "Windows Phone"
      • - *
      • Windows Desktop "Windows PC"
      • - *
      • Mac Desktop "Mac OS"
      • - *
      • Unknown OS "Unknown"
      • - *
      - * @version Egret 2.4 - * @platform Web,Native + * @private */ + p.setTo = function (minX, minY, maxX, maxY) { + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + this.updateArea(); + return this; + }; /** - * @language zh_CN - * 指示当前的操作系统。os 属性返回下列字符串: - *
        - *
      • 苹果手机操作系统 "iOS"
      • - *
      • 安卓手机操作系统 "Android"
      • - *
      • 微软手机操作系统 "Windows Phone"
      • - *
      • 微软桌面操作系统 "Windows PC"
      • - *
      • 苹果桌面操作系统 "Mac OS"
      • - *
      • 未知操作系统 "Unknown"
      • - *
      - * @version Egret 2.4 - * @platform Web,Native + * @private + * 把所有值都取整 */ - ,function () { - return Capabilities.$os; - } - ); - d(Capabilities, "runtimeType" + p.intValues = function () { + this.minX = Math.floor(this.minX); + this.minY = Math.floor(this.minY); + this.maxX = Math.ceil(this.maxX); + this.maxY = Math.ceil(this.maxY); + this.updateArea(); + }; /** - * @language en_US - * It indicates the current type of operation. runtimeType property returns the following string: - *
        - *
      • Run on Web egret.RuntimeType.WEB
      • - *
      • Run on Native egret.RuntimeType.NATIVE
      • - *
      - * @version Egret 2.4 - * @platform Web,Native + * @private */ + p.updateArea = function () { + this.width = this.maxX - this.minX; + this.height = this.maxY - this.minY; + this.area = this.width * this.height; + }; /** - * @language zh_CN - * 指示当前的运行类型。runtimeType 属性返回下列字符串: - *
        - *
      • 运行在Web上 egret.RuntimeType.WEB
      • - *
      • 运行在Native上 egret.RuntimeType.NATIVE
      • - *
      - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return Capabilities.$runtimeType; - } - ); - d(Capabilities, "supportVersion" - /*** - * @language en_US - * version of the native support. - * @type {string} - * @version Egret 2.5 - * @platform Web,Native - */ - /*** - * @language zh_CN - * native support 的版本号。 - * @type {string} - * @version Egret 2.5 - * @platform Web,Native + * @private + * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 */ - ,function () { - return Capabilities.$supportVersion; - } - ); - /** - * 设置系统信息 - */ - Capabilities.$setNativeCapabilities = function (value) { - var arr = value.split("-"); - if (arr.length <= 4) { - //todo 未来去掉数量判断,2.5.4版本之前的参数大于4个 - var osType = arr[0]; - switch (osType) { - case "android": - osType = "Android"; - break; - case "ios": - osType = 'iOS'; - break; + p.union = function (target) { + if (this.minX > target.minX) { + this.minX = target.minX; } - Capabilities.$os = osType; - var version = arr[2].substring(1, arr[2].length); - Capabilities.$supportVersion = version; - } - }; - d(Capabilities, "renderMode" - /*** - * @language en_US - * current render mode. - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native - */ - /*** - * @language zh_CN - * 当前渲染模式。 - * @type {string} - * @version Egret 3.0.7 - * @platform Web,Native + if (this.minY > target.minY) { + this.minY = target.minY; + } + if (this.maxX < target.maxX) { + this.maxX = target.maxX; + } + if (this.maxY < target.maxY) { + this.maxY = target.maxY; + } + this.updateArea(); + }; + /** + * @private + * 注意!由于性能优化,此方法不判断自身是否为空,必须在外部确认自身和目标区域都不为空再调用合并。否则结果始终从0,0点开始。 */ - ,function () { - return Capabilities.$renderMode; - } - ); - d(Capabilities, "boundingClientWidth" - /*** - * @language en_US - * Clients border width. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native + p.intersect = function (target) { + if (this.minX < target.minX) { + this.minX = target.minX; + } + if (this.maxX > target.maxX) { + this.maxX = target.maxX; + } + if (this.minX >= this.maxX) { + this.setEmpty(); + return; + } + if (this.minY < target.minY) { + this.minY = target.minY; + } + if (this.maxY > target.maxY) { + this.maxY = target.maxY; + } + if (this.minY >= this.maxY) { + this.setEmpty(); + return; + } + this.updateArea(); + }; + /** + * @private */ - /*** - * @language zh_CN - * 客户端边界宽度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native + p.setEmpty = function () { + this.minX = 0; + this.minY = 0; + this.maxX = 0; + this.maxY = 0; + this.width = 0; + this.height = 0; + this.area = 0; + }; + /** + * @private + * 确定此 Region 对象是否为空。 */ - ,function () { - return Capabilities.$boundingClientWidth; - } - ); - d(Capabilities, "boundingClientHeight" - /*** - * @language en_US - * Clients border height. - * The value before the document class initialization is always 0. - * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. - * @version Egret 3.1.3 - * @platform Web,Native + p.isEmpty = function () { + return this.width <= 0 || this.height <= 0; + }; + /** + * @private */ - /*** - * @language zh_CN - * 客户端边界高度。 - * 该值在文档类初始化之前始终是0。 - * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 - * @version Egret 3.1.3 - * @platform Web,Native + p.intersects = function (target) { + if (this.isEmpty()) { + return false; + } + var max = this.minX > target.minX ? this.minX : target.minX; + var min = this.maxX < target.maxX ? this.maxX : target.maxX; + if (max > min) { + return false; + } + max = this.minY > target.minY ? this.minY : target.minY; + min = this.maxY < target.maxY ? this.maxY : target.maxY; + return max <= min; + }; + /** + * @private */ - ,function () { - return Capabilities.$boundingClientHeight; - } - ); - /** - * @private - */ - Capabilities.$language = "zh-CN"; - /** - * @private - */ - Capabilities.$os = "Unknown"; - /** - * @private - */ - Capabilities.$runtimeType = "Unknown"; - Capabilities.$supportVersion = "Unknown"; - Capabilities.$renderMode = "Unknown"; - Capabilities.$boundingClientWidth = 0; - Capabilities.$boundingClientHeight = 0; - return Capabilities; - }()); - egret.Capabilities = Capabilities; - egret.registerClass(Capabilities,'egret.Capabilities'); - if (DEBUG) { - egret.$markReadOnly(Capabilities, "language", false); - egret.$markReadOnly(Capabilities, "isMobile", false); - egret.$markReadOnly(Capabilities, "os", false); - egret.$markReadOnly(Capabilities, "runtimeType", false); - egret.$markReadOnly(Capabilities, "supportVersion", false); - egret.$markReadOnly(Capabilities, "renderMode", false); - egret.$markReadOnly(Capabilities, "boundingClientWidth", false); - egret.$markReadOnly(Capabilities, "boundingClientHeight", false); - } + p.updateRegion = function (bounds, matrix) { + if (bounds.width == 0 || bounds.height == 0) { + //todo 理论上应该是空 + this.setEmpty(); + return; + } + var m = matrix; + var a = m.a; + var b = m.b; + var c = m.c; + var d = m.d; + var tx = m.tx; + var ty = m.ty; + var x = bounds.x; + var y = bounds.y; + var xMax = x + bounds.width; + var yMax = y + bounds.height; + var minX, minY, maxX, maxY; + //优化,通常情况下不缩放旋转的对象占多数,直接加上偏移量即可。 + if (a == 1.0 && b == 0.0 && c == 0.0 && d == 1.0) { + minX = x + tx - 1; + minY = y + ty - 1; + maxX = xMax + tx + 1; + maxY = yMax + ty + 1; + } + else { + var x0 = a * x + c * y + tx; + var y0 = b * x + d * y + ty; + var x1 = a * xMax + c * y + tx; + var y1 = b * xMax + d * y + ty; + var x2 = a * xMax + c * yMax + tx; + var y2 = b * xMax + d * yMax + ty; + var x3 = a * x + c * yMax + tx; + var y3 = b * x + d * yMax + ty; + var tmp = 0; + if (x0 > x1) { + tmp = x0; + x0 = x1; + x1 = tmp; + } + if (x2 > x3) { + tmp = x2; + x2 = x3; + x3 = tmp; + } + minX = (x0 < x2 ? x0 : x2) - 1; + maxX = (x1 > x3 ? x1 : x3) + 1; + if (y0 > y1) { + tmp = y0; + y0 = y1; + y1 = tmp; + } + if (y2 > y3) { + tmp = y2; + y2 = y3; + y3 = tmp; + } + minY = (y0 < y2 ? y0 : y2) - 1; + maxY = (y1 > y3 ? y1 : y3) + 1; + } + this.minX = minX; + this.minY = minY; + this.maxX = maxX; + this.maxY = maxY; + this.width = maxX - minX; + this.height = maxY - minY; + this.area = this.width * this.height; + }; + return Region; + }()); + sys.Region = Region; + egret.registerClass(Region,'egret.sys.Region'); + })(sys = egret.sys || (egret.sys = {})); })(egret || (egret = {})); -var testDeviceType = function () { - if (!this["navigator"]) { - return true; - } - var ua = navigator.userAgent.toLowerCase(); - return (ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1); -}; -var testRuntimeType = function () { - if (this["navigator"]) { - return true; - } - return false; -}; -egret.Capabilities.$isMobile = testDeviceType(); -egret.Capabilities.$runtimeType = testRuntimeType() ? egret.RuntimeType.WEB : egret.RuntimeType.NATIVE; ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. @@ -17286,797 +15409,986 @@ egret.Capabilities.$runtimeType = testRuntimeType() ? egret.RuntimeType.WEB : eg ////////////////////////////////////////////////////////////////////////////////////// var egret; (function (egret) { + var sys; + (function (sys) { + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var blendModes = ["source-over", "lighter", "destination-out"]; + var defaultCompositeOp = "source-over"; + var BLACK_COLOR = "#000000"; + var CAPS_STYLES = { none: 'butt', square: 'square', round: 'round' }; + var renderBufferPool = []; //渲染缓冲区对象池 /** - * @language en_US - * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts - */ - /** - * @language zh_CN - * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 - * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger - * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapFont.ts + * @private + * Canvas渲染器 */ - var BitmapFont = (function (_super) { - __extends(BitmapFont, _super); + var CanvasRenderer = (function () { + function CanvasRenderer() { + this.nestLevel = 0; //渲染的嵌套层次,0表示在调用堆栈的最外层。 + this.renderingMask = false; + } + var d = __define,c=CanvasRenderer,p=c.prototype; /** - * @language en_US - * Create an egret.BitmapFont object - * @param texture {egret.Texture} Texture set that use TextureMerger create - * @param config {any} Configure data that use TextureMerger create - * @version Egret 2.4 - * @platform Web,Native + * 渲染一个显示对象 + * @param displayObject 要渲染的显示对象 + * @param buffer 渲染缓冲 + * @param matrix 要对显示对象整体叠加的变换矩阵 + * @param dirtyList 脏矩形列表 + * @param forRenderTexture 绘制目标是RenderTexture的标志 + * @returns drawCall触发绘制的次数 */ + p.render = function (displayObject, buffer, matrix, dirtyList, forRenderTexture) { + this.nestLevel++; + var context = buffer.context; + var root = forRenderTexture ? displayObject : null; + //绘制显示对象 + var drawCall = this.drawDisplayObject(displayObject, context, dirtyList, matrix, null, null, root); + this.nestLevel--; + if (this.nestLevel === 0) { + //最大缓存6个渲染缓冲 + if (renderBufferPool.length > 6) { + renderBufferPool.length = 6; + } + var length = renderBufferPool.length; + for (var i = 0; i < length; i++) { + renderBufferPool[i].resize(0, 0); + } + } + return drawCall; + }; /** - * @language zh_CN - * 创建一个 egret.BitmapFont 对象 - * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 - * @param config {any} 使用TextureMerger生成的配置数据 - * @version Egret 2.4 - * @platform Web,Native + * @private + * 绘制一个显示对象 */ - function BitmapFont(texture, config) { - _super.call(this, texture); - /** - * @private - */ - this.firstCharHeight = 0; - if (typeof (config) == "string") { - this.charList = this.parseConfig(config); + p.drawDisplayObject = function (displayObject, context, dirtyList, matrix, displayList, clipRegion, root) { + var drawCalls = 0; + var node; + if (displayList && !root) { + if (displayList.isDirty) { + drawCalls += displayList.drawToSurface(); + } + node = displayList.$renderNode; + } + else { + node = displayObject.$getRenderNode(); + } + if (node) { + if (dirtyList) { + var renderRegion = node.renderRegion; + if (clipRegion && !clipRegion.intersects(renderRegion)) { + node.needRedraw = false; + } + else if (!node.needRedraw) { + var l = dirtyList.length; + for (var j = 0; j < l; j++) { + if (renderRegion.intersects(dirtyList[j])) { + node.needRedraw = true; + break; + } + } + } + } + else { + node.needRedraw = true; + } + if (node.needRedraw) { + var renderAlpha; + var m; + if (root) { + renderAlpha = displayObject.$getConcatenatedAlphaAt(root, displayObject.$getConcatenatedAlpha()); + m = egret.Matrix.create().copyFrom(displayObject.$getConcatenatedMatrix()); + displayObject.$getConcatenatedMatrixAt(root, m); + matrix.$preMultiplyInto(m, m); + context.setTransform(m.a, m.b, m.c, m.d, m.tx, m.ty); + egret.Matrix.release(m); + } + else { + renderAlpha = node.renderAlpha; + m = node.renderMatrix; + context.setTransform(m.a, m.b, m.c, m.d, m.tx + matrix.tx, m.ty + matrix.ty); + } + context.globalAlpha = renderAlpha; + drawCalls += this.renderNode(node, context); + node.needRedraw = false; + } + } + if (displayList && !root) { + return drawCalls; + } + var children = displayObject.$children; + if (children) { + var length = children.length; + for (var i = 0; i < length; i++) { + var child = children[i]; + if (!child.$visible || child.$alpha <= 0 || child.$maskedObject) { + continue; + } + var filters = child.$getFilters(); + if (filters && filters.length > 0) { + drawCalls += this.drawWithFilter(child, context, dirtyList, matrix, clipRegion, root); + } + else if ((child.$blendMode !== 0 || + (child.$mask && (child.$mask.$parentDisplayList || root)))) { + drawCalls += this.drawWithClip(child, context, dirtyList, matrix, clipRegion, root); + } + else if (child.$scrollRect || child.$maskRect) { + drawCalls += this.drawWithScrollRect(child, context, dirtyList, matrix, clipRegion, root); + } + else { + if (child["isFPS"]) { + this.drawDisplayObject(child, context, dirtyList, matrix, child.$displayList, clipRegion, root); + } + else { + drawCalls += this.drawDisplayObject(child, context, dirtyList, matrix, child.$displayList, clipRegion, root); + } + } + } + } + return drawCalls; + }; + /** + * @private + */ + p.drawWithFilter = function (displayObject, context, dirtyList, matrix, clipRegion, root) { + var drawCalls = 0; + var filters = displayObject.$getFilters(); + var filtersLen = filters.length; + var hasBlendMode = (displayObject.$blendMode !== 0); + if (hasBlendMode) { + var compositeOp = blendModes[displayObject.$blendMode]; + if (!compositeOp) { + compositeOp = defaultCompositeOp; + } + } + // 获取显示对象的链接矩阵 + var displayMatrix = egret.Matrix.create(); + displayMatrix.copyFrom(displayObject.$getConcatenatedMatrix()); + // 获取显示对象的矩形区域 + var region; + region = egret.sys.Region.create(); + var bounds = displayObject.$getOriginalBounds(); + region.updateRegion(bounds, displayMatrix); + // 为显示对象创建一个新的buffer + // todo 这里应该计算 region.x region.y + var displayBuffer = this.createRenderBuffer(region.width, region.height); + var displayContext = displayBuffer.context; + displayContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY); + var offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY); + drawCalls += this.drawDisplayObject(displayObject, displayContext, dirtyList, offsetM, displayObject.$displayList, region, root); + egret.Matrix.release(offsetM); + //绘制结果到屏幕 + if (drawCalls > 0) { + if (hasBlendMode) { + context.globalCompositeOperation = compositeOp; + } + drawCalls++; + context.globalAlpha = 1; + context.setTransform(1, 0, 0, 1, region.minX + matrix.tx, region.minY + matrix.ty); + // 应用滤镜 + var imageData = displayContext.getImageData(0, 0, displayBuffer.surface.width, displayBuffer.surface.height); + for (var i = 0; i < filtersLen; i++) { + var filter = filters[i]; + if (filter.type == "colorTransform") { + colorFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$matrix); + } + else if (filter.type == "blur") { + blurFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, filter.$blurX, filter.$blurY); + } + else if (filter.type == "glow") { + // TODO glow滤镜实现 kickout hideObject + var r = filter.$red; + var g = filter.$green; + var b = filter.$blue; + var a = filter.$alpha; + dropShadowFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r, g, b, a], filter.$blurX, filter.$blurY, filter.$angle || 0, filter.$distance || 0, filter.$strength); + } + } + displayContext.putImageData(imageData, 0, 0); + // 绘制结果的时候,应用滤镜 + context.drawImage(displayBuffer.surface, 0, 0); + if (hasBlendMode) { + context.globalCompositeOperation = defaultCompositeOp; + } + } + renderBufferPool.push(displayBuffer); + egret.sys.Region.release(region); + egret.Matrix.release(displayMatrix); + return drawCalls; + }; + /** + * @private + */ + p.drawWithClip = function (displayObject, context, dirtyList, matrix, clipRegion, root) { + var drawCalls = 0; + var hasBlendMode = (displayObject.$blendMode !== 0); + if (hasBlendMode) { + var compositeOp = blendModes[displayObject.$blendMode]; + if (!compositeOp) { + compositeOp = defaultCompositeOp; + } + } + var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; + var mask = displayObject.$mask; + if (mask) { + var maskRenderNode = mask.$getRenderNode(); + if (maskRenderNode) { + var maskRenderMatrix = maskRenderNode.renderMatrix; + //遮罩scaleX或scaleY为0,放弃绘制 + if ((maskRenderMatrix.a == 0 && maskRenderMatrix.b == 0) || (maskRenderMatrix.c == 0 && maskRenderMatrix.d == 0)) { + return drawCalls; + } + } + } + //if (mask && !mask.$parentDisplayList) { + // mask = null; //如果遮罩不在显示列表中,放弃绘制遮罩。 + //} + //计算scrollRect和mask的clip区域是否需要绘制,不需要就直接返回,跳过所有子项的遍历。 + var maskRegion; + var displayMatrix = egret.Matrix.create(); + displayMatrix.copyFrom(displayObject.$getConcatenatedMatrix()); + if (displayObject.$parentDisplayList) { + var displayRoot = displayObject.$parentDisplayList.root; + var invertedMatrix; + if (displayRoot !== displayObject.$stage) { + displayObject.$getConcatenatedMatrixAt(displayRoot, displayMatrix); + } + } + if (mask) { + var bounds = mask.$getOriginalBounds(); + maskRegion = egret.sys.Region.create(); + var m = egret.Matrix.create(); + m.copyFrom(mask.$getConcatenatedMatrix()); + if (invertedMatrix) { + invertedMatrix.$preMultiplyInto(m, m); + } + maskRegion.updateRegion(bounds, m); + egret.Matrix.release(m); } - else if (config && config.hasOwnProperty("frames")) { - this.charList = config.frames; + var region; + if (scrollRect) { + region = egret.sys.Region.create(); + region.updateRegion(scrollRect, displayMatrix); } - else { - this.charList = {}; + if (region && maskRegion) { + region.intersect(maskRegion); + egret.sys.Region.release(maskRegion); } - } - var d = __define,c=BitmapFont,p=c.prototype; - /** - * @language en_US - * Obtain corresponding texture through the name attribute - * @param name {string} name Attribute - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 通过 name 属性获取对应纹理 - * @param name {string} name属性 - * @returns {egret.Texture} - * @version Egret 2.4 - * @platform Web,Native - */ - p.getTexture = function (name) { - var texture = this._textureMap[name]; - if (!texture) { - var c = this.charList[name]; - if (!c) { - return null; + else if (!region && maskRegion) { + region = maskRegion; + } + if (region) { + if (region.isEmpty() || (clipRegion && !clipRegion.intersects(region))) { + egret.sys.Region.release(region); + egret.Matrix.release(displayMatrix); + return drawCalls; } - texture = this.createTexture(name, c.x, c.y, c.w, c.h, c.offX, c.offY, c.sourceW, c.sourceH); - this._textureMap[name] = texture; } - return texture; - }; - /** - * @private - */ - p.getConfig = function (name, key) { - if (!this.charList[name]) { - return 0; + else { + region = egret.sys.Region.create(); + bounds = displayObject.$getOriginalBounds(); + region.updateRegion(bounds, displayMatrix); } - return this.charList[name][key]; - }; - /** - * @private - * - * @returns - */ - p._getFirstCharHeight = function () { - if (this.firstCharHeight == 0) { - for (var str in this.charList) { - var c = this.charList[str]; - if (c) { - var sourceH = c.sourceH; - if (sourceH === undefined) { - var h = c.h; - if (h === undefined) { - h = 0; - } - var offY = c.offY; - if (offY === undefined) { - offY = 0; - } - sourceH = h + offY; - } - if (sourceH <= 0) { - continue; - } - this.firstCharHeight = sourceH; + var found = false; + if (!dirtyList) { + found = true; + } + else { + var l = dirtyList.length; + for (var j = 0; j < l; j++) { + if (region.intersects(dirtyList[j])) { + found = true; break; } } } - return this.firstCharHeight; - }; - /** - * @private - * - * @param fntText - * @returns - */ - p.parseConfig = function (fntText) { - fntText = fntText.split("\r\n").join("\n"); - var lines = fntText.split("\n"); - var charsCount = this.getConfigByKey(lines[3], "count"); - var chars = {}; - for (var i = 4; i < 4 + charsCount; i++) { - var charText = lines[i]; - var letter = String.fromCharCode(this.getConfigByKey(charText, "id")); - var c = {}; - chars[letter] = c; - c["x"] = this.getConfigByKey(charText, "x"); - c["y"] = this.getConfigByKey(charText, "y"); - c["w"] = this.getConfigByKey(charText, "width"); - c["h"] = this.getConfigByKey(charText, "height"); - c["offX"] = this.getConfigByKey(charText, "xoffset"); - c["offY"] = this.getConfigByKey(charText, "yoffset"); - c["xadvance"] = this.getConfigByKey(charText, "xadvance"); + if (!found) { + egret.sys.Region.release(region); + egret.Matrix.release(displayMatrix); + return drawCalls; } - return chars; - }; - /** - * @private - * - * @param configText - * @param key - * @returns - */ - p.getConfigByKey = function (configText, key) { - var itemConfigTextList = configText.split(" "); - for (var i = 0, length = itemConfigTextList.length; i < length; i++) { - var itemConfigText = itemConfigTextList[i]; - if (key == itemConfigText.substring(0, key.length)) { - var value = itemConfigText.substring(key.length + 1); - return parseInt(value); + //没有遮罩,同时显示对象没有子项 + if (!mask && (!displayObject.$children || displayObject.$children.length == 0)) { + if (scrollRect) { + var m = displayMatrix; + context.save(); + context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY); + context.beginPath(); + context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); + context.clip(); } + if (hasBlendMode) { + context.globalCompositeOperation = compositeOp; + } + drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); + if (hasBlendMode) { + context.globalCompositeOperation = defaultCompositeOp; + } + if (scrollRect) { + context.restore(); + } + return drawCalls; } - return 0; - }; - return BitmapFont; - }(egret.SpriteSheet)); - egret.BitmapFont = BitmapFont; - egret.registerClass(BitmapFont,'egret.BitmapFont'); -})(egret || (egret = {})); -var egret; -(function (egret) { - /** - * @language en_US - * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - */ - /** - * @language zh_CN - * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/BitmapText.ts - */ - var BitmapText = (function (_super) { - __extends(BitmapText, _super); - /** - * @language en_US - * Create an egret.BitmapText object - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 创建一个 egret.BitmapText 对象 - * @version Egret 2.4 - * @platform Web,Native - */ - function BitmapText() { - _super.call(this); - /** - * @private - */ - this.$textOffsetX = 0; - /** - * @private - */ - this.$textOffsetY = 0; - /** - * @private - */ - this.$textStartX = 0; - /** - * @private - */ - this.$textStartY = 0; - /** - * @private - */ - this.$lineHeights = []; - this.$renderNode = new egret.sys.BitmapNode(); - //this.cacheAsBitmap = true; - this.$BitmapText = { - 0: NaN, - 1: NaN, - 2: "", - 3: 0, - 4: 0, - 5: null, - 6: false, - 7: false, - 8: false, - 9: false, - 10: "left", - 11: "top", - 12: egret.Bitmap.defaultSmoothing //smoothing - }; - } - var d = __define,c=BitmapText,p=c.prototype; - d(p, "smoothing" - /** - * @language en_US - * Whether or not is smoothed when scaled. - * @default true。 - * @version Egret 3.0 - * @platform Web - */ - /** - * @language zh_CN - * 控制在缩放时是否进行平滑处理。 - * @default true。 - * @version Egret 3.0 - * @platform Web - */ - ,function () { - var values = this.$BitmapText; - return values[12 /* smoothing */]; - } - ,function (value) { - value = !!value; - var values = this.$BitmapText; - if (value == values[12 /* smoothing */]) { - return; + //遮罩是单纯的填充图形,且alpha为1,性能优化 + //todo 平台差异 + if (mask && egret.Capabilities.$runtimeType == egret.RuntimeType.WEB && (!mask.$children || mask.$children.length == 0) && + maskRenderNode && maskRenderNode.type == 3 /* GraphicsNode */ && + maskRenderNode.drawData.length == 1 && + maskRenderNode.drawData[0].type == 1 /* Fill */ && + maskRenderNode.drawData[0].fillAlpha == 1) { + this.renderingMask = true; + context.save(); + var calls = this.drawDisplayObject(mask, context, dirtyList, matrix, mask.$displayList, clipRegion, root); + this.renderingMask = false; + if (scrollRect) { + var m = displayMatrix; + context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY); + context.beginPath(); + context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); + context.clip(); } - values[12 /* smoothing */] = value; - this.$invalidate(); + calls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); + context.restore(); + return calls; } - ); - d(p, "text" - /** - * @language en_US - * A string to display in the text field. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 要显示的文本内容 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$BitmapText[2 /* text */]; + //todo 若显示对象是容器,同时子项有混合模式,则需要先绘制背景到displayBuffer并清除背景区域 + //绘制显示对象自身,若有scrollRect,应用clip + var displayBuffer = this.createRenderBuffer(region.width, region.height); + var displayContext = displayBuffer.context; + if (!displayContext) { + drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); + egret.sys.Region.release(region); + egret.Matrix.release(displayMatrix); + return drawCalls; } - ,function (value) { - this.$setText(value); + displayContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY); + var offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY); + drawCalls += this.drawDisplayObject(displayObject, displayContext, dirtyList, offsetM, displayObject.$displayList, region, root); + //绘制遮罩 + if (mask) { + //如果只有一次绘制或是已经被cache直接绘制到displayContext + if (egret.Capabilities.$runtimeType == egret.RuntimeType.WEB && maskRenderNode && maskRenderNode.$getRenderCount() == 1 || mask.$displayList) { + displayContext.globalCompositeOperation = "destination-in"; + drawCalls += this.drawDisplayObject(mask, displayContext, dirtyList, offsetM, mask.$displayList, region, root); + } + else { + var maskBuffer = this.createRenderBuffer(region.width, region.height); + var maskContext = maskBuffer.context; + if (!maskContext) { + drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, clipRegion, root); + renderBufferPool.push(displayBuffer); + egret.sys.Region.release(region); + egret.Matrix.release(displayMatrix); + return drawCalls; + } + maskContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY); + offsetM = egret.Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY); + var calls = this.drawDisplayObject(mask, maskContext, dirtyList, offsetM, mask.$displayList, region, root); + if (calls > 0) { + drawCalls += calls; + displayContext.globalCompositeOperation = "destination-in"; + displayContext.setTransform(1, 0, 0, 1, 0, 0); + displayContext.globalAlpha = 1; + displayContext.drawImage(maskBuffer.surface, 0, 0); + } + renderBufferPool.push(maskBuffer); + } } - ); - /** - * @private - */ - p.$setText = function (value) { - value = String(value); - var values = this.$BitmapText; - if (value == values[2 /* text */]) - return false; - values[2 /* text */] = value; - this.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - p.$getWidth = function () { - var w = this.$BitmapText[0 /* textFieldWidth */]; - return isNaN(w) ? this.$getContentBounds().width : w; - }; - /** - * @private - */ - p.$setWidth = function (value) { - //value = +value || 0; - var values = this.$BitmapText; - if (value < 0 || value == values[0 /* textFieldWidth */]) { - return false; + egret.Matrix.release(offsetM); + //绘制结果到屏幕 + if (drawCalls > 0) { + drawCalls++; + if (hasBlendMode) { + context.globalCompositeOperation = compositeOp; + } + if (scrollRect) { + var m = displayMatrix; + context.save(); + context.setTransform(m.a, m.b, m.c, m.d, m.tx - region.minX, m.ty - region.minY); + context.beginPath(); + context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); + context.clip(); + } + context.globalAlpha = 1; + context.setTransform(1, 0, 0, 1, region.minX + matrix.tx, region.minY + matrix.ty); + context.drawImage(displayBuffer.surface, 0, 0); + if (scrollRect) { + context.restore(); + } + if (hasBlendMode) { + context.globalCompositeOperation = defaultCompositeOp; + } } - values[0 /* textFieldWidth */] = value; - this.$invalidateContentBounds(); - return true; - }; - /** - * @private - */ - p.$invalidateContentBounds = function () { - _super.prototype.$invalidateContentBounds.call(this); - this.$BitmapText[7 /* textLinesChanged */] = true; - }; - /** - * @private - */ - p.$getHeight = function () { - var h = this.$BitmapText[1 /* textFieldHeight */]; - return isNaN(h) ? this.$getContentBounds().height : h; + renderBufferPool.push(displayBuffer); + egret.sys.Region.release(region); + egret.Matrix.release(displayMatrix); + return drawCalls; }; /** * @private - */ - p.$setHeight = function (value) { - //value = +value || 0; - var values = this.$BitmapText; - if (value < 0 || value == values[1 /* textFieldHeight */]) { - return false; - } - values[1 /* textFieldHeight */] = value; - this.$invalidateContentBounds(); - return true; - }; - d(p, "font" - /** - * @language en_US - * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. - * @default null - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 - * @default null - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$BitmapText[5 /* font */]; - } - ,function (value) { - this.$setFont(value); - } - ); - p.$setFont = function (value) { - var values = this.$BitmapText; - if (values[5 /* font */] == value) { - return false; - } - values[5 /* font */] = value; - this.$BitmapText[6 /* fontStringChanged */] = true; - this.$invalidateContentBounds(); - return true; - }; - d(p, "lineSpacing" - /** - /** - * @language en_US - * An integer representing the amount of vertical space between lines. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$BitmapText[3 /* lineSpacing */]; - } - ,function (value) { - this.$setLineSpacing(value); - } - ); - p.$setLineSpacing = function (value) { - value = +value || 0; - var values = this.$BitmapText; - if (values[3 /* lineSpacing */] == value) - return false; - values[3 /* lineSpacing */] = value; - this.$invalidateContentBounds(); - return true; - }; - d(p, "letterSpacing" - /** - * @language en_US - * An integer representing the amount of distance between characters. - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 一个整数,表示字符之间的距量。 - * @default 0 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$BitmapText[4 /* letterSpacing */]; + */ + p.drawWithScrollRect = function (displayObject, context, dirtyList, matrix, clipRegion, root) { + var drawCalls = 0; + var scrollRect = displayObject.$scrollRect ? displayObject.$scrollRect : displayObject.$maskRect; + if (scrollRect.width == 0 || scrollRect.height == 0) { + return drawCalls; } - ,function (value) { - this.$setLetterSpacing(value); + var m = egret.Matrix.create(); + m.copyFrom(displayObject.$getConcatenatedMatrix()); + if (root) { + displayObject.$getConcatenatedMatrixAt(root, m); } - ); - p.$setLetterSpacing = function (value) { - value = +value || 0; - var values = this.$BitmapText; - if (values[4 /* letterSpacing */] == value) - return false; - values[4 /* letterSpacing */] = value; - this.$invalidateContentBounds(); - return true; - }; - d(p, "textAlign" - /** - * @language en_US - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - */ - /** - * @language zh_CN - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT - * @version Egret 2.5.6 - * @platform Web,Native - */ - ,function () { - return this.$BitmapText[10 /* textAlign */]; + else if (displayObject.$parentDisplayList) { + var displayRoot = displayObject.$parentDisplayList.root; + if (displayRoot !== displayObject.$stage) { + displayObject.$getConcatenatedMatrixAt(displayRoot, m); + } } - ,function (value) { - this.$setTextAlign(value); + var region = egret.sys.Region.create(); + if (!scrollRect.isEmpty()) { + region.updateRegion(scrollRect, m); } - ); - p.$setTextAlign = function (value) { - var values = this.$BitmapText; - if (values[10 /* textAlign */] == value) - return false; - values[10 /* textAlign */] = value; - this.$invalidateContentBounds(); - return true; - }; - d(p, "verticalAlign" - /** - * @language en_US - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - */ - /** - * @language zh_CN - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP - * @version Egret 2.5.6 - * @platform Web,Native - */ - ,function () { - return this.$BitmapText[11 /* verticalAlign */]; + if (region.isEmpty() || (clipRegion && !clipRegion.intersects(region))) { + egret.sys.Region.release(region); + egret.Matrix.release(m); + return drawCalls; } - ,function (value) { - this.$setVerticalAlign(value); + var found = false; + if (!dirtyList) { + found = true; } - ); - p.$setVerticalAlign = function (value) { - var values = this.$BitmapText; - if (values[11 /* verticalAlign */] == value) - return false; - values[11 /* verticalAlign */] = value; - this.$invalidateContentBounds(); - return true; + else { + var l = dirtyList.length; + for (var j = 0; j < l; j++) { + if (region.intersects(dirtyList[j])) { + found = true; + break; + } + } + } + if (!found) { + egret.sys.Region.release(region); + egret.Matrix.release(m); + return drawCalls; + } + //绘制显示对象自身 + context.save(); + context.setTransform(m.a, m.b, m.c, m.d, m.tx + matrix.tx, m.ty + matrix.ty); + context.beginPath(); + context.rect(scrollRect.x, scrollRect.y, scrollRect.width, scrollRect.height); + context.clip(); + drawCalls += this.drawDisplayObject(displayObject, context, dirtyList, matrix, displayObject.$displayList, region, root); + context.restore(); + egret.sys.Region.release(region); + egret.Matrix.release(m); + return drawCalls; + }; + /** + * 将一个RenderNode对象绘制到渲染缓冲 + * @param node 要绘制的节点 + * @param buffer 渲染缓冲 + * @param matrix 要叠加的矩阵 + * @param forHitTest 绘制结果是用于碰撞检测。若为true,当渲染GraphicsNode时,会忽略透明度样式设置,全都绘制为不透明的。 + */ + p.drawNodeToBuffer = function (node, buffer, matrix, forHitTest) { + var context = buffer.context; + context.setTransform(matrix.a, matrix.b, matrix.c, matrix.d, matrix.tx, matrix.ty); + this.renderNode(node, context, forHitTest); }; /** * @private */ - p.$render = function () { - var values = this.$BitmapText; - var textLines = this.$getTextLines(); - var length = textLines.length; - if (length == 0) { - return; + p.renderNode = function (node, context, forHitTest) { + var drawCalls = 0; + switch (node.type) { + case 1 /* BitmapNode */: + drawCalls = this.renderBitmap(node, context); + break; + case 2 /* TextNode */: + drawCalls = 1; + this.renderText(node, context); + break; + case 3 /* GraphicsNode */: + drawCalls = 1; + this.renderGraphics(node, context, forHitTest); + break; + case 4 /* GroupNode */: + drawCalls = this.renderGroup(node, context); + break; + case 6 /* SetAlphaNode */: + context.globalAlpha = node.drawData[0]; + break; } - var textLinesWidth = this.$textLinesWidth; - var bitmapFont = values[5 /* font */]; - var node = this.$renderNode; - if (bitmapFont.$texture) { - node.image = bitmapFont.$texture._bitmapData; + return drawCalls; + }; + /** + * @private + */ + p.renderBitmap = function (node, context) { + var image = node.image; + if (context.$imageSmoothingEnabled != node.smoothing) { + context.imageSmoothingEnabled = node.smoothing; + context.$imageSmoothingEnabled = node.smoothing; } - node.smoothing = values[12 /* smoothing */]; - var emptyHeight = bitmapFont._getFirstCharHeight(); - var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); - var hasSetHeight = !isNaN(values[1 /* textFieldHeight */]); - var textWidth = values[8 /* textWidth */]; - var textFieldWidth = values[0 /* textFieldWidth */]; - var textFieldHeight = values[1 /* textFieldHeight */]; - var align = values[10 /* textAlign */]; - var yPos = this.$textOffsetY + this.$textStartY; - var lineHeights = this.$lineHeights; - for (var i = 0; i < length; i++) { - var lineHeight = lineHeights[i]; - if (hasSetHeight && i > 0 && yPos + lineHeight > textFieldHeight) { - break; + var data = node.drawData; + var length = data.length; + var pos = 0; + var m = node.matrix; + var blendMode = node.blendMode; + var saved = false; + if (m) { + if (context.saveTransform) { + context.saveTransform(); } - var line = textLines[i]; - var len = line.length; - var xPos = this.$textOffsetX; - if (align != egret.HorizontalAlign.LEFT) { - var countWidth = textFieldWidth > textWidth ? textFieldWidth : textWidth; - if (align == egret.HorizontalAlign.RIGHT) { - xPos += countWidth - textLinesWidth[i]; - } - else if (align == egret.HorizontalAlign.CENTER) { - xPos += Math.floor((countWidth - textLinesWidth[i]) / 2); - } + else { + context.save(); } - for (var j = 0; j < len; j++) { - var character = line.charAt(j); - var texture = bitmapFont.getTexture(character); - if (!texture) { - if (character == " ") { - xPos += emptyWidth; - } - else { - egret.$warn(1046, character); - } - continue; + saved = true; + context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); + } + if (blendMode) { + context.globalCompositeOperation = blendModes[blendMode]; + } + var drawCalls = 0; + while (pos < length) { + drawCalls++; + context.drawImage(image, data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++]); + } + if (saved) { + if (context.restoreTransform) { + context.restoreTransform(); + if (blendMode) { + context.globalCompositeOperation = defaultCompositeOp; } - var bitmapWidth = texture._bitmapWidth; - var bitmapHeight = texture._bitmapHeight; - node.imageWidth = texture._sourceWidth; - node.imageHeight = texture._sourceHeight; - node.drawImage(texture._bitmapX, texture._bitmapY, bitmapWidth, bitmapHeight, xPos + texture._offsetX, yPos + texture._offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight()); - xPos += bitmapFont.getConfig(character, "xadvance") || (texture.$getTextureWidth() + values[4 /* letterSpacing */]); } - yPos += lineHeight + values[3 /* lineSpacing */]; + else { + context.restore(); + } + } + else if (blendMode) { + context.globalCompositeOperation = defaultCompositeOp; + } + return drawCalls; + }; + /** + * @private + */ + p.renderText = function (node, context) { + context.textAlign = "left"; + context.textBaseline = "middle"; + context.lineJoin = "round"; //确保描边样式是圆角 + var drawData = node.drawData; + var length = drawData.length; + var pos = 0; + while (pos < length) { + var x = drawData[pos++]; + var y = drawData[pos++]; + var text = drawData[pos++]; + var format = drawData[pos++]; + context.font = getFontString(node, format); + var textColor = format.textColor == null ? node.textColor : format.textColor; + var strokeColor = format.strokeColor == null ? node.strokeColor : format.strokeColor; + var stroke = format.stroke == null ? node.stroke : format.stroke; + context.fillStyle = egret.toColorString(textColor); + context.strokeStyle = egret.toColorString(strokeColor); + if (stroke) { + context.lineWidth = stroke * 2; + context.strokeText(text, x, y); + } + context.fillText(text, x, y); } }; /** * @private */ - p.$measureContentBounds = function (bounds) { - var lines = this.$getTextLines(); - if (lines.length == 0) { - bounds.setEmpty(); - } - else { - bounds.setTo(this.$textOffsetX + this.$textStartX, this.$textOffsetY + this.$textStartY, this.$BitmapText[8 /* textWidth */] - this.$textOffsetX, this.$BitmapText[9 /* textHeight */] - this.$textOffsetY); + p.renderGraphics = function (node, context, forHitTest) { + var drawData = node.drawData; + var length = drawData.length; + forHitTest = !!forHitTest; + for (var i = 0; i < length; i++) { + var path = drawData[i]; + switch (path.type) { + case 1 /* Fill */: + var fillPath = path; + context.fillStyle = forHitTest ? BLACK_COLOR : getRGBAString(fillPath.fillColor, fillPath.fillAlpha); + this.renderPath(path, context); + if (this.renderingMask) { + context.clip(); + } + else { + context.fill(); + } + break; + case 2 /* GradientFill */: + var g = path; + context.fillStyle = forHitTest ? BLACK_COLOR : getGradient(context, g.gradientType, g.colors, g.alphas, g.ratios, g.matrix); + context.save(); + var m = g.matrix; + this.renderPath(path, context); + context.transform(m.a, m.b, m.c, m.d, m.tx, m.ty); + context.fill(); + context.restore(); + break; + case 3 /* Stroke */: + var strokeFill = path; + var lineWidth = strokeFill.lineWidth; + context.lineWidth = lineWidth; + context.strokeStyle = forHitTest ? BLACK_COLOR : getRGBAString(strokeFill.lineColor, strokeFill.lineAlpha); + context.lineCap = CAPS_STYLES[strokeFill.caps]; + context.lineJoin = strokeFill.joints; + context.miterLimit = strokeFill.miterLimit; + //对1像素和3像素特殊处理,向右下角偏移0.5像素,以显示清晰锐利的线条。 + var isSpecialCaseWidth = lineWidth === 1 || lineWidth === 3; + if (isSpecialCaseWidth) { + context.translate(0.5, 0.5); + } + this.renderPath(path, context); + context.stroke(); + if (isSpecialCaseWidth) { + context.translate(-0.5, -0.5); + } + break; + } } }; - d(p, "textWidth" - /** - * @language en_US - * Get the BitmapText measured width - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 获取位图文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - this.$getTextLines(); - return this.$BitmapText[8 /* textWidth */]; + p.renderPath = function (path, context) { + context.beginPath(); + var data = path.$data; + var commands = path.$commands; + var commandCount = commands.length; + var pos = 0; + for (var commandIndex = 0; commandIndex < commandCount; commandIndex++) { + var command = commands[commandIndex]; + switch (command) { + case 4 /* CubicCurveTo */: + context.bezierCurveTo(data[pos++], data[pos++], data[pos++], data[pos++], data[pos++], data[pos++]); + break; + case 3 /* CurveTo */: + context.quadraticCurveTo(data[pos++], data[pos++], data[pos++], data[pos++]); + break; + case 2 /* LineTo */: + context.lineTo(data[pos++], data[pos++]); + break; + case 1 /* MoveTo */: + context.moveTo(data[pos++], data[pos++]); + break; + } } - ); - d(p, "textHeight" - /** - * @language en_US - * Get Text BitmapText height - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 获取位图文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - this.$getTextLines(); - return this.$BitmapText[9 /* textHeight */]; + }; + p.renderGroup = function (groupNode, context) { + var drawCalls = 0; + var children = groupNode.drawData; + var length = children.length; + for (var i = 0; i < length; i++) { + var node = children[i]; + drawCalls += this.renderNode(node, context); } - ); + return drawCalls; + }; /** * @private - * - * @returns */ - p.$getTextLines = function () { - var values = this.$BitmapText; - if (!values[7 /* textLinesChanged */]) { - return this.textLines; + p.createRenderBuffer = function (width, height) { + var buffer = renderBufferPool.pop(); + if (buffer) { + buffer.resize(width, height, true); } - var textLines = []; - this.textLines = textLines; - var textLinesWidth = []; - this.$textLinesWidth = textLinesWidth; - values[7 /* textLinesChanged */] = false; - var lineHeights = []; - this.$lineHeights = lineHeights; - if (!values[2 /* text */] || !values[5 /* font */]) { - return textLines; + else { + buffer = new egret.sys.RenderBuffer(width, height); } - var lineSpacing = values[3 /* lineSpacing */]; - var letterSpacing = values[4 /* letterSpacing */]; - var textWidth = 0; - var textHeight = 0; - var textOffsetX = 0; - var textOffsetY = 0; - var hasWidthSet = !isNaN(values[0 /* textFieldWidth */]); - var textFieldWidth = values[0 /* textFieldWidth */]; - var textFieldHeight = values[1 /* textFieldHeight */]; - var bitmapFont = values[5 /* font */]; - var emptyHeight = bitmapFont._getFirstCharHeight(); - var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); - var text = values[2 /* text */]; - var textArr = text.split(/(?:\r\n|\r|\n)/); - var length = textArr.length; - var isFirstLine = true; - for (var i = 0; i < length; i++) { - var line = textArr[i]; - var len = line.length; - var lineHeight = 0; - var xPos = 0; - var isFirstChar = true; - var isLastChar = false; - for (var j = 0; j < len; j++) { - if (!isFirstChar) { - xPos += letterSpacing; - } - var character = line.charAt(j); - var texureWidth; - var textureHeight; - var offsetX = 0; - var offsetY = 0; - var texture = bitmapFont.getTexture(character); - if (!texture) { - if (character == " ") { - texureWidth = emptyWidth; - textureHeight = emptyHeight; - } - else { - egret.$warn(1046, character); - if (isFirstChar) { - isFirstChar = false; - } - continue; - } + return buffer; + }; + return CanvasRenderer; + }()); + egret.CanvasRenderer = CanvasRenderer; + egret.registerClass(CanvasRenderer,'egret.CanvasRenderer',["egret.sys.SystemRenderer"]); + /** + * @private + * 获取字体字符串 + */ + function getFontString(node, format) { + var italic = format.italic == null ? node.italic : format.italic; + var bold = format.bold == null ? node.bold : format.bold; + var size = format.size == null ? node.size : format.size; + var fontFamily = format.fontFamily || node.fontFamily; + var font = italic ? "italic " : "normal "; + font += bold ? "bold " : "normal "; + font += size + "px " + fontFamily; + return font; + } + /** + * @private + * 获取RGBA字符串 + */ + function getRGBAString(color, alpha) { + var red = color >> 16; + var green = (color >> 8) & 0xFF; + var blue = color & 0xFF; + return "rgba(" + red + "," + green + "," + blue + "," + alpha + ")"; + } + /** + * @private + * 获取渐变填充样式对象 + */ + function getGradient(context, type, colors, alphas, ratios, matrix) { + var gradient; + if (type == egret.GradientType.LINEAR) { + gradient = context.createLinearGradient(-1, 0, 1, 0); + } + else { + gradient = context.createRadialGradient(0, 0, 0, 0, 0, 1); + } + //todo colors alphas ratios数量不一致情况处理 + var l = colors.length; + for (var i = 0; i < l; i++) { + gradient.addColorStop(ratios[i] / 255, getRGBAString(colors[i], alphas[i])); + } + return gradient; + } + /** + * @private + */ + function colorFilter(buffer, w, h, matrix) { + var r0 = matrix[0], r1 = matrix[1], r2 = matrix[2], r3 = matrix[3], r4 = matrix[4]; + var g0 = matrix[5], g1 = matrix[6], g2 = matrix[7], g3 = matrix[8], g4 = matrix[9]; + var b0 = matrix[10], b1 = matrix[11], b2 = matrix[12], b3 = matrix[13], b4 = matrix[14]; + var a0 = matrix[15], a1 = matrix[16], a2 = matrix[17], a3 = matrix[18], a4 = matrix[19]; + for (var p = 0, e = w * h * 4; p < e; p += 4) { + var r = buffer[p + 0]; + var g = buffer[p + 1]; + var b = buffer[p + 2]; + var a = buffer[p + 3]; + buffer[p + 0] = r0 * r + r1 * g + r2 * b + r3 * a + r4; + buffer[p + 1] = g0 * r + g1 * g + g2 * b + g3 * a + g4; + buffer[p + 2] = b0 * r + b1 * g + b2 * b + b3 * a + b4; + buffer[p + 3] = a0 * r + a1 * g + a2 * b + a3 * a + a4; + } + } + /** + * @private + */ + function blurFilter(buffer, w, h, blurX, blurY) { + blurFilterH(buffer, w, h, blurX); + blurFilterV(buffer, w, h, blurY); + } + /** + * @private + */ + function blurFilterH(buffer, w, h, blurX) { + var lineBuffer = new Uint8ClampedArray(w * 4); + var lineSize = w * 4; + var windowLength = (blurX * 2) + 1; + var windowSize = windowLength * 4; + for (var y = 0; y < h; y++) { + var pLineStart = y * lineSize; + var rs = 0, gs = 0, bs = 0, as = 0, alpha = 0, alpha2 = 0; + // Fill window + for (var ptr = -blurX * 4, end = blurX * 4 + 4; ptr < end; ptr += 4) { + var key = pLineStart + ptr; + if (key < pLineStart || key >= pLineStart + lineSize) { + continue; + } + alpha = buffer[key + 3]; + rs += buffer[key + 0] * alpha; + gs += buffer[key + 1] * alpha; + bs += buffer[key + 2] * alpha; + as += alpha; + } + // Slide window + for (var ptr = pLineStart, end = pLineStart + lineSize, linePtr = 0, lastPtr = ptr - blurX * 4, nextPtr = ptr + (blurX + 1) * 4; ptr < end; ptr += 4, linePtr += 4, nextPtr += 4, lastPtr += 4) { + lineBuffer[linePtr + 0] = rs / as; + lineBuffer[linePtr + 1] = gs / as; + lineBuffer[linePtr + 2] = bs / as; + lineBuffer[linePtr + 3] = as / windowLength; + alpha = buffer[nextPtr + 3]; + alpha2 = buffer[lastPtr + 3]; + if (alpha || alpha == 0) { + if (alpha2 || alpha2 == 0) { + rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; + gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; + bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; + as += alpha - alpha2; } else { - texureWidth = texture.$getTextureWidth(); - textureHeight = texture.$getTextureHeight(); - offsetX = texture._offsetX; - offsetY = texture._offsetY; - } - if (isFirstChar) { - isFirstChar = false; - textOffsetX = Math.min(offsetX, textOffsetX); - } - if (isFirstLine) { - isFirstLine = false; - textOffsetY = Math.min(offsetY, textOffsetY); - } - if (hasWidthSet && j > 0 && xPos + texureWidth > textFieldWidth) { - if (!setLineData(line.substring(0, j))) - break; - line = line.substring(j); - len = line.length; - j = 0; - //最后一个字符要计算纹理宽度,而不是xadvance - if (j == len - 1) { - xPos = texureWidth; - } - else { - xPos = bitmapFont.getConfig(character, "xadvance") || texureWidth; - } - lineHeight = textureHeight; - continue; + rs += buffer[nextPtr + 0] * alpha; + gs += buffer[nextPtr + 1] * alpha; + bs += buffer[nextPtr + 2] * alpha; + as += alpha; } - //最后一个字符要计算纹理宽度,而不是xadvance - if (j == len - 1) { - xPos += texureWidth; + } + else { + if (alpha2 || alpha2 == 0) { + rs += -buffer[lastPtr + 0] * alpha2; + gs += -buffer[lastPtr + 1] * alpha2; + bs += -buffer[lastPtr + 2] * alpha2; + as += -alpha2; } else { - xPos += bitmapFont.getConfig(character, "xadvance") || texureWidth; } - lineHeight = Math.max(textureHeight, lineHeight); } - if (textFieldHeight && i > 0 && textHeight > textFieldHeight) { - break; - } - isLastChar = true; - if (!setLineData(line)) - break; } - function setLineData(str) { - if (textFieldHeight && textLines.length > 0 && textHeight > textFieldHeight) { - return false; - } - textHeight += lineHeight + lineSpacing; - if (!isFirstChar && !isLastChar) { - xPos -= letterSpacing; + // Copy line + buffer.set(lineBuffer, pLineStart); + } + } + /** + * @private + */ + function blurFilterV(buffer, w, h, blurY) { + var columnBuffer = new Uint8ClampedArray(h * 4); + var stride = w * 4; + var windowLength = (blurY * 2) + 1; + for (var x = 0; x < w; x++) { + var pColumnStart = x * 4; + var rs = 0, gs = 0, bs = 0, as = 0, alpha = 0, alpha2 = 0; + // Fill window + for (var ptr = -blurY * stride, end = blurY * stride + stride; ptr < end; ptr += stride) { + var key = pColumnStart + ptr; + if (key < pColumnStart || key >= pColumnStart + h * stride) { + continue; } - textLines.push(str); - lineHeights.push(lineHeight); - textLinesWidth.push(xPos); - textWidth = Math.max(xPos, textWidth); - return true; - } - textHeight -= lineSpacing; - values[8 /* textWidth */] = textWidth; - values[9 /* textHeight */] = textHeight; - this.$textOffsetX = textOffsetX; - this.$textOffsetY = textOffsetY; - this.$textStartX = 0; - this.$textStartY = 0; - var alignType; - if (textFieldWidth > textWidth) { - alignType = values[10 /* textAlign */]; - if (alignType == egret.HorizontalAlign.RIGHT) { - this.$textStartX = textFieldWidth - textWidth; + alpha = buffer[key + 3]; + rs += buffer[key + 0] * alpha; + gs += buffer[key + 1] * alpha; + bs += buffer[key + 2] * alpha; + as += alpha; + } + // Slide window + for (var ptr = pColumnStart, end = pColumnStart + h * stride, columnPtr = 0, lastPtr = pColumnStart - blurY * stride, nextPtr = pColumnStart + ((blurY + 1) * stride); ptr < end; ptr += stride, columnPtr += 4, nextPtr += stride, lastPtr += stride) { + columnBuffer[columnPtr + 0] = rs / as; + columnBuffer[columnPtr + 1] = gs / as; + columnBuffer[columnPtr + 2] = bs / as; + columnBuffer[columnPtr + 3] = as / windowLength; + alpha = buffer[nextPtr + 3]; + alpha2 = buffer[lastPtr + 3]; + if (alpha || alpha == 0) { + if (alpha2 || alpha2 == 0) { + rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; + gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; + bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; + as += alpha - alpha2; + } + else { + rs += buffer[nextPtr + 0] * alpha; + gs += buffer[nextPtr + 1] * alpha; + bs += buffer[nextPtr + 2] * alpha; + as += alpha; + } } - else if (alignType == egret.HorizontalAlign.CENTER) { - this.$textStartX = Math.floor((textFieldWidth - textWidth) / 2); + else { + if (alpha2 || alpha2 == 0) { + rs += -buffer[lastPtr + 0] * alpha2; + gs += -buffer[lastPtr + 1] * alpha2; + bs += -buffer[lastPtr + 2] * alpha2; + as += -alpha2; + } + else { + } } } - if (textFieldHeight > textHeight) { - alignType = values[11 /* verticalAlign */]; - if (alignType == egret.VerticalAlign.BOTTOM) { - this.$textStartY = textFieldHeight - textHeight; - } - else if (alignType == egret.VerticalAlign.MIDDLE) { - this.$textStartY = Math.floor((textFieldHeight - textHeight) / 2); + // Copy column + for (var i = x * 4, end = i + h * stride, j = 0; i < end; i += stride, j += 4) { + buffer[i + 0] = columnBuffer[j + 0]; + buffer[i + 1] = columnBuffer[j + 1]; + buffer[i + 2] = columnBuffer[j + 2]; + buffer[i + 3] = columnBuffer[j + 3]; + } + } + } + function glowFilter(buffer, w, h, color, blurX, blurY, strength) { + dropShadowFilter(buffer, w, h, color, blurX, blurY, 0, 0, strength); + } + function dropShadowFilter(buffer, w, h, color, blurX, blurY, angle, distance, strength) { + var tmp = alphaFilter(buffer, color); + panFilter(tmp, w, h, angle, distance); + blurFilter(tmp, w, h, blurX, blurY); + scaleAlphaChannel(tmp, strength); + compositeSourceOver(tmp, buffer); + buffer.set(tmp); + } + function alphaFilter(buffer, color) { + if (!color) { + color = [0, 0, 0, 0]; + } + var plane = new Uint8ClampedArray(buffer); + for (var ptr = 0, end = plane.length; ptr < end; ptr += 4) { + var alpha = plane[ptr + 3]; + plane[ptr + 0] = color[0] * alpha; + plane[ptr + 1] = color[1] * alpha; + plane[ptr + 2] = color[2] * alpha; + } + return plane; + } + function panFilter(buffer, w, h, angle, distance) { + var dy = (Math.sin(angle) * distance) | 0; + var dx = (Math.cos(angle) * distance) | 0; + var oldBuffer = new Int32Array(buffer.buffer); + var newBuffer = new Int32Array(oldBuffer.length); + for (var oy = 0; oy < h; oy++) { + var ny = oy + dy; + if (ny < 0 || ny > h) { + continue; + } + for (var ox = 0; ox < w; ox++) { + var nx = ox + dx; + if (nx < 0 || nx > w) { + continue; } + newBuffer[ny * w + nx] = oldBuffer[oy * w + ox]; } - return textLines; - }; - /** - * @language en_US - * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 - * @default 0.33 - * @version Egret 2.4 - * @platform Web,Native - */ - BitmapText.EMPTY_FACTOR = 0.33; - return BitmapText; - }(egret.DisplayObject)); - egret.BitmapText = BitmapText; - egret.registerClass(BitmapText,'egret.BitmapText'); + } + oldBuffer.set(newBuffer); + } + function scaleAlphaChannel(buffer, value) { + for (var ptr = 0, end = buffer.length; ptr < end; ptr += 4) { + buffer[ptr + 3] *= value; + } + } + function compositeSourceOver(dst, src) { + for (var ptr = 0, end = dst.length; ptr < end; ptr += 4) { + var Dr = dst[ptr + 0]; + var Dg = dst[ptr + 1]; + var Db = dst[ptr + 2]; + var Da = dst[ptr + 3] / 255; + var Sr = src[ptr + 0]; + var Sg = src[ptr + 1]; + var Sb = src[ptr + 2]; + var Sa = src[ptr + 3] / 255; + dst[ptr + 0] = Sr + Dr * (1 - Sa); + dst[ptr + 1] = Sg + Dg * (1 - Sa); + dst[ptr + 2] = Sb + Db * (1 - Sa); + dst[ptr + 3] = (Sa + Da * (1 - Sa)) * 255; + } + } })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -18087,125 +16399,25 @@ var egret; // // * Redistributions of source code must retain the above copyright // notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * The HorizontalAlign class defines the possible values for the horizontal alignment. - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * HorizontalAlign 类为水平对齐方式定义可能的值。 - * @see egret.TextField#textAlign - * @version Egret 2.4 - * @platform Web,Native - */ - var HorizontalAlign = (function () { - function HorizontalAlign() { - } - var d = __define,c=HorizontalAlign,p=c.prototype; - /** - * @language en_US - * Horizontally align content to the left of the container. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 将内容与容器的左侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - */ - HorizontalAlign.LEFT = "left"; - /** - * @language en_US - * Horizontally align content to the right of the container. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 将内容与容器的右侧对齐。 - * @version Egret 2.4 - * @platform Web,Native - */ - HorizontalAlign.RIGHT = "right"; - /** - * @language en_US - * Horizontally align content in the center of the container. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 在容器的水平中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native - */ - HorizontalAlign.CENTER = "center"; - /** - * @language en_US - * Horizontal alignment with both edges. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 水平两端对齐。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - */ - HorizontalAlign.JUSTIFY = "justify"; - /** - * @language en_US - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". - * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. - * Note: TextFiled does not support this alignment method. - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 - * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 - * 注意:TextFiled不支持此对齐方式。 - * @constant egret.HorizontalAlign.CONTENT_JUSTIFY - * @version Egret 2.4 - * @platform Web,Native - */ - HorizontalAlign.CONTENT_JUSTIFY = "contentJustify"; - return HorizontalAlign; - }()); - egret.HorizontalAlign = HorizontalAlign; - egret.registerClass(HorizontalAlign,'egret.HorizontalAlign'); -})(egret || (egret = {})); +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. @@ -18236,234 +16448,102 @@ var egret; ////////////////////////////////////////////////////////////////////////////////////// var egret; (function (egret) { - /** - * @language en_US - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - */ - /** - * @language zh_CN - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/HtmlTextParser.ts - */ - var HtmlTextParser = (function () { + var sys; + (function (sys) { /** - * @version Egret 2.4 - * @platform Web,Native + * @private + * 屏幕适配器默认实现,开发者可以实现自定义规则的屏幕适配器。并在初始化加载时将适配器的实例赋值给egret.sys.screenAdapter上,从而替换掉默认适配器。 */ - function HtmlTextParser() { - this.replaceArr = []; + var DefaultScreenAdapter = (function (_super) { + __extends(DefaultScreenAdapter, _super); /** * @private */ - this.resutlArr = []; - this.initReplaceArr(); - } - var d = __define,c=HtmlTextParser,p=c.prototype; - p.initReplaceArr = function () { - this.replaceArr = []; - this.replaceArr.push([/</g, "<"]); - this.replaceArr.push([/>/g, ">"]); - this.replaceArr.push([/&/g, "&"]); - this.replaceArr.push([/"/g, "\""]); - this.replaceArr.push([/'/g, "\'"]); - }; - /** - * @private - * - * @param value - * @returns - */ - p.replaceSpecial = function (value) { - for (var i = 0; i < this.replaceArr.length; i++) { - var k = this.replaceArr[i][0]; - var v = this.replaceArr[i][1]; - value = value.replace(k, v); - } - return value; - }; - /** - * @language en_US - * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property - * @param htmltext {string} Text in html - * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 - * @param htmltext {string} html文本 - * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 - * @version Egret 2.4 - * @platform Web,Native - */ - p.parser = function (htmltext) { - this.stackArray = []; - this.resutlArr = []; - var firstIdx = 0; //文本段开始位置 - var length = htmltext.length; - while (firstIdx < length) { - var starIdx = htmltext.indexOf("<", firstIdx); - if (starIdx < 0) { - this.addToResultArr(htmltext.substring(firstIdx)); - firstIdx = length; - } - else { - this.addToResultArr(htmltext.substring(firstIdx, starIdx)); - var fontEnd = htmltext.indexOf(">", starIdx); - if (fontEnd == -1) { - egret.$error(1038); - fontEnd = starIdx; - } - else if (htmltext.charAt(starIdx + 1) == "\/") { - this.stackArray.pop(); - } - else { - this.addToArray(htmltext.substring(starIdx + 1, fontEnd)); - } - firstIdx = fontEnd + 1; - } - } - return this.resutlArr; - }; - /** - * @private - * - * @param value - */ - p.addToResultArr = function (value) { - if (value == "") { - return; - } - value = this.replaceSpecial(value); - if (this.stackArray.length > 0) { - this.resutlArr.push({ text: value, style: this.stackArray[this.stackArray.length - 1] }); - } - else { - this.resutlArr.push({ text: value }); - } - }; - //将字符数据转成Json数据 - p.changeStringToObject = function (str) { - str = str.trim(); - var info = {}; - var header = []; - if (str.charAt(0) == "i" || str.charAt(0) == "b" || str.charAt(0) == "u") { - this.addProperty(info, str, "true"); - } - else if (header = str.match(/^(font|a)\s/)) { - str = str.substring(header[0].length).trim(); - var next = 0; - var titles; - while (titles = str.match(this.getHeadReg())) { - var title = titles[0]; - var value = ""; - var str = str.substring(title.length).trim(); - if (str.charAt(0) == "\"") { - var next = str.indexOf("\"", 1); - value = str.substring(1, next); - next += 1; - } - else if (str.charAt(0) == "\'") { - var next = str.indexOf("\'", 1); - value = str.substring(1, next); - next += 1; - } - else { - value = str.match(/(\S)+/)[0]; - next = value.length; - } - this.addProperty(info, title.substring(0, title.length - 1).trim(), value.trim()); - str = str.substring(next).trim(); - } - } - return info; - }; - /** - * @private - * - * @returns - */ - p.getHeadReg = function () { - return /^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/; - }; - /** - * @private - * - * @param info - * @param head - * @param value - */ - p.addProperty = function (info, head, value) { - switch (head.toLowerCase()) { - case "color": - case "textcolor": - value = value.replace(/#/, "0x"); - info.textColor = parseInt(value); - break; - case "strokecolor": - value = value.replace(/#/, "0x"); - info.strokeColor = parseInt(value); - break; - case "stroke": - info.stroke = parseInt(value); - break; - case "b": - case "bold": - info.bold = value == "true"; - break; - case "u": - info.underline = value == "true"; - break; - case "i": - case "italic": - info.italic = value == "true"; - break; - case "size": - info.size = parseInt(value); - break; - case "fontfamily": - info.fontFamily = value; - break; - case "href": - info.href = this.replaceSpecial(value); - break; - case "target": - info.target = this.replaceSpecial(value); - break; - } - }; - /** - * @private - * - * @param infoStr - */ - p.addToArray = function (infoStr) { - var info = this.changeStringToObject(infoStr); - if (this.stackArray.length == 0) { - this.stackArray.push(info); + function DefaultScreenAdapter() { + _super.call(this); } - else { - var lastInfo = this.stackArray[this.stackArray.length - 1]; - for (var key in lastInfo) { - if (info[key] == null) { - info[key] = lastInfo[key]; - } + var d = __define,c=DefaultScreenAdapter,p=c.prototype; + /** + * @private + * 计算舞台显示尺寸 + * @param scaleMode 当前的缩放模式 + * @param screenWidth 播放器视口宽度 + * @param screenHeight 播放器视口高度 + * @param contentWidth 初始化内容宽度 + * @param contentHeight 初始化内容高度 + */ + p.calculateStageSize = function (scaleMode, screenWidth, screenHeight, contentWidth, contentHeight) { + var displayWidth = screenWidth; + var displayHeight = screenHeight; + var stageWidth = contentWidth; + var stageHeight = contentHeight; + var scaleX = (screenWidth / stageWidth) || 0; + var scaleY = (screenHeight / stageHeight) || 0; + switch (scaleMode) { + case egret.StageScaleMode.EXACT_FIT: + break; + case egret.StageScaleMode.FIXED_HEIGHT: + stageWidth = Math.round(screenWidth / scaleY); + break; + case egret.StageScaleMode.FIXED_WIDTH: + stageHeight = Math.round(screenHeight / scaleX); + break; + case egret.StageScaleMode.NO_BORDER: + if (scaleX > scaleY) { + displayHeight = Math.round(stageHeight * scaleX); + } + else { + displayWidth = Math.round(stageWidth * scaleY); + } + break; + case egret.StageScaleMode.SHOW_ALL: + if (scaleX > scaleY) { + displayWidth = Math.round(stageWidth * scaleY); + } + else { + displayHeight = Math.round(stageHeight * scaleX); + } + break; + case egret.StageScaleMode.FIXED_NARROW: + if (scaleX > scaleY) { + stageWidth = Math.round(screenWidth / scaleY); + } + else { + stageHeight = Math.round(screenHeight / scaleX); + } + break; + case egret.StageScaleMode.FIXED_WIDE: + if (scaleX > scaleY) { + stageHeight = Math.round(screenHeight / scaleX); + } + else { + stageWidth = Math.round(screenWidth / scaleY); + } + break; + default: + stageWidth = screenWidth; + stageHeight = screenHeight; + break; } - this.stackArray.push(info); - } - }; - return HtmlTextParser; - }()); - egret.HtmlTextParser = HtmlTextParser; - egret.registerClass(HtmlTextParser,'egret.HtmlTextParser'); + //宽高不是2的整数倍会导致图片绘制出现问题 + if (displayWidth % 2 != 0) { + displayWidth += 1; + } + if (displayHeight % 2 != 0) { + displayHeight += 1; + } + return { + stageWidth: stageWidth, + stageHeight: stageHeight, + displayWidth: displayWidth, + displayHeight: displayHeight + }; + }; + return DefaultScreenAdapter; + }(egret.HashObject)); + sys.DefaultScreenAdapter = DefaultScreenAdapter; + egret.registerClass(DefaultScreenAdapter,'egret.sys.DefaultScreenAdapter',["egret.sys.IScreenAdapter"]); + })(sys = egret.sys || (egret.sys = {})); })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -18493,6 +16573,119 @@ var egret; // EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // ////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * StageScaleMode class provides values for the stage zoom mode. + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/player/StageScaleMode.ts + */ + /** + * @language zh_CN + * StageScaleMode 类为舞台缩放模式提供值。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/player/StageScaleMode.ts + */ + var StageScaleMode = (function () { + function StageScaleMode() { + } + var d = __define,c=StageScaleMode,p=c.prototype; + /** + * @language en_US + * Do not scale application content. Even when you change the player viewport size, it remains unchanged. If the player is smaller than the viewport content, possibly with some cropping.
      + * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) always with the player viewport size consistent. + */ + /** + * @language zh_CN + * 不缩放应用程序内容。即使在更改播放器视口大小时,它仍然保持不变。如果播放器视口比内容小,则可能进行一些裁切。
      + * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终跟播放器视口大小保持一致。 + */ + StageScaleMode.NO_SCALE = "noScale"; + /** + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling a wide directions application content to fill the viewport players on both sides in the other direction may not be wide enough and left black bars.
      + * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. + */ + /** + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较宽方向填满播放器视口,另一个方向的两侧可能会不够宽而留有黑边。
      + * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 + */ + StageScaleMode.SHOW_ALL = "showAll"; + /** + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling a narrow direction of application content to fill the viewport players on both sides in the other direction may exceed the viewport and the player is cut.
      + * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. + */ + /** + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容的较窄方向填满播放器视口,另一个方向的两侧可能会超出播放器视口而被裁切。
      + * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 + */ + StageScaleMode.NO_BORDER = "noBorder"; + /** + * @language en_US + * Do not keep the original aspect ratio scaling application content, after scaling application content just fill the player viewport.
      + * In this mode, the stage size (Stage.stageWidth, Stage.stageHeight) is always equal to the initialization incoming external application content size. + */ + /** + * @language zh_CN + * 不保持原始宽高比缩放应用程序内容,缩放后应用程序内容正好填满播放器视口。
      + * 在此模式下,舞台尺寸(Stage.stageWidth,Stage.stageHeight)始终等于初始化时外部传入的应用程序内容尺寸。 + */ + StageScaleMode.EXACT_FIT = "exactFit"; + /** + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant width, height may change.
      + * In this mode, the stage width (Stage.stageWidth) is always equal to initialize external incoming application content width. Stage height (Stage.stageHeight) by the current scale with the player viewport height decision. + */ + /** + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始宽度不变,高度可能会改变。
      + * 在此模式下,舞台宽度(Stage.stageWidth)始终等于初始化时外部传入的应用程序内容宽度。舞台高度(Stage.stageHeight)由当前的缩放比例与播放器视口高度决定。 + */ + StageScaleMode.FIXED_WIDTH = "fixedWidth"; + /** + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, but only to keep the contents of the original application constant height, width may change.
      + * In this mode, the stage height (Stage.stageHeight) is always equal to initialize external incoming application content height. Stage width (Stage.stageWidth) by the current scale with the player viewport width decision. + */ + /** + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,但只保持应用程序内容的原始高度不变,宽度可能会改变。
      + * 在此模式下,舞台高度(Stage.stageHeight)始终等于初始化时外部传入的应用程序内容高度。舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽度决定。 + */ + StageScaleMode.FIXED_HEIGHT = "fixedHeight"; + /** + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player,a narrow direction may not be wide enough and fill.
      + * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. + */ + /** + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较窄方向可能会不够宽而填充。
      + * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 + */ + StageScaleMode.FIXED_NARROW = "fixedNarrow"; + /** + * @language en_US + * Keep the original aspect ratio scaling application content, after scaling application content in the horizontal and vertical directions to fill the viewport player, a wide direction may exceed the viewport and the player is cut.
      + * In this mode, the stage height (Stage.stageHeight) and the stage width (Stage.stageWidth) by the current scale with the player viewport size. + */ + /** + * @language zh_CN + * 保持原始宽高比缩放应用程序内容,缩放后应用程序内容在水平和垂直方向都填满播放器视口,应用程序内容的较宽方向的两侧可能会超出播放器视口而被裁切。
      + * 在此模式下,舞台高度(Stage.stageHeight)和舞台宽度(Stage.stageWidth)由当前的缩放比例与播放器视口宽高决定。 + */ + StageScaleMode.FIXED_WIDE = "fixedWide"; + return StageScaleMode; + }()); + egret.StageScaleMode = StageScaleMode; + egret.registerClass(StageScaleMode,'egret.StageScaleMode'); +})(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. @@ -18523,245 +16716,298 @@ var egret; ////////////////////////////////////////////////////////////////////////////////////// var egret; (function (egret) { - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - var InputController = (function (_super) { - __extends(InputController, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function InputController() { - _super.call(this); - /** - * @private - */ - this._text = null; - /** - * @private - */ - this._isFocus = false; - } - var d = __define,c=InputController,p=c.prototype; - /** - * - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - p.init = function (text) { - this._text = text; - this.stageText = new egret.StageText(); - this.stageText.$setTextField(this._text); - }; - /** - * @private - * - */ - p._addStageText = function () { - if (!this._text.$inputEnabled) { - this._text.$touchEnabled = true; - } - this.tempStage = this._text.stage; - this.stageText.$addToStage(); - this.stageText.addEventListener("updateText", this.updateTextHandler, this); - this._text.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); - this.stageText.addEventListener("blur", this.blurHandler, this); - this.stageText.addEventListener("focus", this.focusHandler, this); - }; - /** - * @private - * - */ - p._removeStageText = function () { - if (!this._text.$inputEnabled) { - this._text.$touchEnabled = false; - } - this.stageText.$removeFromStage(); - this.stageText.removeEventListener("updateText", this.updateTextHandler, this); - this._text.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - this.stageText.removeEventListener("blur", this.blurHandler, this); - this.stageText.removeEventListener("focus", this.focusHandler, this); - }; + var sys; + (function (sys) { + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var sys; + (function (sys) { /** * @private - * - * @returns */ - p._getText = function () { - return this.stageText.$getText(); - }; + sys.$START_TIME = 0; /** * @private - * - * @param value + * 是否要广播Event.RENDER事件的标志。 */ - p._setText = function (value) { - this.stageText.$setText(value); - }; + sys.$invalidateRenderFlag = false; /** * @private + * 需要立即刷新屏幕的标志 */ - p._setColor = function (value) { - this.stageText.$setColor(value); - }; + sys.$requestRenderingFlag = false; /** * @private - * - * @param event + * Egret心跳计时器 */ - p.focusHandler = function (event) { - //不再显示竖线,并且输入框显示最开始 - if (!this._isFocus) { - this._isFocus = true; - if (!event["showing"]) { - this._text.$isTyping = true; + var SystemTicker = (function () { + /** + * @private + */ + function SystemTicker() { + /** + * @private + */ + this.playerList = []; + /** + * @private + */ + this.callBackList = []; + /** + * @private + */ + this.thisObjectList = []; + /** + * @private + * 全局帧率 + */ + this.$frameRate = 30; + this.lastTimeStamp = 0; + /** + * @private + * ticker 花销的时间 + */ + this.costEnterFrame = 0; + if (DEBUG && sys.$ticker) { + egret.$error(1008, "egret.sys.SystemTicker"); } - this._text.$invalidateContentBounds(); - this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_IN, true)); - } - }; - /** - * @private - * - * @param event - */ - p.blurHandler = function (event) { - if (this._isFocus) { - //不再显示竖线,并且输入框显示最开始 - this._isFocus = false; - this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - this._text.$isTyping = false; - this._text.$invalidateContentBounds(); - //失去焦点后调用 - this.stageText.$onBlur(); - this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_OUT, true)); - } - }; - //点中文本 - p.onMouseDownHandler = function (event) { - event.stopPropagation(); - this.$onFocus(); - }; - p.$onFocus = function () { - var self = this; - if (!this._text.visible) { - return; - } - if (this._isFocus) { - return; + sys.$START_TIME = Date.now(); + this.frameDeltaTime = 1000 / this.$frameRate; + this.lastCount = this.frameInterval = Math.round(60000 / this.$frameRate); } - this.tempStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); - //强制更新输入框位置 - this.stageText.$show(); - }; - //未点中文本 - p.onStageDownHandler = function (event) { - this.stageText.$hide(); - }; - /** - * @private - * - * @param event - */ - p.updateTextHandler = function (event) { - var values = this._text.$TextField; - var textValue = this.stageText.$getText(); - var isChanged = false; - if (values[35 /* restrictAnd */] != null) { - var reg = new RegExp("[" + values[35 /* restrictAnd */] + "]", "g"); - var result = textValue.match(reg); - if (result) { - textValue = result.join(""); + var d = __define,c=SystemTicker,p=c.prototype; + /** + * @private + * 注册一个播放器实例并运行 + */ + p.$addPlayer = function (player) { + if (this.playerList.indexOf(player) != -1) { + return; + } + if (DEBUG) { + egret_stages.push(player.stage); + } + this.playerList = this.playerList.concat(); + this.playerList.push(player); + }; + /** + * @private + * 停止一个播放器实例的运行。 + */ + p.$removePlayer = function (player) { + var index = this.playerList.indexOf(player); + if (index !== -1) { + if (DEBUG) { + var i = egret_stages.indexOf(player.stage); + egret_stages.splice(i, 1); + } + this.playerList = this.playerList.concat(); + this.playerList.splice(index, 1); + } + }; + /** + * @private + */ + p.$startTick = function (callBack, thisObject) { + var index = this.getTickIndex(callBack, thisObject); + if (index != -1) { + return; + } + this.concatTick(); + this.callBackList.push(callBack); + this.thisObjectList.push(thisObject); + }; + /** + * @private + */ + p.$stopTick = function (callBack, thisObject) { + var index = this.getTickIndex(callBack, thisObject); + if (index == -1) { + return; + } + this.concatTick(); + this.callBackList.splice(index, 1); + this.thisObjectList.splice(index, 1); + }; + /** + * @private + */ + p.getTickIndex = function (callBack, thisObject) { + var callBackList = this.callBackList; + var thisObjectList = this.thisObjectList; + for (var i = callBackList.length - 1; i >= 0; i--) { + if (callBackList[i] == callBack && + thisObjectList[i] == thisObject) { + return i; + } + } + return -1; + }; + /** + * @private + * + */ + p.concatTick = function () { + this.callBackList = this.callBackList.concat(); + this.thisObjectList = this.thisObjectList.concat(); + }; + /** + * @private + * 设置全局帧率 + */ + p.$setFrameRate = function (value) { + value = +value || 0; + if (value <= 0) { + return false; + } + if (this.$frameRate == value) { + return false; + } + this.$frameRate = value; + if (value > 60) { + value = 60; + } + //todo + if (egret.Capabilities.runtimeType == egret.RuntimeType.NATIVE) { + egret_native.setFrameRate(value); + value = 60; + } + this.frameDeltaTime = 1000 / value; + //这里用60*1000来避免浮点数计算不准确的问题。 + this.lastCount = this.frameInterval = Math.round(60000 / value); + return true; + }; + /** + * @private + * 执行一次刷新 + */ + p.update = function () { + var t1 = egret.getTimer(); + var callBackList = this.callBackList; + var thisObjectList = this.thisObjectList; + var length = callBackList.length; + var requestRenderingFlag = sys.$requestRenderingFlag; + var timeStamp = egret.getTimer(); + for (var i = 0; i < length; i++) { + if (callBackList[i].call(thisObjectList[i], timeStamp)) { + requestRenderingFlag = true; + } + } + var t2 = egret.getTimer(); + var deltaTime = timeStamp - this.lastTimeStamp; + if (deltaTime >= this.frameDeltaTime) { + this.lastCount = this.frameInterval; } else { - textValue = ""; + this.lastCount -= 1000; + if (this.lastCount > 0) { + if (requestRenderingFlag) { + this.render(false, this.costEnterFrame + t2 - t1); + } + return; + } + this.lastCount += this.frameInterval; } - isChanged = true; - } - if (values[36 /* restrictNot */] != null) { - reg = new RegExp("[^" + values[36 /* restrictNot */] + "]", "g"); - result = textValue.match(reg); - if (result) { - textValue = result.join(""); + this.lastTimeStamp = timeStamp; + this.render(true, this.costEnterFrame + t2 - t1); + var t3 = egret.getTimer(); + this.broadcastEnterFrame(); + var t4 = egret.getTimer(); + this.costEnterFrame = t4 - t3; + }; + /** + * @private + * 执行一次屏幕渲染 + */ + p.render = function (triggerByFrame, costTicker) { + var playerList = this.playerList; + var length = playerList.length; + if (length == 0) { + return; } - else { - textValue = ""; + if (sys.$invalidateRenderFlag) { + this.broadcastRender(); + sys.$invalidateRenderFlag = false; } - isChanged = true; - } - if (isChanged && this.stageText.$getText() != textValue) { - this.stageText.$setText(textValue); - } - this.resetText(); - //抛出change事件 - this._text.dispatchEvent(new egret.Event(egret.Event.CHANGE, true)); - }; - /** - * @private - * - */ - p.resetText = function () { - this._text.$setBaseText(this.stageText.$getText()); - }; - /** - * @private - * - */ - p._hideInput = function () { - this.stageText.$removeFromStage(); - }; - /** - * @private - * - */ - p.updateInput = function () { - if (!this._text.$visible && this.stageText) { - this._hideInput(); - } - }; + for (var i = 0; i < length; i++) { + playerList[i].$render(triggerByFrame, costTicker); + } + sys.$requestRenderingFlag = false; + }; + /** + * @private + * 广播EnterFrame事件。 + */ + p.broadcastEnterFrame = function () { + var list = egret.DisplayObject.$enterFrameCallBackList; + var length = list.length; + if (length == 0) { + return; + } + list = list.concat(); + for (var i = 0; i < length; i++) { + list[i].dispatchEventWith(egret.Event.ENTER_FRAME); + } + }; + /** + * @private + * 广播Render事件。 + */ + p.broadcastRender = function () { + var list = egret.DisplayObject.$renderCallBackList; + var length = list.length; + if (length == 0) { + return; + } + list = list.concat(); + for (var i = 0; i < length; i++) { + list[i].dispatchEventWith(egret.Event.RENDER); + } + }; + return SystemTicker; + }()); + sys.SystemTicker = SystemTicker; + egret.registerClass(SystemTicker,'egret.sys.SystemTicker'); /** * @private - * + * 心跳计时器单例 */ - p._updateProperties = function () { - if (this._isFocus) { - //整体修改 - this.stageText.$resetStageText(); - this.updateInput(); - return; - } - var stage = this._text.$stage; - if (stage == null) { - } - else { - var item = this._text; - var visible = item.$visible; - while (true) { - if (!visible) { - break; - } - item = item.parent; - if (item == stage) { - break; - } - visible = item.$visible; - } - } - this.stageText.$setText(this._text.$TextField[13 /* text */]); - //整体修改 - this.stageText.$resetStageText(); - this.updateInput(); - }; - return InputController; - }(egret.HashObject)); - egret.InputController = InputController; - egret.registerClass(InputController,'egret.InputController'); + sys.$ticker = new sys.SystemTicker(); + })(sys = egret.sys || (egret.sys = {})); })(egret || (egret = {})); +if (DEBUG) { + var egret_stages = []; +} ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. @@ -18791,6 +17037,134 @@ var egret; // ////////////////////////////////////////////////////////////////////////////////////// var egret; +(function (egret) { + var sys; + (function (sys) { + /** + * @private + * 用户交互操作管理器 + */ + var TouchHandler = (function (_super) { + __extends(TouchHandler, _super); + /** + * @private + */ + function TouchHandler(stage) { + _super.call(this); + this.maxTouches = 0; + this.useTouchesCount = 0; + /** + * @private + */ + this.touchDownTarget = {}; + /** + * @private + */ + this.lastTouchX = -1; + /** + * @private + */ + this.lastTouchY = -1; + this.stage = stage; + } + var d = __define,c=TouchHandler,p=c.prototype; + /** + * @private + * 设置同时触摸数量 + */ + p.$initMaxTouches = function () { + this.maxTouches = this.stage.$maxTouches; + }; + /** + * @private + * 触摸开始(按下) + * @param x 事件发生处相对于舞台的坐标x + * @param y 事件发生处相对于舞台的坐标y + * @param touchPointID 分配给触摸点的唯一标识号 + */ + p.onTouchBegin = function (x, y, touchPointID) { + if (this.useTouchesCount >= this.maxTouches) { + return; + } + this.lastTouchX = x; + this.lastTouchY = y; + var target = this.findTarget(x, y); + if (this.touchDownTarget[touchPointID] == null) { + this.touchDownTarget[touchPointID] = target; + this.useTouchesCount++; + } + egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_BEGIN, true, true, x, y, touchPointID, true); + }; + /** + * @private + * 触摸移动 + * @param x 事件发生处相对于舞台的坐标x + * @param y 事件发生处相对于舞台的坐标y + * @param touchPointID 分配给触摸点的唯一标识号 + */ + p.onTouchMove = function (x, y, touchPointID) { + if (this.touchDownTarget[touchPointID] == null) { + return; + } + if (this.lastTouchX == x && this.lastTouchY == y) { + return; + } + this.lastTouchX = x; + this.lastTouchY = y; + var target = this.findTarget(x, y); + egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_MOVE, true, true, x, y, touchPointID, true); + }; + /** + * @private + * 触摸结束(弹起) + * @param x 事件发生处相对于舞台的坐标x + * @param y 事件发生处相对于舞台的坐标y + * @param touchPointID 分配给触摸点的唯一标识号 + */ + p.onTouchEnd = function (x, y, touchPointID) { + if (this.touchDownTarget[touchPointID] == null) { + return; + } + var target = this.findTarget(x, y); + var oldTarget = this.touchDownTarget[touchPointID]; + delete this.touchDownTarget[touchPointID]; + this.useTouchesCount--; + egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_END, true, true, x, y, touchPointID, false); + if (oldTarget == target) { + egret.TouchEvent.dispatchTouchEvent(target, egret.TouchEvent.TOUCH_TAP, true, true, x, y, touchPointID, false); + } + else { + egret.TouchEvent.dispatchTouchEvent(oldTarget, egret.TouchEvent.TOUCH_RELEASE_OUTSIDE, true, true, x, y, touchPointID, false); + } + }; + /** + * @private + * 获取舞台坐标下的触摸对象 + */ + p.findTarget = function (stageX, stageY) { + var target = this.stage.$hitTest(stageX, stageY); + if (!target) { + target = this.stage; + } + return target; + }; + return TouchHandler; + }(egret.HashObject)); + sys.TouchHandler = TouchHandler; + egret.registerClass(TouchHandler,'egret.sys.TouchHandler'); + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +var egret; +(function (egret) { + /** + * @copy egret.Orientation + */ + egret.DeviceOrientation = null; +})(egret || (egret = {})); +var egret; +(function (egret) { +})(egret || (egret = {})); +var egret; (function (egret) { })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// @@ -18811,1814 +17185,1845 @@ var egret; // // THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS // OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var SplitRegex = new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"); - /** - * @private - * 根据样式测量文本宽度 - */ - function measureTextWidth(text, values, style) { - style = style || {}; - var italic = style.italic == null ? values[16 /* italic */] : style.italic; - var bold = style.bold == null ? values[15 /* bold */] : style.bold; - var size = style.size == null ? values[0 /* fontSize */] : style.size; - var fontFamily = style.fontFamily || values[8 /* fontFamily */] || TextField.default_fontFamily; - return egret.sys.measureText(text, fontFamily, size, bold, italic); - } - /** - * @language en_US - * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering - * If developers expect no differences among all platforms, please use BitmapText - * @see http://edn.egret.com/cn/docs/page/141 Create Text - * - * @event egret.Event.CHANGE Dispatched when entering text user input。 - * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. - * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - */ - /** - * @language zh_CN - * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 - * 如果开发者希望所有平台完全无差异,请使用BitmapText - * @see http://edn.egret.com/cn/docs/page/141 创建文本 - * - * @event egret.Event.CHANGE 输入文本有用户输入时调度。 - * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 - * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/text/TextField.ts - */ - var TextField = (function (_super) { - __extends(TextField, _super); - /** - * @version Egret 2.4 - * @platform Web,Native - */ - function TextField() { - _super.call(this); - this.$inputEnabled = false; - /** - * @private - */ - this.inputUtils = null; - /** - * @private - */ - this.graphicsNode = null; - /** - * @private - */ - this.isFlow = false; - /** - * @private - */ - this.textArr = []; - /** - * @private - */ - this.linesArr = []; - /** - * @private - */ - this.$isTyping = false; - var textNode = new egret.sys.TextNode(); - textNode.fontFamily = TextField.default_fontFamily; - this.textNode = textNode; - this.$renderNode = textNode; - this.$TextField = { - 0: 30, - 1: 0, - 2: 0xffffff, - 3: NaN, - 4: NaN, - 5: 0, - 6: 0, - 7: 0, - 8: TextField.default_fontFamily, - 9: "left", - 10: "top", - 11: "#ffffff", - 12: "", - 13: "", - 14: [], - 15: false, - 16: false, - 17: true, - 18: false, - 19: false, - 20: false, - 21: 0, - 22: 0, - 23: 0, - 24: egret.TextFieldType.DYNAMIC, - 25: 0x000000, - 26: "#000000", - 27: 0, - 28: -1, - 29: 0, - 30: false, - 31: false, - 32: 0x000000, - 33: false, - 34: 0xffffff, - 35: null, - 36: null, - 37: egret.TextFieldInputType.TEXT //inputType - }; - } - var d = __define,c=TextField,p=c.prototype; - /** - * @private - */ - p.isInput = function () { - return this.$TextField[24 /* type */] == egret.TextFieldType.INPUT; - }; - p.$setTouchEnabled = function (value) { - var result = _super.prototype.$setTouchEnabled.call(this, value); - if (this.isInput()) { - this.$inputEnabled = true; - } - return result; - }; - d(p, "fontFamily" - /** - * @language en_US - * The name of the font to use, or a comma-separated list of font names. - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 要使用的字体的名称或用逗号分隔的字体名称列表。 - * @default "Arial" - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$TextField[8 /* fontFamily */]; - } - ,function (value) { - this.$setFontFamily(value); - } - ); - p.$setFontFamily = function (value) { - var values = this.$TextField; - if (values[8 /* fontFamily */] == value) { - return false; - } - values[8 /* fontFamily */] = value; - this.invalidateFontString(); - return true; - }; - d(p, "size" - /** - * @language en_US - * The size in pixels of text - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 文本的字号大小。 - * @default 30 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$TextField[0 /* fontSize */]; - } - ,function (value) { - this.$setSize(value); - } - ); - p.$setSize = function (value) { - value = +value || 0; - var values = this.$TextField; - if (values[0 /* fontSize */] == value) { - return false; - } - values[0 /* fontSize */] = value; - this.invalidateFontString(); - return true; - }; - d(p, "bold" - /** - * @language en_US - * Specifies whether the text is boldface. - * @default false - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 是否显示为粗体。 - * @default false - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$TextField[15 /* bold */]; - } - ,function (value) { - this.$setBold(value); - } - ); - p.$setBold = function (value) { - value = !!value; - var values = this.$TextField; - if (value == values[15 /* bold */]) { - return false; - } - values[15 /* bold */] = value; - this.invalidateFontString(); - return true; - }; - d(p, "italic" +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * Type of operation. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 运行类型的类型。 + * @version Egret 2.4 + * @platform Web,Native + */ + var RuntimeType = (function () { + function RuntimeType() { + } + var d = __define,c=RuntimeType,p=c.prototype; + /** + * @language en_US + * Running on Web + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 运行在Web上 + * @version Egret 2.4 + * @platform Web,Native + */ + RuntimeType.WEB = "web"; + /** + * @language en_US + * Running on NATIVE + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 运行在NATIVE上 + * @version Egret 2.4 + * @platform Web,Native + */ + RuntimeType.NATIVE = "native"; + return RuntimeType; + }()); + egret.RuntimeType = RuntimeType; + egret.registerClass(RuntimeType,'egret.RuntimeType'); + /** + * @language en_US + * The Capabilities class provides properties that describe the system and runtime that are hosting the application. + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/system/Capabilities.ts + */ + /** + * @language zh_CN + * Capabilities 类提供一些属性,这些属性描述了承载应用程序的系统和运行时。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/system/Capabilities.ts + */ + var Capabilities = (function () { + function Capabilities() { + } + var d = __define,c=Capabilities,p=c.prototype; + d(Capabilities, "language" /** * @language en_US - * Determines whether the text is italic font. - * @default false + * Specifies the language code of the system on which the content is running. The language is specified as a lowercase + * two-letter language code from ISO 639-1. For Chinese, an additional uppercase two-letter country code from ISO 3166 + * distinguishes between Simplified and Traditional Chinese.
      + * The following table lists the possible values,but not limited to them: + *
        + *
      • Simplified Chinese zh-CN
      • + *
      • Traditional Chinese zh-TW
      • + *
      • English en
      • + *
      • Japanese ja
      • + *
      • Korean ko
      • + *
      * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 是否显示为斜体。 - * @default false + * 表示运行内容的系统的语言代码。语言指定为 ISO 639-1 中的小写双字母语言代码。 + * 对于中文,另外使用 ISO 3166 中的大写双字母国家/地区代码,以区分简体中文和繁体中文。
      + * 以下是可能但不限于的语言和值: + *
        + *
      • 简体中文 zh-CN
      • + *
      • 繁体中文 zh-TW
      • + *
      • 英语 en
      • + *
      • 日语 ja
      • + *
      • 韩语 ko
      • + *
      * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.$TextField[16 /* italic */]; - } - ,function (value) { - this.$setItalic(value); + return Capabilities.$language; } ); - p.$setItalic = function (value) { - value = !!value; - var values = this.$TextField; - if (value == values[16 /* italic */]) { - return false; - } - values[16 /* italic */] = value; - this.invalidateFontString(); - return true; - }; - /** - * @private - * - */ - p.invalidateFontString = function () { - this.$TextField[17 /* fontStringChanged */] = true; - this.$invalidateTextField(); - }; - d(p, "textAlign" + d(Capabilities, "isMobile" /** * @language en_US - * Horizontal alignment of text. - * @default:egret.HorizontalAlign.LEFT + * Specifies whether the system is running in a mobile device.(such as a mobile phone or tablet) * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 文本的水平对齐方式。 - * @default:egret.HorizontalAlign.LEFT + * 表示程序内容是否运行在移动设备中(例如移动电话或平板电脑)。 * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.$TextField[9 /* textAlign */]; - } - ,function (value) { - this.$setTextAlign(value); + return Capabilities.$isMobile; } ); - p.$setTextAlign = function (value) { - var values = this.$TextField; - if (values[9 /* textAlign */] == value) { - return false; - } - values[9 /* textAlign */] = value; - this.$invalidateTextField(); - return true; - }; - d(p, "verticalAlign" + d(Capabilities, "os" /** * @language en_US - * Vertical alignment of text. - * @default:egret.VerticalAlign.TOP + * Specifies the current operating system. The os property can return the following strings: + *
        + *
      • iPhone "iOS"
      • + *
      • Android Phone "Android"
      • + *
      • Windows Phone "Windows Phone"
      • + *
      • Windows Desktop "Windows PC"
      • + *
      • Mac Desktop "Mac OS"
      • + *
      • Unknown OS "Unknown"
      • + *
      * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 文字的垂直对齐方式。 - * @default:egret.VerticalAlign.TOP + * 指示当前的操作系统。os 属性返回下列字符串: + *
        + *
      • 苹果手机操作系统 "iOS"
      • + *
      • 安卓手机操作系统 "Android"
      • + *
      • 微软手机操作系统 "Windows Phone"
      • + *
      • 微软桌面操作系统 "Windows PC"
      • + *
      • 苹果桌面操作系统 "Mac OS"
      • + *
      • 未知操作系统 "Unknown"
      • + *
      * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.$TextField[10 /* verticalAlign */]; - } - ,function (value) { - this.$setVerticalAlign(value); + return Capabilities.$os; } ); - p.$setVerticalAlign = function (value) { - var values = this.$TextField; - if (values[10 /* verticalAlign */] == value) { - return false; - } - values[10 /* verticalAlign */] = value; - this.$invalidateTextField(); - return true; - }; - d(p, "lineSpacing" + d(Capabilities, "runtimeType" /** * @language en_US - * An integer representing the amount of vertical space between lines. - * @default 0 + * It indicates the current type of operation. runtimeType property returns the following string: + *
        + *
      • Run on Web egret.RuntimeType.WEB
      • + *
      • Run on Native egret.RuntimeType.NATIVE
      • + *
      * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 一个整数,表示行与行之间的垂直间距量 - * @default 0 + * 指示当前的运行类型。runtimeType 属性返回下列字符串: + *
        + *
      • 运行在Web上 egret.RuntimeType.WEB
      • + *
      • 运行在Native上 egret.RuntimeType.NATIVE
      • + *
      * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.$TextField[1 /* lineSpacing */]; - } - ,function (value) { - this.$setLineSpacing(value); + return Capabilities.$runtimeType; } ); - p.$setLineSpacing = function (value) { - value = +value || 0; - var values = this.$TextField; - if (values[1 /* lineSpacing */] == value) - return false; - values[1 /* lineSpacing */] = value; - this.$invalidateTextField(); - return true; - }; - d(p, "textColor" - /** + d(Capabilities, "supportVersion" + /*** * @language en_US - * Color of the text. - * @default 0x000000 - * @version Egret 2.4 + * version of the native support. + * @type {string} + * @version Egret 2.5 * @platform Web,Native */ - /** + /*** * @language zh_CN - * 文本颜色 - * @default 0x000000 - * @version Egret 2.4 + * native support 的版本号。 + * @type {string} + * @version Egret 2.5 * @platform Web,Native */ ,function () { - return this.$TextField[2 /* textColor */]; - } - ,function (value) { - this.$setTextColor(value); + return Capabilities.$supportVersion; } ); - p.$setTextColor = function (value) { - value = +value | 0; - var values = this.$TextField; - if (values[2 /* textColor */] == value) { - return false; - } - values[2 /* textColor */] = value; - if (this.inputUtils) { - this.inputUtils._setColor(this.$TextField[2 /* textColor */]); + /** + * 设置系统信息 + */ + Capabilities.$setNativeCapabilities = function (value) { + var arr = value.split("-"); + if (arr.length <= 4) { + //todo 未来去掉数量判断,2.5.4版本之前的参数大于4个 + var osType = arr[0]; + switch (osType) { + case "android": + osType = "Android"; + break; + case "ios": + osType = 'iOS'; + break; + } + Capabilities.$os = osType; + var version = arr[2].substring(1, arr[2].length); + Capabilities.$supportVersion = version; } - this.$invalidate(); - return true; }; - d(p, "wordWrap" - /** + d(Capabilities, "renderMode" + /*** * @language en_US - * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; - * if the value is false, the text field by newline characters. - * @default false - * @version Egret 2.4 + * current render mode. + * @type {string} + * @version Egret 3.0.7 * @platform Web,Native */ - /** + /*** * @language zh_CN - * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; - * 如果值为 false,则该文本字段按字符换行。 - * @default false - * @version Egret 2.4 + * 当前渲染模式。 + * @type {string} + * @version Egret 3.0.7 * @platform Web,Native */ ,function () { - return this.$TextField[19 /* wordWrap */]; - } - ,function (value) { - value = !!value; - var values = this.$TextField; - if (value == values[19 /* wordWrap */]) { - return; - } - if (values[20 /* displayAsPassword */]) { - return; - } - values[19 /* wordWrap */] = value; - this.$invalidateTextField(); + return Capabilities.$renderMode; } ); - d(p, "type" - /** - * @version Egret 2.4 + d(Capabilities, "boundingClientWidth" + /*** + * @language en_US + * Clients border width. + * The value before the document class initialization is always 0. + * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. + * @version Egret 3.1.3 + * @platform Web,Native + */ + /*** + * @language zh_CN + * 客户端边界宽度。 + * 该值在文档类初始化之前始终是0。 + * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 + * @version Egret 3.1.3 * @platform Web,Native */ ,function () { - return this.$TextField[24 /* type */]; + return Capabilities.$boundingClientWidth; } - /** + ); + d(Capabilities, "boundingClientHeight" + /*** * @language en_US - * Type of the text field. - * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). - * @default egret.TextFieldType.DYNAMIC + * Clients border height. + * The value before the document class initialization is always 0. + * This value will change after the distribution Event.RESIZE and StageOrientationEvent.ORIENTATION_CHANGE. + * @version Egret 3.1.3 + * @platform Web,Native */ - /** + /*** * @language zh_CN - * 文本字段的类型。 - * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 - * @default egret.TextFieldType.DYNAMIC + * 客户端边界高度。 + * 该值在文档类初始化之前始终是0。 + * 该值在派发 Event.RESIZE 以及 StageOrientationEvent.ORIENTATION_CHANGE 之后会发生改变。 + * @version Egret 3.1.3 + * @platform Web,Native */ - ,function (value) { - this.$setType(value); + ,function () { + return Capabilities.$boundingClientHeight; } ); /** * @private - * - * @param value */ - p.$setType = function (value) { - var values = this.$TextField; - if (values[24 /* type */] != value) { - values[24 /* type */] = value; - if (value == egret.TextFieldType.INPUT) { - if (isNaN(values[3 /* textFieldWidth */])) { - this.$setWidth(100); - } - if (isNaN(values[4 /* textFieldHeight */])) { - this.$setHeight(30); - } - this.$setTouchEnabled(true); - //创建stageText - if (this.inputUtils == null) { - this.inputUtils = new egret.InputController(); - } - this.inputUtils.init(this); - this.$invalidateTextField(); - if (this.$stage) { - this.inputUtils._addStageText(); - } - } - else { - if (this.inputUtils) { - this.inputUtils._removeStageText(); - this.inputUtils = null; - } - this.$setTouchEnabled(false); - } - return true; - } - return false; - }; - d(p, "inputType" + Capabilities.$language = "zh-CN"; + /** + * @private + */ + Capabilities.$os = "Unknown"; + /** + * @private + */ + Capabilities.$runtimeType = "Unknown"; + Capabilities.$supportVersion = "Unknown"; + Capabilities.$renderMode = "Unknown"; + Capabilities.$boundingClientWidth = 0; + Capabilities.$boundingClientHeight = 0; + return Capabilities; + }()); + egret.Capabilities = Capabilities; + egret.registerClass(Capabilities,'egret.Capabilities'); + if (DEBUG) { + egret.$markReadOnly(Capabilities, "language", false); + egret.$markReadOnly(Capabilities, "isMobile", false); + egret.$markReadOnly(Capabilities, "os", false); + egret.$markReadOnly(Capabilities, "runtimeType", false); + egret.$markReadOnly(Capabilities, "supportVersion", false); + egret.$markReadOnly(Capabilities, "renderMode", false); + egret.$markReadOnly(Capabilities, "boundingClientWidth", false); + egret.$markReadOnly(Capabilities, "boundingClientHeight", false); + } +})(egret || (egret = {})); +var testDeviceType = function () { + if (!this["navigator"]) { + return true; + } + var ua = navigator.userAgent.toLowerCase(); + return (ua.indexOf('mobile') != -1 || ua.indexOf('android') != -1); +}; +var testRuntimeType = function () { + if (this["navigator"]) { + return true; + } + return false; +}; +egret.Capabilities.$isMobile = testDeviceType(); +egret.Capabilities.$runtimeType = testRuntimeType() ? egret.RuntimeType.WEB : egret.RuntimeType.NATIVE; +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * Bitmap font, texture set of a font. It is generally used as the value of the BitmapText.font attribute. + * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger + * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 Text(Containing the specific usage of the bitmap font ) + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/text/BitmapFont.ts + */ + /** + * @language zh_CN + * 位图字体,是一个字体的纹理集,通常作为BitmapText.font属性的值。 + * @see http://bbs.egret-labs.org/thread-918-1-1.html TextureMerger + * @see http://bbs.egret-labs.org/forum.php?mod=viewthread&tid=251 文本(含位图字体具体用法) + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/text/BitmapFont.ts + */ + var BitmapFont = (function (_super) { + __extends(BitmapFont, _super); + /** + * @language en_US + * Create an egret.BitmapFont object + * @param texture {egret.Texture} Texture set that use TextureMerger create + * @param config {any} Configure data that use TextureMerger create + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 创建一个 egret.BitmapFont 对象 + * @param texture {egret.Texture} 使用TextureMerger生成的纹理集 + * @param config {any} 使用TextureMerger生成的配置数据 + * @version Egret 2.4 + * @platform Web,Native + */ + function BitmapFont(texture, config) { + _super.call(this, texture); /** - * @version Egret 3.1.2 - * @platform Web,Native + * @private */ - ,function () { - return this.$TextField[37 /* inputType */]; + this.firstCharHeight = 0; + if (typeof (config) == "string") { + this.charList = this.parseConfig(config); } - /** - * @language en_US - * Pop-up keyboard type. - * Any of a TextFieldInputType constants. - */ - /** - * @language zh_CN - * 弹出键盘的类型。 - * TextFieldInputType 常量中的任一个。 - */ - ,function (value) { - this.$TextField[37 /* inputType */] = value; + else if (config && config.hasOwnProperty("frames")) { + this.charList = config.frames; } - ); - d(p, "text" - /** - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.$getText(); + else { + this.charList = {}; } - /** - * @language en_US - * Serve as a string of the current text field in the text - */ - /** - * @language zh_CN - * 作为文本字段中当前文本的字符串 - */ - ,function (value) { - this.$setText(value); + } + var d = __define,c=BitmapFont,p=c.prototype; + /** + * @language en_US + * Obtain corresponding texture through the name attribute + * @param name {string} name Attribute + * @returns {egret.Texture} + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 通过 name 属性获取对应纹理 + * @param name {string} name属性 + * @returns {egret.Texture} + * @version Egret 2.4 + * @platform Web,Native + */ + p.getTexture = function (name) { + var texture = this._textureMap[name]; + if (!texture) { + var c = this.charList[name]; + if (!c) { + return null; + } + texture = this.createTexture(name, c.x, c.y, c.w, c.h, c.offX, c.offY, c.sourceW, c.sourceH); + this._textureMap[name] = texture; } - ); + return texture; + }; /** * @private - * - * @returns */ - p.$getText = function () { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - return this.inputUtils._getText(); + p.getConfig = function (name, key) { + if (!this.charList[name]) { + return 0; } - return this.$TextField[13 /* text */]; + return this.charList[name][key]; }; /** * @private * - * @param value + * @returns */ - p.$setBaseText = function (value) { - if (value == null) { - value = ""; - } - value = value.toString(); - this.isFlow = false; - var values = this.$TextField; - if (values[13 /* text */] != value) { - this.$invalidateTextField(); - values[13 /* text */] = value; - var text = ""; - if (values[20 /* displayAsPassword */]) { - text = this.changeToPassText(value); - } - else { - text = value; + p._getFirstCharHeight = function () { + if (this.firstCharHeight == 0) { + for (var str in this.charList) { + var c = this.charList[str]; + if (c) { + var sourceH = c.sourceH; + if (sourceH === undefined) { + var h = c.h; + if (h === undefined) { + h = 0; + } + var offY = c.offY; + if (offY === undefined) { + offY = 0; + } + sourceH = h + offY; + } + if (sourceH <= 0) { + continue; + } + this.firstCharHeight = sourceH; + break; + } } - this.setMiddleStyle([{ text: text }]); - return true; } - return false; + return this.firstCharHeight; }; /** * @private * - * @param value + * @param fntText + * @returns */ - p.$setText = function (value) { - if (value == null) { - value = ""; + p.parseConfig = function (fntText) { + fntText = fntText.split("\r\n").join("\n"); + var lines = fntText.split("\n"); + var charsCount = this.getConfigByKey(lines[3], "count"); + var chars = {}; + for (var i = 4; i < 4 + charsCount; i++) { + var charText = lines[i]; + var letter = String.fromCharCode(this.getConfigByKey(charText, "id")); + var c = {}; + chars[letter] = c; + c["x"] = this.getConfigByKey(charText, "x"); + c["y"] = this.getConfigByKey(charText, "y"); + c["w"] = this.getConfigByKey(charText, "width"); + c["h"] = this.getConfigByKey(charText, "height"); + c["offX"] = this.getConfigByKey(charText, "xoffset"); + c["offY"] = this.getConfigByKey(charText, "yoffset"); + c["xadvance"] = this.getConfigByKey(charText, "xadvance"); } - var result = this.$setBaseText(value); - if (this.inputUtils) { - this.inputUtils._setText(this.$TextField[13 /* text */]); + return chars; + }; + /** + * @private + * + * @param configText + * @param key + * @returns + */ + p.getConfigByKey = function (configText, key) { + var itemConfigTextList = configText.split(" "); + for (var i = 0, length = itemConfigTextList.length; i < length; i++) { + var itemConfigText = itemConfigTextList[i]; + if (key == itemConfigText.substring(0, key.length)) { + var value = itemConfigText.substring(key.length + 1); + return parseInt(value); + } } - return result; + return 0; }; - d(p, "displayAsPassword" + return BitmapFont; + }(egret.SpriteSheet)); + egret.BitmapFont = BitmapFont; + egret.registerClass(BitmapFont,'egret.BitmapFont'); +})(egret || (egret = {})); +var egret; +(function (egret) { + /** + * @language en_US + * Bitmap font adopts the Bitmap+SpriteSheet mode to render text. + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/text/BitmapText.ts + */ + /** + * @language zh_CN + * 位图字体采用了Bitmap+SpriteSheet的方式来渲染文字。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/text/BitmapText.ts + */ + var BitmapText = (function (_super) { + __extends(BitmapText, _super); + /** + * @language en_US + * Create an egret.BitmapText object + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 创建一个 egret.BitmapText 对象 + * @version Egret 2.4 + * @platform Web,Native + */ + function BitmapText() { + _super.call(this); + /** + * @private + */ + this.$textOffsetX = 0; + /** + * @private + */ + this.$textOffsetY = 0; + /** + * @private + */ + this.$textStartX = 0; + /** + * @private + */ + this.$textStartY = 0; + /** + * @private + */ + this.$lineHeights = []; + this.$renderNode = new egret.sys.BitmapNode(); + //this.cacheAsBitmap = true; + this.$BitmapText = { + 0: NaN, + 1: NaN, + 2: "", + 3: 0, + 4: 0, + 5: null, + 6: false, + 7: false, + 8: false, + 9: false, + 10: "left", + 11: "top", + 12: egret.Bitmap.defaultSmoothing //smoothing + }; + } + var d = __define,c=BitmapText,p=c.prototype; + d(p, "smoothing" /** * @language en_US - * Specify whether the text field is a password text field. - * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. - * @default false + * Whether or not is smoothed when scaled. + * @default true。 + * @version Egret 3.0 + * @platform Web */ /** * @language zh_CN - * 指定文本字段是否是密码文本字段。 - * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 - * @default false + * 控制在缩放时是否进行平滑处理。 + * @default true。 + * @version Egret 3.0 + * @platform Web */ ,function () { - return this.$TextField[20 /* displayAsPassword */]; + var values = this.$BitmapText; + return values[12 /* smoothing */]; } ,function (value) { - this.$setDisplayAsPassword(value); - } - ); - /** - * @private - * - * @param value - */ - p.$setDisplayAsPassword = function (value) { - var values = this.$TextField; - if (values[20 /* displayAsPassword */] != value) { - values[20 /* displayAsPassword */] = value; - this.$invalidateTextField(); - var text = ""; - if (value) { - text = this.changeToPassText(values[13 /* text */]); - } - else { - text = values[13 /* text */]; + value = !!value; + var values = this.$BitmapText; + if (value == values[12 /* smoothing */]) { + return; } - this.setMiddleStyle([{ text: text }]); - return true; + values[12 /* smoothing */] = value; + this.$invalidate(); } - return false; - }; - d(p, "strokeColor" + ); + d(p, "text" /** + * @language en_US + * A string to display in the text field. * @version Egret 2.4 * @platform Web,Native */ - ,function () { - return this.$TextField[25 /* strokeColor */]; - } - /** - * @language en_US - * Represent the stroke color of the text. - * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. - * @default 0x000000 - */ /** * @language zh_CN - * 表示文本的描边颜色。 - * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 - * @default 0x000000 - */ - ,function (value) { - value = +value || 0; - this.$setStrokeColor(value); - } - ); - /** - * @private - * - * @param value - */ - p.$setStrokeColor = function (value) { - var values = this.$TextField; - if (values[25 /* strokeColor */] != value) { - this.$invalidateTextField(); - values[25 /* strokeColor */] = value; - values[26 /* strokeColorString */] = egret.toColorString(value); - return true; - } - return false; - }; - d(p, "stroke" - /** + * 要显示的文本内容 * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.$TextField[27 /* stroke */]; + return this.$BitmapText[2 /* text */]; } - /** - * @language en_US - * Indicate the stroke width. - * 0 means no stroke. - * @default 0 - */ - /** - * @language zh_CN - * 表示描边宽度。 - * 0为没有描边。 - * @default 0 - */ ,function (value) { - this.$setStroke(value); + this.$setText(value); } ); /** * @private - * - * @param value */ - p.$setStroke = function (value) { - if (this.$TextField[27 /* stroke */] != value) { - this.$invalidateTextField(); - this.$TextField[27 /* stroke */] = value; - return true; - } - return false; + p.$setText = function (value) { + value = String(value); + var values = this.$BitmapText; + if (value == values[2 /* text */]) + return false; + values[2 /* text */] = value; + this.$invalidateContentBounds(); + return true; }; - d(p, "maxChars" - /** - * @language en_US - * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. - * The default value is 0. - * @default 0 - */ - /** - * @language zh_CN - * 文本字段中最多可包含的字符数(即用户输入的字符数)。 - * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 - * @default 0 - */ - ,function () { - return this.$TextField[21 /* maxChars */]; - } - ,function (value) { - this.$setMaxChars(value); - } - ); /** * @private - * - * @param value */ - p.$setMaxChars = function (value) { - if (this.$TextField[21 /* maxChars */] != value) { - this.$TextField[21 /* maxChars */] = value; - return true; - } - return false; + p.$getWidth = function () { + var w = this.$BitmapText[0 /* textFieldWidth */]; + return isNaN(w) ? this.$getContentBounds().width : w; }; - d(p, "scrollV" - /** - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return Math.min(Math.max(this.$TextField[28 /* scrollV */], 1), this.maxScrollV); + /** + * @private + */ + p.$setWidth = function (value) { + //value = +value || 0; + var values = this.$BitmapText; + if (value < 0 || value == values[0 /* textFieldWidth */]) { + return false; } - /** - * @language en_US - * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. - * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. - * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). - */ - /** - * @language zh_CN - * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 - * 垂直滚动的单位是行,而水平滚动的单位是像素。 - * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 - */ - ,function (value) { - this.$TextField[28 /* scrollV */] = Math.max(value, 1); - this.$invalidateTextField(); + values[0 /* textFieldWidth */] = value; + this.$invalidateContentBounds(); + return true; + }; + /** + * @private + */ + p.$invalidateContentBounds = function () { + _super.prototype.$invalidateContentBounds.call(this); + this.$BitmapText[7 /* textLinesChanged */] = true; + }; + /** + * @private + */ + p.$getHeight = function () { + var h = this.$BitmapText[1 /* textFieldHeight */]; + return isNaN(h) ? this.$getContentBounds().height : h; + }; + /** + * @private + */ + p.$setHeight = function (value) { + //value = +value || 0; + var values = this.$BitmapText; + if (value < 0 || value == values[1 /* textFieldHeight */]) { + return false; } - ); - d(p, "maxScrollV" + values[1 /* textFieldHeight */] = value; + this.$invalidateContentBounds(); + return true; + }; + d(p, "font" /** * @language en_US - * The maximum value of scrollV + * The name of the font to use, or a comma-separated list of font names, the type of value must be BitmapFont. + * @default null * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * scrollV 的最大值 + * 要使用的字体的名称或用逗号分隔的字体名称列表,类型必须是 BitmapFont。 + * @default null * @version Egret 2.4 * @platform Web,Native */ ,function () { - this.$getLinesArr(); - return Math.max(this.$TextField[29 /* numLines */] - egret.TextFieldUtils.$getScrollNum(this) + 1, 1); + return this.$BitmapText[5 /* font */]; } - ); - d(p, "selectionBeginIndex" - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return 0; + ,function (value) { + this.$setFont(value); } ); - d(p, "selectionEndIndex" + p.$setFont = function (value) { + var values = this.$BitmapText; + if (values[5 /* font */] == value) { + return false; + } + values[5 /* font */] = value; + this.$BitmapText[6 /* fontStringChanged */] = true; + this.$invalidateContentBounds(); + return true; + }; + d(p, "lineSpacing" /** - * @private + /** + * @language en_US + * An integer representing the amount of vertical space between lines. + * @default 0 * @version Egret 2.4 * @platform Web,Native */ - ,function () { - return 0; - } - ); - d(p, "caretIndex" /** - * @private + * @language zh_CN + * 一个整数,表示行与行之间的垂直间距量 + * @default 0 * @version Egret 2.4 * @platform Web,Native */ ,function () { - return 0; + return this.$BitmapText[3 /* lineSpacing */]; + } + ,function (value) { + this.$setLineSpacing(value); } ); - /** - * @private - * - * @param beginIndex - * @param endIndex - */ - p.$setSelection = function (beginIndex, endIndex) { - return false; - }; - /** - * @private - * - * @returns - */ - p.$getLineHeight = function () { - return this.$TextField[1 /* lineSpacing */] + this.$TextField[0 /* fontSize */]; + p.$setLineSpacing = function (value) { + value = +value || 0; + var values = this.$BitmapText; + if (values[3 /* lineSpacing */] == value) + return false; + values[3 /* lineSpacing */] = value; + this.$invalidateContentBounds(); + return true; }; - d(p, "numLines" + d(p, "letterSpacing" /** * @language en_US - * Number of lines of text. + * An integer representing the amount of distance between characters. + * @default 0 * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 文本行数。 + * 一个整数,表示字符之间的距量。 + * @default 0 * @version Egret 2.4 * @platform Web,Native */ ,function () { - this.$getLinesArr(); - return this.$TextField[29 /* numLines */]; + return this.$BitmapText[4 /* letterSpacing */]; } - ); - d(p, "multiline" - ,function () { - return this.$TextField[30 /* multiline */]; + ,function (value) { + this.$setLetterSpacing(value); } + ); + p.$setLetterSpacing = function (value) { + value = +value || 0; + var values = this.$BitmapText; + if (values[4 /* letterSpacing */] == value) + return false; + values[4 /* letterSpacing */] = value; + this.$invalidateContentBounds(); + return true; + }; + d(p, "textAlign" /** * @language en_US - * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. - * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). - * @default false + * Horizontal alignment of text. + * @default:egret.HorizontalAlign.LEFT + * @version Egret 2.5.6 + * @platform Web,Native */ /** * @language zh_CN - * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 - * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 - * @default false + * 文本的水平对齐方式。 + * @default:egret.HorizontalAlign.LEFT + * @version Egret 2.5.6 + * @platform Web,Native */ + ,function () { + return this.$BitmapText[10 /* textAlign */]; + } ,function (value) { - this.$setMultiline(value); + this.$setTextAlign(value); } ); - /** - * @private - * - * @param value - */ - p.$setMultiline = function (value) { - this.$TextField[30 /* multiline */] = value; - this.$invalidateTextField(); + p.$setTextAlign = function (value) { + var values = this.$BitmapText; + if (values[10 /* textAlign */] == value) + return false; + values[10 /* textAlign */] = value; + this.$invalidateContentBounds(); return true; }; - d(p, "restrict" - ,function () { - var values = this.$TextField; - var str = null; - if (values[35 /* restrictAnd */] != null) { - str = values[35 /* restrictAnd */]; - } - if (values[36 /* restrictNot */] != null) { - if (str == null) { - str = ""; - } - str += "^" + values[36 /* restrictNot */]; - } - return str; - } + d(p, "verticalAlign" /** * @language en_US - * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
      - * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
      - * The following example allows only uppercase characters, spaces, and numbers in the text field:
      - * My_txt.restrict = "A-Z 0-9";
      - * The following example includes all characters except lowercase letters:
      - * My_txt.restrict = "^ a-z";
      - * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
      - * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
      - * My_txt.restrict = "A-Z ^ Q";
      - * @version Egret 2.4 + * Vertical alignment of text. + * @default:egret.VerticalAlign.TOP + * @version Egret 2.5.6 * @platform Web,Native - * @default null */ /** * @language zh_CN - * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
      - * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
      - * 下例仅允许在文本字段中输入大写字符、空格和数字:
      - * my_txt.restrict = "A-Z 0-9";
      - * 下例包含除小写字母之外的所有字符:
      - * my_txt.restrict = "^a-z";
      - * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
      - * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
      - * my_txt.restrict = "A-Z^Q";
      - * @version Egret 2.4 + * 文字的垂直对齐方式。 + * @default:egret.VerticalAlign.TOP + * @version Egret 2.5.6 * @platform Web,Native - * @default null */ + ,function () { + return this.$BitmapText[11 /* verticalAlign */]; + } ,function (value) { - var values = this.$TextField; - if (value == null) { - values[35 /* restrictAnd */] = null; - values[36 /* restrictNot */] = null; - } - else { - var index = -1; - while (index < value.length) { - index = value.indexOf("^", index); - if (index == 0) { - break; - } - else if (index > 0) { - if (value.charAt(index - 1) != "\\") { - break; - } - index++; - } - else { - break; - } - } - if (index == 0) { - values[35 /* restrictAnd */] = null; - values[36 /* restrictNot */] = value.substring(index + 1); - } - else if (index > 0) { - values[35 /* restrictAnd */] = value.substring(0, index); - values[36 /* restrictNot */] = value.substring(index + 1); - } - else { - values[35 /* restrictAnd */] = value; - values[36 /* restrictNot */] = null; - } - } + this.$setVerticalAlign(value); } ); + p.$setVerticalAlign = function (value) { + var values = this.$BitmapText; + if (values[11 /* verticalAlign */] == value) + return false; + values[11 /* verticalAlign */] = value; + this.$invalidateContentBounds(); + return true; + }; /** * @private - * - * @param value */ - p.$setWidth = function (value) { - var values = this.$TextField; - if (isNaN(value)) { - if (isNaN(values[3 /* textFieldWidth */])) { - return false; - } - values[3 /* textFieldWidth */] = NaN; + p.$render = function () { + var values = this.$BitmapText; + var textLines = this.$getTextLines(); + var length = textLines.length; + if (length == 0) { + return; } - else { - if (values[3 /* textFieldWidth */] == value) { - return false; + var textLinesWidth = this.$textLinesWidth; + var bitmapFont = values[5 /* font */]; + var node = this.$renderNode; + if (bitmapFont.$texture) { + node.image = bitmapFont.$texture._bitmapData; + } + node.smoothing = values[12 /* smoothing */]; + var emptyHeight = bitmapFont._getFirstCharHeight(); + var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); + var hasSetHeight = !isNaN(values[1 /* textFieldHeight */]); + var textWidth = values[8 /* textWidth */]; + var textFieldWidth = values[0 /* textFieldWidth */]; + var textFieldHeight = values[1 /* textFieldHeight */]; + var align = values[10 /* textAlign */]; + var yPos = this.$textOffsetY + this.$textStartY; + var lineHeights = this.$lineHeights; + for (var i = 0; i < length; i++) { + var lineHeight = lineHeights[i]; + if (hasSetHeight && i > 0 && yPos + lineHeight > textFieldHeight) { + break; + } + var line = textLines[i]; + var len = line.length; + var xPos = this.$textOffsetX; + if (align != egret.HorizontalAlign.LEFT) { + var countWidth = textFieldWidth > textWidth ? textFieldWidth : textWidth; + if (align == egret.HorizontalAlign.RIGHT) { + xPos += countWidth - textLinesWidth[i]; + } + else if (align == egret.HorizontalAlign.CENTER) { + xPos += Math.floor((countWidth - textLinesWidth[i]) / 2); + } + } + for (var j = 0; j < len; j++) { + var character = line.charAt(j); + var texture = bitmapFont.getTexture(character); + if (!texture) { + if (character == " ") { + xPos += emptyWidth; + } + else { + egret.$warn(1046, character); + } + continue; + } + var bitmapWidth = texture._bitmapWidth; + var bitmapHeight = texture._bitmapHeight; + node.imageWidth = texture._sourceWidth; + node.imageHeight = texture._sourceHeight; + node.drawImage(texture._bitmapX, texture._bitmapY, bitmapWidth, bitmapHeight, xPos + texture._offsetX, yPos + texture._offsetY, texture.$getScaleBitmapWidth(), texture.$getScaleBitmapHeight()); + xPos += bitmapFont.getConfig(character, "xadvance") || (texture.$getTextureWidth() + values[4 /* letterSpacing */]); } - values[3 /* textFieldWidth */] = value; - } - value = +value; - if (value < 0) { - return false; + yPos += lineHeight + values[3 /* lineSpacing */]; } - this.$invalidateTextField(); - return true; }; /** * @private - * - * @param value */ - p.$setHeight = function (value) { - var values = this.$TextField; - if (isNaN(value)) { - if (isNaN(values[4 /* textFieldHeight */])) { - return false; - } - values[4 /* textFieldHeight */] = NaN; + p.$measureContentBounds = function (bounds) { + var lines = this.$getTextLines(); + if (lines.length == 0) { + bounds.setEmpty(); } else { - if (values[4 /* textFieldHeight */] == value) { - return false; - } - values[4 /* textFieldHeight */] = value; - } - value = +value; - if (value < 0) { - return false; + bounds.setTo(this.$textOffsetX + this.$textStartX, this.$textOffsetY + this.$textStartY, this.$BitmapText[8 /* textWidth */] - this.$textOffsetX, this.$BitmapText[9 /* textHeight */] - this.$textOffsetY); } - this.$invalidateTextField(); - return true; - }; - /** - * @private - * 获取显示宽度 - */ - p.$getWidth = function () { - var values = this.$TextField; - return isNaN(values[3 /* textFieldWidth */]) ? this.$getContentBounds().width : values[3 /* textFieldWidth */]; - }; - /** - * @private - * 获取显示宽度 - */ - p.$getHeight = function () { - var values = this.$TextField; - return isNaN(values[4 /* textFieldHeight */]) ? this.$getContentBounds().height : values[4 /* textFieldHeight */]; }; - d(p, "border" + d(p, "textWidth" /** + * @language en_US + * Get the BitmapText measured width * @version Egret 2.4 * @platform Web,Native */ - ,function () { - return this.$TextField[31 /* border */]; - } - /** - * @language en_US - * Specifies whether the text field has a border. - * If true, the text field has a border. If false, the text field has no border. - * Use borderColor property to set the border color. - * @default false - */ /** * @language zh_CN - * 指定文本字段是否具有边框。 - * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 - * 使用 borderColor 属性来设置边框颜色。 - * @default false - */ - ,function (value) { - this.$TextField[31 /* border */] = !!value; - this.$invalidate(); - } - ); - d(p, "borderColor" - /** + * 获取位图文本测量宽度 * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.$TextField[32 /* borderColor */]; - } - /** - * @language en_US - * The color of the text field border. - * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. - * @default 0x000000 - */ - /** - * @language zh_CN - * 文本字段边框的颜色。 - * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 - * @default 0x000000 - */ - ,function (value) { - this.$TextField[32 /* borderColor */] = +value || 0; - this.$invalidate(); + this.$getTextLines(); + return this.$BitmapText[8 /* textWidth */]; } ); - d(p, "background" + d(p, "textHeight" /** + * @language en_US + * Get Text BitmapText height * @version Egret 2.4 * @platform Web,Native */ - ,function () { - return this.$TextField[33 /* background */]; - } - /** - * @language en_US - * Specifies whether the text field has a background fill. - * If true, the text field has a background fill. If false, the text field has no background fill. - * Use the backgroundColor property to set the background color of the text field. - * @default false - */ /** * @language zh_CN - * 指定文本字段是否具有背景填充。 - * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 - * 使用 backgroundColor 属性来设置文本字段的背景颜色。 - * @default false - */ - ,function (value) { - this.$TextField[33 /* background */] = value; - this.$invalidate(); - } - ); - d(p, "backgroundColor" - /** + * 获取位图文本测量高度 * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.$TextField[34 /* backgroundColor */]; - } - /** - * @language en_US - * Color of the text field background. - * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. - * @default 0xFFFFFF - */ - /** - * @language zh_CN - * 文本字段背景的颜色。 - * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 - * @default 0xFFFFFF - */ - ,function (value) { - this.$TextField[34 /* backgroundColor */] = value; - this.$invalidate(); + this.$getTextLines(); + return this.$BitmapText[9 /* textHeight */]; } ); /** * @private * + * @returns */ - p.fillBackground = function (lines) { - var graphics = this.graphicsNode; - if (graphics) { - graphics.clear(); + p.$getTextLines = function () { + var values = this.$BitmapText; + if (!values[7 /* textLinesChanged */]) { + return this.textLines; } - var values = this.$TextField; - if (values[33 /* background */] || values[31 /* border */] || lines.length > 0) { - if (!graphics) { - graphics = this.graphicsNode = new egret.sys.GraphicsNode(); - var groupNode = new egret.sys.GroupNode(); - groupNode.addNode(graphics); - groupNode.addNode(this.textNode); - this.$renderNode = groupNode; + var textLines = []; + this.textLines = textLines; + var textLinesWidth = []; + this.$textLinesWidth = textLinesWidth; + values[7 /* textLinesChanged */] = false; + var lineHeights = []; + this.$lineHeights = lineHeights; + if (!values[2 /* text */] || !values[5 /* font */]) { + return textLines; + } + var lineSpacing = values[3 /* lineSpacing */]; + var letterSpacing = values[4 /* letterSpacing */]; + var textWidth = 0; + var textHeight = 0; + var textOffsetX = 0; + var textOffsetY = 0; + var hasWidthSet = !isNaN(values[0 /* textFieldWidth */]); + var textFieldWidth = values[0 /* textFieldWidth */]; + var textFieldHeight = values[1 /* textFieldHeight */]; + var bitmapFont = values[5 /* font */]; + var emptyHeight = bitmapFont._getFirstCharHeight(); + var emptyWidth = Math.ceil(emptyHeight * BitmapText.EMPTY_FACTOR); + var text = values[2 /* text */]; + var textArr = text.split(/(?:\r\n|\r|\n)/); + var length = textArr.length; + var isFirstLine = true; + for (var i = 0; i < length; i++) { + var line = textArr[i]; + var len = line.length; + var lineHeight = 0; + var xPos = 0; + var isFirstChar = true; + var isLastChar = false; + for (var j = 0; j < len; j++) { + if (!isFirstChar) { + xPos += letterSpacing; + } + var character = line.charAt(j); + var texureWidth; + var textureHeight; + var offsetX = 0; + var offsetY = 0; + var texture = bitmapFont.getTexture(character); + if (!texture) { + if (character == " ") { + texureWidth = emptyWidth; + textureHeight = emptyHeight; + } + else { + egret.$warn(1046, character); + if (isFirstChar) { + isFirstChar = false; + } + continue; + } + } + else { + texureWidth = texture.$getTextureWidth(); + textureHeight = texture.$getTextureHeight(); + offsetX = texture._offsetX; + offsetY = texture._offsetY; + } + if (isFirstChar) { + isFirstChar = false; + textOffsetX = Math.min(offsetX, textOffsetX); + } + if (isFirstLine) { + isFirstLine = false; + textOffsetY = Math.min(offsetY, textOffsetY); + } + if (hasWidthSet && j > 0 && xPos + texureWidth > textFieldWidth) { + if (!setLineData(line.substring(0, j))) + break; + line = line.substring(j); + len = line.length; + j = 0; + //最后一个字符要计算纹理宽度,而不是xadvance + if (j == len - 1) { + xPos = texureWidth; + } + else { + xPos = bitmapFont.getConfig(character, "xadvance") || texureWidth; + } + lineHeight = textureHeight; + continue; + } + //最后一个字符要计算纹理宽度,而不是xadvance + if (j == len - 1) { + xPos += texureWidth; + } + else { + xPos += bitmapFont.getConfig(character, "xadvance") || texureWidth; + } + lineHeight = Math.max(textureHeight, lineHeight); + } + if (textFieldHeight && i > 0 && textHeight > textFieldHeight) { + break; } - var fillPath; - var strokePath; - //渲染背景 - if (values[33 /* background */]) { - fillPath = graphics.beginFill(values[34 /* backgroundColor */]); - fillPath.drawRect(0, 0, this.$getWidth(), this.$getHeight()); + isLastChar = true; + if (!setLineData(line)) + break; + } + function setLineData(str) { + if (textFieldHeight && textLines.length > 0 && textHeight > textFieldHeight) { + return false; } - //渲染边框 - if (values[31 /* border */]) { - strokePath = graphics.lineStyle(1, values[32 /* borderColor */]); - //1像素和3像素线条宽度的情况,会向右下角偏移0.5像素绘制。少画一像素宽度,正好能不超出文本测量边界。 - strokePath.drawRect(0, 0, this.$getWidth() - 1, this.$getHeight() - 1); + textHeight += lineHeight + lineSpacing; + if (!isFirstChar && !isLastChar) { + xPos -= letterSpacing; } - //渲染下划线 - if (lines.length > 0) { - var textColor = values[2 /* textColor */]; - var lastColor = -1; - var length = lines.length; - for (var i = 0; i < length; i += 4) { - var x = lines[i]; - var y = lines[i + 1]; - var w = lines[i + 2]; - var color = lines[i + 3] || textColor; - if (lastColor < 0 || lastColor != color) { - lastColor = color; - strokePath = graphics.lineStyle(2, color, 1, egret.CapsStyle.NONE); - } - strokePath.moveTo(x, y); - strokePath.lineTo(x + w, y); - } + textLines.push(str); + lineHeights.push(lineHeight); + textLinesWidth.push(xPos); + textWidth = Math.max(xPos, textWidth); + return true; + } + textHeight -= lineSpacing; + values[8 /* textWidth */] = textWidth; + values[9 /* textHeight */] = textHeight; + this.$textOffsetX = textOffsetX; + this.$textOffsetY = textOffsetY; + this.$textStartX = 0; + this.$textStartY = 0; + var alignType; + if (textFieldWidth > textWidth) { + alignType = values[10 /* textAlign */]; + if (alignType == egret.HorizontalAlign.RIGHT) { + this.$textStartX = textFieldWidth - textWidth; + } + else if (alignType == egret.HorizontalAlign.CENTER) { + this.$textStartX = Math.floor((textFieldWidth - textWidth) / 2); } } - if (graphics) { - var bounds = this.$getRenderBounds(); - graphics.x = bounds.x; - graphics.y = bounds.y; - graphics.width = bounds.width; - graphics.height = bounds.height; - egret.Rectangle.release(bounds); + if (textFieldHeight > textHeight) { + alignType = values[11 /* verticalAlign */]; + if (alignType == egret.VerticalAlign.BOTTOM) { + this.$textStartY = textFieldHeight - textHeight; + } + else if (alignType == egret.VerticalAlign.MIDDLE) { + this.$textStartY = Math.floor((textFieldHeight - textHeight) / 2); + } } + return textLines; }; /** * @language en_US - * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. - * @version Egret 3.0.8 + * A ratio of the width of the space character. This value is multiplied by the height of the first character is the space character width. + * @default 0.33 + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 一个空格字符的宽度比例。这个数值乘以第一个字符的高度即为空格字符的宽。 + * @default 0.33 + * @version Egret 2.4 + * @platform Web,Native + */ + BitmapText.EMPTY_FACTOR = 0.33; + return BitmapText; + }(egret.DisplayObject)); + egret.BitmapText = BitmapText; + egret.registerClass(BitmapText,'egret.BitmapText'); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * The HorizontalAlign class defines the possible values for the horizontal alignment. + * @see egret.TextField#textAlign + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * HorizontalAlign 类为水平对齐方式定义可能的值。 + * @see egret.TextField#textAlign + * @version Egret 2.4 + * @platform Web,Native + */ + var HorizontalAlign = (function () { + function HorizontalAlign() { + } + var d = __define,c=HorizontalAlign,p=c.prototype; + /** + * @language en_US + * Horizontally align content to the left of the container. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 将内容与容器的左侧对齐。 + * @version Egret 2.4 + * @platform Web,Native + */ + HorizontalAlign.LEFT = "left"; + /** + * @language en_US + * Horizontally align content to the right of the container. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 将内容与容器的右侧对齐。 + * @version Egret 2.4 + * @platform Web,Native + */ + HorizontalAlign.RIGHT = "right"; + /** + * @language en_US + * Horizontally align content in the center of the container. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 在容器的水平中心对齐内容。 + * @version Egret 2.4 + * @platform Web,Native + */ + HorizontalAlign.CENTER = "center"; + /** + * @language en_US + * Horizontal alignment with both edges. + * Note: TextFiled does not support this alignment method. + * @constant egret.HorizontalAlign.JUSTIFY + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 水平两端对齐。 + * 注意:TextFiled不支持此对齐方式。 + * @constant egret.HorizontalAlign.JUSTIFY + * @version Egret 2.4 + * @platform Web,Native + */ + HorizontalAlign.JUSTIFY = "justify"; + /** + * @language en_US + * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Width \" of the container \". + * The Content Width \" of the container \" is the size of the max. child item. If the size of all child items are less than the width of the container, they will be adjusted to the width of the container. + * Note: TextFiled does not support this alignment method. + * @constant egret.HorizontalAlign.CONTENT_JUSTIFY + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容宽度"。 + * 容器的"内容宽度"是最大子项的大小,如果所有子项都小于容器的宽度,则会将所有子项的大小调整为容器的宽度。 + * 注意:TextFiled不支持此对齐方式。 + * @constant egret.HorizontalAlign.CONTENT_JUSTIFY + * @version Egret 2.4 * @platform Web,Native */ + HorizontalAlign.CONTENT_JUSTIFY = "contentJustify"; + return HorizontalAlign; + }()); + egret.HorizontalAlign = HorizontalAlign; + egret.registerClass(HorizontalAlign,'egret.HorizontalAlign'); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property + * @see http://edn.egret.com/cn/docs/page/146 Text mixed in a variety of style + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/text/HtmlTextParser.ts + */ + /** + * @language zh_CN + * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 + * @see http://edn.egret.com/cn/docs/page/146 多种样式文本混合 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/text/HtmlTextParser.ts + */ + var HtmlTextParser = (function () { /** - * @language zh_CN - * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 - * @version Egret 3.0.8 + * @version Egret 2.4 * @platform Web,Native */ - p.setFocus = function () { - if (this.type == egret.TextFieldType.INPUT && this.$stage) { - this.inputUtils.$onFocus(); - } - }; - /** - * @private - * - */ - p.$onRemoveFromStage = function () { - _super.prototype.$onRemoveFromStage.call(this); - this.removeEvent(); - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._removeStageText(); - } + function HtmlTextParser() { + this.replaceArr = []; + /** + * @private + */ + this.resutlArr = []; + this.initReplaceArr(); + } + var d = __define,c=HtmlTextParser,p=c.prototype; + p.initReplaceArr = function () { + this.replaceArr = []; + this.replaceArr.push([/</g, "<"]); + this.replaceArr.push([/>/g, ">"]); + this.replaceArr.push([/&/g, "&"]); + this.replaceArr.push([/"/g, "\""]); + this.replaceArr.push([/'/g, "\'"]); }; /** * @private * - * @param stage - * @param nestLevel - */ - p.$onAddToStage = function (stage, nestLevel) { - _super.prototype.$onAddToStage.call(this, stage, nestLevel); - this.addEvent(); - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - this.inputUtils._addStageText(); - } - }; - /** - * 不能重写$invalidateContentBounds,因为内部graphics调用clear时会触发$invalidateContentBounds这狗方法,从而导致死循环。 + * @param value + * @returns */ - p.$invalidateTextField = function () { - this.$invalidateContentBounds(); - this.$TextField[18 /* textLinesChanged */] = true; - }; - p.$update = function (dirtyRegionPolicy, bounds) { - var tmpBounds = this.$getRenderBounds(); - var result = _super.prototype.$update.call(this, dirtyRegionPolicy, tmpBounds); - egret.Rectangle.release(tmpBounds); - return result; - }; - p.$getRenderBounds = function () { - var bounds = this.$getContentBounds(); - var tmpBounds = egret.Rectangle.create(); - tmpBounds.copyFrom(bounds); - if (this.$TextField[31 /* border */]) { - tmpBounds.width += 2; - tmpBounds.height += 2; - } - var _strokeDouble = this.$TextField[27 /* stroke */] * 2; - if (_strokeDouble > 0) { - tmpBounds.width += _strokeDouble * 2; - tmpBounds.height += _strokeDouble * 2; + p.replaceSpecial = function (value) { + for (var i = 0; i < this.replaceArr.length; i++) { + var k = this.replaceArr[i][0]; + var v = this.replaceArr[i][1]; + value = value.replace(k, v); } - tmpBounds.x -= _strokeDouble + 2; //+2和+4 是为了解决脏区域的问题 - tmpBounds.y -= _strokeDouble + 2; - tmpBounds.width = Math.ceil(tmpBounds.width) + 4; - tmpBounds.height = Math.ceil(tmpBounds.height) + 4; - return tmpBounds; + return value; }; /** - * @private + * @language en_US + * Convert the text in html format to the object that can be assigned to the egret.TextField#textFlow property + * @param htmltext {string} Text in html + * @returns {Array} 可赋值给 egret.TextField#textFlow Object that can be assigned to the egret.TextField#textFlow property + * @version Egret 2.4 + * @platform Web,Native */ - p.$measureContentBounds = function (bounds) { - this.$getLinesArr(); - var w = !isNaN(this.$TextField[3 /* textFieldWidth */]) ? this.$TextField[3 /* textFieldWidth */] : this.$TextField[5 /* textWidth */]; - var h = !isNaN(this.$TextField[4 /* textFieldHeight */]) ? this.$TextField[4 /* textFieldHeight */] : egret.TextFieldUtils.$getTextHeight(this); - bounds.setTo(0, 0, w, h); - }; /** - * @private - * @see egret.DisplayObject._render - * @param renderContext + * @language zh_CN + * 将html格式文本转换为可赋值给 egret.TextField#textFlow 属性的对象 + * @param htmltext {string} html文本 + * @returns {Array} 可赋值给 egret.TextField#textFlow 属性的对象 + * @version Egret 2.4 + * @platform Web,Native */ - p.$render = function () { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { - if (this.$hasAnyFlags(2032 /* InitFlags */) || this.$hasAnyFlags(1648 /* DownOnAddedOrRemoved */)) { - this.inputUtils._updateProperties(); - } - if (this.$isTyping) { - return; - } - } - else if (this.$TextField[3 /* textFieldWidth */] == 0) { - return; - } - var underLines = this.drawText(); - this.fillBackground(underLines); - //tudo 宽高很小的情况下webgl模式绘制异常 - var bounds = this.$getRenderBounds(); - var node = this.textNode; - node.x = bounds.x; - node.y = bounds.y; - node.width = Math.ceil(bounds.width); - node.height = Math.ceil(bounds.height); - egret.Rectangle.release(bounds); - }; - d(p, "textFlow" - /** - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.textArr; - } - /** - * @language en_US - * Set rich text - */ - /** - * @language zh_CN - * 设置富文本 - * @see http://edn.egret.com/cn/index.php/article/index/id/146 - */ - ,function (textArr) { - this.isFlow = true; - var text = ""; - if (textArr == null) - textArr = []; - for (var i = 0; i < textArr.length; i++) { - var element = textArr[i]; - text += element.text; - } - if (this.$TextField[20 /* displayAsPassword */]) { - this.$setBaseText(text); + p.parser = function (htmltext) { + this.stackArray = []; + this.resutlArr = []; + var firstIdx = 0; //文本段开始位置 + var length = htmltext.length; + while (firstIdx < length) { + var starIdx = htmltext.indexOf("<", firstIdx); + if (starIdx < 0) { + this.addToResultArr(htmltext.substring(firstIdx)); + firstIdx = length; } else { - this.$TextField[13 /* text */] = text; - this.setMiddleStyle(textArr); - } - } - ); - /** - * @private - * - * @param text - * @returns - */ - p.changeToPassText = function (text) { - if (this.$TextField[20 /* displayAsPassword */]) { - var passText = ""; - for (var i = 0, num = text.length; i < num; i++) { - switch (text.charAt(i)) { - case '\n': - passText += "\n"; - break; - case '\r': - break; - default: - passText += '*'; + this.addToResultArr(htmltext.substring(firstIdx, starIdx)); + var fontEnd = htmltext.indexOf(">", starIdx); + if (fontEnd == -1) { + egret.$error(1038); + fontEnd = starIdx; } - } - return passText; - } - return text; - }; - /** - * @private - * - * @param textArr - */ - p.setMiddleStyle = function (textArr) { - this.$TextField[18 /* textLinesChanged */] = true; - this.textArr = textArr; - this.$invalidateTextField(); - }; - d(p, "textWidth" - /** - * @language en_US - * Get the text measured width - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 获取文本测量宽度 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - this.$getLinesArr(); - return this.$TextField[5 /* textWidth */]; - } - ); - d(p, "textHeight" - /** - * @language en_US - * Get Text measuring height - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 获取文本测量高度 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - this.$getLinesArr(); - return egret.TextFieldUtils.$getTextHeight(this); + else if (htmltext.charAt(starIdx + 1) == "\/") { + this.stackArray.pop(); + } + else { + this.addToArray(htmltext.substring(starIdx + 1, fontEnd)); + } + firstIdx = fontEnd + 1; + } } - ); - /** - * @private - * @param text - * @version Egret 2.4 - * @platform Web,Native - */ - p.appendText = function (text) { - this.appendElement({ text: text }); + return this.resutlArr; }; /** * @private - * @param element - * @version Egret 2.4 - * @platform Web,Native + * + * @param value */ - p.appendElement = function (element) { - var text = this.$TextField[13 /* text */] + element.text; - if (this.$TextField[20 /* displayAsPassword */]) { - this.$setBaseText(text); + p.addToResultArr = function (value) { + if (value == "") { + return; + } + value = this.replaceSpecial(value); + if (this.stackArray.length > 0) { + this.resutlArr.push({ text: value, style: this.stackArray[this.stackArray.length - 1] }); } else { - this.$TextField[13 /* text */] = text; - this.textArr.push(element); - this.setMiddleStyle(this.textArr); + this.resutlArr.push({ text: value }); } }; - /** - * @private - * - * @returns - */ - p.$getLinesArr = function () { - var values = this.$TextField; - if (!values[18 /* textLinesChanged */]) { - return this.linesArr; - } - values[18 /* textLinesChanged */] = false; - var text2Arr = this.textArr; - this.linesArr.length = 0; - values[6 /* textHeight */] = 0; - values[5 /* textWidth */] = 0; - var textFieldWidth = values[3 /* textFieldWidth */]; - //宽度被设置为0 - if (!isNaN(textFieldWidth) && textFieldWidth == 0) { - values[29 /* numLines */] = 0; - return [{ width: 0, height: 0, charNum: 0, elements: [], hasNextLine: false }]; + //将字符数据转成Json数据 + p.changeStringToObject = function (str) { + str = str.trim(); + var info = {}; + var header = []; + if (str.charAt(0) == "i" || str.charAt(0) == "b" || str.charAt(0) == "u") { + this.addProperty(info, str, "true"); } - var linesArr = this.linesArr; - var lineW = 0; - var lineCharNum = 0; - var lineH = 0; - var lineCount = 0; - var lineElement; - for (var i = 0, text2ArrLength = text2Arr.length; i < text2ArrLength; i++) { - var element = text2Arr[i]; - //可能设置为没有文本,忽略绘制 - if (!element.text) { - continue; - } - element.style = element.style || {}; - var text = element.text.toString(); - var textArr = text.split(/(?:\r\n|\r|\n)/); - for (var j = 0, textArrLength = textArr.length; j < textArrLength; j++) { - if (linesArr[lineCount] == null) { - lineElement = { width: 0, height: 0, elements: [], charNum: 0, hasNextLine: false }; - linesArr[lineCount] = lineElement; - lineW = 0; - lineH = 0; - lineCharNum = 0; - } - if (values[24 /* type */] == egret.TextFieldType.INPUT) { - lineH = values[0 /* fontSize */]; - } - else { - lineH = Math.max(lineH, element.style.size || values[0 /* fontSize */]); + else if (header = str.match(/^(font|a)\s/)) { + str = str.substring(header[0].length).trim(); + var next = 0; + var titles; + while (titles = str.match(this.getHeadReg())) { + var title = titles[0]; + var value = ""; + var str = str.substring(title.length).trim(); + if (str.charAt(0) == "\"") { + var next = str.indexOf("\"", 1); + value = str.substring(1, next); + next += 1; } - var isNextLine = true; - if (textArr[j] == "") { - if (j == textArrLength - 1) { - isNextLine = false; - } + else if (str.charAt(0) == "\'") { + var next = str.indexOf("\'", 1); + value = str.substring(1, next); + next += 1; } else { - var w = measureTextWidth(textArr[j], values, element.style); - if (isNaN(textFieldWidth)) { - lineW += w; - lineCharNum += textArr[j].length; - lineElement.elements.push({ - width: w, - text: textArr[j], - style: element.style - }); - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - if (lineW + w <= textFieldWidth) { - lineElement.elements.push({ - width: w, - text: textArr[j], - style: element.style - }); - lineW += w; - lineCharNum += textArr[j].length; - if (j == textArrLength - 1) { - isNextLine = false; - } - } - else { - var k = 0; - var ww = 0; - var word = textArr[j]; - if (values[19 /* wordWrap */]) { - var words = word.split(SplitRegex); - } - else { - words = word.match(/./g); - } - var wl = words.length; - var charNum = 0; - for (; k < wl; k++) { - w = measureTextWidth(words[k], values, element.style); - if (lineW != 0 && lineW + w > textFieldWidth && lineW + k != 0) { - break; - } - if (ww + w > textFieldWidth) { - var words2 = words[k].match(/./g); - for (var k2 = 0, wl2 = words2.length; k2 < wl2; k2++) { - w = measureTextWidth(words2[k2], values, element.style); - if (k2 > 0 && lineW + w > textFieldWidth) { - break; - } - charNum += words2[k2].length; - ww += w; - lineW += w; - lineCharNum += charNum; - } - } - else { - charNum += words[k].length; - ww += w; - lineW += w; - lineCharNum += charNum; - } - } - if (k > 0) { - lineElement.elements.push({ - width: ww, - text: word.substring(0, charNum), - style: element.style - }); - var leftWord = word.substring(charNum); - for (var m = 0, lwleng = leftWord.length; m < lwleng; m++) { - if (leftWord.charAt(m) != " ") { - break; - } - } - textArr[j] = leftWord.substring(m); - } - if (textArr[j] != "") { - j--; - isNextLine = false; - } - } - } - } - if (isNextLine) { - lineCharNum++; - lineElement.hasNextLine = true; + value = str.match(/(\S)+/)[0]; + next = value.length; } - if (j < textArr.length - 1) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - //if (this._type == TextFieldType.INPUT && !this._multiline) { - // this._numLines = linesArr.length; - // return linesArr; - //} - lineCount++; + this.addProperty(info, title.substring(0, title.length - 1).trim(), value.trim()); + str = str.substring(next).trim(); + } + } + return info; + }; + /** + * @private + * + * @returns + */ + p.getHeadReg = function () { + return /^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/; + }; + /** + * @private + * + * @param info + * @param head + * @param value + */ + p.addProperty = function (info, head, value) { + switch (head.toLowerCase()) { + case "color": + case "textcolor": + value = value.replace(/#/, "0x"); + info.textColor = parseInt(value); + break; + case "strokecolor": + value = value.replace(/#/, "0x"); + info.strokeColor = parseInt(value); + break; + case "stroke": + info.stroke = parseInt(value); + break; + case "b": + case "bold": + info.bold = value == "true"; + break; + case "u": + info.underline = value == "true"; + break; + case "i": + case "italic": + info.italic = value == "true"; + break; + case "size": + info.size = parseInt(value); + break; + case "fontfamily": + info.fontFamily = value; + break; + case "href": + info.href = this.replaceSpecial(value); + break; + case "target": + info.target = this.replaceSpecial(value); + break; + } + }; + /** + * @private + * + * @param infoStr + */ + p.addToArray = function (infoStr) { + var info = this.changeStringToObject(infoStr); + if (this.stackArray.length == 0) { + this.stackArray.push(info); + } + else { + var lastInfo = this.stackArray[this.stackArray.length - 1]; + for (var key in lastInfo) { + if (info[key] == null) { + info[key] = lastInfo[key]; } } - if (i == text2Arr.length - 1 && lineElement) { - lineElement.width = lineW; - lineElement.height = lineH; - lineElement.charNum = lineCharNum; - values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); - values[6 /* textHeight */] += lineH; - } + this.stackArray.push(info); } - values[29 /* numLines */] = linesArr.length; - return linesArr; + }; + return HtmlTextParser; + }()); + egret.HtmlTextParser = HtmlTextParser; + egret.registerClass(HtmlTextParser,'egret.HtmlTextParser'); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @private + * @version Egret 2.4 + * @platform Web,Native + */ + var InputController = (function (_super) { + __extends(InputController, _super); + /** + * @version Egret 2.4 + * @platform Web,Native + */ + function InputController() { + _super.call(this); + /** + * @private + */ + this._text = null; + /** + * @private + */ + this._isFocus = false; + } + var d = __define,c=InputController,p=c.prototype; + /** + * + * @param text + * @version Egret 2.4 + * @platform Web,Native + */ + p.init = function (text) { + this._text = text; + this.stageText = new egret.StageText(); + this.stageText.$setTextField(this._text); }; /** * @private - * 返回要绘制的下划线列表 + * */ - p.drawText = function () { - var node = this.textNode; - var values = this.$TextField; - //更新文本样式 - node.bold = values[15 /* bold */]; - node.fontFamily = values[8 /* fontFamily */] || TextField.default_fontFamily; - node.italic = values[16 /* italic */]; - node.size = values[0 /* fontSize */]; - node.stroke = values[27 /* stroke */]; - node.strokeColor = values[25 /* strokeColor */]; - node.textColor = values[2 /* textColor */]; - //先算出需要的数值 - var lines = this.$getLinesArr(); - if (values[5 /* textWidth */] == 0) { - return []; + p._addStageText = function () { + if (!this._text.$inputEnabled) { + this._text.$touchEnabled = true; } - var maxWidth = !isNaN(values[3 /* textFieldWidth */]) ? values[3 /* textFieldWidth */] : values[5 /* textWidth */]; - var textHeight = egret.TextFieldUtils.$getTextHeight(this); - var drawY = 0; - var startLine = egret.TextFieldUtils.$getStartLine(this); - var textFieldHeight = values[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { - var vAlign = egret.TextFieldUtils.$getValign(this); - drawY += vAlign * (textFieldHeight - textHeight); + this.tempStage = this._text.stage; + this.stageText.$addToStage(); + this.stageText.addEventListener("updateText", this.updateTextHandler, this); + this._text.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); + this.stageText.addEventListener("blur", this.blurHandler, this); + this.stageText.addEventListener("focus", this.focusHandler, this); + }; + /** + * @private + * + */ + p._removeStageText = function () { + if (!this._text.$inputEnabled) { + this._text.$touchEnabled = false; } - drawY = Math.round(drawY); - var hAlign = egret.TextFieldUtils.$getHalign(this); - var drawX = 0; - var underLineData = []; - for (var i = startLine, numLinesLength = values[29 /* numLines */]; i < numLinesLength; i++) { - var line = lines[i]; - var h = line.height; - drawY += h / 2; - if (i != startLine) { - if (values[24 /* type */] == egret.TextFieldType.INPUT && !values[30 /* multiline */]) { - break; - } - if (!isNaN(textFieldHeight) && drawY > textFieldHeight) { - break; - } - } - drawX = Math.round((maxWidth - line.width) * hAlign); - for (var j = 0, elementsLength = line.elements.length; j < elementsLength; j++) { - var element = line.elements[j]; - var size = element.style.size || values[0 /* fontSize */]; - node.drawText(drawX, drawY + (h - size) / 2, element.text, element.style); - if (element.style.underline) { - underLineData.push(drawX, drawY + (h) / 2, element.width, element.style.textColor); - } - drawX += element.width; + this.stageText.$removeFromStage(); + this.stageText.removeEventListener("updateText", this.updateTextHandler, this); + this._text.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onMouseDownHandler, this); + this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); + this.stageText.removeEventListener("blur", this.blurHandler, this); + this.stageText.removeEventListener("focus", this.focusHandler, this); + }; + /** + * @private + * + * @returns + */ + p._getText = function () { + return this.stageText.$getText(); + }; + /** + * @private + * + * @param value + */ + p._setText = function (value) { + this.stageText.$setText(value); + }; + /** + * @private + */ + p._setColor = function (value) { + this.stageText.$setColor(value); + }; + /** + * @private + * + * @param event + */ + p.focusHandler = function (event) { + //不再显示竖线,并且输入框显示最开始 + if (!this._isFocus) { + this._isFocus = true; + if (!event["showing"]) { + this._text.$isTyping = true; } - drawY += h / 2 + values[1 /* lineSpacing */]; + this._text.$invalidateContentBounds(); + this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_IN, true)); } - return underLineData; }; - //增加点击事件 - p.addEvent = function () { - this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); + /** + * @private + * + * @param event + */ + p.blurHandler = function (event) { + if (this._isFocus) { + //不再显示竖线,并且输入框显示最开始 + this._isFocus = false; + this.tempStage.removeEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); + this._text.$isTyping = false; + this._text.$invalidateContentBounds(); + //失去焦点后调用 + this.stageText.$onBlur(); + this._text.dispatchEvent(new egret.FocusEvent(egret.FocusEvent.FOCUS_OUT, true)); + } }; - //释放点击事件 - p.removeEvent = function () { - this.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); + //点中文本 + p.onMouseDownHandler = function (event) { + event.stopPropagation(); + this.$onFocus(); }; - //处理富文本中有href的 - p.onTapHandler = function (e) { - if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { + p.$onFocus = function () { + var self = this; + if (!this._text.visible) { return; } - var ele = egret.TextFieldUtils.$getTextElement(this, e.localX, e.localY); - if (ele == null) { + if (this._isFocus) { return; } - var style = ele.style; - if (style && style.href) { - if (style.href.match(/^event:/)) { - var type = style.href.match(/^event:/)[0]; - egret.TextEvent.dispatchTextEvent(this, egret.TextEvent.LINK, style.href.substring(type.length)); + this.tempStage.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.onStageDownHandler, this); + //强制更新输入框位置 + this.stageText.$show(); + }; + //未点中文本 + p.onStageDownHandler = function (event) { + this.stageText.$hide(); + }; + /** + * @private + * + * @param event + */ + p.updateTextHandler = function (event) { + var values = this._text.$TextField; + var textValue = this.stageText.$getText(); + var isChanged = false; + if (values[35 /* restrictAnd */] != null) { + var reg = new RegExp("[" + values[35 /* restrictAnd */] + "]", "g"); + var result = textValue.match(reg); + if (result) { + textValue = result.join(""); } else { - open(style.href, style.target || "_blank"); + textValue = ""; + } + isChanged = true; + } + if (values[36 /* restrictNot */] != null) { + reg = new RegExp("[^" + values[36 /* restrictNot */] + "]", "g"); + result = textValue.match(reg); + if (result) { + textValue = result.join(""); + } + else { + textValue = ""; } + isChanged = true; + } + if (isChanged && this.stageText.$getText() != textValue) { + this.stageText.$setText(textValue); } + this.resetText(); + //抛出change事件 + this._text.dispatchEvent(new egret.Event(egret.Event.CHANGE, true)); }; /** - * @language en_US - * default fontFamily - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 默认文本字体 - * @version Egret 2.4 - * @platform Web,Native - */ - TextField.default_fontFamily = "Arial"; - return TextField; - }(egret.DisplayObject)); - egret.TextField = TextField; - egret.registerClass(TextField,'egret.TextField'); - if (DEBUG) { - egret.$markReadOnly(TextField, "numLines"); - egret.$markReadOnly(TextField, "textWidth"); - egret.$markReadOnly(TextField, "textHeight"); - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. - * @version Egret 3.1.2 - * @platform Web,Native - */ - /** - * @language zh_CN - * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 - * @version Egret 3.1.2 - * @platform Web,Native - */ - var TextFieldInputType = (function () { - function TextFieldInputType() { - } - var d = __define,c=TextFieldInputType,p=c.prototype; - /** - * @language en_US - * The default - * @version Egret 3.1.2 - * @platform Web,Native - */ - /** - * @language zh_CN - * 默认 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native - */ - TextFieldInputType.TEXT = "text"; - /** - * @language en_US - * Telephone Number Inputs - * @version Egret 3.1.2 - * @platform Web,Native + * @private + * */ + p.resetText = function () { + this._text.$setBaseText(this.stageText.$getText()); + }; /** - * @language zh_CN - * 电话号码 input 类型 - * @version Egret 3.1.2 - * @platform Web,Native + * @private + * */ - TextFieldInputType.TEL = "tel"; + p._hideInput = function () { + this.stageText.$removeFromStage(); + }; /** - * @language en_US - * Password Inputs - * @version Egret 3.1.2 - * @platform Web,Native + * @private + * */ + p.updateInput = function () { + if (!this._text.$visible && this.stageText) { + this._hideInput(); + } + }; /** - * @language zh_CN - * password 类型 - * @version Egret 3.1.2 - * @platform Web,Native + * @private + * */ - TextFieldInputType.PASSWORD = "password"; - return TextFieldInputType; - }()); - egret.TextFieldInputType = TextFieldInputType; - egret.registerClass(TextFieldInputType,'egret.TextFieldInputType'); + p._updateProperties = function () { + if (this._isFocus) { + //整体修改 + this.stageText.$resetStageText(); + this.updateInput(); + return; + } + var stage = this._text.$stage; + if (stage == null) { + } + else { + var item = this._text; + var visible = item.$visible; + while (true) { + if (!visible) { + break; + } + item = item.parent; + if (item == stage) { + break; + } + visible = item.$visible; + } + } + this.stageText.$setText(this._text.$TextField[13 /* text */]); + //整体修改 + this.stageText.$resetStageText(); + this.updateInput(); + }; + return InputController; + }(egret.HashObject)); + egret.InputController = InputController; + egret.registerClass(InputController,'egret.InputController'); })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -20644,58 +19049,40 @@ var egret; // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, // OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 - * @version Egret 2.4 - * @platform Web,Native - */ - var TextFieldType = (function () { - function TextFieldType() { - } - var d = __define,c=TextFieldType,p=c.prototype; - /** - * @language en_US - * Used to specify dynamic text - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 用于指定动态文本 - * @version Egret 2.4 - * @platform Web,Native - */ - TextFieldType.DYNAMIC = "dynamic"; - /** - * @language en_US - * Used to specify the input text - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 用于指定输入文本 - * @version Egret 2.4 - * @platform Web,Native - */ - TextFieldType.INPUT = "input"; - return TextFieldType; - }()); - egret.TextFieldType = TextFieldType; - egret.registerClass(TextFieldType,'egret.TextFieldType'); +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -20727,1461 +19114,2818 @@ var egret; ////////////////////////////////////////////////////////////////////////////////////// var egret; (function (egret) { + var SplitRegex = new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"); /** * @private + * 根据样式测量文本宽度 + */ + function measureTextWidth(text, values, style) { + style = style || {}; + var italic = style.italic == null ? values[16 /* italic */] : style.italic; + var bold = style.bold == null ? values[15 /* bold */] : style.bold; + var size = style.size == null ? values[0 /* fontSize */] : style.size; + var fontFamily = style.fontFamily || values[8 /* fontFamily */] || TextField.default_fontFamily; + return egret.sys.measureText(text, fontFamily, size, bold, italic); + } + /** + * @language en_US + * TextField is the text rendering class of egret. It conducts rendering by using the browser / device API. Due to different ways of font rendering in different browsers / devices, there may be differences in the rendering + * If developers expect no differences among all platforms, please use BitmapText + * @see http://edn.egret.com/cn/docs/page/141 Create Text + * + * @event egret.Event.CHANGE Dispatched when entering text user input。 + * @event egret.FocusEvent.FOCUS_IN Dispatched after the focus to enter text. + * @event egret.FocusEvent.FOCUS_OUT Enter the text loses focus after dispatch. * @version Egret 2.4 * @platform Web,Native + * @includeExample egret/text/TextField.ts */ - var TextFieldUtils = (function () { - function TextFieldUtils() { + /** + * @language zh_CN + * TextField是egret的文本渲染类,采用浏览器/设备的API进行渲染,在不同的浏览器/设备中由于字体渲染方式不一,可能会有渲染差异 + * 如果开发者希望所有平台完全无差异,请使用BitmapText + * @see http://edn.egret.com/cn/docs/page/141 创建文本 + * + * @event egret.Event.CHANGE 输入文本有用户输入时调度。 + * @event egret.FocusEvent.FOCUS_IN 聚焦输入文本后调度。 + * @event egret.FocusEvent.FOCUS_OUT 输入文本失去焦点后调度。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/text/TextField.ts + */ + var TextField = (function (_super) { + __extends(TextField, _super); + /** + * @version Egret 2.4 + * @platform Web,Native + */ + function TextField() { + _super.call(this); + this.$inputEnabled = false; + /** + * @private + */ + this.inputUtils = null; + /** + * @private + */ + this.graphicsNode = null; + /** + * @private + */ + this.isFlow = false; + /** + * @private + */ + this.textArr = []; + /** + * @private + */ + this.linesArr = []; + /** + * @private + */ + this.$isTyping = false; + var textNode = new egret.sys.TextNode(); + textNode.fontFamily = TextField.default_fontFamily; + this.textNode = textNode; + this.$renderNode = textNode; + this.$TextField = { + 0: 30, + 1: 0, + 2: 0xffffff, + 3: NaN, + 4: NaN, + 5: 0, + 6: 0, + 7: 0, + 8: TextField.default_fontFamily, + 9: "left", + 10: "top", + 11: "#ffffff", + 12: "", + 13: "", + 14: [], + 15: false, + 16: false, + 17: true, + 18: false, + 19: false, + 20: false, + 21: 0, + 22: 0, + 23: 0, + 24: egret.TextFieldType.DYNAMIC, + 25: 0x000000, + 26: "#000000", + 27: 0, + 28: -1, + 29: 0, + 30: false, + 31: false, + 32: 0x000000, + 33: false, + 34: 0xffffff, + 35: null, + 36: null, + 37: egret.TextFieldInputType.TEXT //inputType + }; } - var d = __define,c=TextFieldUtils,p=c.prototype; + var d = __define,c=TextField,p=c.prototype; /** - * 获取第一个绘制的行数 - * @param textfield 文本 - * @returns {number} 行数,从0开始 * @private */ - TextFieldUtils.$getStartLine = function (textfield) { - var values = textfield.$TextField; - var textHeight = TextFieldUtils.$getTextHeight(textfield); - var startLine = 0; - var textFieldHeight = values[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight)) { - if (textHeight < textFieldHeight) { - } - else if (textHeight > textFieldHeight) { - startLine = Math.max(values[28 /* scrollV */] - 1, 0); - startLine = Math.min(values[29 /* numLines */] - 1, startLine); - } - if (!values[30 /* multiline */]) { - startLine = Math.max(values[28 /* scrollV */] - 1, 0); - if (values[29 /* numLines */] > 0) { - startLine = Math.min(values[29 /* numLines */] - 1, startLine); - } - } + p.isInput = function () { + return this.$TextField[24 /* type */] == egret.TextFieldType.INPUT; + }; + p.$setTouchEnabled = function (value) { + var result = _super.prototype.$setTouchEnabled.call(this, value); + if (this.isInput()) { + this.$inputEnabled = true; + } + return result; + }; + d(p, "fontFamily" + /** + * @language en_US + * The name of the font to use, or a comma-separated list of font names. + * @default "Arial" + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 要使用的字体的名称或用逗号分隔的字体名称列表。 + * @default "Arial" + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[8 /* fontFamily */]; + } + ,function (value) { + this.$setFontFamily(value); + } + ); + p.$setFontFamily = function (value) { + var values = this.$TextField; + if (values[8 /* fontFamily */] == value) { + return false; + } + values[8 /* fontFamily */] = value; + this.invalidateFontString(); + return true; + }; + d(p, "size" + /** + * @language en_US + * The size in pixels of text + * @default 30 + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 文本的字号大小。 + * @default 30 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[0 /* fontSize */]; + } + ,function (value) { + this.$setSize(value); + } + ); + p.$setSize = function (value) { + value = +value || 0; + var values = this.$TextField; + if (values[0 /* fontSize */] == value) { + return false; + } + values[0 /* fontSize */] = value; + this.invalidateFontString(); + return true; + }; + d(p, "bold" + /** + * @language en_US + * Specifies whether the text is boldface. + * @default false + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 是否显示为粗体。 + * @default false + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[15 /* bold */]; } - return startLine; + ,function (value) { + this.$setBold(value); + } + ); + p.$setBold = function (value) { + value = !!value; + var values = this.$TextField; + if (value == values[15 /* bold */]) { + return false; + } + values[15 /* bold */] = value; + this.invalidateFontString(); + return true; }; - /** - * 获取水平比例 - * @param textfield 文本 - * @returns {number} 水平比例 - * @private - */ - TextFieldUtils.$getHalign = function (textfield) { - var lineArr = textfield.$getLinesArr(); - var halign = 0; - if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.CENTER) { - halign = 0.5; + d(p, "italic" + /** + * @language en_US + * Determines whether the text is italic font. + * @default false + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 是否显示为斜体。 + * @default false + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[16 /* italic */]; } - else if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.RIGHT) { - halign = 1; + ,function (value) { + this.$setItalic(value); } - if (textfield.$TextField[24 /* type */] == egret.TextFieldType.INPUT && !textfield.$TextField[30 /* multiline */] && lineArr.length > 1) { - halign = 0; + ); + p.$setItalic = function (value) { + value = !!value; + var values = this.$TextField; + if (value == values[16 /* italic */]) { + return false; } - return halign; + values[16 /* italic */] = value; + this.invalidateFontString(); + return true; }; /** * @private * - * @param textfield - * @returns */ - TextFieldUtils.$getTextHeight = function (textfield) { - var textHeight = (egret.TextFieldType.INPUT == textfield.$TextField[24 /* type */] - && !textfield.$TextField[30 /* multiline */]) ? textfield.$TextField[0 /* fontSize */] : (textfield.$TextField[6 /* textHeight */] + (textfield.$TextField[29 /* numLines */] - 1) * textfield.$TextField[1 /* lineSpacing */]); - return textHeight; + p.invalidateFontString = function () { + this.$TextField[17 /* fontStringChanged */] = true; + this.$invalidateTextField(); }; - /** - * 获取垂直比例 - * @param textfield 文本 - * @returns {number} 垂直比例 - * @private - */ - TextFieldUtils.$getValign = function (textfield) { - var textHeight = TextFieldUtils.$getTextHeight(textfield); - //if (textfield.$TextField[sys.TextKeys.type] == egret.TextFieldType.INPUT) { - // if (textfield.$TextField[sys.TextKeys.multiline]) { - //return 0; - //} - //return 0.5; - //} - var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight)) { - if (textHeight < textFieldHeight) { - var valign = 0; - if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.MIDDLE) - valign = 0.5; - else if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.BOTTOM) - valign = 1; - return valign; - } + d(p, "textAlign" + /** + * @language en_US + * Horizontal alignment of text. + * @default:egret.HorizontalAlign.LEFT + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 文本的水平对齐方式。 + * @default:egret.HorizontalAlign.LEFT + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[9 /* textAlign */]; } - return 0; + ,function (value) { + this.$setTextAlign(value); + } + ); + p.$setTextAlign = function (value) { + var values = this.$TextField; + if (values[9 /* textAlign */] == value) { + return false; + } + values[9 /* textAlign */] = value; + this.$invalidateTextField(); + return true; }; - /** - * 根据x、y获取文本项 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本单项 - * @private - */ - TextFieldUtils.$getTextElement = function (textfield, x, y) { - var hitTextEle = TextFieldUtils.$getHit(textfield, x, y); - var lineArr = textfield.$getLinesArr(); - if (hitTextEle && lineArr[hitTextEle.lineIndex] && lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]) { - return lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]; + d(p, "verticalAlign" + /** + * @language en_US + * Vertical alignment of text. + * @default:egret.VerticalAlign.TOP + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 文字的垂直对齐方式。 + * @default:egret.VerticalAlign.TOP + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[10 /* verticalAlign */]; } - return null; + ,function (value) { + this.$setVerticalAlign(value); + } + ); + p.$setVerticalAlign = function (value) { + var values = this.$TextField; + if (values[10 /* verticalAlign */] == value) { + return false; + } + values[10 /* verticalAlign */] = value; + this.$invalidateTextField(); + return true; }; - /** - * 获取文本点击块 - * @param textfield 文本 - * @param x x坐标值 - * @param y y坐标值 - * @returns 文本点击块 - * @private - */ - TextFieldUtils.$getHit = function (textfield, x, y) { - var lineArr = textfield.$getLinesArr(); - if (textfield.$TextField[3 /* textFieldWidth */] == 0) { - return null; + d(p, "lineSpacing" + /** + * @language en_US + * An integer representing the amount of vertical space between lines. + * @default 0 + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 一个整数,表示行与行之间的垂直间距量 + * @default 0 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[1 /* lineSpacing */]; } - var line = 0; - var textHeight = TextFieldUtils.$getTextHeight(textfield); - var startY = 0; - var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; - if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { - var valign = TextFieldUtils.$getValign(textfield); - startY = valign * (textFieldHeight - textHeight); - if (startY != 0) { - y -= startY; - } + ,function (value) { + this.$setLineSpacing(value); + } + ); + p.$setLineSpacing = function (value) { + value = +value || 0; + var values = this.$TextField; + if (values[1 /* lineSpacing */] == value) + return false; + values[1 /* lineSpacing */] = value; + this.$invalidateTextField(); + return true; + }; + d(p, "textColor" + /** + * @language en_US + * Color of the text. + * @default 0x000000 + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 文本颜色 + * @default 0x000000 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[2 /* textColor */]; + } + ,function (value) { + this.$setTextColor(value); + } + ); + p.$setTextColor = function (value) { + value = +value | 0; + var values = this.$TextField; + if (values[2 /* textColor */] == value) { + return false; + } + values[2 /* textColor */] = value; + if (this.inputUtils) { + this.inputUtils._setColor(this.$TextField[2 /* textColor */]); + } + this.$invalidate(); + return true; + }; + d(p, "wordWrap" + /** + * @language en_US + * A Boolean value that indicates whether the text field word wrap. If the value is true, then the text field by word wrap; + * if the value is false, the text field by newline characters. + * @default false + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 一个布尔值,表示文本字段是否按单词换行。如果值为 true,则该文本字段按单词换行; + * 如果值为 false,则该文本字段按字符换行。 + * @default false + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[19 /* wordWrap */]; } - var startLine = TextFieldUtils.$getStartLine(textfield); - var lineH = 0; - for (var i = startLine; i < lineArr.length; i++) { - var lineEle = lineArr[i]; - if (lineH + lineEle.height >= y) { - line = i + 1; - break; - } - else { - lineH += lineEle.height; + ,function (value) { + value = !!value; + var values = this.$TextField; + if (value == values[19 /* wordWrap */]) { + return; } - if (lineH + textfield.$TextField[1 /* lineSpacing */] > y) { - return null; + if (values[20 /* displayAsPassword */]) { + return; } - lineH += textfield.$TextField[1 /* lineSpacing */]; + values[19 /* wordWrap */] = value; + this.$invalidateTextField(); } - if (line == 0) { - return null; + ); + d(p, "type" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[24 /* type */]; } - var lineElement = lineArr[line - 1]; - var lineW = 0; - for (i = 0; i < lineElement.elements.length; i++) { - var iwTE = lineElement.elements[i]; - if (lineW + iwTE.width < x) { - lineW += iwTE.width; + /** + * @language en_US + * Type of the text field. + * Any one of the following TextFieldType constants: TextFieldType.DYNAMIC (specifies the dynamic text field that users can not edit), or TextFieldType.INPUT (specifies the dynamic text field that users can edit). + * @default egret.TextFieldType.DYNAMIC + */ + /** + * @language zh_CN + * 文本字段的类型。 + * 以下 TextFieldType 常量中的任一个:TextFieldType.DYNAMIC(指定用户无法编辑的动态文本字段),或 TextFieldType.INPUT(指定用户可以编辑的输入文本字段)。 + * @default egret.TextFieldType.DYNAMIC + */ + ,function (value) { + this.$setType(value); + } + ); + /** + * @private + * + * @param value + */ + p.$setType = function (value) { + var values = this.$TextField; + if (values[24 /* type */] != value) { + values[24 /* type */] = value; + if (value == egret.TextFieldType.INPUT) { + if (isNaN(values[3 /* textFieldWidth */])) { + this.$setWidth(100); + } + if (isNaN(values[4 /* textFieldHeight */])) { + this.$setHeight(30); + } + this.$setTouchEnabled(true); + //创建stageText + if (this.inputUtils == null) { + this.inputUtils = new egret.InputController(); + } + this.inputUtils.init(this); + this.$invalidateTextField(); + if (this.$stage) { + this.inputUtils._addStageText(); + } } else { - return { "lineIndex": line - 1, "textElementIndex": i }; + if (this.inputUtils) { + this.inputUtils._removeStageText(); + this.inputUtils = null; + } + this.$setTouchEnabled(false); } + return true; } - return null; + return false; }; + d(p, "inputType" + /** + * @version Egret 3.1.2 + * @platform Web,Native + */ + ,function () { + return this.$TextField[37 /* inputType */]; + } + /** + * @language en_US + * Pop-up keyboard type. + * Any of a TextFieldInputType constants. + */ + /** + * @language zh_CN + * 弹出键盘的类型。 + * TextFieldInputType 常量中的任一个。 + */ + ,function (value) { + this.$TextField[37 /* inputType */] = value; + } + ); + d(p, "text" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$getText(); + } + /** + * @language en_US + * Serve as a string of the current text field in the text + */ + /** + * @language zh_CN + * 作为文本字段中当前文本的字符串 + */ + ,function (value) { + this.$setText(value); + } + ); /** - * 获取当前显示多少行 - * @param textfield 文本 - * @returns {number} 显示的行数 * @private + * + * @returns */ - TextFieldUtils.$getScrollNum = function (textfield) { - var scrollNum = 1; - if (textfield.$TextField[30 /* multiline */]) { - var height = textfield.height; - var size = textfield.size; - var lineSpacing = textfield.lineSpacing; - scrollNum = Math.floor(height / (size + lineSpacing)); - var leftH = height - (size + lineSpacing) * scrollNum; - if (leftH > size / 2) { - scrollNum++; - } - } - return scrollNum; - }; - return TextFieldUtils; - }()); - egret.TextFieldUtils = TextFieldUtils; - egret.registerClass(TextFieldUtils,'egret.TextFieldUtils'); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - var sys; - (function (sys) { - })(sys = egret.sys || (egret.sys = {})); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * The VerticalAlign class defines the possible values for the vertical alignment. - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * VerticalAlign 类为垂直对齐方式定义可能的值。 - * @see egret.TextField#verticalAlign - * @version Egret 2.4 - * @platform Web,Native - */ - var VerticalAlign = (function () { - function VerticalAlign() { - } - var d = __define,c=VerticalAlign,p=c.prototype; + p.$getText = function () { + if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { + return this.inputUtils._getText(); + } + return this.$TextField[13 /* text */]; + }; /** - * @language en_US - * Vertically align content to the top of the container. - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ + p.$setBaseText = function (value) { + if (value == null) { + value = ""; + } + value = value.toString(); + this.isFlow = false; + var values = this.$TextField; + if (values[13 /* text */] != value) { + this.$invalidateTextField(); + values[13 /* text */] = value; + var text = ""; + if (values[20 /* displayAsPassword */]) { + text = this.changeToPassText(value); + } + else { + text = value; + } + this.setMiddleStyle([{ text: text }]); + return true; + } + return false; + }; /** - * @language zh_CN - * 将内容与容器的顶部对齐。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ - VerticalAlign.TOP = "top"; + p.$setText = function (value) { + if (value == null) { + value = ""; + } + var result = this.$setBaseText(value); + if (this.inputUtils) { + this.inputUtils._setText(this.$TextField[13 /* text */]); + } + return result; + }; + d(p, "displayAsPassword" + /** + * @language en_US + * Specify whether the text field is a password text field. + * If the value of this property is true, the text field is treated as a password text field and hides the input characters using asterisks instead of the actual characters. If false, the text field is not treated as a password text field. + * @default false + */ + /** + * @language zh_CN + * 指定文本字段是否是密码文本字段。 + * 如果此属性的值为 true,则文本字段被视为密码文本字段,并使用星号而不是实际字符来隐藏输入的字符。如果为 false,则不会将文本字段视为密码文本字段。 + * @default false + */ + ,function () { + return this.$TextField[20 /* displayAsPassword */]; + } + ,function (value) { + this.$setDisplayAsPassword(value); + } + ); /** - * @language en_US - * Vertically align content to the bottom of the container. - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ + p.$setDisplayAsPassword = function (value) { + var values = this.$TextField; + if (values[20 /* displayAsPassword */] != value) { + values[20 /* displayAsPassword */] = value; + this.$invalidateTextField(); + var text = ""; + if (value) { + text = this.changeToPassText(values[13 /* text */]); + } + else { + text = values[13 /* text */]; + } + this.setMiddleStyle([{ text: text }]); + return true; + } + return false; + }; + d(p, "strokeColor" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[25 /* strokeColor */]; + } + /** + * @language en_US + * Represent the stroke color of the text. + * Contain three 8-bit numbers with RGB color components; for example, 0xFF0000 is red, 0x00FF00 is green. + * @default 0x000000 + */ + /** + * @language zh_CN + * 表示文本的描边颜色。 + * 包含三个 8 位 RGB 颜色成分的数字;例如,0xFF0000 为红色,0x00FF00 为绿色。 + * @default 0x000000 + */ + ,function (value) { + value = +value || 0; + this.$setStrokeColor(value); + } + ); /** - * @language zh_CN - * 将内容与容器的底部对齐。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ - VerticalAlign.BOTTOM = "bottom"; + p.$setStrokeColor = function (value) { + var values = this.$TextField; + if (values[25 /* strokeColor */] != value) { + this.$invalidateTextField(); + values[25 /* strokeColor */] = value; + values[26 /* strokeColorString */] = egret.toColorString(value); + return true; + } + return false; + }; + d(p, "stroke" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[27 /* stroke */]; + } + /** + * @language en_US + * Indicate the stroke width. + * 0 means no stroke. + * @default 0 + */ + /** + * @language zh_CN + * 表示描边宽度。 + * 0为没有描边。 + * @default 0 + */ + ,function (value) { + this.$setStroke(value); + } + ); /** - * @language en_US - * Vertically align content in the middle of the container. - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ + p.$setStroke = function (value) { + if (this.$TextField[27 /* stroke */] != value) { + this.$invalidateTextField(); + this.$TextField[27 /* stroke */] = value; + return true; + } + return false; + }; + d(p, "maxChars" + /** + * @language en_US + * The maximum number of characters that the text field can contain, as entered by a user. \n A script can insert more text than maxChars allows; the maxChars property indicates only how much text a user can enter. If the value of this property is 0, a user can enter an unlimited amount of text. + * The default value is 0. + * @default 0 + */ + /** + * @language zh_CN + * 文本字段中最多可包含的字符数(即用户输入的字符数)。 + * 脚本可以插入比 maxChars 允许的字符数更多的文本;maxChars 属性仅表示用户可以输入多少文本。如果此属性的值为 0,则用户可以输入无限数量的文本。 + * @default 0 + */ + ,function () { + return this.$TextField[21 /* maxChars */]; + } + ,function (value) { + this.$setMaxChars(value); + } + ); /** - * @language zh_CN - * 在容器的垂直中心对齐内容。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ - VerticalAlign.MIDDLE = "middle"; + p.$setMaxChars = function (value) { + if (this.$TextField[21 /* maxChars */] != value) { + this.$TextField[21 /* maxChars */] = value; + return true; + } + return false; + }; + d(p, "scrollV" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return Math.min(Math.max(this.$TextField[28 /* scrollV */], 1), this.maxScrollV); + } + /** + * @language en_US + * Vertical position of text in a text field. scrollV property helps users locate specific passages in a long article, and create scrolling text fields. + * Vertically scrolling units are lines, and horizontal scrolling unit is pixels. + * If the first displayed line is the first line in the text field, scrollV is set to 1 (instead of 0). + */ + /** + * @language zh_CN + * 文本在文本字段中的垂直位置。scrollV 属性可帮助用户定位到长篇文章的特定段落,还可用于创建滚动文本字段。 + * 垂直滚动的单位是行,而水平滚动的单位是像素。 + * 如果显示的第一行是文本字段中的第一行,则 scrollV 设置为 1(而非 0)。 + */ + ,function (value) { + this.$TextField[28 /* scrollV */] = Math.max(value, 1); + this.$invalidateTextField(); + } + ); + d(p, "maxScrollV" + /** + * @language en_US + * The maximum value of scrollV + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * scrollV 的最大值 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + this.$getLinesArr(); + return Math.max(this.$TextField[29 /* numLines */] - egret.TextFieldUtils.$getScrollNum(this) + 1, 1); + } + ); + d(p, "selectionBeginIndex" + /** + * @private + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return 0; + } + ); + d(p, "selectionEndIndex" + /** + * @private + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return 0; + } + ); + d(p, "caretIndex" + /** + * @private + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return 0; + } + ); /** - * @language en_US - * Vertical alignment with both edges - * Note: TextFiled does not support this alignment method." - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param beginIndex + * @param endIndex */ + p.$setSelection = function (beginIndex, endIndex) { + return false; + }; /** - * @language zh_CN - * 垂直两端对齐 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @returns */ - VerticalAlign.JUSTIFY = "justify"; + p.$getLineHeight = function () { + return this.$TextField[1 /* lineSpacing */] + this.$TextField[0 /* fontSize */]; + }; + d(p, "numLines" + /** + * @language en_US + * Number of lines of text. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 文本行数。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + this.$getLinesArr(); + return this.$TextField[29 /* numLines */]; + } + ); + d(p, "multiline" + ,function () { + return this.$TextField[30 /* multiline */]; + } + /** + * @language en_US + * Indicate whether field is a multiline text field. Note that this property is valid only when the type is TextFieldType.INPUT. + * If the value is true, the text field is multiline; if the value is false, the text field is a single-line text field. In a field of type TextFieldType.INPUT, the multiline value determines whether the Enter key creates a new line (a value of false, and the Enter key is ignored). + * @default false + */ + /** + * @language zh_CN + * 表示字段是否为多行文本字段。注意,此属性仅在type为TextFieldType.INPUT时才有效。 + * 如果值为 true,则文本字段为多行文本字段;如果值为 false,则文本字段为单行文本字段。在类型为 TextFieldType.INPUT 的字段中,multiline 值将确定 Enter 键是否创建新行(如果值为 false,则将忽略 Enter 键)。 + * @default false + */ + ,function (value) { + this.$setMultiline(value); + } + ); /** - * @language en_US - * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". - * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. - * Note: TextFiled does not support this alignment method. - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ + p.$setMultiline = function (value) { + this.$TextField[30 /* multiline */] = value; + this.$invalidateTextField(); + return true; + }; + d(p, "restrict" + ,function () { + var values = this.$TextField; + var str = null; + if (values[35 /* restrictAnd */] != null) { + str = values[35 /* restrictAnd */]; + } + if (values[36 /* restrictNot */] != null) { + if (str == null) { + str = ""; + } + str += "^" + values[36 /* restrictNot */]; + } + return str; + } + /** + * @language en_US + * Indicates a user can enter into the text field character set. If you restrict property is null, you can enter any character. If you restrict property is an empty string, you can not enter any character. If you restrict property is a string of characters, you can enter only characters in the string in the text field. The string is scanned from left to right. You can use a hyphen (-) to specify a range. Only restricts user interaction; a script may put any text into the text field.
      + * If the string of characters caret (^) at the beginning, all characters are initially accepted, then the string are excluded from receiving ^ character. If the string does not begin with a caret (^) to, any characters are initially accepted and then a string of characters included in the set of accepted characters.
      + * The following example allows only uppercase characters, spaces, and numbers in the text field:
      + * My_txt.restrict = "A-Z 0-9";
      + * The following example includes all characters except lowercase letters:
      + * My_txt.restrict = "^ a-z";
      + * If you need to enter characters \ ^, use two backslash "\\ -" "\\ ^":
      + * Can be used anywhere in the string ^ to rule out including characters and switch between characters, but can only be used to exclude a ^. The following code includes only uppercase letters except uppercase Q:
      + * My_txt.restrict = "A-Z ^ Q";
      + * @version Egret 2.4 + * @platform Web,Native + * @default null + */ + /** + * @language zh_CN + * 表示用户可输入到文本字段中的字符集。如果 restrict 属性的值为 null,则可以输入任何字符。如果 restrict 属性的值为空字符串,则不能输入任何字符。如果 restrict 属性的值为一串字符,则只能在文本字段中输入该字符串中的字符。从左向右扫描该字符串。可以使用连字符 (-) 指定一个范围。只限制用户交互;脚本可将任何文本放入文本字段中。
      + * 如果字符串以尖号 (^) 开头,则先接受所有字符,然后从接受字符集中排除字符串中 ^ 之后的字符。如果字符串不以尖号 (^) 开头,则最初不接受任何字符,然后将字符串中的字符包括在接受字符集中。
      + * 下例仅允许在文本字段中输入大写字符、空格和数字:
      + * my_txt.restrict = "A-Z 0-9";
      + * 下例包含除小写字母之外的所有字符:
      + * my_txt.restrict = "^a-z";
      + * 如果需要输入字符 \ ^,请使用2个反斜杠 "\\-" "\\^" :
      + * 可在字符串中的任何位置使用 ^,以在包含字符与排除字符之间进行切换,但是最多只能有一个 ^ 用来排除。下面的代码只包含除大写字母 Q 之外的大写字母:
      + * my_txt.restrict = "A-Z^Q";
      + * @version Egret 2.4 + * @platform Web,Native + * @default null + */ + ,function (value) { + var values = this.$TextField; + if (value == null) { + values[35 /* restrictAnd */] = null; + values[36 /* restrictNot */] = null; + } + else { + var index = -1; + while (index < value.length) { + index = value.indexOf("^", index); + if (index == 0) { + break; + } + else if (index > 0) { + if (value.charAt(index - 1) != "\\") { + break; + } + index++; + } + else { + break; + } + } + if (index == 0) { + values[35 /* restrictAnd */] = null; + values[36 /* restrictNot */] = value.substring(index + 1); + } + else if (index > 0) { + values[35 /* restrictAnd */] = value.substring(0, index); + values[36 /* restrictNot */] = value.substring(index + 1); + } + else { + values[35 /* restrictAnd */] = value; + values[36 /* restrictNot */] = null; + } + } + } + ); /** - * @language zh_CN - * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 - * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 - * 注意:TextFiled不支持此对齐方式。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ - VerticalAlign.CONTENT_JUSTIFY = "contentJustify"; - return VerticalAlign; - }()); - egret.VerticalAlign = VerticalAlign; - egret.registerClass(VerticalAlign,'egret.VerticalAlign'); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * The Endian class contains values that denote the byte order used to represent multibyte numbers. - * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 - * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 - * @version Egret 2.4 - * @platform Web,Native - */ - var Endian = (function () { - function Endian() { - } - var d = __define,c=Endian,p=c.prototype; + p.$setWidth = function (value) { + var values = this.$TextField; + if (isNaN(value)) { + if (isNaN(values[3 /* textFieldWidth */])) { + return false; + } + values[3 /* textFieldWidth */] = NaN; + } + else { + if (values[3 /* textFieldWidth */] == value) { + return false; + } + values[3 /* textFieldWidth */] = value; + } + value = +value; + if (value < 0) { + return false; + } + this.$invalidateTextField(); + return true; + }; /** - * @language en_US - * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param value */ + p.$setHeight = function (value) { + var values = this.$TextField; + if (isNaN(value)) { + if (isNaN(values[4 /* textFieldHeight */])) { + return false; + } + values[4 /* textFieldHeight */] = NaN; + } + else { + if (values[4 /* textFieldHeight */] == value) { + return false; + } + values[4 /* textFieldHeight */] = value; + } + value = +value; + if (value < 0) { + return false; + } + this.$invalidateTextField(); + return true; + }; /** - * @language zh_CN - * 表示多字节数字的最低有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * 获取显示宽度 */ - Endian.LITTLE_ENDIAN = "littleEndian"; + p.$getWidth = function () { + var values = this.$TextField; + return isNaN(values[3 /* textFieldWidth */]) ? this.$getContentBounds().width : values[3 /* textFieldWidth */]; + }; /** - * @language en_US - * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. - * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). - * @version Egret 2.4 - * @platform Web,Native + * @private + * 获取显示宽度 */ + p.$getHeight = function () { + var values = this.$TextField; + return isNaN(values[4 /* textFieldHeight */]) ? this.$getContentBounds().height : values[4 /* textFieldHeight */]; + }; + d(p, "border" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[31 /* border */]; + } + /** + * @language en_US + * Specifies whether the text field has a border. + * If true, the text field has a border. If false, the text field has no border. + * Use borderColor property to set the border color. + * @default false + */ + /** + * @language zh_CN + * 指定文本字段是否具有边框。 + * 如果为 true,则文本字段具有边框。如果为 false,则文本字段没有边框。 + * 使用 borderColor 属性来设置边框颜色。 + * @default false + */ + ,function (value) { + this.$TextField[31 /* border */] = !!value; + this.$invalidate(); + } + ); + d(p, "borderColor" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[32 /* borderColor */]; + } + /** + * @language en_US + * The color of the text field border. + * Even currently is no border can be retrieved or set this property, but only if the text field has the border property is set to true, the color is visible. + * @default 0x000000 + */ + /** + * @language zh_CN + * 文本字段边框的颜色。 + * 即使当前没有边框,也可检索或设置此属性,但只有当文本字段已将 border 属性设置为 true 时,才可以看到颜色。 + * @default 0x000000 + */ + ,function (value) { + this.$TextField[32 /* borderColor */] = +value || 0; + this.$invalidate(); + } + ); + d(p, "background" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[33 /* background */]; + } + /** + * @language en_US + * Specifies whether the text field has a background fill. + * If true, the text field has a background fill. If false, the text field has no background fill. + * Use the backgroundColor property to set the background color of the text field. + * @default false + */ + /** + * @language zh_CN + * 指定文本字段是否具有背景填充。 + * 如果为 true,则文本字段具有背景填充。如果为 false,则文本字段没有背景填充。 + * 使用 backgroundColor 属性来设置文本字段的背景颜色。 + * @default false + */ + ,function (value) { + this.$TextField[33 /* background */] = value; + this.$invalidate(); + } + ); + d(p, "backgroundColor" + /** + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.$TextField[34 /* backgroundColor */]; + } + /** + * @language en_US + * Color of the text field background. + * Even currently is no background, can be retrieved or set this property, but only if the text field has the background property set to true, the color is visible. + * @default 0xFFFFFF + */ + /** + * @language zh_CN + * 文本字段背景的颜色。 + * 即使当前没有背景,也可检索或设置此属性,但只有当文本字段已将 background 属性设置为 true 时,才可以看到颜色。 + * @default 0xFFFFFF + */ + ,function (value) { + this.$TextField[34 /* backgroundColor */] = value; + this.$invalidate(); + } + ); /** - * @language zh_CN - * 表示多字节数字的最高有效字节位于字节序列的最前面。 - * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * */ - Endian.BIG_ENDIAN = "bigEndian"; - return Endian; - }()); - egret.Endian = Endian; - egret.registerClass(Endian,'egret.Endian'); - /** - * @language en_US - * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. - * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - */ - /** - * @language zh_CN - * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 - * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/ByteArray.ts - */ - var ByteArray = (function () { + p.fillBackground = function (lines) { + var graphics = this.graphicsNode; + if (graphics) { + graphics.clear(); + } + var values = this.$TextField; + if (values[33 /* background */] || values[31 /* border */] || lines.length > 0) { + if (!graphics) { + graphics = this.graphicsNode = new egret.sys.GraphicsNode(); + var groupNode = new egret.sys.GroupNode(); + groupNode.addNode(graphics); + groupNode.addNode(this.textNode); + this.$renderNode = groupNode; + } + var fillPath; + var strokePath; + //渲染背景 + if (values[33 /* background */]) { + fillPath = graphics.beginFill(values[34 /* backgroundColor */]); + fillPath.drawRect(0, 0, this.$getWidth(), this.$getHeight()); + } + //渲染边框 + if (values[31 /* border */]) { + strokePath = graphics.lineStyle(1, values[32 /* borderColor */]); + //1像素和3像素线条宽度的情况,会向右下角偏移0.5像素绘制。少画一像素宽度,正好能不超出文本测量边界。 + strokePath.drawRect(0, 0, this.$getWidth() - 1, this.$getHeight() - 1); + } + //渲染下划线 + if (lines.length > 0) { + var textColor = values[2 /* textColor */]; + var lastColor = -1; + var length = lines.length; + for (var i = 0; i < length; i += 4) { + var x = lines[i]; + var y = lines[i + 1]; + var w = lines[i + 2]; + var color = lines[i + 3] || textColor; + if (lastColor < 0 || lastColor != color) { + lastColor = color; + strokePath = graphics.lineStyle(2, color, 1, egret.CapsStyle.NONE); + } + strokePath.moveTo(x, y); + strokePath.lineTo(x + w, y); + } + } + } + if (graphics) { + var bounds = this.$getRenderBounds(); + graphics.x = bounds.x; + graphics.y = bounds.y; + graphics.width = bounds.width; + graphics.height = bounds.height; + egret.Rectangle.release(bounds); + } + }; /** - * @version Egret 2.4 + * @language en_US + * Enter the text automatically entered into the input state, the input type is text only and may only be invoked in the user interaction. + * @version Egret 3.0.8 * @platform Web,Native */ - function ByteArray(buffer) { - /** - * @private - */ - this.BUFFER_EXT_SIZE = 0; //Buffer expansion size - /** - * @private - */ - this.EOF_byte = -1; - /** - * @private - */ - this.EOF_code_point = -1; - this._setArrayBuffer(buffer || new ArrayBuffer(this.BUFFER_EXT_SIZE)); - this.endian = Endian.BIG_ENDIAN; - } - var d = __define,c=ByteArray,p=c.prototype; + /** + * @language zh_CN + * 输入文本自动进入到输入状态,仅在类型是输入文本并且是在用户交互下才可以调用。 + * @version Egret 3.0.8 + * @platform Web,Native + */ + p.setFocus = function () { + if (this.type == egret.TextFieldType.INPUT && this.$stage) { + this.inputUtils.$onFocus(); + } + }; /** * @private - * @param buffer + * */ - p._setArrayBuffer = function (buffer) { - this.write_position = buffer.byteLength; - this.data = new DataView(buffer); - this._position = 0; + p.$onRemoveFromStage = function () { + _super.prototype.$onRemoveFromStage.call(this); + this.removeEvent(); + if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { + this.inputUtils._removeStageText(); + } }; /** - * @deprecated - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param stage + * @param nestLevel */ - p.setArrayBuffer = function (buffer) { + p.$onAddToStage = function (stage, nestLevel) { + _super.prototype.$onAddToStage.call(this, stage, nestLevel); + this.addEvent(); + if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { + this.inputUtils._addStageText(); + } }; - d(p, "buffer" - ,function () { - return this.data.buffer; + /** + * 不能重写$invalidateContentBounds,因为内部graphics调用clear时会触发$invalidateContentBounds这狗方法,从而导致死循环。 + */ + p.$invalidateTextField = function () { + this.$invalidateContentBounds(); + this.$TextField[18 /* textLinesChanged */] = true; + }; + p.$update = function (dirtyRegionPolicy, bounds) { + var tmpBounds = this.$getRenderBounds(); + var result = _super.prototype.$update.call(this, dirtyRegionPolicy, tmpBounds); + egret.Rectangle.release(tmpBounds); + return result; + }; + p.$getRenderBounds = function () { + var bounds = this.$getContentBounds(); + var tmpBounds = egret.Rectangle.create(); + tmpBounds.copyFrom(bounds); + if (this.$TextField[31 /* border */]) { + tmpBounds.width += 2; + tmpBounds.height += 2; } - /** - * @private - */ - ,function (value) { - this.data = new DataView(value); + var _strokeDouble = this.$TextField[27 /* stroke */] * 2; + if (_strokeDouble > 0) { + tmpBounds.width += _strokeDouble * 2; + tmpBounds.height += _strokeDouble * 2; } - ); - d(p, "dataView" - /** - * @private - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this.data; + tmpBounds.x -= _strokeDouble + 2; //+2和+4 是为了解决脏区域的问题 + tmpBounds.y -= _strokeDouble + 2; + tmpBounds.width = Math.ceil(tmpBounds.width) + 4; + tmpBounds.height = Math.ceil(tmpBounds.height) + 4; + return tmpBounds; + }; + /** + * @private + */ + p.$measureContentBounds = function (bounds) { + this.$getLinesArr(); + var w = !isNaN(this.$TextField[3 /* textFieldWidth */]) ? this.$TextField[3 /* textFieldWidth */] : this.$TextField[5 /* textWidth */]; + var h = !isNaN(this.$TextField[4 /* textFieldHeight */]) ? this.$TextField[4 /* textFieldHeight */] : egret.TextFieldUtils.$getTextHeight(this); + bounds.setTo(0, 0, w, h); + }; + /** + * @private + * @see egret.DisplayObject._render + * @param renderContext + */ + p.$render = function () { + if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { + if (this.$hasAnyFlags(2032 /* InitFlags */) || this.$hasAnyFlags(1648 /* DownOnAddedOrRemoved */)) { + this.inputUtils._updateProperties(); + } + if (this.$isTyping) { + return; + } } - /** - * @private - */ - ,function (value) { - this.data = value; - this.write_position = value.byteLength; + else if (this.$TextField[3 /* textFieldWidth */] == 0) { + return; } - ); - d(p, "bufferOffset" + var underLines = this.drawText(); + this.fillBackground(underLines); + //tudo 宽高很小的情况下webgl模式绘制异常 + var bounds = this.$getRenderBounds(); + var node = this.textNode; + node.x = bounds.x; + node.y = bounds.y; + node.width = Math.ceil(bounds.width); + node.height = Math.ceil(bounds.height); + egret.Rectangle.release(bounds); + }; + d(p, "textFlow" /** - * @private + * @version Egret 2.4 + * @platform Web,Native */ ,function () { - return this.data.byteOffset; + return this.textArr; } - ); - d(p, "position" /** * @language en_US - * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. - * @version Egret 2.4 - * @platform Web,Native + * Set rich text */ /** * @language zh_CN - * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 - * @version Egret 2.4 - * @platform Web,Native + * 设置富文本 + * @see http://edn.egret.com/cn/index.php/article/index/id/146 */ - ,function () { - return this._position; - } - ,function (value) { - //if (this._position < value) { - // if (!this.validate(value - this._position)) { - // return; - // } - //} - this._position = value; - this.write_position = value > this.write_position ? value : this.write_position; + ,function (textArr) { + this.isFlow = true; + var text = ""; + if (textArr == null) + textArr = []; + for (var i = 0; i < textArr.length; i++) { + var element = textArr[i]; + text += element.text; + } + if (this.$TextField[20 /* displayAsPassword */]) { + this.$setBaseText(text); + } + else { + this.$TextField[13 /* text */] = text; + this.setMiddleStyle(textArr); + } } ); - d(p, "length" + /** + * @private + * + * @param text + * @returns + */ + p.changeToPassText = function (text) { + if (this.$TextField[20 /* displayAsPassword */]) { + var passText = ""; + for (var i = 0, num = text.length; i < num; i++) { + switch (text.charAt(i)) { + case '\n': + passText += "\n"; + break; + case '\r': + break; + default: + passText += '*'; + } + } + return passText; + } + return text; + }; + /** + * @private + * + * @param textArr + */ + p.setMiddleStyle = function (textArr) { + this.$TextField[18 /* textLinesChanged */] = true; + this.textArr = textArr; + this.$invalidateTextField(); + }; + d(p, "textWidth" /** * @language en_US - * The length of the ByteArray object (in bytes). - * If the length is set to be larger than the current length, the right-side zero padding byte array. - * If the length is set smaller than the current length, the byte array is truncated. + * Get the text measured width * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * ByteArray 对象的长度(以字节为单位)。 - * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 - * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 + * 获取文本测量宽度 * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.write_position; - } - ,function (value) { - this.write_position = value; - var tmp = new Uint8Array(new ArrayBuffer(value)); - var byteLength = this.data.buffer.byteLength; - if (byteLength > value) { - this._position = value; - } - var length = Math.min(byteLength, value); - tmp.set(new Uint8Array(this.data.buffer, 0, length)); - this.buffer = tmp.buffer; + this.$getLinesArr(); + return this.$TextField[5 /* textWidth */]; } ); - d(p, "bytesAvailable" + d(p, "textHeight" /** * @language en_US - * The number of bytes that can be read from the current position of the byte array to the end of the array data. - * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. + * Get Text measuring height * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 - * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 + * 获取文本测量高度 * @version Egret 2.4 * @platform Web,Native */ ,function () { - return this.data.byteLength - this._position; + this.$getLinesArr(); + return egret.TextFieldUtils.$getTextHeight(this); } ); /** - * @language en_US - * Clears the contents of the byte array and resets the length and position properties to 0. + * @private + * @param text * @version Egret 2.4 * @platform Web,Native */ + p.appendText = function (text) { + this.appendElement({ text: text }); + }; /** - * @language zh_CN - * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 - + * @private + * @param element * @version Egret 2.4 * @platform Web,Native */ - p.clear = function () { - this._setArrayBuffer(new ArrayBuffer(this.BUFFER_EXT_SIZE)); + p.appendElement = function (element) { + var text = this.$TextField[13 /* text */] + element.text; + if (this.$TextField[20 /* displayAsPassword */]) { + this.$setBaseText(text); + } + else { + this.$TextField[13 /* text */] = text; + this.textArr.push(element); + this.setMiddleStyle(this.textArr); + } }; /** - * @language en_US - * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. - * @return If the byte is non-zero, it returns true; otherwise, it returns false. - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @returns */ + p.$getLinesArr = function () { + var values = this.$TextField; + if (!values[18 /* textLinesChanged */]) { + return this.linesArr; + } + values[18 /* textLinesChanged */] = false; + var text2Arr = this.textArr; + this.linesArr.length = 0; + values[6 /* textHeight */] = 0; + values[5 /* textWidth */] = 0; + var textFieldWidth = values[3 /* textFieldWidth */]; + //宽度被设置为0 + if (!isNaN(textFieldWidth) && textFieldWidth == 0) { + values[29 /* numLines */] = 0; + return [{ width: 0, height: 0, charNum: 0, elements: [], hasNextLine: false }]; + } + var linesArr = this.linesArr; + var lineW = 0; + var lineCharNum = 0; + var lineH = 0; + var lineCount = 0; + var lineElement; + for (var i = 0, text2ArrLength = text2Arr.length; i < text2ArrLength; i++) { + var element = text2Arr[i]; + //可能设置为没有文本,忽略绘制 + if (!element.text) { + continue; + } + element.style = element.style || {}; + var text = element.text.toString(); + var textArr = text.split(/(?:\r\n|\r|\n)/); + for (var j = 0, textArrLength = textArr.length; j < textArrLength; j++) { + if (linesArr[lineCount] == null) { + lineElement = { width: 0, height: 0, elements: [], charNum: 0, hasNextLine: false }; + linesArr[lineCount] = lineElement; + lineW = 0; + lineH = 0; + lineCharNum = 0; + } + if (values[24 /* type */] == egret.TextFieldType.INPUT) { + lineH = values[0 /* fontSize */]; + } + else { + lineH = Math.max(lineH, element.style.size || values[0 /* fontSize */]); + } + var isNextLine = true; + if (textArr[j] == "") { + if (j == textArrLength - 1) { + isNextLine = false; + } + } + else { + var w = measureTextWidth(textArr[j], values, element.style); + if (isNaN(textFieldWidth)) { + lineW += w; + lineCharNum += textArr[j].length; + lineElement.elements.push({ + width: w, + text: textArr[j], + style: element.style + }); + if (j == textArrLength - 1) { + isNextLine = false; + } + } + else { + if (lineW + w <= textFieldWidth) { + lineElement.elements.push({ + width: w, + text: textArr[j], + style: element.style + }); + lineW += w; + lineCharNum += textArr[j].length; + if (j == textArrLength - 1) { + isNextLine = false; + } + } + else { + var k = 0; + var ww = 0; + var word = textArr[j]; + if (values[19 /* wordWrap */]) { + var words = word.split(SplitRegex); + } + else { + words = word.match(/./g); + } + var wl = words.length; + var charNum = 0; + for (; k < wl; k++) { + w = measureTextWidth(words[k], values, element.style); + if (lineW != 0 && lineW + w > textFieldWidth && lineW + k != 0) { + break; + } + if (ww + w > textFieldWidth) { + var words2 = words[k].match(/./g); + for (var k2 = 0, wl2 = words2.length; k2 < wl2; k2++) { + w = measureTextWidth(words2[k2], values, element.style); + if (k2 > 0 && lineW + w > textFieldWidth) { + break; + } + charNum += words2[k2].length; + ww += w; + lineW += w; + lineCharNum += charNum; + } + } + else { + charNum += words[k].length; + ww += w; + lineW += w; + lineCharNum += charNum; + } + } + if (k > 0) { + lineElement.elements.push({ + width: ww, + text: word.substring(0, charNum), + style: element.style + }); + var leftWord = word.substring(charNum); + for (var m = 0, lwleng = leftWord.length; m < lwleng; m++) { + if (leftWord.charAt(m) != " ") { + break; + } + } + textArr[j] = leftWord.substring(m); + } + if (textArr[j] != "") { + j--; + isNextLine = false; + } + } + } + } + if (isNextLine) { + lineCharNum++; + lineElement.hasNextLine = true; + } + if (j < textArr.length - 1) { + lineElement.width = lineW; + lineElement.height = lineH; + lineElement.charNum = lineCharNum; + values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); + values[6 /* textHeight */] += lineH; + //if (this._type == TextFieldType.INPUT && !this._multiline) { + // this._numLines = linesArr.length; + // return linesArr; + //} + lineCount++; + } + } + if (i == text2Arr.length - 1 && lineElement) { + lineElement.width = lineW; + lineElement.height = lineH; + lineElement.charNum = lineCharNum; + values[5 /* textWidth */] = Math.max(values[5 /* textWidth */], lineW); + values[6 /* textHeight */] += lineH; + } + } + values[29 /* numLines */] = linesArr.length; + return linesArr; + }; /** - * @language zh_CN - * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false - * @return 如果字节不为零,则返回 true,否则返回 false - * @version Egret 2.4 - * @platform Web,Native + * @private + * 返回要绘制的下划线列表 */ - p.readBoolean = function () { - if (!this.validate(ByteArray.SIZE_OF_BOOLEAN)) - return null; - return this.data.getUint8(this.position++) != 0; + p.drawText = function () { + var node = this.textNode; + var values = this.$TextField; + //更新文本样式 + node.bold = values[15 /* bold */]; + node.fontFamily = values[8 /* fontFamily */] || TextField.default_fontFamily; + node.italic = values[16 /* italic */]; + node.size = values[0 /* fontSize */]; + node.stroke = values[27 /* stroke */]; + node.strokeColor = values[25 /* strokeColor */]; + node.textColor = values[2 /* textColor */]; + //先算出需要的数值 + var lines = this.$getLinesArr(); + if (values[5 /* textWidth */] == 0) { + return []; + } + var maxWidth = !isNaN(values[3 /* textFieldWidth */]) ? values[3 /* textFieldWidth */] : values[5 /* textWidth */]; + var textHeight = egret.TextFieldUtils.$getTextHeight(this); + var drawY = 0; + var startLine = egret.TextFieldUtils.$getStartLine(this); + var textFieldHeight = values[4 /* textFieldHeight */]; + if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { + var vAlign = egret.TextFieldUtils.$getValign(this); + drawY += vAlign * (textFieldHeight - textHeight); + } + drawY = Math.round(drawY); + var hAlign = egret.TextFieldUtils.$getHalign(this); + var drawX = 0; + var underLineData = []; + for (var i = startLine, numLinesLength = values[29 /* numLines */]; i < numLinesLength; i++) { + var line = lines[i]; + var h = line.height; + drawY += h / 2; + if (i != startLine) { + if (values[24 /* type */] == egret.TextFieldType.INPUT && !values[30 /* multiline */]) { + break; + } + if (!isNaN(textFieldHeight) && drawY > textFieldHeight) { + break; + } + } + drawX = Math.round((maxWidth - line.width) * hAlign); + for (var j = 0, elementsLength = line.elements.length; j < elementsLength; j++) { + var element = line.elements[j]; + var size = element.style.size || values[0 /* fontSize */]; + node.drawText(drawX, drawY + (h - size) / 2, element.text, element.style); + if (element.style.underline) { + underLineData.push(drawX, drawY + (h) / 2, element.width, element.style.textColor); + } + drawX += element.width; + } + drawY += h / 2 + values[1 /* lineSpacing */]; + } + return underLineData; }; - /** - * @language en_US - * Read signed bytes from the byte stream. - * @return An integer ranging from -128 to 127 - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 从字节流中读取带符号的字节 - * @return 介于 -128 和 127 之间的整数 - * @version Egret 2.4 - * @platform Web,Native - */ - p.readByte = function () { - if (!this.validate(ByteArray.SIZE_OF_INT8)) - return null; - return this.data.getInt8(this.position++); + //增加点击事件 + p.addEvent = function () { + this.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); + }; + //释放点击事件 + p.removeEvent = function () { + this.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onTapHandler, this); + }; + //处理富文本中有href的 + p.onTapHandler = function (e) { + if (this.$TextField[24 /* type */] == egret.TextFieldType.INPUT) { + return; + } + var ele = egret.TextFieldUtils.$getTextElement(this, e.localX, e.localY); + if (ele == null) { + return; + } + var style = ele.style; + if (style && style.href) { + if (style.href.match(/^event:/)) { + var type = style.href.match(/^event:/)[0]; + egret.TextEvent.dispatchTextEvent(this, egret.TextEvent.LINK, style.href.substring(type.length)); + } + else { + open(style.href, style.target || "_blank"); + } + } }; /** * @language en_US - * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray - * @param bytes ByteArray object that data is read into - * @param offset Offset (position) in bytes. Read data should be written from this position - * @param length Byte number to be read Default value 0 indicates reading all available data + * default fontFamily * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 - * @param bytes 要将数据读入的 ByteArray 对象 - * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 - * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 + * 默认文本字体 * @version Egret 2.4 * @platform Web,Native */ - p.readBytes = function (bytes, offset, length) { - if (offset === void 0) { offset = 0; } - if (length === void 0) { length = 0; } - if (length == 0) { - length = this.bytesAvailable; - } - else if (!this.validate(length)) { - return null; - } - if (bytes) { - bytes.validateBuffer(offset + length); - } - else { - bytes = new ByteArray(new ArrayBuffer(offset + length)); - } - //This method is expensive - for (var i = 0; i < length; i++) { - bytes.data.setUint8(i + offset, this.data.getUint8(this.position++)); - } - }; + TextField.default_fontFamily = "Arial"; + return TextField; + }(egret.DisplayObject)); + egret.TextField = TextField; + egret.registerClass(TextField,'egret.TextField'); + if (DEBUG) { + egret.$markReadOnly(TextField, "numLines"); + egret.$markReadOnly(TextField, "textWidth"); + egret.$markReadOnly(TextField, "textHeight"); + } +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * TextFieldInputType class is an enumeration of constant value used in setting the inputType property of the TextField class. + * @version Egret 3.1.2 + * @platform Web,Native + */ + /** + * @language zh_CN + * TextFieldInputType 类是在设置 TextField 类的 inputType 属性时使用的常数值的枚举。 + * @version Egret 3.1.2 + * @platform Web,Native + */ + var TextFieldInputType = (function () { + function TextFieldInputType() { + } + var d = __define,c=TextFieldInputType,p=c.prototype; /** * @language en_US - * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream - * @return Double-precision (64 bit) floating point number - * @version Egret 2.4 + * The default + * @version Egret 3.1.2 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 - * @return 双精度(64 位)浮点数 - * @version Egret 2.4 + * 默认 input 类型 + * @version Egret 3.1.2 * @platform Web,Native */ - p.readDouble = function () { - if (!this.validate(ByteArray.SIZE_OF_FLOAT64)) - return null; - var value = this.data.getFloat64(this.position, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_FLOAT64; - return value; - }; + TextFieldInputType.TEXT = "text"; /** * @language en_US - * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream - * @return Single-precision (32 bit) floating point number - * @version Egret 2.4 + * Telephone Number Inputs + * @version Egret 3.1.2 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 - * @return 单精度(32 位)浮点数 - * @version Egret 2.4 + * 电话号码 input 类型 + * @version Egret 3.1.2 * @platform Web,Native */ - p.readFloat = function () { - if (!this.validate(ByteArray.SIZE_OF_FLOAT32)) - return null; - var value = this.data.getFloat32(this.position, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_FLOAT32; - return value; - }; + TextFieldInputType.TEL = "tel"; /** * @language en_US - * Read a 32-bit signed integer from the byte stream. - * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 - * @version Egret 2.4 + * Password Inputs + * @version Egret 3.1.2 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取一个带符号的 32 位整数 - * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 - * @version Egret 2.4 + * password 类型 + * @version Egret 3.1.2 * @platform Web,Native */ - p.readInt = function () { - if (!this.validate(ByteArray.SIZE_OF_INT32)) - return null; - var value = this.data.getInt32(this.position, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_INT32; - return value; - }; - ///** - // * 使用指定的字符集从字节流中读取指定长度的多字节字符串 - // * @param length 要从字节流中读取的字节数 - // * @param charSet 表示用于解释字节的字符集的字符串。可能的字符集字符串包括 "shift-jis"、"cn-gb"、"iso-8859-1"”等 - // * @return UTF-8 编码的字符串 - // * @method egret.ByteArray#readMultiByte - // */ - //public readMultiByte(length:number, charSet?:string):string { - // if (!this.validate(length)) return null; - // - // return ""; - //} + TextFieldInputType.PASSWORD = "password"; + return TextFieldInputType; + }()); + egret.TextFieldInputType = TextFieldInputType; + egret.registerClass(TextFieldInputType,'egret.TextFieldInputType'); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * TextFieldType class is an enumeration of constant value used in setting the type property of the TextField class. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * TextFieldType 类是在设置 TextField 类的 type 属性时使用的常数值的枚举。 + * @version Egret 2.4 + * @platform Web,Native + */ + var TextFieldType = (function () { + function TextFieldType() { + } + var d = __define,c=TextFieldType,p=c.prototype; /** * @language en_US - * Read a 16-bit signed integer from the byte stream. - * @return A 16-bit signed integer ranging from -32768 to 32767 + * Used to specify dynamic text * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取一个带符号的 16 位整数 - * @return 介于 -32768 和 32767 之间的 16 位带符号整数 + * 用于指定动态文本 * @version Egret 2.4 * @platform Web,Native */ - p.readShort = function () { - if (!this.validate(ByteArray.SIZE_OF_INT16)) - return null; - var value = this.data.getInt16(this.position, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_INT16; - return value; - }; + TextFieldType.DYNAMIC = "dynamic"; /** * @language en_US - * Read unsigned bytes from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 255 + * Used to specify the input text * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取无符号的字节 - * @return 介于 0 和 255 之间的 32 位无符号整数 + * 用于指定输入文本 * @version Egret 2.4 * @platform Web,Native */ - p.readUnsignedByte = function () { - if (!this.validate(ByteArray.SIZE_OF_UINT8)) - return null; - return this.data.getUint8(this.position++); + TextFieldType.INPUT = "input"; + return TextFieldType; + }()); + egret.TextFieldType = TextFieldType; + egret.registerClass(TextFieldType,'egret.TextFieldType'); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @private + * @version Egret 2.4 + * @platform Web,Native + */ + var TextFieldUtils = (function () { + function TextFieldUtils() { + } + var d = __define,c=TextFieldUtils,p=c.prototype; + /** + * 获取第一个绘制的行数 + * @param textfield 文本 + * @returns {number} 行数,从0开始 + * @private + */ + TextFieldUtils.$getStartLine = function (textfield) { + var values = textfield.$TextField; + var textHeight = TextFieldUtils.$getTextHeight(textfield); + var startLine = 0; + var textFieldHeight = values[4 /* textFieldHeight */]; + if (!isNaN(textFieldHeight)) { + if (textHeight < textFieldHeight) { + } + else if (textHeight > textFieldHeight) { + startLine = Math.max(values[28 /* scrollV */] - 1, 0); + startLine = Math.min(values[29 /* numLines */] - 1, startLine); + } + if (!values[30 /* multiline */]) { + startLine = Math.max(values[28 /* scrollV */] - 1, 0); + if (values[29 /* numLines */] > 0) { + startLine = Math.min(values[29 /* numLines */] - 1, startLine); + } + } + } + return startLine; }; /** - * @language en_US - * Read a 32-bit unsigned integer from the byte stream. - * @return A 32-bit unsigned integer ranging from 0 to 4294967295 - * @version Egret 2.4 - * @platform Web,Native + * 获取水平比例 + * @param textfield 文本 + * @returns {number} 水平比例 + * @private */ + TextFieldUtils.$getHalign = function (textfield) { + var lineArr = textfield.$getLinesArr(); + var halign = 0; + if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.CENTER) { + halign = 0.5; + } + else if (textfield.$TextField[9 /* textAlign */] == egret.HorizontalAlign.RIGHT) { + halign = 1; + } + if (textfield.$TextField[24 /* type */] == egret.TextFieldType.INPUT && !textfield.$TextField[30 /* multiline */] && lineArr.length > 1) { + halign = 0; + } + return halign; + }; /** - * @language zh_CN - * 从字节流中读取一个无符号的 32 位整数 - * @return 介于 0 和 4294967295 之间的 32 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param textfield + * @returns */ - p.readUnsignedInt = function () { - if (!this.validate(ByteArray.SIZE_OF_UINT32)) - return null; - var value = this.data.getUint32(this.position, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_UINT32; - return value; + TextFieldUtils.$getTextHeight = function (textfield) { + var textHeight = (egret.TextFieldType.INPUT == textfield.$TextField[24 /* type */] + && !textfield.$TextField[30 /* multiline */]) ? textfield.$TextField[0 /* fontSize */] : (textfield.$TextField[6 /* textHeight */] + (textfield.$TextField[29 /* numLines */] - 1) * textfield.$TextField[1 /* lineSpacing */]); + return textHeight; }; /** - * @language en_US - * Read a 16-bit unsigned integer from the byte stream. - * @return A 16-bit unsigned integer ranging from 0 to 65535 - * @version Egret 2.4 - * @platform Web,Native + * 获取垂直比例 + * @param textfield 文本 + * @returns {number} 垂直比例 + * @private */ + TextFieldUtils.$getValign = function (textfield) { + var textHeight = TextFieldUtils.$getTextHeight(textfield); + //if (textfield.$TextField[sys.TextKeys.type] == egret.TextFieldType.INPUT) { + // if (textfield.$TextField[sys.TextKeys.multiline]) { + //return 0; + //} + //return 0.5; + //} + var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; + if (!isNaN(textFieldHeight)) { + if (textHeight < textFieldHeight) { + var valign = 0; + if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.MIDDLE) + valign = 0.5; + else if (textfield.$TextField[10 /* verticalAlign */] == egret.VerticalAlign.BOTTOM) + valign = 1; + return valign; + } + } + return 0; + }; /** - * @language zh_CN - * 从字节流中读取一个无符号的 16 位整数 - * @return 介于 0 和 65535 之间的 16 位无符号整数 - * @version Egret 2.4 - * @platform Web,Native + * 根据x、y获取文本项 + * @param textfield 文本 + * @param x x坐标值 + * @param y y坐标值 + * @returns 文本单项 + * @private */ - p.readUnsignedShort = function () { - if (!this.validate(ByteArray.SIZE_OF_UINT16)) + TextFieldUtils.$getTextElement = function (textfield, x, y) { + var hitTextEle = TextFieldUtils.$getHit(textfield, x, y); + var lineArr = textfield.$getLinesArr(); + if (hitTextEle && lineArr[hitTextEle.lineIndex] && lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]) { + return lineArr[hitTextEle.lineIndex].elements[hitTextEle.textElementIndex]; + } + return null; + }; + /** + * 获取文本点击块 + * @param textfield 文本 + * @param x x坐标值 + * @param y y坐标值 + * @returns 文本点击块 + * @private + */ + TextFieldUtils.$getHit = function (textfield, x, y) { + var lineArr = textfield.$getLinesArr(); + if (textfield.$TextField[3 /* textFieldWidth */] == 0) { return null; - var value = this.data.getUint16(this.position, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_UINT16; - return value; + } + var line = 0; + var textHeight = TextFieldUtils.$getTextHeight(textfield); + var startY = 0; + var textFieldHeight = textfield.$TextField[4 /* textFieldHeight */]; + if (!isNaN(textFieldHeight) && textFieldHeight > textHeight) { + var valign = TextFieldUtils.$getValign(textfield); + startY = valign * (textFieldHeight - textHeight); + if (startY != 0) { + y -= startY; + } + } + var startLine = TextFieldUtils.$getStartLine(textfield); + var lineH = 0; + for (var i = startLine; i < lineArr.length; i++) { + var lineEle = lineArr[i]; + if (lineH + lineEle.height >= y) { + line = i + 1; + break; + } + else { + lineH += lineEle.height; + } + if (lineH + textfield.$TextField[1 /* lineSpacing */] > y) { + return null; + } + lineH += textfield.$TextField[1 /* lineSpacing */]; + } + if (line == 0) { + return null; + } + var lineElement = lineArr[line - 1]; + var lineW = 0; + for (i = 0; i < lineElement.elements.length; i++) { + var iwTE = lineElement.elements[i]; + if (lineW + iwTE.width < x) { + lineW += iwTE.width; + } + else { + return { "lineIndex": line - 1, "textElementIndex": i }; + } + } + return null; + }; + /** + * 获取当前显示多少行 + * @param textfield 文本 + * @returns {number} 显示的行数 + * @private + */ + TextFieldUtils.$getScrollNum = function (textfield) { + var scrollNum = 1; + if (textfield.$TextField[30 /* multiline */]) { + var height = textfield.height; + var size = textfield.size; + var lineSpacing = textfield.lineSpacing; + scrollNum = Math.floor(height / (size + lineSpacing)); + var leftH = height - (size + lineSpacing) * scrollNum; + if (leftH > size / 2) { + scrollNum++; + } + } + return scrollNum; }; + return TextFieldUtils; + }()); + egret.TextFieldUtils = TextFieldUtils; + egret.registerClass(TextFieldUtils,'egret.TextFieldUtils'); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + var sys; + (function (sys) { + })(sys = egret.sys || (egret.sys = {})); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * The VerticalAlign class defines the possible values for the vertical alignment. + * @see egret.TextField#verticalAlign + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * VerticalAlign 类为垂直对齐方式定义可能的值。 + * @see egret.TextField#verticalAlign + * @version Egret 2.4 + * @platform Web,Native + */ + var VerticalAlign = (function () { + function VerticalAlign() { + } + var d = __define,c=VerticalAlign,p=c.prototype; /** * @language en_US - * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) - * @return UTF-8 character string + * Vertically align content to the top of the container. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) - * @return UTF-8 编码的字符串 + * 将内容与容器的顶部对齐。 * @version Egret 2.4 * @platform Web,Native */ - p.readUTF = function () { - if (!this.validate(ByteArray.SIZE_OF_UINT16)) - return null; - var length = this.data.getUint16(this.position, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_UINT16; - if (length > 0) { - return this.readUTFBytes(length); - } - else { - return ""; - } - }; + VerticalAlign.TOP = "top"; /** * @language en_US - * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string - * @param Specify a short unsigned integer of the UTF-8 byte length - * @return A character string consists of UTF-8 bytes of the specified length + * Vertically align content to the bottom of the container. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 - * @param length 指明 UTF-8 字节长度的无符号短整型数 - * @return 由指定长度的 UTF-8 字节组成的字符串 + * 将内容与容器的底部对齐。 * @version Egret 2.4 * @platform Web,Native */ - p.readUTFBytes = function (length) { - if (!this.validate(length)) - return null; - var bytes = new Uint8Array(this.buffer, this.bufferOffset + this.position, length); - this.position += length; - /*var bytes: Uint8Array = new Uint8Array(new ArrayBuffer(length)); - for (var i = 0; i < length; i++) { - bytes[i] = this.data.getUint8(this.position++); - }*/ - return this.decodeUTF8(bytes); - }; + VerticalAlign.BOTTOM = "bottom"; /** * @language en_US - * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. - * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. + * Vertically align content in the middle of the container. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 - * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 + * 在容器的垂直中心对齐内容。 * @version Egret 2.4 * @platform Web,Native */ - p.writeBoolean = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_BOOLEAN); - this.data.setUint8(this.position++, value ? 1 : 0); - }; + VerticalAlign.MIDDLE = "middle"; /** * @language en_US - * Write a byte into the byte stream - * The low 8 bits of the parameter are used. The high 24 bits are ignored. - * @param value A 32-bit integer. The low 8 bits will be written into the byte stream + * Vertical alignment with both edges + * Note: TextFiled does not support this alignment method." * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 在字节流中写入一个字节 - * 使用参数的低 8 位。忽略高 24 位 - * @param value 一个 32 位整数。低 8 位将被写入字节流 + * 垂直两端对齐 + * 注意:TextFiled不支持此对齐方式。 * @version Egret 2.4 * @platform Web,Native */ - p.writeByte = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_INT8); - this.data.setInt8(this.position++, value); - }; + VerticalAlign.JUSTIFY = "justify"; /** * @language en_US - * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream - * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written - * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. - * @param bytes ByteArray Object - * @param offset A zero-based index specifying the position into the array to begin writing - * @param length An unsigned integer specifying how far into the buffer to write + * Align the content of the child items, relative to the container. This operation will adjust uniformly the size of all the child items to be the Content Height \" of the container \". + * The Content Height \" of the container \" is the size of the max. child item. If the size of all child items are less than the height of the container, they will be adjusted to the height of the container. + * Note: TextFiled does not support this alignment method. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 - * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 - * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 - * @param bytes ByteArray 对象 - * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 - * @param length 一个无符号整数,表示在缓冲区中的写入范围 + * 相对于容器对子项进行内容对齐。这会将所有子项的大小统一调整为容器的"内容高度"。 + * 容器的"内容高度"是最大子项的大小,如果所有子项都小于容器的高度,则会将所有子项的大小调整为容器的高度。 + * 注意:TextFiled不支持此对齐方式。 * @version Egret 2.4 * @platform Web,Native */ - p.writeBytes = function (bytes, offset, length) { - if (offset === void 0) { offset = 0; } - if (length === void 0) { length = 0; } - var writeLength; - if (offset < 0) { - return; - } - if (length < 0) { - return; - } - else if (length == 0) { - writeLength = bytes.length - offset; - } - else { - writeLength = Math.min(bytes.length - offset, length); - } - if (writeLength > 0) { - this.validateBuffer(writeLength); - var tmp_data = new DataView(bytes.buffer); - var length = writeLength; - var BYTES_OF_UINT32 = 4; - for (; length > BYTES_OF_UINT32; length -= BYTES_OF_UINT32) { - this.data.setUint32(this._position, tmp_data.getUint32(offset)); - this.position += BYTES_OF_UINT32; - offset += BYTES_OF_UINT32; - } - for (; length > 0; length--) { - this.data.setUint8(this.position++, tmp_data.getUint8(offset++)); - } - } - }; + VerticalAlign.CONTENT_JUSTIFY = "contentJustify"; + return VerticalAlign; + }()); + egret.VerticalAlign = VerticalAlign; + egret.registerClass(VerticalAlign,'egret.VerticalAlign'); +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * The Endian class contains values that denote the byte order used to represent multibyte numbers. + * The byte order is either bigEndian (most significant byte first) or littleEndian (least significant byte first). + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * Endian 类中包含一些值,它们表示用于表示多字节数字的字节顺序。 + * 字节顺序为 bigEndian(最高有效字节位于最前)或 littleEndian(最低有效字节位于最前)。 + * @version Egret 2.4 + * @platform Web,Native + */ + var Endian = (function () { + function Endian() { + } + var d = __define,c=Endian,p=c.prototype; /** * @language en_US - * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream - * @param value Double-precision (64 bit) floating point number + * Indicates the least significant byte of the multibyte number appears first in the sequence of bytes. + * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 - * @param value 双精度(64 位)浮点数 + * 表示多字节数字的最低有效字节位于字节序列的最前面。 + * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 * @version Egret 2.4 * @platform Web,Native */ - p.writeDouble = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_FLOAT64); - this.data.setFloat64(this.position, value, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_FLOAT64; - }; + Endian.LITTLE_ENDIAN = "littleEndian"; /** * @language en_US - * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream - * @param value Single-precision (32 bit) floating point number + * Indicates the most significant byte of the multibyte number appears first in the sequence of bytes. + * The hexadecimal number 0x12345678 has 4 bytes (2 hexadecimal digits per byte). The most significant byte is 0x12. The least significant byte is 0x78. (For the equivalent decimal number, 305419896, the most significant digit is 3, and the least significant digit is 6). * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 - * @param value 单精度(32 位)浮点数 + * 表示多字节数字的最高有效字节位于字节序列的最前面。 + * 十六进制数字 0x12345678 包含 4 个字节(每个字节包含 2 个十六进制数字)。最高有效字节为 0x12。最低有效字节为 0x78。(对于等效的十进制数字 305419896,最高有效数字是 3,最低有效数字是 6)。 * @version Egret 2.4 * @platform Web,Native */ - p.writeFloat = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_FLOAT32); - this.data.setFloat32(this.position, value, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_FLOAT32; - }; + Endian.BIG_ENDIAN = "bigEndian"; + return Endian; + }()); + egret.Endian = Endian; + egret.registerClass(Endian,'egret.Endian'); + /** + * @language en_US + * The ByteArray class provides methods and attributes for optimized reading and writing as well as dealing with binary data. + * Note: The ByteArray class is applied to the advanced developers who need to access data at the byte layer. + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/ByteArray.ts + */ + /** + * @language zh_CN + * ByteArray 类提供用于优化读取、写入以及处理二进制数据的方法和属性。 + * 注意:ByteArray 类适用于需要在字节层访问数据的高级开发人员。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/ByteArray.ts + */ + var ByteArray = (function () { /** - * @language en_US - * Write a 32-bit signed integer into the byte stream - * @param value An integer to be written into the byte stream * @version Egret 2.4 * @platform Web,Native */ + function ByteArray(buffer) { + /** + * @private + */ + this.BUFFER_EXT_SIZE = 0; //Buffer expansion size + /** + * @private + */ + this.EOF_byte = -1; + /** + * @private + */ + this.EOF_code_point = -1; + this._setArrayBuffer(buffer || new ArrayBuffer(this.BUFFER_EXT_SIZE)); + this.endian = Endian.BIG_ENDIAN; + } + var d = __define,c=ByteArray,p=c.prototype; /** - * @language zh_CN - * 在字节流中写入一个带符号的 32 位整数 - * @param value 要写入字节流的整数 - * @version Egret 2.4 - * @platform Web,Native + * @private + * @param buffer */ - p.writeInt = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_INT32); - this.data.setInt32(this.position, value, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_INT32; + p._setArrayBuffer = function (buffer) { + this.write_position = buffer.byteLength; + this.data = new DataView(buffer); + this._position = 0; }; /** - * @language en_US - * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. - * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 - * @param value 32 位整数,该整数的低 16 位将被写入字节流 + * @deprecated * @version Egret 2.4 * @platform Web,Native */ - p.writeShort = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_INT16); - this.data.setInt16(this.position, value, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_INT16; + p.setArrayBuffer = function (buffer) { }; + d(p, "buffer" + ,function () { + return this.data.buffer; + } + /** + * @private + */ + ,function (value) { + this.data = new DataView(value); + } + ); + d(p, "dataView" + /** + * @private + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.data; + } + /** + * @private + */ + ,function (value) { + this.data = value; + this.write_position = value.byteLength; + } + ); + d(p, "bufferOffset" + /** + * @private + */ + ,function () { + return this.data.byteOffset; + } + ); + d(p, "position" + /** + * @language en_US + * The current position of the file pointer (in bytes) to move or return to the ByteArray object. The next time you start reading reading method call in this position, or will start writing in this position next time call a write method. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 将文件指针的当前位置(以字节为单位)移动或返回到 ByteArray 对象中。下一次调用读取方法时将在此位置开始读取,或者下一次调用写入方法时将在此位置开始写入。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this._position; + } + ,function (value) { + //if (this._position < value) { + // if (!this.validate(value - this._position)) { + // return; + // } + //} + this._position = value; + this.write_position = value > this.write_position ? value : this.write_position; + } + ); + d(p, "length" + /** + * @language en_US + * The length of the ByteArray object (in bytes). + * If the length is set to be larger than the current length, the right-side zero padding byte array. + * If the length is set smaller than the current length, the byte array is truncated. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * ByteArray 对象的长度(以字节为单位)。 + * 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧。 + * 如果将长度设置为小于当前长度的值,将会截断该字节数组。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.write_position; + } + ,function (value) { + this.write_position = value; + var tmp = new Uint8Array(new ArrayBuffer(value)); + var byteLength = this.data.buffer.byteLength; + if (byteLength > value) { + this._position = value; + } + var length = Math.min(byteLength, value); + tmp.set(new Uint8Array(this.data.buffer, 0, length)); + this.buffer = tmp.buffer; + } + ); + d(p, "bytesAvailable" + /** + * @language en_US + * The number of bytes that can be read from the current position of the byte array to the end of the array data. + * When you access a ByteArray object, the bytesAvailable property in conjunction with the read methods each use to make sure you are reading valid data. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 可从字节数组的当前位置到数组末尾读取的数据的字节数。 + * 每次访问 ByteArray 对象时,将 bytesAvailable 属性与读取方法结合使用,以确保读取有效的数据。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this.data.byteLength - this._position; + } + ); /** * @language en_US - * Write a 32-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream + * Clears the contents of the byte array and resets the length and position properties to 0. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 在字节流中写入一个无符号的 32 位整数 - * @param value 要写入字节流的无符号整数 + * 清除字节数组的内容,并将 length 和 position 属性重置为 0。 + * @version Egret 2.4 * @platform Web,Native - */ - p.writeUnsignedInt = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_UINT32); - this.data.setUint32(this.position, value, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_UINT32; - }; - /** - * @language en_US - * Write a 16-bit unsigned integer into the byte stream - * @param value An unsigned integer to be written into the byte stream - * @version Egret 2.5 - * @platform Web,Native - */ - /** - * @language zh_CN - * 在字节流中写入一个无符号的 16 位整数 - * @param value 要写入字节流的无符号整数 - * @version Egret 2.5 - * @platform Web,Native - */ - p.writeUnsignedShort = function (value) { - this.validateBuffer(ByteArray.SIZE_OF_UINT16); - this.data.setUint16(this.position, value, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_UINT16; + */ + p.clear = function () { + this._setArrayBuffer(new ArrayBuffer(this.BUFFER_EXT_SIZE)); }; /** * @language en_US - * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string - * @param value Character string value to be written + * Read a Boolean value from the byte stream. Read a simple byte. If the byte is non-zero, it returns true; otherwise, it returns false. + * @return If the byte is non-zero, it returns true; otherwise, it returns false. * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 - * @param value 要写入的字符串值 + * 从字节流中读取布尔值。读取单个字节,如果字节非零,则返回 true,否则返回 false + * @return 如果字节不为零,则返回 true,否则返回 false * @version Egret 2.4 * @platform Web,Native */ - p.writeUTF = function (value) { - var utf8bytes = this.encodeUTF8(value); - var length = utf8bytes.length; - this.validateBuffer(ByteArray.SIZE_OF_UINT16 + length); - this.data.setUint16(this.position, length, this.endian == Endian.LITTLE_ENDIAN); - this.position += ByteArray.SIZE_OF_UINT16; - this._writeUint8Array(utf8bytes, false); + p.readBoolean = function () { + if (!this.validate(ByteArray.SIZE_OF_BOOLEAN)) + return null; + return this.data.getUint8(this.position++) != 0; }; /** * @language en_US - * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word - * @param value Character string value to be written + * Read signed bytes from the byte stream. + * @return An integer ranging from -128 to 127 * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 - * @param value 要写入的字符串值 + * 从字节流中读取带符号的字节 + * @return 介于 -128 和 127 之间的整数 * @version Egret 2.4 * @platform Web,Native */ - p.writeUTFBytes = function (value) { - this._writeUint8Array(this.encodeUTF8(value)); + p.readByte = function () { + if (!this.validate(ByteArray.SIZE_OF_INT8)) + return null; + return this.data.getInt8(this.position++); }; /** - * - * @returns + * @language en_US + * Read data byte number specified by the length parameter from the byte stream. Starting from the position specified by offset, read bytes into the ByteArray object specified by the bytes parameter, and write bytes into the target ByteArray + * @param bytes ByteArray object that data is read into + * @param offset Offset (position) in bytes. Read data should be written from this position + * @param length Byte number to be read Default value 0 indicates reading all available data * @version Egret 2.4 * @platform Web,Native */ - p.toString = function () { - return "[ByteArray] length:" + this.length + ", bytesAvailable:" + this.bytesAvailable; - }; - /** - * @private - * 将 Uint8Array 写入字节流 - * @param bytes 要写入的Uint8Array - * @param validateBuffer - */ - p._writeUint8Array = function (bytes, validateBuffer) { - if (validateBuffer === void 0) { validateBuffer = true; } - if (validateBuffer) { - this.validateBuffer(this.position + bytes.length); - } - for (var i = 0; i < bytes.length; i++) { - this.data.setUint8(this.position++, bytes[i]); - } - }; /** - * @param len - * @returns + * @language zh_CN + * 从字节流中读取 length 参数指定的数据字节数。从 offset 指定的位置开始,将字节读入 bytes 参数指定的 ByteArray 对象中,并将字节写入目标 ByteArray 中 + * @param bytes 要将数据读入的 ByteArray 对象 + * @param offset bytes 中的偏移(位置),应从该位置写入读取的数据 + * @param length 要读取的字节数。默认值 0 导致读取所有可用的数据 * @version Egret 2.4 * @platform Web,Native - * @private */ - p.validate = function (len) { - //len += this.data.byteOffset; - if (this.data.byteLength > 0 && this._position + len <= this.data.byteLength) { - return true; + p.readBytes = function (bytes, offset, length) { + if (offset === void 0) { offset = 0; } + if (length === void 0) { length = 0; } + if (length == 0) { + length = this.bytesAvailable; + } + else if (!this.validate(length)) { + return null; + } + if (bytes) { + bytes.validateBuffer(offset + length); } else { - egret.$error(1025); + bytes = new ByteArray(new ArrayBuffer(offset + length)); } - }; - /**********************/ - /* PRIVATE METHODS */ - /**********************/ - /** - * @private - * @param len - * @param needReplace - */ - p.validateBuffer = function (len, needReplace) { - if (needReplace === void 0) { needReplace = false; } - this.write_position = len > this.write_position ? len : this.write_position; - len += this._position; - if (this.data.byteLength < len || needReplace) { - var tmp = new Uint8Array(new ArrayBuffer(len + this.BUFFER_EXT_SIZE)); - var length = Math.min(this.data.buffer.byteLength, len + this.BUFFER_EXT_SIZE); - tmp.set(new Uint8Array(this.data.buffer, 0, length)); - this.buffer = tmp.buffer; + //This method is expensive + for (var i = 0; i < length; i++) { + bytes.data.setUint8(i + offset, this.data.getUint8(this.position++)); } }; /** - * @private - * UTF-8 Encoding/Decoding + * @language en_US + * Read an IEEE 754 double-precision (64 bit) floating point number from the byte stream + * @return Double-precision (64 bit) floating point number + * @version Egret 2.4 + * @platform Web,Native */ - p.encodeUTF8 = function (str) { - var pos = 0; - var codePoints = this.stringToCodePoints(str); - var outputBytes = []; - while (codePoints.length > pos) { - var code_point = codePoints[pos++]; - if (this.inRange(code_point, 0xD800, 0xDFFF)) { - this.encoderError(code_point); - } - else if (this.inRange(code_point, 0x0000, 0x007f)) { - outputBytes.push(code_point); - } - else { - var count, offset; - if (this.inRange(code_point, 0x0080, 0x07FF)) { - count = 1; - offset = 0xC0; - } - else if (this.inRange(code_point, 0x0800, 0xFFFF)) { - count = 2; - offset = 0xE0; - } - else if (this.inRange(code_point, 0x10000, 0x10FFFF)) { - count = 3; - offset = 0xF0; - } - outputBytes.push(this.div(code_point, Math.pow(64, count)) + offset); - while (count > 0) { - var temp = this.div(code_point, Math.pow(64, count - 1)); - outputBytes.push(0x80 + (temp % 64)); - count -= 1; - } - } - } - return new Uint8Array(outputBytes); - }; /** - * @private - * - * @param data - * @returns + * @language zh_CN + * 从字节流中读取一个 IEEE 754 双精度(64 位)浮点数 + * @return 双精度(64 位)浮点数 + * @version Egret 2.4 + * @platform Web,Native */ - p.decodeUTF8 = function (data) { - var fatal = false; - var pos = 0; - var result = ""; - var code_point; - var utf8_code_point = 0; - var utf8_bytes_needed = 0; - var utf8_bytes_seen = 0; - var utf8_lower_boundary = 0; - while (data.length > pos) { - var _byte = data[pos++]; - if (_byte == this.EOF_byte) { - if (utf8_bytes_needed != 0) { - code_point = this.decoderError(fatal); - } - else { - code_point = this.EOF_code_point; - } - } - else { - if (utf8_bytes_needed == 0) { - if (this.inRange(_byte, 0x00, 0x7F)) { - code_point = _byte; - } - else { - if (this.inRange(_byte, 0xC2, 0xDF)) { - utf8_bytes_needed = 1; - utf8_lower_boundary = 0x80; - utf8_code_point = _byte - 0xC0; - } - else if (this.inRange(_byte, 0xE0, 0xEF)) { - utf8_bytes_needed = 2; - utf8_lower_boundary = 0x800; - utf8_code_point = _byte - 0xE0; - } - else if (this.inRange(_byte, 0xF0, 0xF4)) { - utf8_bytes_needed = 3; - utf8_lower_boundary = 0x10000; - utf8_code_point = _byte - 0xF0; - } - else { - this.decoderError(fatal); - } - utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); - code_point = null; - } - } - else if (!this.inRange(_byte, 0x80, 0xBF)) { - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - pos--; - code_point = this.decoderError(fatal, _byte); - } - else { - utf8_bytes_seen += 1; - utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); - if (utf8_bytes_seen !== utf8_bytes_needed) { - code_point = null; - } - else { - var cp = utf8_code_point; - var lower_boundary = utf8_lower_boundary; - utf8_code_point = 0; - utf8_bytes_needed = 0; - utf8_bytes_seen = 0; - utf8_lower_boundary = 0; - if (this.inRange(cp, lower_boundary, 0x10FFFF) && !this.inRange(cp, 0xD800, 0xDFFF)) { - code_point = cp; - } - else { - code_point = this.decoderError(fatal, _byte); - } - } - } - } - //Decode string - if (code_point !== null && code_point !== this.EOF_code_point) { - if (code_point <= 0xFFFF) { - if (code_point > 0) - result += String.fromCharCode(code_point); - } - else { - code_point -= 0x10000; - result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); - result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); - } - } - } - return result; + p.readDouble = function () { + if (!this.validate(ByteArray.SIZE_OF_FLOAT64)) + return null; + var value = this.data.getFloat64(this.position, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_FLOAT64; + return value; }; /** - * @private - * - * @param code_point + * @language en_US + * Read an IEEE 754 single-precision (32 bit) floating point number from the byte stream + * @return Single-precision (32 bit) floating point number + * @version Egret 2.4 + * @platform Web,Native */ - p.encoderError = function (code_point) { - egret.$error(1026, code_point); - }; /** - * @private - * - * @param fatal - * @param opt_code_point - * @returns + * @language zh_CN + * 从字节流中读取一个 IEEE 754 单精度(32 位)浮点数 + * @return 单精度(32 位)浮点数 + * @version Egret 2.4 + * @platform Web,Native */ - p.decoderError = function (fatal, opt_code_point) { - if (fatal) { - egret.$error(1027); - } - return opt_code_point || 0xFFFD; + p.readFloat = function () { + if (!this.validate(ByteArray.SIZE_OF_FLOAT32)) + return null; + var value = this.data.getFloat32(this.position, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_FLOAT32; + return value; }; /** - * @private - * - * @param a - * @param min - * @param max + * @language en_US + * Read a 32-bit signed integer from the byte stream. + * @return A 32-bit signed integer ranging from -2147483648 to 2147483647 + * @version Egret 2.4 + * @platform Web,Native */ - p.inRange = function (a, min, max) { - return min <= a && a <= max; + /** + * @language zh_CN + * 从字节流中读取一个带符号的 32 位整数 + * @return 介于 -2147483648 和 2147483647 之间的 32 位带符号整数 + * @version Egret 2.4 + * @platform Web,Native + */ + p.readInt = function () { + if (!this.validate(ByteArray.SIZE_OF_INT32)) + return null; + var value = this.data.getInt32(this.position, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_INT32; + return value; }; + ///** + // * 使用指定的字符集从字节流中读取指定长度的多字节字符串 + // * @param length 要从字节流中读取的字节数 + // * @param charSet 表示用于解释字节的字符集的字符串。可能的字符集字符串包括 "shift-jis"、"cn-gb"、"iso-8859-1"”等 + // * @return UTF-8 编码的字符串 + // * @method egret.ByteArray#readMultiByte + // */ + //public readMultiByte(length:number, charSet?:string):string { + // if (!this.validate(length)) return null; + // + // return ""; + //} /** - * @private - * - * @param n - * @param d + * @language en_US + * Read a 16-bit signed integer from the byte stream. + * @return A 16-bit signed integer ranging from -32768 to 32767 + * @version Egret 2.4 + * @platform Web,Native */ - p.div = function (n, d) { - return Math.floor(n / d); + /** + * @language zh_CN + * 从字节流中读取一个带符号的 16 位整数 + * @return 介于 -32768 和 32767 之间的 16 位带符号整数 + * @version Egret 2.4 + * @platform Web,Native + */ + p.readShort = function () { + if (!this.validate(ByteArray.SIZE_OF_INT16)) + return null; + var value = this.data.getInt16(this.position, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_INT16; + return value; }; /** - * @private - * - * @param string + * @language en_US + * Read unsigned bytes from the byte stream. + * @return A 32-bit unsigned integer ranging from 0 to 255 + * @version Egret 2.4 + * @platform Web,Native */ - p.stringToCodePoints = function (string) { - /** @type {Array.} */ - var cps = []; - // Based on http://www.w3.org/TR/WebIDL/#idl-DOMString - var i = 0, n = string.length; - while (i < string.length) { - var c = string.charCodeAt(i); - if (!this.inRange(c, 0xD800, 0xDFFF)) { - cps.push(c); - } - else if (this.inRange(c, 0xDC00, 0xDFFF)) { - cps.push(0xFFFD); - } - else { - if (i == n - 1) { - cps.push(0xFFFD); - } - else { - var d = string.charCodeAt(i + 1); - if (this.inRange(d, 0xDC00, 0xDFFF)) { - var a = c & 0x3FF; - var b = d & 0x3FF; - i += 1; - cps.push(0x10000 + (a << 10) + b); - } - else { - cps.push(0xFFFD); - } - } - } - i += 1; - } - return cps; + /** + * @language zh_CN + * 从字节流中读取无符号的字节 + * @return 介于 0 和 255 之间的 32 位无符号整数 + * @version Egret 2.4 + * @platform Web,Native + */ + p.readUnsignedByte = function () { + if (!this.validate(ByteArray.SIZE_OF_UINT8)) + return null; + return this.data.getUint8(this.position++); }; /** - * @private + * @language en_US + * Read a 32-bit unsigned integer from the byte stream. + * @return A 32-bit unsigned integer ranging from 0 to 4294967295 + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_BOOLEAN = 1; /** - * @private + * @language zh_CN + * 从字节流中读取一个无符号的 32 位整数 + * @return 介于 0 和 4294967295 之间的 32 位无符号整数 + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_INT8 = 1; + p.readUnsignedInt = function () { + if (!this.validate(ByteArray.SIZE_OF_UINT32)) + return null; + var value = this.data.getUint32(this.position, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_UINT32; + return value; + }; /** - * @private + * @language en_US + * Read a 16-bit unsigned integer from the byte stream. + * @return A 16-bit unsigned integer ranging from 0 to 65535 + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_INT16 = 2; /** - * @private + * @language zh_CN + * 从字节流中读取一个无符号的 16 位整数 + * @return 介于 0 和 65535 之间的 16 位无符号整数 + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_INT32 = 4; + p.readUnsignedShort = function () { + if (!this.validate(ByteArray.SIZE_OF_UINT16)) + return null; + var value = this.data.getUint16(this.position, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_UINT16; + return value; + }; /** - * @private + * @language en_US + * Read a UTF-8 character string from the byte stream Assume that the prefix of the character string is a short unsigned integer (use byte to express length) + * @return UTF-8 character string + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_UINT8 = 1; /** - * @private + * @language zh_CN + * 从字节流中读取一个 UTF-8 字符串。假定字符串的前缀是无符号的短整型(以字节表示长度) + * @return UTF-8 编码的字符串 + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_UINT16 = 2; + p.readUTF = function () { + if (!this.validate(ByteArray.SIZE_OF_UINT16)) + return null; + var length = this.data.getUint16(this.position, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_UINT16; + if (length > 0) { + return this.readUTFBytes(length); + } + else { + return ""; + } + }; /** - * @private + * @language en_US + * Read a UTF-8 byte sequence specified by the length parameter from the byte stream, and then return a character string + * @param Specify a short unsigned integer of the UTF-8 byte length + * @return A character string consists of UTF-8 bytes of the specified length + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_UINT32 = 4; /** - * @private + * @language zh_CN + * 从字节流中读取一个由 length 参数指定的 UTF-8 字节序列,并返回一个字符串 + * @param length 指明 UTF-8 字节长度的无符号短整型数 + * @return 由指定长度的 UTF-8 字节组成的字符串 + * @version Egret 2.4 + * @platform Web,Native */ - ByteArray.SIZE_OF_FLOAT32 = 4; + p.readUTFBytes = function (length) { + if (!this.validate(length)) + return null; + var bytes = new Uint8Array(this.buffer, this.bufferOffset + this.position, length); + this.position += length; + /*var bytes: Uint8Array = new Uint8Array(new ArrayBuffer(length)); + for (var i = 0; i < length; i++) { + bytes[i] = this.data.getUint8(this.position++); + }*/ + return this.decodeUTF8(bytes); + }; /** - * @private + * @language en_US + * Write a Boolean value. A single byte is written according to the value parameter. If the value is true, write 1; if the value is false, write 0. + * @param value A Boolean value determining which byte is written. If the value is true, write 1; if the value is false, write 0. + * @version Egret 2.4 + * @platform Web,Native */ +<<<<<<< HEAD ByteArray.SIZE_OF_FLOAT64 = 8; return ByteArray; }()); @@ -22283,537 +22027,561 @@ var egret; ,function (logType) { } ); +======= + /** + * @language zh_CN + * 写入布尔值。根据 value 参数写入单个字节。如果为 true,则写入 1,如果为 false,则写入 0 + * @param value 确定写入哪个字节的布尔值。如果该参数为 true,则该方法写入 1;如果该参数为 false,则该方法写入 0 + * @version Egret 2.4 + * @platform Web,Native + */ + p.writeBoolean = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_BOOLEAN); + this.data.setUint8(this.position++, value ? 1 : 0); + }; +>>>>>>> 4b8c5c4a241e7d9bd1c1bd245f7622d16a8879b6 /** * @language en_US - * open all + * Write a byte into the byte stream + * The low 8 bits of the parameter are used. The high 24 bits are ignored. + * @param value A 32-bit integer. The low 8 bits will be written into the byte stream * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 全开 + * 在字节流中写入一个字节 + * 使用参数的低 8 位。忽略高 24 位 + * @param value 一个 32 位整数。低 8 位将被写入字节流 * @version Egret 2.4 * @platform Web,Native */ - Logger.ALL = "all"; + p.writeByte = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_INT8); + this.data.setInt8(this.position++, value); + }; /** * @language en_US - * level: DEBUG + * Write the byte sequence that includes length bytes in the specified byte array, bytes, (starting at the byte specified by offset, using a zero-based index), into the byte stream + * If the length parameter is omitted, the default length value 0 is used and the entire buffer starting at offset is written. If the offset parameter is also omitted, the entire buffer is written + * If the offset or length parameter is out of range, they are clamped to the beginning and end of the bytes array. + * @param bytes ByteArray Object + * @param offset A zero-based index specifying the position into the array to begin writing + * @param length An unsigned integer specifying how far into the buffer to write * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 等级为 DEBUG + * 将指定字节数组 bytes(起始偏移量为 offset,从零开始的索引)中包含 length 个字节的字节序列写入字节流 + * 如果省略 length 参数,则使用默认长度 0;该方法将从 offset 开始写入整个缓冲区。如果还省略了 offset 参数,则写入整个缓冲区 + * 如果 offset 或 length 超出范围,它们将被锁定到 bytes 数组的开头和结尾 + * @param bytes ByteArray 对象 + * @param offset 从 0 开始的索引,表示在数组中开始写入的位置 + * @param length 一个无符号整数,表示在缓冲区中的写入范围 * @version Egret 2.4 * @platform Web,Native */ - Logger.DEBUG = "debug"; + p.writeBytes = function (bytes, offset, length) { + if (offset === void 0) { offset = 0; } + if (length === void 0) { length = 0; } + var writeLength; + if (offset < 0) { + return; + } + if (length < 0) { + return; + } + else if (length == 0) { + writeLength = bytes.length - offset; + } + else { + writeLength = Math.min(bytes.length - offset, length); + } + if (writeLength > 0) { + this.validateBuffer(writeLength); + var tmp_data = new DataView(bytes.buffer); + var length = writeLength; + var BYTES_OF_UINT32 = 4; + for (; length > BYTES_OF_UINT32; length -= BYTES_OF_UINT32) { + this.data.setUint32(this._position, tmp_data.getUint32(offset)); + this.position += BYTES_OF_UINT32; + offset += BYTES_OF_UINT32; + } + for (; length > 0; length--) { + this.data.setUint8(this.position++, tmp_data.getUint8(offset++)); + } + } + }; /** * @language en_US - * level: INFO + * Write an IEEE 754 double-precision (64 bit) floating point number into the byte stream + * @param value Double-precision (64 bit) floating point number * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 等级为 INFO + * 在字节流中写入一个 IEEE 754 双精度(64 位)浮点数 + * @param value 双精度(64 位)浮点数 * @version Egret 2.4 * @platform Web,Native */ - Logger.INFO = "info"; + p.writeDouble = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_FLOAT64); + this.data.setFloat64(this.position, value, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_FLOAT64; + }; /** * @language en_US - * level: WARN + * Write an IEEE 754 single-precision (32 bit) floating point number into the byte stream + * @param value Single-precision (32 bit) floating point number * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 等级为 WARN + * 在字节流中写入一个 IEEE 754 单精度(32 位)浮点数 + * @param value 单精度(32 位)浮点数 * @version Egret 2.4 * @platform Web,Native */ - Logger.WARN = "warn"; + p.writeFloat = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_FLOAT32); + this.data.setFloat32(this.position, value, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_FLOAT32; + }; /** * @language en_US - * level: ERROR + * Write a 32-bit signed integer into the byte stream + * @param value An integer to be written into the byte stream * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 等级为 ERROR + * 在字节流中写入一个带符号的 32 位整数 + * @param value 要写入字节流的整数 * @version Egret 2.4 * @platform Web,Native */ - Logger.ERROR = "error"; + p.writeInt = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_INT32); + this.data.setInt32(this.position, value, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_INT32; + }; /** * @language en_US - * close all + * Write a 16-bit integer into the byte stream. The low 16 bits of the parameter are used. The high 16 bits are ignored. + * @param value A 32-bit integer. Its low 16 bits will be written into the byte stream * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 全关 + * 在字节流中写入一个 16 位整数。使用参数的低 16 位。忽略高 16 位 + * @param value 32 位整数,该整数的低 16 位将被写入字节流 * @version Egret 2.4 * @platform Web,Native */ - Logger.OFF = "off"; - return Logger; - }()); - egret.Logger = Logger; - egret.registerClass(Logger,'egret.Logger'); -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @version Egret 2.4 - * @platform Web,Native - */ - var NumberUtils = (function () { - function NumberUtils() { - } - var d = __define,c=NumberUtils,p=c.prototype; + p.writeShort = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_INT16); + this.data.setInt16(this.position, value, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_INT16; + }; /** * @language en_US - * Judge whether it is a numerical value - * @param value Parameter that needs to be judged - * @returns + * Write a 32-bit unsigned integer into the byte stream + * @param value An unsigned integer to be written into the byte stream * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 判断是否是数值 - * @param value 需要判断的参数 - * @returns + * 在字节流中写入一个无符号的 32 位整数 + * @param value 要写入字节流的无符号整数 * @version Egret 2.4 * @platform Web,Native */ - NumberUtils.isNumber = function (value) { - return typeof (value) === "number" && !isNaN(value); + p.writeUnsignedInt = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_UINT32); + this.data.setUint32(this.position, value, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_UINT32; }; /** * @language en_US - * Obtain the approximate sin value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} sin value + * Write a 16-bit unsigned integer into the byte stream + * @param value An unsigned integer to be written into the byte stream + * @version Egret 2.5 + * @platform Web,Native + */ + /** + * @language zh_CN + * 在字节流中写入一个无符号的 16 位整数 + * @param value 要写入字节流的无符号整数 + * @version Egret 2.5 + * @platform Web,Native + */ + p.writeUnsignedShort = function (value) { + this.validateBuffer(ByteArray.SIZE_OF_UINT16); + this.data.setUint16(this.position, value, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_UINT16; + }; + /** + * @language en_US + * Write a UTF-8 string into the byte stream. The length of the UTF-8 string in bytes is written first, as a 16-bit integer, followed by the bytes representing the characters of the string + * @param value Character string value to be written * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 得到对应角度值的sin近似值 - * @param value {number} 角度值 - * @returns {number} sin值 + * 将 UTF-8 字符串写入字节流。先写入以字节表示的 UTF-8 字符串长度(作为 16 位整数),然后写入表示字符串字符的字节 + * @param value 要写入的字符串值 * @version Egret 2.4 * @platform Web,Native */ - NumberUtils.sin = function (value) { - var valueFloor = Math.floor(value); - var valueCeil = valueFloor + 1; - var resultFloor = NumberUtils.sinInt(valueFloor); - if (valueFloor == value) { - return resultFloor; + p.writeUTF = function (value) { + var utf8bytes = this.encodeUTF8(value); + var length = utf8bytes.length; + this.validateBuffer(ByteArray.SIZE_OF_UINT16 + length); + this.data.setUint16(this.position, length, this.endian == Endian.LITTLE_ENDIAN); + this.position += ByteArray.SIZE_OF_UINT16; + this._writeUint8Array(utf8bytes, false); + }; + /** + * @language en_US + * Write a UTF-8 string into the byte stream. Similar to the writeUTF() method, but the writeUTFBytes() method does not prefix the string with a 16-bit length word + * @param value Character string value to be written + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 将 UTF-8 字符串写入字节流。类似于 writeUTF() 方法,但 writeUTFBytes() 不使用 16 位长度的词为字符串添加前缀 + * @param value 要写入的字符串值 + * @version Egret 2.4 + * @platform Web,Native + */ + p.writeUTFBytes = function (value) { + this._writeUint8Array(this.encodeUTF8(value)); + }; + /** + * + * @returns + * @version Egret 2.4 + * @platform Web,Native + */ + p.toString = function () { + return "[ByteArray] length:" + this.length + ", bytesAvailable:" + this.bytesAvailable; + }; + /** + * @private + * 将 Uint8Array 写入字节流 + * @param bytes 要写入的Uint8Array + * @param validateBuffer + */ + p._writeUint8Array = function (bytes, validateBuffer) { + if (validateBuffer === void 0) { validateBuffer = true; } + if (validateBuffer) { + this.validateBuffer(this.position + bytes.length); + } + for (var i = 0; i < bytes.length; i++) { + this.data.setUint8(this.position++, bytes[i]); + } + }; + /** + * @param len + * @returns + * @version Egret 2.4 + * @platform Web,Native + * @private + */ + p.validate = function (len) { + //len += this.data.byteOffset; + if (this.data.byteLength > 0 && this._position + len <= this.data.byteLength) { + return true; + } + else { + egret.$error(1025); } - var resultCeil = NumberUtils.sinInt(valueCeil); - return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; }; + /**********************/ + /* PRIVATE METHODS */ + /**********************/ /** * @private - * - * @param value - * @returns + * @param len + * @param needReplace */ - NumberUtils.sinInt = function (value) { - value = value % 360; - if (value < 0) { - value += 360; + p.validateBuffer = function (len, needReplace) { + if (needReplace === void 0) { needReplace = false; } + this.write_position = len > this.write_position ? len : this.write_position; + len += this._position; + if (this.data.byteLength < len || needReplace) { + var tmp = new Uint8Array(new ArrayBuffer(len + this.BUFFER_EXT_SIZE)); + var length = Math.min(this.data.buffer.byteLength, len + this.BUFFER_EXT_SIZE); + tmp.set(new Uint8Array(this.data.buffer, 0, length)); + this.buffer = tmp.buffer; } - return egret_sin_map[value]; }; /** - * @language en_US - * Obtain the approximate cos value of the corresponding angle value - * @param value {number} Angle value - * @returns {number} cos value - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 得到对应角度值的cos近似值 - * @param value {number} 角度值 - * @returns {number} cos值 - * @version Egret 2.4 - * @platform Web,Native + * @private + * UTF-8 Encoding/Decoding */ - NumberUtils.cos = function (value) { - var valueFloor = Math.floor(value); - var valueCeil = valueFloor + 1; - var resultFloor = NumberUtils.cosInt(valueFloor); - if (valueFloor == value) { - return resultFloor; + p.encodeUTF8 = function (str) { + var pos = 0; + var codePoints = this.stringToCodePoints(str); + var outputBytes = []; + while (codePoints.length > pos) { + var code_point = codePoints[pos++]; + if (this.inRange(code_point, 0xD800, 0xDFFF)) { + this.encoderError(code_point); + } + else if (this.inRange(code_point, 0x0000, 0x007f)) { + outputBytes.push(code_point); + } + else { + var count, offset; + if (this.inRange(code_point, 0x0080, 0x07FF)) { + count = 1; + offset = 0xC0; + } + else if (this.inRange(code_point, 0x0800, 0xFFFF)) { + count = 2; + offset = 0xE0; + } + else if (this.inRange(code_point, 0x10000, 0x10FFFF)) { + count = 3; + offset = 0xF0; + } + outputBytes.push(this.div(code_point, Math.pow(64, count)) + offset); + while (count > 0) { + var temp = this.div(code_point, Math.pow(64, count - 1)); + outputBytes.push(0x80 + (temp % 64)); + count -= 1; + } + } } - var resultCeil = NumberUtils.cosInt(valueCeil); - return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; + return new Uint8Array(outputBytes); }; /** * @private * - * @param value + * @param data * @returns */ - NumberUtils.cosInt = function (value) { - value = value % 360; - if (value < 0) { - value += 360; - } - return egret_cos_map[value]; - }; - return NumberUtils; - }()); - egret.NumberUtils = NumberUtils; - egret.registerClass(NumberUtils,'egret.NumberUtils'); -})(egret || (egret = {})); -var egret_sin_map = {}; -var egret_cos_map = {}; -var DEG_TO_RAD = Math.PI / 180; -for (var NumberUtils_i = 0; NumberUtils_i < 360; NumberUtils_i++) { - egret_sin_map[NumberUtils_i] = Math.sin(NumberUtils_i * DEG_TO_RAD); - egret_cos_map[NumberUtils_i] = Math.cos(NumberUtils_i * DEG_TO_RAD); -} -egret_sin_map[90] = 1; -egret_cos_map[90] = 0; -egret_sin_map[180] = 0; -egret_cos_map[180] = -1; -egret_sin_map[270] = -1; -egret_cos_map[270] = 0; -//对未提供bind的浏览器实现bind机制 -if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - if (typeof this !== "function") { - // closest thing possible to the ECMAScript 5 internal IsCallable function - egret.$error(1029); - } - var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () { - }, fBound = function () { - return fToBind.apply(this instanceof fNOP && oThis - ? this - : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); - }; - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); - return fBound; - }; -} -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { - /** - * @language en_US - * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() - * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
      - * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending - * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at - * slightly offset intervals. - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - */ - /** - * @language zh_CN - * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 - * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 - * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 - * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 - * @see egret.TimerEvent - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/Timer.ts - */ - var Timer = (function (_super) { - __extends(Timer, _super); + p.decodeUTF8 = function (data) { + var fatal = false; + var pos = 0; + var result = ""; + var code_point; + var utf8_code_point = 0; + var utf8_bytes_needed = 0; + var utf8_bytes_seen = 0; + var utf8_lower_boundary = 0; + while (data.length > pos) { + var _byte = data[pos++]; + if (_byte == this.EOF_byte) { + if (utf8_bytes_needed != 0) { + code_point = this.decoderError(fatal); + } + else { + code_point = this.EOF_code_point; + } + } + else { + if (utf8_bytes_needed == 0) { + if (this.inRange(_byte, 0x00, 0x7F)) { + code_point = _byte; + } + else { + if (this.inRange(_byte, 0xC2, 0xDF)) { + utf8_bytes_needed = 1; + utf8_lower_boundary = 0x80; + utf8_code_point = _byte - 0xC0; + } + else if (this.inRange(_byte, 0xE0, 0xEF)) { + utf8_bytes_needed = 2; + utf8_lower_boundary = 0x800; + utf8_code_point = _byte - 0xE0; + } + else if (this.inRange(_byte, 0xF0, 0xF4)) { + utf8_bytes_needed = 3; + utf8_lower_boundary = 0x10000; + utf8_code_point = _byte - 0xF0; + } + else { + this.decoderError(fatal); + } + utf8_code_point = utf8_code_point * Math.pow(64, utf8_bytes_needed); + code_point = null; + } + } + else if (!this.inRange(_byte, 0x80, 0xBF)) { + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + pos--; + code_point = this.decoderError(fatal, _byte); + } + else { + utf8_bytes_seen += 1; + utf8_code_point = utf8_code_point + (_byte - 0x80) * Math.pow(64, utf8_bytes_needed - utf8_bytes_seen); + if (utf8_bytes_seen !== utf8_bytes_needed) { + code_point = null; + } + else { + var cp = utf8_code_point; + var lower_boundary = utf8_lower_boundary; + utf8_code_point = 0; + utf8_bytes_needed = 0; + utf8_bytes_seen = 0; + utf8_lower_boundary = 0; + if (this.inRange(cp, lower_boundary, 0x10FFFF) && !this.inRange(cp, 0xD800, 0xDFFF)) { + code_point = cp; + } + else { + code_point = this.decoderError(fatal, _byte); + } + } + } + } + //Decode string + if (code_point !== null && code_point !== this.EOF_code_point) { + if (code_point <= 0xFFFF) { + if (code_point > 0) + result += String.fromCharCode(code_point); + } + else { + code_point -= 0x10000; + result += String.fromCharCode(0xD800 + ((code_point >> 10) & 0x3ff)); + result += String.fromCharCode(0xDC00 + (code_point & 0x3ff)); + } + } + } + return result; + }; /** - * @language en_US - * Constructs a new Timer object with the specified delay and repeatCount states. - * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. - * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, - * the timer runs the specified number of times and then stops. - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param code_point */ + p.encoderError = function (code_point) { + egret.$error(1026, code_point); + }; /** - * @language zh_CN - * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 - * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 - * @version Egret 2.4 - * @platform Web,Native + * @private + * + * @param fatal + * @param opt_code_point + * @returns */ - function Timer(delay, repeatCount) { - if (repeatCount === void 0) { repeatCount = 0; } - _super.call(this); - /** - * @private - */ - this._delay = 0; - /** - * @private - */ - this._currentCount = 0; - /** - * @private - */ - this._running = false; - /** - * @private - */ - this.updateInterval = 1000; - /** - * @private - */ - this.lastCount = 1000; - this.delay = delay; - this.repeatCount = +repeatCount | 0; - } - var d = __define,c=Timer,p=c.prototype; - d(p, "delay" - /** - * @language en_US - * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
      - * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
      - * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this._delay; + p.decoderError = function (fatal, opt_code_point) { + if (fatal) { + egret.$error(1027); } - ,function (value) { - //value = +value||0; - if (value < 1) { - value = 1; + return opt_code_point || 0xFFFD; + }; + /** + * @private + * + * @param a + * @param min + * @param max + */ + p.inRange = function (a, min, max) { + return min <= a && a <= max; + }; + /** + * @private + * + * @param n + * @param d + */ + p.div = function (n, d) { + return Math.floor(n / d); + }; + /** + * @private + * + * @param string + */ + p.stringToCodePoints = function (string) { + /** @type {Array.} */ + var cps = []; + // Based on http://www.w3.org/TR/WebIDL/#idl-DOMString + var i = 0, n = string.length; + while (i < string.length) { + var c = string.charCodeAt(i); + if (!this.inRange(c, 0xD800, 0xDFFF)) { + cps.push(c); } - if (this._delay == value) { - return; + else if (this.inRange(c, 0xDC00, 0xDFFF)) { + cps.push(0xFFFD); } - this._delay = value; - this.lastCount = this.updateInterval = Math.round(60 * value); - } - ); - d(p, "currentCount" - /** - * @language en_US - * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this._currentCount; - } - ); - d(p, "running" - /** - * @language en_US - * The timer's current state; true if the timer is running, otherwise false. - * @version Egret 2.4 - * @platform Web,Native - */ - /** - * @language zh_CN - * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 - * @version Egret 2.4 - * @platform Web,Native - */ - ,function () { - return this._running; + else { + if (i == n - 1) { + cps.push(0xFFFD); + } + else { + var d = string.charCodeAt(i + 1); + if (this.inRange(d, 0xDC00, 0xDFFF)) { + var a = c & 0x3FF; + var b = d & 0x3FF; + i += 1; + cps.push(0x10000 + (a << 10) + b); + } + else { + cps.push(0xFFFD); + } + } + } + i += 1; } - ); + return cps; + }; /** - * @language en_US - * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. - * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. - * @version Egret 2.4 - * @platform Web,Native + * @private */ + ByteArray.SIZE_OF_BOOLEAN = 1; /** - * @language zh_CN - * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 - * @version Egret 2.4 - * @platform Web,Native + * @private */ - p.reset = function () { - this.stop(); - this._currentCount = 0; - }; + ByteArray.SIZE_OF_INT8 = 1; /** - * @language en_US - * Starts the timer, if it is not already running. - * @version Egret 2.4 - * @platform Web,Native + * @private */ + ByteArray.SIZE_OF_INT16 = 2; /** - * @language zh_CN - * 如果计时器尚未运行,则启动计时器。 - * @version Egret 2.4 - * @platform Web,Native + * @private */ - p.start = function () { - if (this._running) - return; - this.lastCount = this.updateInterval; - egret.sys.$ticker.$startTick(this.$update, this); - this._running = true; - }; + ByteArray.SIZE_OF_INT32 = 4; /** - * @language en_US - * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of - * repetitions, as set by the repeatCount property. - * @version Egret 2.4 - * @platform Web,Native + * @private */ + ByteArray.SIZE_OF_UINT8 = 1; /** - * @language zh_CN - * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 - * @version Egret 2.4 - * @platform Web,Native + * @private */ - p.stop = function () { - if (!this._running) - return; - egret.stopTick(this.$update, this); - this._running = false; - }; + ByteArray.SIZE_OF_UINT16 = 2; + /** + * @private + */ + ByteArray.SIZE_OF_UINT32 = 4; /** * @private - * Ticker以60FPS频率刷新此方法 */ - p.$update = function (timeStamp) { - this.lastCount -= 1000; - if (this.lastCount > 0) { - return false; - } - this.lastCount += this.updateInterval; - this._currentCount++; - var complete = (this.repeatCount > 0 && this._currentCount >= this.repeatCount); - egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER); - if (complete) { - this.stop(); - egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER_COMPLETE); - } - return false; - }; - return Timer; - }(egret.EventDispatcher)); - egret.Timer = Timer; - egret.registerClass(Timer,'egret.Timer'); - if (DEBUG) { - egret.$markReadOnly(Timer, "currentCount"); - egret.$markReadOnly(Timer, "running"); - } -})(egret || (egret = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var egret; -(function (egret) { + ByteArray.SIZE_OF_FLOAT32 = 4; + /** + * @private + */ + ByteArray.SIZE_OF_FLOAT64 = 8; + return ByteArray; + }()); + egret.ByteArray = ByteArray; + egret.registerClass(ByteArray,'egret.ByteArray'); })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23103,34 +22871,217 @@ var egret; * @platform Web,Native * @includeExample egret/utils/getDefinitionByName.ts */ - function getDefinitionByName(name) { - if (!name) + function getDefinitionByName(name) { + if (!name) + return null; + var definition = getDefinitionByNameCache[name]; + if (definition) { + return definition; + } + var paths = name.split("."); + var length = paths.length; + definition = __global; + for (var i = 0; i < length; i++) { + var path = paths[i]; + definition = definition[path]; + if (!definition) { + return null; + } + } + getDefinitionByNameCache[name] = definition; + return definition; + } + egret.getDefinitionByName = getDefinitionByName; + if (DEBUG) { + egret["cleanCache"] = function () { + getDefinitionByNameCache = {}; + }; + } +})(egret || (egret = {})); +var __global = __global || this; +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** + * @language en_US + * Return the fully qualified class name of an object + * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to + * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. + * @returns A string containing the fully qualified class name. + * @example + *
      +     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
      +     * 
      + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedClassName.ts + */ + /** + * @language zh_CN + * 返回对象的完全限定类名。 + * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 + * (如number)和类对象 + * @returns 包含完全限定类名称的字符串。 + * @example + *
      +     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
      +     * 
      + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedClassName.ts + */ + function getQualifiedClassName(value) { + var type = typeof value; + if (!value || (type != "object" && !value.prototype)) { + return type; + } + var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); + if (prototype.hasOwnProperty("__class__")) { + return prototype["__class__"]; + } + var constructorString = prototype.constructor.toString().trim(); + var index = constructorString.indexOf("("); + var className = constructorString.substring(9, index); + Object.defineProperty(prototype, "__class__", { + value: className, + enumerable: false, + writable: true + }); + return className; + } + egret.getQualifiedClassName = getQualifiedClassName; +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; +(function (egret) { + /** @language en_US + * Returns the fully qualified class name of the base class of the object specified by the value parameter. + * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including + * all available JavaScript types, object instances, primitive types such as number, and class objects. + * @returns A fully qualified base class name, or null if none exists. + * @example + *
      +     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
      +     * 
      + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedSuperclassName.ts + */ + /** + * @language zh_CN + * 返回 value 参数指定的对象的基类的完全限定类名。 + * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 + * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 + * @example + *
      +     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
      +     * 
      + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getQualifiedSuperclassName.ts + */ + function getQualifiedSuperclassName(value) { + if (!value || (typeof value != "object" && !value.prototype)) { return null; - var definition = getDefinitionByNameCache[name]; - if (definition) { - return definition; } - var paths = name.split("."); - var length = paths.length; - definition = __global; - for (var i = 0; i < length; i++) { - var path = paths[i]; - definition = definition[path]; - if (!definition) { - return null; - } + var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); + var superProto = Object.getPrototypeOf(prototype); + if (!superProto) { + return null; } - getDefinitionByNameCache[name] = definition; - return definition; - } - egret.getDefinitionByName = getDefinitionByName; - if (DEBUG) { - egret["cleanCache"] = function () { - getDefinitionByNameCache = {}; - }; + var superClass = egret.getQualifiedClassName(superProto.constructor); + if (!superClass) { + return null; + } + return superClass; } + egret.getQualifiedSuperclassName = getQualifiedSuperclassName; })(egret || (egret = {})); -var __global = __global || this; ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. @@ -23161,6 +23112,26 @@ var __global = __global || this; ////////////////////////////////////////////////////////////////////////////////////// var egret; (function (egret) { + /** + * @language en_US + * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized + * @returns The number of milliseconds since the Egret framework was initialized + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getTimer.ts + */ + /** + * @language zh_CN + * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 + * @returns 启动 Egret 框架以来经过的毫秒数。 + * @version Egret 2.4 + * @platform Web,Native + * @includeExample egret/utils/getTimer.ts + */ + function getTimer() { + return Date.now() - egret.sys.$START_TIME; + } + egret.getTimer = getTimer; })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23194,52 +23165,31 @@ var egret; (function (egret) { /** * @language en_US - * Return the fully qualified class name of an object - * @param value The object for which a fully qualified class name is desired. Any JavaScript value may be passed to - * this method including all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A string containing the fully qualified class name. + * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. + * @param name {string} Name of the definition. + * @returns {boolean} Whether the public definition exists * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //return "egret.DisplayObject"
      -     * 
      + * egret.hasDefinition("egret.DisplayObject") //return true * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts + * @includeExample egret/utils/hasDefinition.ts */ /** * @language zh_CN - * 返回对象的完全限定类名。 - * @param value 需要完全限定类名称的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型 - * (如number)和类对象 - * @returns 包含完全限定类名称的字符串。 + * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 + * @param name {string} 定义的名称。 + * @returns {boolean} 公共定义是否存在 * @example - *
      -     *  egret.getQualifiedClassName(egret.DisplayObject) //返回 "egret.DisplayObject"
      -     * 
      + * egret.hasDefinition("egret.DisplayObject") //返回 true * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getQualifiedClassName.ts + * @includeExample egret/utils/hasDefinition.ts */ - function getQualifiedClassName(value) { - var type = typeof value; - if (!value || (type != "object" && !value.prototype)) { - return type; - } - var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); - if (prototype.hasOwnProperty("__class__")) { - return prototype["__class__"]; - } - var constructorString = prototype.constructor.toString().trim(); - var index = constructorString.indexOf("("); - var className = constructorString.substring(9, index); - Object.defineProperty(prototype, "__class__", { - value: className, - enumerable: false, - writable: true - }); - return className; + function hasDefinition(name) { + var definition = egret.getDefinitionByName(name); + return definition ? true : false; } - egret.getQualifiedClassName = getQualifiedClassName; + egret.hasDefinition = hasDefinition; })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23271,48 +23221,53 @@ var egret; ////////////////////////////////////////////////////////////////////////////////////// var egret; (function (egret) { - /** @language en_US - * Returns the fully qualified class name of the base class of the object specified by the value parameter. - * @param value The object for which a parent class is desired. Any JavaScript value may be passed to this method including - * all available JavaScript types, object instances, primitive types such as number, and class objects. - * @returns A fully qualified base class name, or null if none exists. + /** + * @language en_US + * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance + * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. + * @param instance the instance to be checked. + * @param typeName the string value representing a specific class or interface. + * @returns A value of true if the object is a instance of the class or interface specified as the parameter. * @example *
      -     *  egret.getQualifiedSuperclassName(egret.Bitmap) //return "egret.DisplayObject"
      +     *     var instance = new egret.Sprite();
      +     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      +     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      +     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
            * 
      + * @see egret.registerClass() * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts */ /** * @language zh_CN - * 返回 value 参数指定的对象的基类的完全限定类名。 - * @param value 需要取得父类的对象,可以将任何 JavaScript 值传递给此方法,包括所有可用的 JavaScript 类型、对象实例、原始类型(如number)和类对象 - * @returns 完全限定的基类名称,或 null(如果不存在基类名称)。 + * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 + * @param instance 要判断的实例。 + * @param typeName 类或接口的完全名称. + * @returns 返回true表示当前对象是指定类或接口的实例。 * @example *
      -     *  egret.getQualifiedSuperclassName(egret.Sprite) //返回 "egret.DisplayObject"
      +     *     var instance = new egret.Sprite();
      +     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
      +     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
      +     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
            * 
      + * @see egret.registerClass() * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getQualifiedSuperclassName.ts */ - function getQualifiedSuperclassName(value) { - if (!value || (typeof value != "object" && !value.prototype)) { - return null; - } - var prototype = value.prototype ? value.prototype : Object.getPrototypeOf(value); - var superProto = Object.getPrototypeOf(prototype); - if (!superProto) { - return null; + function is(instance, typeName) { + if (!instance || typeof instance != "object") { + return false; } - var superClass = egret.getQualifiedClassName(superProto.constructor); - if (!superClass) { - return null; + var prototype = Object.getPrototypeOf(instance); + var types = prototype ? prototype.__types__ : null; + if (!types) { + return false; } - return superClass; + return (types.indexOf(typeName) !== -1); } - egret.getQualifiedSuperclassName = getQualifiedSuperclassName; + egret.is = is; })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23346,24 +23301,138 @@ var egret; (function (egret) { /** * @language en_US - * Used to compute relative time.this method returns the number of milliseconds since the Egret framework was initialized - * @returns The number of milliseconds since the Egret framework was initialized + * Logger is an entrance for the log processing module of the engine * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getTimer.ts */ /** * @language zh_CN - * 用于计算相对时间。此方法返回自启动 Egret 框架以来经过的毫秒数。 - * @returns 启动 Egret 框架以来经过的毫秒数。 + * Logger是引擎的日志处理模块入口 * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/getTimer.ts */ - function getTimer() { - return Date.now() - egret.sys.$START_TIME; - } - egret.getTimer = getTimer; + var Logger = (function () { + function Logger() { + } + var d = __define,c=Logger,p=c.prototype; + d(Logger, "logLevel",undefined + /** + * @language en_US + * Set the current need to open the log level. Grade level are: ALL + * This feature is only in DEBUG mode to take effect.
      + *
        + *
      • Logger.ALL - all levels of log can be printed out. + *
      • Logger.DEBUG - print debug, info, log, warn, error. + *
      • Logger.INFO - print info, log, warn, error. + *
      • Logger.WARN - can print warn, error. + *
      • Logger.ERROR - You can print error. + *
      • Logger.OFF - all closed. + * + *param LogType from this level to start printing. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 设置当前需要开启的log级别。级别等级分别为:ALL < DEBUG < INFO < WARN < ERROR < OFF
        + * 此功能只在 DEBUG 模式下才生效。
        + *
          + *
        • Logger.ALL -- 所有等级的log都可以打印出来。
        • + *
        • Logger.DEBUG -- 可以打印debug、info、log、warn、error。
        • + *
        • Logger.INFO -- 可以打印info、log、warn、error。
        • + *
        • Logger.WARN -- 可以打印warn、error。
        • + *
        • Logger.ERROR -- 可以打印error。
        • + *
        • Logger.OFF -- 全部关闭。
        • + *
        + * @param logType 从这个等级开始打印。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function (logType) { + } + ); + /** + * @language en_US + * open all + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 全开 + * @version Egret 2.4 + * @platform Web,Native + */ + Logger.ALL = "all"; + /** + * @language en_US + * level: DEBUG + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 等级为 DEBUG + * @version Egret 2.4 + * @platform Web,Native + */ + Logger.DEBUG = "debug"; + /** + * @language en_US + * level: INFO + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 等级为 INFO + * @version Egret 2.4 + * @platform Web,Native + */ + Logger.INFO = "info"; + /** + * @language en_US + * level: WARN + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 等级为 WARN + * @version Egret 2.4 + * @platform Web,Native + */ + Logger.WARN = "warn"; + /** + * @language en_US + * level: ERROR + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 等级为 ERROR + * @version Egret 2.4 + * @platform Web,Native + */ + Logger.ERROR = "error"; + /** + * @language en_US + * close all + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 全关 + * @version Egret 2.4 + * @platform Web,Native + */ + Logger.OFF = "off"; + return Logger; + }()); + egret.Logger = Logger; + egret.registerClass(Logger,'egret.Logger'); })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23396,33 +23465,146 @@ var egret; var egret; (function (egret) { /** - * @language en_US - * Check whether a public definition exists in the specified application domain. The definition can be that of a class, a naming space or a function. - * @param name {string} Name of the definition. - * @returns {boolean} Whether the public definition exists - * @example - * egret.hasDefinition("egret.DisplayObject") //return true - * @version Egret 2.4 - * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts - */ - /** - * @language zh_CN - * 检查指定的应用程序域之内是否存在一个公共定义。该定义可以是一个类、一个命名空间或一个函数的定义。 - * @param name {string} 定义的名称。 - * @returns {boolean} 公共定义是否存在 - * @example - * egret.hasDefinition("egret.DisplayObject") //返回 true * @version Egret 2.4 * @platform Web,Native - * @includeExample egret/utils/hasDefinition.ts */ - function hasDefinition(name) { - var definition = egret.getDefinitionByName(name); - return definition ? true : false; - } - egret.hasDefinition = hasDefinition; + var NumberUtils = (function () { + function NumberUtils() { + } + var d = __define,c=NumberUtils,p=c.prototype; + /** + * @language en_US + * Judge whether it is a numerical value + * @param value Parameter that needs to be judged + * @returns + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 判断是否是数值 + * @param value 需要判断的参数 + * @returns + * @version Egret 2.4 + * @platform Web,Native + */ + NumberUtils.isNumber = function (value) { + return typeof (value) === "number" && !isNaN(value); + }; + /** + * @language en_US + * Obtain the approximate sin value of the corresponding angle value + * @param value {number} Angle value + * @returns {number} sin value + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 得到对应角度值的sin近似值 + * @param value {number} 角度值 + * @returns {number} sin值 + * @version Egret 2.4 + * @platform Web,Native + */ + NumberUtils.sin = function (value) { + var valueFloor = Math.floor(value); + var valueCeil = valueFloor + 1; + var resultFloor = NumberUtils.sinInt(valueFloor); + if (valueFloor == value) { + return resultFloor; + } + var resultCeil = NumberUtils.sinInt(valueCeil); + return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; + }; + /** + * @private + * + * @param value + * @returns + */ + NumberUtils.sinInt = function (value) { + value = value % 360; + if (value < 0) { + value += 360; + } + return egret_sin_map[value]; + }; + /** + * @language en_US + * Obtain the approximate cos value of the corresponding angle value + * @param value {number} Angle value + * @returns {number} cos value + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 得到对应角度值的cos近似值 + * @param value {number} 角度值 + * @returns {number} cos值 + * @version Egret 2.4 + * @platform Web,Native + */ + NumberUtils.cos = function (value) { + var valueFloor = Math.floor(value); + var valueCeil = valueFloor + 1; + var resultFloor = NumberUtils.cosInt(valueFloor); + if (valueFloor == value) { + return resultFloor; + } + var resultCeil = NumberUtils.cosInt(valueCeil); + return (value - valueFloor) * resultCeil + (valueCeil - value) * resultFloor; + }; + /** + * @private + * + * @param value + * @returns + */ + NumberUtils.cosInt = function (value) { + value = value % 360; + if (value < 0) { + value += 360; + } + return egret_cos_map[value]; + }; + return NumberUtils; + }()); + egret.NumberUtils = NumberUtils; + egret.registerClass(NumberUtils,'egret.NumberUtils'); })(egret || (egret = {})); +var egret_sin_map = {}; +var egret_cos_map = {}; +var DEG_TO_RAD = Math.PI / 180; +for (var NumberUtils_i = 0; NumberUtils_i < 360; NumberUtils_i++) { + egret_sin_map[NumberUtils_i] = Math.sin(NumberUtils_i * DEG_TO_RAD); + egret_cos_map[NumberUtils_i] = Math.cos(NumberUtils_i * DEG_TO_RAD); +} +egret_sin_map[90] = 1; +egret_cos_map[90] = 0; +egret_sin_map[180] = 0; +egret_cos_map[180] = -1; +egret_sin_map[270] = -1; +egret_cos_map[270] = 0; +//对未提供bind的浏览器实现bind机制 +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + egret.$error(1029); + } + var aArgs = Array.prototype.slice.call(arguments, 1), fToBind = this, fNOP = function () { + }, fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, aArgs.concat(Array.prototype.slice.call(arguments))); + }; + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + return fBound; + }; +} ////////////////////////////////////////////////////////////////////////////////////// // // Copyright (c) 2014-present, Egret Technology. @@ -23455,51 +23637,31 @@ var egret; (function (egret) { /** * @language en_US - * Indicates whether an object is a instance of the class or interface specified as the parameter.This method has better performance - * compared width the instanceOf operator,and it can indicate whether an object is a instance of the specific interface. - * @param instance the instance to be checked. - * @param typeName the string value representing a specific class or interface. - * @returns A value of true if the object is a instance of the class or interface specified as the parameter. - * @example - *
        -     *     var instance = new egret.Sprite();
        -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
        -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
        -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
        -     * 
        - * @see egret.registerClass() + * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
        + * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. + * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds + * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime + * to render after processing of this method completes. + * @param thisObject the call back method's "this" * @version Egret 2.4 * @platform Web,Native */ /** * @language zh_CN - * 检查指定对象是否为 Egret 框架内指定接口或类或其子类的实例。此方法与使用 instanceOf 关键字相比具有更高的性能,并且能判断接口的实现。 - * @param instance 要判断的实例。 - * @param typeName 类或接口的完全名称. - * @returns 返回true表示当前对象是指定类或接口的实例。 - * @example - *
        -     *     var instance = new egret.Sprite();
        -     *     egret.log(egret.is(instance,"egret.Sprite"))  //true
        -     *     egret.log(egret.is(instance,"egret.DisplayObjectContainer"))  //true
        -     *     egret.log(egret.is(instance,"egret.Bitmap"))  //false
        -     * 
        - * @see egret.registerClass() + * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 + * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 + * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 + * @param thisObject 回调方法的this对象引用。 * @version Egret 2.4 * @platform Web,Native */ - function is(instance, typeName) { - if (!instance || typeof instance != "object") { - return false; - } - var prototype = Object.getPrototypeOf(instance); - var types = prototype ? prototype.__types__ : null; - if (!types) { - return false; + function startTick(callBack, thisObject) { + if (DEBUG && !callBack) { + egret.$error(1003, "callBack"); } - return (types.indexOf(typeName) !== -1); + egret.sys.$ticker.$startTick(callBack, thisObject); } - egret.is = is; + egret.startTick = startTick; })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23533,8 +23695,7 @@ var egret; (function (egret) { /** * @language en_US - * Register and start a timer,which will notify the callback method at a rate of 60 FPS ,and pass the current time stamp as parameters.
        - * Note: After the registration,it will notify the callback method continuously,you can call the stopTick () method to stop it. + * Stops the timer started by the egret.startTick() method. * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime * to render after processing of this method completes. @@ -23544,20 +23705,20 @@ var egret; */ /** * @language zh_CN - * 注册并启动一个计时器,通常会以60FPS的速率触发回调方法,并传入当前时间戳。注意:注册后将会持续触发回调方法,若要停止回调,需要手动调用stopTick()方法。 + * 停止之前用 startTick() 方法启动的计时器。 * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 * @param thisObject 回调方法的this对象引用。 * @version Egret 2.4 * @platform Web,Native */ - function startTick(callBack, thisObject) { + function stopTick(callBack, thisObject) { if (DEBUG && !callBack) { egret.$error(1003, "callBack"); } - egret.sys.$ticker.$startTick(callBack, thisObject); + egret.sys.$ticker.$stopTick(callBack, thisObject); } - egret.startTick = startTick; + egret.stopTick = stopTick; })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23591,30 +23752,232 @@ var egret; (function (egret) { /** * @language en_US - * Stops the timer started by the egret.startTick() method. - * @param callBack the call back method. the timeStamp parameter of this method represents the number of milliseconds - * since the Egret framework was initialized. If the return value of this method is true, it will force Egret runtime - * to render after processing of this method completes. - * @param thisObject the call back method's "this" + * The Timer class is the interface to timers, which let you run code on a specified time sequence. Use the start() + * method to start a timer. Add an event listener for the timer event to set up code to be run on the timer interval.
        + * You can create Timer objects to run once or repeat at specified intervals to execute code on a schedule. Depending + * on the framerate or the runtime environment (available memory and other factors), the runtime may dispatchEvent events at + * slightly offset intervals. + * @see egret.TimerEvent * @version Egret 2.4 * @platform Web,Native + * @includeExample egret/utils/Timer.ts */ /** * @language zh_CN - * 停止之前用 startTick() 方法启动的计时器。 - * @param callBack 要执行的回调方法。参数 timeStamp 表示从启动Egret框架开始经过的时间(毫秒)。 - * 若回调方法返回值为true,其作用与TimerEvent.updateAfterEvent()类似,将会忽略帧频限制,在此方法处理完成后立即重绘屏幕。 - * @param thisObject 回调方法的this对象引用。 + * Timer 类是计时器的接口,它使您能按指定的时间序列运行代码。 + * 使用 start() 方法来启动计时器。为 timer 事件添加事件侦听器,以便将代码设置为按计时器间隔运行。 + * 可以创建 Timer 对象以运行一次或按指定间隔重复运行,从而按计划执行代码。 + * 根据 Egret 的帧速率或运行时环境(可用内存和其他因素),运行时调度事件的间隔可能稍有不同。 + * @see egret.TimerEvent * @version Egret 2.4 * @platform Web,Native + * @includeExample egret/utils/Timer.ts */ - function stopTick(callBack, thisObject) { - if (DEBUG && !callBack) { - egret.$error(1003, "callBack"); + var Timer = (function (_super) { + __extends(Timer, _super); + /** + * @language en_US + * Constructs a new Timer object with the specified delay and repeatCount states. + * @param delay The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended. + * Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. + * @param repeatCount Specifies the number of repetitions. If zero, the timer repeats indefinitely.If nonzero, + * the timer runs the specified number of times and then stops. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 使用指定的 delay 和 repeatCount 状态构造新的 Timer 对象。 + * @param delay 计时器事件间的延迟(以毫秒为单位)。建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 + * @param repeatCount 指定重复次数。如果为零,则计时器将持续不断重复运行。如果不为 0,则将运行计时器,运行次数为指定的次数,然后停止。 + * @version Egret 2.4 + * @platform Web,Native + */ + function Timer(delay, repeatCount) { + if (repeatCount === void 0) { repeatCount = 0; } + _super.call(this); + /** + * @private + */ + this._delay = 0; + /** + * @private + */ + this._currentCount = 0; + /** + * @private + */ + this._running = false; + /** + * @private + */ + this.updateInterval = 1000; + /** + * @private + */ + this.lastCount = 1000; + /** + * @private + */ + this.lastTimeStamp = 0; + this.delay = delay; + this.repeatCount = +repeatCount | 0; } - egret.sys.$ticker.$stopTick(callBack, thisObject); + var d = __define,c=Timer,p=c.prototype; + d(p, "delay" + /** + * @language en_US + * The delay between timer events, in milliseconds. A delay lower than 20 milliseconds is not recommended.
        + * Note: Timer frequency is limited to 60 frames per second, meaning a delay lower than 16.6 milliseconds causes runtime problems. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 计时器事件间的延迟(以毫秒为单位)。如果在计时器正在运行时设置延迟间隔,则计时器将按相同的 repeatCount 迭代重新启动。
        + * 注意:建议 delay 不要低于 20 毫秒。计时器频率不得超过 60 帧/秒,这意味着低于 16.6 毫秒的延迟可导致出现运行时问题。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this._delay; + } + ,function (value) { + //value = +value||0; + if (value < 1) { + value = 1; + } + if (this._delay == value) { + return; + } + this._delay = value; + this.lastCount = this.updateInterval = Math.round(60 * value); + } + ); + d(p, "currentCount" + /** + * @language en_US + * The total number of times the timer has fired since it started at zero. If the timer has been reset, only the fires since the reset are counted. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 计时器从 0 开始后触发的总次数。如果已重置了计时器,则只会计入重置后的触发次数。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this._currentCount; + } + ); + d(p, "running" + /** + * @language en_US + * The timer's current state; true if the timer is running, otherwise false. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 计时器的当前状态;如果计时器正在运行,则为 true,否则为 false。 + * @version Egret 2.4 + * @platform Web,Native + */ + ,function () { + return this._running; + } + ); + /** + * @language en_US + * Stops the timer, if it is running, and sets the currentCount property back to 0, like the reset button of a stopwatch. + * Then, when start() is called, the timer instance runs for the specified number of repetitions, as set by the repeatCount value. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 如果计时器正在运行,则停止计时器,并将 currentCount 属性设回为 0,这类似于秒表的重置按钮。然后,在调用 start() 后,将运行计时器实例,运行次数为指定的重复次数(由 repeatCount 值设置)。 + * @version Egret 2.4 + * @platform Web,Native + */ + p.reset = function () { + this.stop(); + this._currentCount = 0; + }; + /** + * @language en_US + * Starts the timer, if it is not already running. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 如果计时器尚未运行,则启动计时器。 + * @version Egret 2.4 + * @platform Web,Native + */ + p.start = function () { + if (this._running) + return; + this.lastCount = this.updateInterval; + this.lastTimeStamp = egret.getTimer(); + egret.sys.$ticker.$startTick(this.$update, this); + this._running = true; + }; + /** + * @language en_US + * Stops the timer. When start() is called after stop(), the timer instance runs for the remaining number of + * repetitions, as set by the repeatCount property. + * @version Egret 2.4 + * @platform Web,Native + */ + /** + * @language zh_CN + * 停止计时器。如果在调用 stop() 后调用 start(),则将继续运行计时器实例,运行次数为剩余的 重复次数(由 repeatCount 属性设置)。 + * @version Egret 2.4 + * @platform Web,Native + */ + p.stop = function () { + if (!this._running) + return; + egret.stopTick(this.$update, this); + this._running = false; + }; + /** + * @private + * Ticker以60FPS频率刷新此方法 + */ + p.$update = function (timeStamp) { + var deltaTime = timeStamp - this.lastTimeStamp; + if (deltaTime >= this._delay) { + this.lastCount = this.updateInterval; + } + else { + this.lastCount -= 1000; + if (this.lastCount > 0) { + return false; + } + this.lastCount += this.updateInterval; + } + this.lastTimeStamp = timeStamp; + this._currentCount++; + var complete = (this.repeatCount > 0 && this._currentCount >= this.repeatCount); + egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER); + if (complete) { + this.stop(); + egret.TimerEvent.dispatchTimerEvent(this, egret.TimerEvent.TIMER_COMPLETE); + } + return false; + }; + return Timer; + }(egret.EventDispatcher)); + egret.Timer = Timer; + egret.registerClass(Timer,'egret.Timer'); + if (DEBUG) { + egret.$markReadOnly(Timer, "currentCount"); + egret.$markReadOnly(Timer, "running"); } - egret.stopTick = stopTick; })(egret || (egret = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -23709,6 +24072,37 @@ var egret; // ////////////////////////////////////////////////////////////////////////////////////// var egret; +(function (egret) { +})(egret || (egret = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var egret; (function (egret) { /** * @private diff --git a/build/egret/egret.min.js b/build/egret/egret.min.js index 25c80be2eb..7032f27ba5 100644 --- a/build/egret/egret.min.js +++ b/build/egret/egret.min.js @@ -1,6 +1,13 @@ -function __extends(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);i.prototype=e.prototype,t.prototype=new i}var egret;!function(t){function e(){return""}function i(t){throw new Error("#"+t)}function n(){}function r(){}function s(){}t.getString=e,t.$error=i,t.$warn=n,t.$markReadOnly=r,t.$markCannotUse=s}(egret||(egret={}));var egret;!function(t){function e(t,e,i){var n=t.prototype;n.__class__=e;var r=[e];i&&(r=r.concat(i));var s=n.__types__;if(n.__types__)for(var a=s.length,o=0;a>o;o++){var h=s[o];-1==r.indexOf(h)&&r.push(h)}n.__types__=r}t.registerClass=e}(egret||(egret={}));var __define=this.__define||function(t,e,i,n){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:i,set:n})},egret;!function(t){t.$hashCount=1;var e=function(){function e(){this.$hashCode=t.$hashCount++}var i=__define,n=e,r=n.prototype;return i(r,"hashCode",function(){return this.$hashCode}),e}();t.HashObject=e,t.registerClass(e,"egret.HashObject",["egret.IHashObject"])}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function n(t){void 0===t&&(t=null),i.call(this),this.$EventDispatcher={0:t?t:this,1:{},2:{},3:0}}__extends(n,i);var r=n,s=r.prototype;return s.$getEventMap=function(t){var e=this.$EventDispatcher,i=t?e[2]:e[1];return i},s.addEventListener=function(t,e,i,n,r){this.$addListener(t,e,i,n,r)},s.once=function(t,e,i,n,r){this.$addListener(t,e,i,n,r,!0)},s.$addListener=function(t,e,i,n,r,s){var a=this.$EventDispatcher,o=n?a[2]:a[1],h=o[t];h?0!==a[3]&&(o[t]=h=h.concat()):h=o[t]=[],this.$insertEventBin(h,t,e,i,n,r,s)},s.$insertEventBin=function(t,e,i,n,r,s,a){s=0|+s;for(var o=-1,h=t.length,l=0;h>l;l++){var u=t[l];if(u.listener==i&&u.thisObject==n&&u.target==this)return!1;-1==o&&u.priorityr;r++){var s=t[r];if(s.listener==e&&s.thisObject==i&&s.target==this)return t.splice(r,1),!0}return!1},s.hasEventListener=function(t){var e=this.$EventDispatcher;return!(!e[1][t]&&!e[2][t])},s.willTrigger=function(t){return this.hasEventListener(t)},s.dispatchEvent=function(t){return t.$currentTarget=this.$EventDispatcher[0],t.$setTarget(t.$currentTarget),this.$notifyListener(t,!1)},s.$notifyListener=function(t,i){var n=this.$EventDispatcher,r=i?n[2]:n[1],s=r[t.$type];if(!s)return!0;var a=s.length;if(0==a)return!0;var o=e;n[3]++;for(var h=0;a>h;h++){var l=s[h];if(l.listener.call(l.thisObject,t),l.dispatchOnce&&o.push(l),t.$isPropagationImmediateStopped)break}for(n[3]--;o.length;)l=o.pop(),l.target.removeEventListener(l.type,l.listener,l.thisObject,l.useCapture);return!t.$isDefaultPrevented},s.dispatchEventWith=function(e,i,n){if(i||this.hasEventListener(e)){var r=t.Event.create(t.Event,e,i);r.data=n;var s=this.dispatchEvent(r);return t.Event.release(r),s}return!0},n}(t.HashObject);t.EventDispatcher=i,t.registerClass(i,"egret.EventDispatcher",["egret.IEventDispatcher"])}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function n(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),i.call(this),this.x=t,this.y=e,this.width=n,this.height=r}__extends(n,i);var r=__define,s=n,a=s.prototype;return n.release=function(t){t&&e.push(t)},n.create=function(){var t=e.pop();return t||(t=new n),t},r(a,"right",function(){return this.x+this.width},function(t){this.width=t-this.x}),r(a,"bottom",function(){return this.y+this.height},function(t){this.height=t-this.y}),r(a,"left",function(){return this.x},function(t){this.width+=this.x-t,this.x=t}),r(a,"top",function(){return this.y},function(t){this.height+=this.y-t,this.y=t}),r(a,"topLeft",function(){return new t.Point(this.left,this.top)},function(t){this.top=t.y,this.left=t.x}),r(a,"bottomRight",function(){return new t.Point(this.right,this.bottom)},function(t){this.bottom=t.y,this.right=t.x}),a.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},a.setTo=function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},a.contains=function(t,e){return this.x<=t&&this.x+this.width>=t&&this.y<=e&&this.y+this.height>=e},a.intersection=function(t){return this.clone().$intersectInPlace(t)},a.inflate=function(t,e){this.x-=t,this.width+=2*t,this.y-=e,this.height+=2*e},a.$intersectInPlace=function(t){var e=this.x,i=this.y,n=t.x,r=t.y,s=Math.max(e,n),a=Math.min(e+this.width,n+t.width);if(a>=s){var o=Math.max(i,r),h=Math.min(i+this.height,r+t.height);if(h>=o)return this.setTo(s,o,a-s,h-o),this}return this.setEmpty(),this},a.intersects=function(t){return Math.max(this.x,t.x)<=Math.min(this.right,t.right)&&Math.max(this.y,t.y)<=Math.min(this.bottom,t.bottom)},a.isEmpty=function(){return this.width<=0||this.height<=0},a.setEmpty=function(){this.x=0,this.y=0,this.width=0,this.height=0},a.clone=function(){return new n(this.x,this.y,this.width,this.height)},a.containsPoint=function(t){return this.xt.x&&this.yt.y?!0:!1},a.containsRect=function(t){var e=t.x+t.width,i=t.y+t.height,n=this.x+this.width,r=this.y+this.height;return t.x>=this.x&&t.x=this.y&&t.ythis.x&&n>=e&&i>this.y&&r>=i},a.equals=function(t){return this===t?!0:this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},a.inflatePoint=function(t){this.inflate(t.x,t.y)},a.offset=function(t,e){this.x+=t,this.y+=e},a.offsetPoint=function(t){this.offset(t.x,t.y)},a.toString=function(){return"(x="+this.x+", y="+this.y+", width="+this.width+", height="+this.height+")"},a.union=function(t){var e=this.clone();if(t.isEmpty())return e;if(e.isEmpty())return e.copyFrom(t),e;var i=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return e.setTo(i,n,Math.max(e.right,t.right)-i,Math.max(e.bottom,t.bottom)-n),e},a.$getBaseWidth=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return e*this.width+i*this.height},a.$getBaseHeight=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return i*this.width+e*this.height},n}(t.HashObject);t.Rectangle=i,t.registerClass(i,"egret.Rectangle"),t.$TempRectangle=new i}(egret||(egret={}));var egret;!function(t){function e(t){return t%=360,t>180?t-=360:-180>t&&(t+=360),t}var i=function(i){function n(){i.call(this),this.$children=null,this.$parent=null,this.$stage=null,this.$nestLevel=0,this.$visible=!0,this.$displayList=null,this.$alpha=1,this.$touchEnabled=n.defaultTouchEnabled,this.$scrollRect=null,this.$blendMode=0,this.$maskedObject=null,this.$mask=null,this.$maskRect=null,this.$parentDisplayList=null,this.$renderNode=null,this.$displayFlags=2032,this.$DisplayObject={0:1,1:1,2:0,3:0,4:0,5:"",6:new t.Matrix,7:new t.Matrix,8:new t.Matrix,9:new t.Rectangle,10:new t.Rectangle,11:!1,12:0,13:0,14:0/0,15:0/0,16:0,17:0,18:0,19:null}}__extends(n,i);var r=__define,s=n,a=s.prototype;return a.$setFlags=function(t){this.$displayFlags|=t},a.$removeFlags=function(t){this.$displayFlags&=~t},a.$removeFlagsUp=function(t){if(this.$hasAnyFlags(t)){this.$removeFlags(t);var e=this.$parent;e&&e.$removeFlagsUp(t)}},a.$hasFlags=function(t){return(this.$displayFlags&t)==t},a.$propagateFlagsUp=function(t){if(!this.$hasFlags(t)){this.$setFlags(t);var e=this.$parent;e&&e.$propagateFlagsUp(t)}},a.$propagateFlagsDown=function(t){this.$setFlags(t)},a.$hasAnyFlags=function(t){return!!(this.$displayFlags&t)},a.invalidateMatrix=function(){this.$setFlags(8),this.invalidatePosition()},a.invalidatePosition=function(){var t=this;t.$invalidateTransform(),t.$propagateFlagsDown(48),t.$parent&&t.$parent.$propagateFlagsUp(4)},r(a,"name",function(){return this.$DisplayObject[5]},function(t){this.$DisplayObject[5]=t}),r(a,"parent",function(){return this.$parent}),a.$setParent=function(t){return this.$parent==t?!1:(this.$parent=t,!0)},a.$onAddToStage=function(e,i){this.$stage=e,this.$nestLevel=i,this.$hasAddToStage=!0,t.Sprite.$EVENT_ADD_TO_STAGE_LIST.push(this)},a.$onRemoveFromStage=function(){this.$nestLevel=0,t.Sprite.$EVENT_REMOVE_FROM_STAGE_LIST.push(this)},r(a,"stage",function(){return this.$stage}),r(a,"matrix",function(){return this.$getMatrix().clone()},function(t){this.$setMatrix(t)}),a.$getMatrix=function(){var t=this.$DisplayObject;return this.$hasFlags(8)&&(t[6].$updateScaleAndRotation(t[0],t[1],t[2],t[3]),this.$removeFlags(8)),t[6]},a.$setMatrix=function(t,i){void 0===i&&(i=!0);var n=this,r=n.$DisplayObject,s=r[6];return s.equals(t)?!1:(s.copyFrom(t),i&&(r[0]=s.$getScaleX(),r[1]=s.$getScaleY(),r[2]=t.$getSkewX(),r[3]=t.$getSkewY(),r[16]=e(180*r[2]/Math.PI),r[17]=e(180*r[3]/Math.PI),r[4]=e(180*r[3]/Math.PI)),n.$removeFlags(8),n.invalidatePosition(),!0)},a.$getConcatenatedMatrix=function(){var e=this.$DisplayObject[7];if(this.$hasFlags(16)){this.$parent?this.$parent.$getConcatenatedMatrix().$preMultiplyInto(this.$getMatrix(),e):e.copyFrom(this.$getMatrix());var i=this.$DisplayObject,n=i[12],r=i[13],s=this.$scrollRect;s?e.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-s.x-n,-s.y-r),e):(0!=n||0!=r)&&e.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-n,-r),e),this.$displayList&&(this.$displayList.$renderNode.moved=!0),this.$renderNode&&(this.$renderNode.moved=!0),this.$removeFlags(16)}return e},a.$getInvertedConcatenatedMatrix=function(){var t=this.$DisplayObject;return this.$hasFlags(32)&&(this.$getConcatenatedMatrix().$invertInto(t[8]),this.$removeFlags(32)),t[8]},r(a,"x",function(){return this.$getX()},function(t){this.$setX(t)}),a.$getX=function(){return this.$DisplayObject[6].tx},a.$setX=function(t){t=+t||0;var e=this.$DisplayObject[6];return t==e.tx?!1:(e.tx=t,this.invalidatePosition(),!0)},r(a,"y",function(){return this.$getY()},function(t){this.$setY(t)}),a.$getY=function(){return this.$DisplayObject[6].ty},a.$setY=function(t){t=+t||0;var e=this.$DisplayObject[6];return t==e.ty?!1:(e.ty=t,this.invalidatePosition(),!0)},r(a,"scaleX",function(){return this.$getScaleX()},function(t){this.$setScaleX(t)}),a.$getScaleX=function(){return this.$DisplayObject[0]},a.$setScaleX=function(t){t=+t||0;var e=this.$DisplayObject;return t==e[0]?!1:(e[0]=t,this.invalidateMatrix(),!0)},r(a,"scaleY",function(){return this.$getScaleY()},function(t){this.$setScaleY(t)}),a.$getScaleY=function(){return this.$DisplayObject[1]},a.$setScaleY=function(t){return t=+t||0,t==this.$DisplayObject[1]?!1:(this.$DisplayObject[1]=t,this.invalidateMatrix(),!0)},r(a,"rotation",function(){return this.$getRotation()},function(t){this.$setRotation(t)}),a.$getRotation=function(){return this.$DisplayObject[4]},a.$setRotation=function(t){t=+t||0,t=e(t);var i=this.$DisplayObject;if(t==i[4])return!1;var n=t-i[4],r=n/180*Math.PI;return i[2]+=r,i[3]+=r,i[4]=t,this.invalidateMatrix(),!0},r(a,"skewX",function(){return this.$DisplayObject[16]},function(t){this.$setSkewX(t)}),a.$setSkewX=function(t){t=+t||0;var i=this.$DisplayObject;return t==i[16]?!1:(i[16]=t,t=e(t),t=t/180*Math.PI,i[2]=t,this.invalidateMatrix(),!0)},r(a,"skewY",function(){return this.$DisplayObject[17]},function(t){this.$setSkewY(t)}),a.$setSkewY=function(t){t=+t||0;var i=this.$DisplayObject;return t==i[17]?!1:(i[17]=t,t=e(t),t=t/180*Math.PI,i[3]=t,this.invalidateMatrix(),!0)},r(a,"width",function(){return this.$getWidth()},function(t){this.$setWidth(t)}),a.$getWidth=function(){return isNaN(this.$getExplicitWidth())?this.$getOriginalBounds().width:this.$getExplicitWidth()},a.$getExplicitWidth=function(){return this.$DisplayObject[14]},a.$setWidth=function(t){return this.$DisplayObject[14]=isNaN(t)?0/0:t,t=+t,0>t?!1:(this.invalidateMatrix(),!0)},r(a,"height",function(){return this.$getHeight()},function(t){this.$setHeight(t)}),a.$getHeight=function(){return isNaN(this.$getExplicitHeight())?this.$getOriginalBounds().height:this.$getExplicitHeight()},a.$getExplicitHeight=function(){return this.$DisplayObject[15]},a.$setHeight=function(t){return this.$DisplayObject[15]=isNaN(t)?0/0:t,t=+t,0>t?!1:(this.invalidateMatrix(),!0)},r(a,"measuredWidth",function(){return this.$getOriginalBounds().width}),r(a,"measuredHeight",function(){return this.$getOriginalBounds().height}),r(a,"anchorOffsetX",function(){return this.$DisplayObject[12]},function(t){this.$setAnchorOffsetX(t)}),a.$getAnchorOffsetX=function(){return this.$DisplayObject[12]},a.$setAnchorOffsetX=function(t){return t=+t||0,t==this.$DisplayObject[12]?!1:(this.$DisplayObject[12]=t,this.invalidatePosition(),!0)},r(a,"anchorOffsetY",function(){return this.$DisplayObject[13]},function(t){this.$setAnchorOffsetY(t)}),a.$getAnchorOffsetY=function(){return this.$DisplayObject[13]},a.$setAnchorOffsetY=function(t){return t=+t||0,t==this.$DisplayObject[13]?!1:(this.$DisplayObject[13]=t,this.invalidatePosition(),!0)},r(a,"visible",function(){return this.$visible},function(t){this.$setVisible(t)}),a.$setVisible=function(t){return t=!!t,t==this.$visible?!1:(this.$visible=t,this.$propagateFlagsDown(1024),this.$invalidateTransform(),!0)},a.$getConcatenatedVisible=function(){var t=this.$DisplayObject;if(this.$hasFlags(1024)){if(this.$parent){var e=this.$parent.$getConcatenatedVisible();t[19]=e&&this.$visible}else t[19]=this.$visible;this.$removeFlags(1024)}return t[19]},r(a,"cacheAsBitmap",function(){return this.$DisplayObject[11]},function(t){t=!!t,this.$DisplayObject[11]=t,this.$setHasDisplayList(t)}),a.$setHasDisplayList=function(e){var i=!!this.$displayList;if(i!=e)if(e){var n=t.sys.DisplayList.create(this);n&&(this.$displayList=n,this.$parentDisplayList&&this.$parentDisplayList.markDirty(n),this.$cacheAsBitmapChanged())}else this.$displayList=null,this.$cacheAsBitmapChanged()},a.$cacheAsBitmapChanged=function(){var t=this.$displayList||this.$parentDisplayList;this.$renderNode&&t&&t.markDirty(this),this.$propagateFlagsDown(48)},r(a,"alpha",function(){return this.$alpha},function(t){this.$setAlpha(t)}),a.$setAlpha=function(t){return t=+t||0,t==this.$alpha?!1:(this.$alpha=t,this.$propagateFlagsDown(64),this.$invalidate(),!0)},a.$getConcatenatedAlpha=function(){var t=this.$DisplayObject;if(this.$hasFlags(64)){if(this.$parent){var e=this.$parent.$getConcatenatedAlpha();t[18]=e*this.$alpha}else t[18]=this.$alpha;this.$removeFlags(64)}return t[18]},r(a,"touchEnabled",function(){return this.$getTouchEnabled()},function(t){this.$setTouchEnabled(t)}),a.$getTouchEnabled=function(){return this.$touchEnabled},a.$setTouchEnabled=function(t){return this.$touchEnabled==t?!1:(this.$touchEnabled=t,!0)},r(a,"scrollRect",function(){return this.$scrollRect},function(t){this.$setScrollRect(t)}),a.$setScrollRect=function(e){return e||this.$scrollRect?(e?(this.$scrollRect||(this.$scrollRect=new t.Rectangle),this.$scrollRect.copyFrom(e)):this.$scrollRect=null,this.invalidatePosition(),!0):!1},r(a,"blendMode",function(){return t.sys.numberToBlendMode(this.$blendMode)},function(e){var i=t.sys.blendModeToNumber(e);i!=this.$blendMode&&(this.$blendMode=i,this.$invalidateTransform())}),r(a,"mask",function(){return this.$mask?this.$mask:this.$maskRect},function(t){if(t!==this){if(t)if(t instanceof n){if(t==this.$mask)return;t.$maskedObject&&(t.$maskedObject.mask=null),t.$maskedObject=this,t.$invalidateTransform(),this.$mask=t,this.$maskRect=null}else this.$setMaskRect(t),this.$mask&&(this.$mask.$maskedObject=null,this.$mask.$invalidateTransform()),this.$mask=null;else this.$mask&&(this.$mask.$maskedObject=null,this.$mask.$invalidateTransform()),this.$mask=null,this.$maskRect=null;this.$invalidateTransform()}}),a.$setMaskRect=function(e){return e||this.$maskRect?(e?(this.$maskRect||(this.$maskRect=new t.Rectangle),this.$maskRect.copyFrom(e)):this.$maskRect=null,this.invalidatePosition(),!0):!1},r(a,"filters",function(){return this.$DisplayObject[20]},function(t){var e=this.$DisplayObject[20];if(!e&&!t)return void(this.$DisplayObject[20]=t);if(this.$invalidateContentBounds(),this.$invalidate(!0),e&&e.length)for(var i=e.length,n=0;i>n;n++)e[n].$removeTarget(this);if(this.$DisplayObject[20]=t,t&&t.length)for(i=t.length,n=0;i>n;n++)t[n].$addTarget(this)}),a.$getFilters=function(){return this.$DisplayObject[20]},a.getTransformedBounds=function(t,e){return t=t||this,this.$getTransformedBounds(t,e)},a.getBounds=function(t,e){if(void 0===e&&(e=!0),t=this.$getTransformedBounds(this,t),e){var i=this.$DisplayObject;(0!=i[12]||0!=i[13])&&(t.x-=i[12],t.y-=i[13])}return t},a.$getTransformedBounds=function(e,i){var n=this.$getOriginalBounds();if(i||(i=new t.Rectangle),i.copyFrom(n),e==this||i.isEmpty())return i;var r;if(e){r=t.$TempMatrix;var s=e.$getInvertedConcatenatedMatrix();s.$preMultiplyInto(this.$getConcatenatedMatrix(),r)}else r=this.$getConcatenatedMatrix();return r.$transformBounds(i),i},a.globalToLocal=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0);var n=this.$getInvertedConcatenatedMatrix();return n.transformPoint(t,e,i)},a.localToGlobal=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0);var n=this.$getConcatenatedMatrix();return n.transformPoint(t,e,i)},a.$invalidateContentBounds=function(){this.$invalidate(),this.$setFlags(2),this.$propagateFlagsUp(4)},a.$getOriginalBounds=function(){var t=this.$DisplayObject[9];if(this.$hasFlags(4)){t.copyFrom(this.$getContentBounds()),this.$measureChildBounds(t),this.$removeFlags(4),this.$displayList&&(this.$displayList.$renderNode.moved=!0);var e=this.$measureFiltersBounds(t);t.copyFrom(e)}return t},a.$measureChildBounds=function(t){},a.$getContentBounds=function(){var t=this.$DisplayObject[10];return this.$hasFlags(2)&&(this.$measureContentBounds(t),this.$renderNode&&(this.$renderNode.moved=!0),this.$removeFlags(2)),t},a.$measureContentBounds=function(t){},a.$invalidate=function(t){if(this.$renderNode&&!this.$hasFlags(256)){this.$setFlags(384);var e=this.$displayList?this.$displayList:this.$parentDisplayList;e&&e.markDirty(this)}},a.$invalidateTransform=function(){var t=this;if(!t.$hasFlags(512)){t.$setFlags(512);var e=t.$displayList;(e||t.$renderNode)&&t.$parentDisplayList&&t.$parentDisplayList.markDirty(e||t)}},a.$getRenderNode=function(){var t=this.$renderNode;return t?(128&this.$displayFlags&&(t.cleanBeforeRender(),this.$render(),this.$removeFlags(128),t=this.$renderNode),t):null},a.$update=function(e,i){var n=this;n.$removeFlagsUp(768);var r=n.$renderNode;r.renderAlpha=n.$getConcatenatedAlpha();var s=n.$getConcatenatedMatrix();if(e==t.DirtyRegionPolicy.OFF){var a=n.$displayList||n.$parentDisplayList;if(!a)return!1;var o=r.renderMatrix;o.copyFrom(s);var h=a.root;h!==n.$stage&&n.$getConcatenatedMatrixAt(h,o)}else{var l=i||n.$getContentBounds();r.renderVisible=n.$getConcatenatedVisible();var a=n.$displayList||n.$parentDisplayList,u=r.renderRegion;if(!a)return u.setTo(0,0,0,0),r.moved=!1,!1;if(!r.moved)return!1;r.moved=!1;var o=r.renderMatrix;o.copyFrom(s);var h=a.root;h!==n.$stage&&n.$getConcatenatedMatrixAt(h,o),l=n.$measureFiltersBounds(l),u.updateRegion(l,o)}return!0},a.$measureFiltersBounds=function(e){var i=this.$DisplayObject[20];if(i&&i.length){var r=i.length;n.boundsForUpdate.copyFrom(e),e=n.boundsForUpdate;for(var s=e.x,a=e.y,o=e.width,h=e.height,l=0;r>l;l++){var u=i[l];if("blur"==u.type){var c=u.blurX,d=u.blurY;s-=c,a-=d,o+=2*c,h+=2*d}else if("glow"==u.type){var c=u.blurX,d=u.blurY;s-=c,a-=d,o+=2*c,h+=2*d;var f=u.distance||0,g=u.angle||0,p=0,v=0;0!=f&&(p=Math.ceil(f*t.NumberUtils.cos(g)),v=Math.ceil(f*t.NumberUtils.sin(g)),p>0?o+=p:0>p&&(s+=p,o-=p),v>0?h+=v:0>v&&(a+=v,h-=v))}}e.x=s,e.y=a,e.width=o,e.height=h}return e},a.$getConcatenatedMatrixAt=function(e,i){var n=e.$getInvertedConcatenatedMatrix();if(0===n.a||0===n.d){var r=this,s=e.$nestLevel;for(i.identity();r.$nestLevel>s;){var a=r.$scrollRect;a&&i.concat(t.$TempMatrix.setTo(1,0,0,1,-a.x,-a.y)),i.concat(r.$getMatrix()),r=r.$parent}}else n.$preMultiplyInto(i,i)},a.$getConcatenatedAlphaAt=function(t,e){var i=t.$getConcatenatedAlpha();if(0===i){e=1;for(var n=this,r=t.$nestLevel;n.$nestLevel>r;)e*=n.$alpha,n=n.$parent}else e/=i;return e},a.$render=function(){},a.$hitTest=function(t,e){var i=this.$DisplayObject;if(!this.$renderNode||!this.$visible||0==i[0]||0==i[1])return null;var n=this.$getInvertedConcatenatedMatrix();if(0==n.a&&0==n.b&&0==n.c&&0==n.d)return null;var r=this.$getContentBounds(),s=n.a*t+n.c*e+n.tx,a=n.b*t+n.d*e+n.ty;if(r.contains(s,a)){if(!this.$children){var o=this.$scrollRect?this.$scrollRect:this.$maskRect;if(o&&!o.contains(s,a))return null;if(this.$mask&&!this.$mask.$hitTest(t,e))return null}return this}return null},a.hitTestPoint=function(e,i,n){if(n){var r,s=this.$getInvertedConcatenatedMatrix(),a=s.a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty,h=this.$displayList;if(h){var l=h.renderBuffer;try{r=l.getPixel(a-h.offsetX,o-h.offsetY)}catch(u){throw new Error(t.sys.tr(1039))}}else{var l=t.sys.hitTestBuffer;l.resize(3,3);var c=t.Matrix.create();c.identity(),c.translate(1-a,1-o),t.sys.canvasRenderer.render(this,l,c,null,!0),t.Matrix.release(c);try{r=l.getPixel(1,1)}catch(u){throw new Error(t.sys.tr(1039))}}return 0===r[3]?!1:!0}var d=this.$DisplayObject;if(0==d[0]||0==d[1])return!1;var s=this.$getInvertedConcatenatedMatrix(),f=this.getBounds(null,!1),a=s.a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty;if(f.contains(a,o)){var g=this.$scrollRect?this.$scrollRect:this.$maskRect;return g&&!g.contains(a,o)?!1:!0}return!1},a.$addListener=function(e,r,s,a,o,h){i.prototype.$addListener.call(this,e,r,s,a,o,h);var l=e==t.Event.ENTER_FRAME;if(l||e==t.Event.RENDER){var u=l?n.$enterFrameCallBackList:n.$renderCallBackList;-1==u.indexOf(this)&&u.push(this)}},a.removeEventListener=function(e,r,s,a){i.prototype.removeEventListener.call(this,e,r,s,a);var o=e==t.Event.ENTER_FRAME;if((o||e==t.Event.RENDER)&&!this.hasEventListener(e)){var h=o?n.$enterFrameCallBackList:n.$renderCallBackList,l=h.indexOf(this);-1!==l&&h.splice(l,1)}},a.dispatchEvent=function(t){if(!t.$bubbles)return i.prototype.dispatchEvent.call(this,t);var e=this.$getPropagationList(this),n=.5*e.length;return t.$setTarget(this),this.$dispatchPropagationEvent(t,e,n),!t.$isDefaultPrevented},a.$getPropagationList=function(t){for(var e=[];t;)e.push(t),t=t.$parent;var i=e.concat();return i.reverse(),e=i.concat(e)},a.$dispatchPropagationEvent=function(t,e,i){for(var n=e.length,r=i-1,s=0;n>s;s++){var a=e[s];if(t.$currentTarget=a,r>s?t.$eventPhase=1:s==i||s==r?t.$eventPhase=2:t.$eventPhase=3,a.$notifyListener(t,i>s),t.$isPropagationStopped||t.$isPropagationImmediateStopped)return}},a.willTrigger=function(t){for(var e=this;e;){if(e.hasEventListener(t))return!0;e=e.$parent}return!1},n.defaultTouchEnabled=!1,n.boundsForUpdate=new t.Rectangle,n.$enterFrameCallBackList=[],n.$renderCallBackList=[],n}(t.EventDispatcher);t.DisplayObject=i,t.registerClass(i,"egret.DisplayObject",["egret.sys.Renderable"])}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(n){e.call(this),this.$scale9Grid=null,this.$fillMode="scale",this._pixelHitTest=!1,this.$renderNode=new t.sys.BitmapNode,this.$Bitmap={0:null,1:null,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:i.defaultSmoothing,11:0/0,12:0/0},this.$setBitmapData(n)}__extends(i,e);var n=__define,r=i,s=r.prototype;return s.$onAddToStage=function(i,n){e.prototype.$onAddToStage.call(this,i,n);var r=this.$Bitmap[0];r&&t.Texture.$addDisplayObject(this,r)},s.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);var i=this.$Bitmap[0];i&&t.Texture.$removeDisplayObject(this,i)},n(s,"bitmapData",function(){var e=this.$Bitmap[0];return e instanceof t.Texture?null:e},function(t){this.$setBitmapData(t)}),n(s,"texture",function(){var e=this.$Bitmap[0];return e instanceof t.Texture?e:null},function(t){this.$setBitmapData(t)}),s.$setBitmapData=function(e){var i=this.$Bitmap,n=i[0];if(e==n)return!1;if(i[0]=e,!e)return n&&t.Texture.$removeDisplayObject(this,n),this.setImageData(null,0,0,0,0,0,0,0,0,0,0),this.$invalidateContentBounds(),!0;if(this.$refreshImageData(),this.$stage){if(n){var r;r=n._bitmapData&&n._bitmapData.hashCode?n._bitmapData.hashCode:n.hashCode;var s;if(s=e._bitmapData&&e._bitmapData.hashCode?e._bitmapData.hashCode:e.hashCode,r==s)return this.$invalidateContentBounds(),!0;t.Texture.$removeDisplayObject(this,n)}t.Texture.$addDisplayObject(this,e)}return this.$invalidateContentBounds(),!0},s.$refreshImageData=function(){var e=this.$Bitmap,i=e[0];if(i)if(i instanceof t.Texture){var n=i;this.setImageData(n._bitmapData,n._bitmapX,n._bitmapY,n._bitmapWidth,n._bitmapHeight,n._offsetX,n._offsetY,n.$getTextureWidth(),n.$getTextureHeight(),n._sourceWidth,n._sourceHeight)}else{var r=i.width,s=i.height;this.setImageData(i,0,0,r,s,0,0,r,s,r,s)}},s.setImageData=function(t,e,i,n,r,s,a,o,h,l,u){var c=this.$Bitmap;c[1]=t,c[2]=e,c[3]=i,c[4]=n,c[5]=r,c[6]=s,c[7]=a,c[8]=o,c[9]=h,c[13]=l,c[14]=u},n(s,"scale9Grid",function(){return this.$scale9Grid},function(t){this.$scale9Grid=t,this.$invalidateContentBounds()}),n(s,"fillMode",function(){return this.$fillMode},function(t){this.$setFillMode(t)}),s.$setFillMode=function(t){return t==this.$fillMode?!1:(this.$fillMode=t,!0)},n(s,"smoothing",function(){var t=this.$Bitmap;return t[10]},function(t){t=!!t;var e=this.$Bitmap;t!=e[10]&&(e[10]=t,this.$invalidate())}),s.$setWidth=function(t){var e=this.$Bitmap;return 0>t||t==e[11]?!1:(e[11]=t,this.$invalidateContentBounds(),!0)},s.$setHeight=function(t){var e=this.$Bitmap;return 0>t||t==e[12]?!1:(e[12]=t,this.$invalidateContentBounds(),!0)},s.$getWidth=function(){var t=this.$Bitmap;return isNaN(t[11])?this.$getContentBounds().width:t[11]},s.$getHeight=function(){var t=this.$Bitmap;return isNaN(t[12])?this.$getContentBounds().height:t[12]},s.$measureContentBounds=function(t){var e=this.$Bitmap;if(e[1]){var e=this.$Bitmap,i=isNaN(e[11])?e[8]:e[11],n=isNaN(e[12])?e[9]:e[12];t.setTo(0,0,i,n)}else i=isNaN(e[11])?0:e[11],n=isNaN(e[12])?0:e[12],t.setTo(0,0,i,n)},s.$render=function(){var e=this.$Bitmap;if(e[1]){var i=isNaN(e[11])?e[8]:e[11],n=isNaN(e[12])?e[9]:e[12];t.sys.BitmapNode.$updateTextureData(this.$renderNode,e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],i,n,e[13],e[14],this.scale9Grid||e[0].scale9Grid,this.fillMode,e[10])}},n(s,"pixelHitTest",function(){return this._pixelHitTest},function(t){this._pixelHitTest=!!t}),s.$hitTest=function(t,i){var n=e.prototype.$hitTest.call(this,t,i);return n&&this._pixelHitTest&&(n=this.hitTestPixel(t,i)),n},s.hitTestPixel=function(e,i){var n,r=this.$getInvertedConcatenatedMatrix(),s=r.a*e+r.c*i+r.tx,a=r.b*e+r.d*i+r.ty,o=this.$displayList;if(o){var h=o.renderBuffer;try{n=h.getPixel(s-o.offsetX,a-o.offsetY)}catch(l){throw console.log(this.$Bitmap[0]),new Error(t.sys.tr(1039))}}else{var h=t.sys.hitTestBuffer;h.resize(3,3);var u=this.$getRenderNode(),c=t.Matrix.create();c.identity(),c.translate(1-s,1-a),t.sys.canvasRenderer.drawNodeToBuffer(u,h,c,!0),t.Matrix.release(c);try{n=h.getPixel(1,1)}catch(l){throw console.log(this.$Bitmap[0]),new Error(t.sys.tr(1039))}}return 0===n[3]?null:this},i.$drawImage=function(e,i,n,r,s,a,o,h,l,u,c,d,f,g,p,v,$){console.warn("deprecated method : Bitmap.$drawImage,use egret.sys.BitmapNode.$drawImage instead of it"),t.sys.BitmapNode.$updateTextureData.call(this,arguments)},i.defaultSmoothing=!0,i}(t.DisplayObject);t.Bitmap=e,t.registerClass(e,"egret.Bitmap")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.REPEAT="repeat",t.SCALE="scale",t.CLIP="clip",t}();t.BitmapFillMode=e,t.registerClass(e,"egret.BitmapFillMode")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.NORMAL="normal",t.ADD="add",t.ERASE="erase",t}();t.BlendMode=e,t.registerClass(e,"egret.BlendMode")}(egret||(egret={}));var egret;!function(t){var e;!function(t){function e(t){var e=r[t];return void 0===e?0:e}function i(t){var e=n[t];return void 0===e?"normal":e}for(var n=["normal","add","erase"],r={},s=n.length,a=0;s>a;a++){var o=n[a];r[o]=a}t.blendModeToNumber=e,t.numberToBlendMode=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.NONE="none",t.ROUND="round",t.SQUARE="square",t}();t.CapsStyle=e,t.registerClass(e,"egret.CapsStyle")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.OFF="off",t.ON="on",t}();t.DirtyRegionPolicy=e,t.registerClass(e,"egret.DirtyRegionPolicy")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){e.call(this),this.$touchChildren=!0,this.$children=[]}__extends(i,e);var n=__define,r=i,s=r.prototype;return s.$propagateFlagsDown=function(t){if(!this.$hasFlags(t)){this.$setFlags(t);for(var e=this.$children,i=e.length,n=0;i>n;n++)e[n].$propagateFlagsDown(t)}},n(s,"numChildren",function(){return this.$children.length}),s.addChild=function(t){var e=this.$children.length;return t.$parent==this&&e--,this.$doAddChild(t,e)},s.addChildAt=function(t,e){return e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length,t.$parent==this&&e--),this.$doAddChild(t,e)},s.$doAddChild=function(e,n,r){void 0===r&&(r=!0);var s=e.$parent;if(s==this)return this.doSetChildIndex(e,n),e;s&&s.removeChild(e),this.$children.splice(n,0,e),e.$setParent(this);var a=this.$stage;if(a&&e.$onAddToStage(a,this.$nestLevel+1),r&&e.dispatchEventWith(t.Event.ADDED,!0),a)for(var o=i.$EVENT_ADD_TO_STAGE_LIST;o.length;){var h=o.shift();h.$stage&&r&&h.dispatchEventWith(t.Event.ADDED_TO_STAGE)}var l=this.$displayList||this.$parentDisplayList;return this.assignParentDisplayList(e,l,l),e.$propagateFlagsDown(1648),this.$propagateFlagsUp(4),this.$childAdded(e,n),e},s.contains=function(t){for(;t;){if(t==this)return!0;t=t.$parent}return!1},s.getChildAt=function(t){return t=0|+t,t>=0&&tr;r++)if(e=i[r],e.name==t)return e;return null},s.removeChild=function(t){var e=this.$children.indexOf(t);return e>=0?this.$doRemoveChild(e):null},s.removeChildAt=function(t){return t=0|+t,t>=0&&t0;){var o=a.shift();n&&o.$hasAddToStage&&(o.$hasAddToStage=!1,o.dispatchEventWith(t.Event.REMOVED_FROM_STAGE)),o.$hasAddToStage=!1,o.$stage=null}}var h=this.$displayList||this.$parentDisplayList;this.assignParentDisplayList(s,h,null),s.$propagateFlagsDown(1648),s.$setParent(null);var l=r.indexOf(s);return r.splice(l,1),this.$propagateFlagsUp(4),s},s.setChildIndex=function(t,e){e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length-1),this.doSetChildIndex(t,e)},s.doSetChildIndex=function(t,e){var i=this.$children.indexOf(t);i!=e&&(this.$childRemoved(t,i),this.$children.splice(i,1),this.$children.splice(e,0,t),this.$childAdded(t,e),t.$invalidateTransform(),this.$propagateFlagsUp(4))},s.swapChildrenAt=function(t,e){t=0|+t,e=0|+e,t>=0&&t=0&&ee){var i=e;e=t,t=i}else if(t==e)return;var n=this.$children,r=n[t],s=n[e];this.$childRemoved(r,t),this.$childRemoved(s,e),n[t]=s,n[e]=r,this.$childAdded(s,t),this.$childAdded(r,e),r.$invalidateTransform(),s.$invalidateTransform(),this.$propagateFlagsUp(4)},s.removeChildren=function(){for(var t=this.$children,e=t.length-1;e>=0;e--)this.$doRemoveChild(e)},s.$childAdded=function(t,e){},s.$childRemoved=function(t,e){},s.$onAddToStage=function(t,i){e.prototype.$onAddToStage.call(this,t,i);var n=this.$children,r=n.length;i++;for(var s=0;r>s;s++){var a=this.$children[s];a.$onAddToStage(t,i)}},s.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);for(var t=this.$children,i=t.length,n=0;i>n;n++){var r=t[n]; +function __extends(t,e){function i(){this.constructor=t}for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);i.prototype=e.prototype,t.prototype=new i}var egret;!function(t){function e(){return""}function i(t){throw new Error("#"+t)}function n(){}function r(){}function s(){}t.getString=e,t.$error=i,t.$warn=n,t.$markReadOnly=r,t.$markCannotUse=s}(egret||(egret={}));var egret;!function(t){function e(t,e,i){var n=t.prototype;n.__class__=e;var r=[e];i&&(r=r.concat(i));var s=n.__types__;if(n.__types__)for(var a=s.length,o=0;a>o;o++){var h=s[o];-1==r.indexOf(h)&&r.push(h)}n.__types__=r}t.registerClass=e}(egret||(egret={}));var __define=this.__define||function(t,e,i,n){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get:i,set:n})},egret;!function(t){t.$hashCount=1;var e=function(){function e(){this.$hashCode=t.$hashCount++}var i=__define,n=e,r=n.prototype;return i(r,"hashCode",function(){return this.$hashCode}),e}();t.HashObject=e,t.registerClass(e,"egret.HashObject",["egret.IHashObject"])}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function n(t){void 0===t&&(t=null),i.call(this),this.$EventDispatcher={0:t?t:this,1:{},2:{},3:0}}__extends(n,i);var r=n,s=r.prototype;return s.$getEventMap=function(t){var e=this.$EventDispatcher,i=t?e[2]:e[1];return i},s.addEventListener=function(t,e,i,n,r){this.$addListener(t,e,i,n,r)},s.once=function(t,e,i,n,r){this.$addListener(t,e,i,n,r,!0)},s.$addListener=function(t,e,i,n,r,s){var a=this.$EventDispatcher,o=n?a[2]:a[1],h=o[t];h?0!==a[3]&&(o[t]=h=h.concat()):h=o[t]=[],this.$insertEventBin(h,t,e,i,n,r,s)},s.$insertEventBin=function(t,e,i,n,r,s,a){s=0|+s;for(var o=-1,h=t.length,l=0;h>l;l++){var u=t[l];if(u.listener==i&&u.thisObject==n&&u.target==this)return!1;-1==o&&u.priorityr;r++){var s=t[r];if(s.listener==e&&s.thisObject==i&&s.target==this)return t.splice(r,1),!0}return!1},s.hasEventListener=function(t){var e=this.$EventDispatcher;return!(!e[1][t]&&!e[2][t])},s.willTrigger=function(t){return this.hasEventListener(t)},s.dispatchEvent=function(t){return t.$currentTarget=this.$EventDispatcher[0],t.$setTarget(t.$currentTarget),this.$notifyListener(t,!1)},s.$notifyListener=function(t,i){var n=this.$EventDispatcher,r=i?n[2]:n[1],s=r[t.$type];if(!s)return!0;var a=s.length;if(0==a)return!0;var o=e;n[3]++;for(var h=0;a>h;h++){var l=s[h];if(l.listener.call(l.thisObject,t),l.dispatchOnce&&o.push(l),t.$isPropagationImmediateStopped)break}for(n[3]--;o.length;)l=o.pop(),l.target.removeEventListener(l.type,l.listener,l.thisObject,l.useCapture);return!t.$isDefaultPrevented},s.dispatchEventWith=function(e,i,n){if(i||this.hasEventListener(e)){var r=t.Event.create(t.Event,e,i);r.data=n;var s=this.dispatchEvent(r);return t.Event.release(r),s}return!0},n}(t.HashObject);t.EventDispatcher=i,t.registerClass(i,"egret.EventDispatcher",["egret.IEventDispatcher"])}(egret||(egret={}));var egret;!function(t){var e=[],i=function(i){function n(t,e,n,r){void 0===t&&(t=0),void 0===e&&(e=0),void 0===n&&(n=0),void 0===r&&(r=0),i.call(this),this.x=t,this.y=e,this.width=n,this.height=r}__extends(n,i);var r=__define,s=n,a=s.prototype;return n.release=function(t){t&&e.push(t)},n.create=function(){var t=e.pop();return t||(t=new n),t},r(a,"right",function(){return this.x+this.width},function(t){this.width=t-this.x}),r(a,"bottom",function(){return this.y+this.height},function(t){this.height=t-this.y}),r(a,"left",function(){return this.x},function(t){this.width+=this.x-t,this.x=t}),r(a,"top",function(){return this.y},function(t){this.height+=this.y-t,this.y=t}),r(a,"topLeft",function(){return new t.Point(this.left,this.top)},function(t){this.top=t.y,this.left=t.x}),r(a,"bottomRight",function(){return new t.Point(this.right,this.bottom)},function(t){this.bottom=t.y,this.right=t.x}),a.copyFrom=function(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this},a.setTo=function(t,e,i,n){return this.x=t,this.y=e,this.width=i,this.height=n,this},a.contains=function(t,e){return this.x<=t&&this.x+this.width>=t&&this.y<=e&&this.y+this.height>=e},a.intersection=function(t){return this.clone().$intersectInPlace(t)},a.inflate=function(t,e){this.x-=t,this.width+=2*t,this.y-=e,this.height+=2*e},a.$intersectInPlace=function(t){var e=this.x,i=this.y,n=t.x,r=t.y,s=Math.max(e,n),a=Math.min(e+this.width,n+t.width);if(a>=s){var o=Math.max(i,r),h=Math.min(i+this.height,r+t.height);if(h>=o)return this.setTo(s,o,a-s,h-o),this}return this.setEmpty(),this},a.intersects=function(t){return Math.max(this.x,t.x)<=Math.min(this.right,t.right)&&Math.max(this.y,t.y)<=Math.min(this.bottom,t.bottom)},a.isEmpty=function(){return this.width<=0||this.height<=0},a.setEmpty=function(){this.x=0,this.y=0,this.width=0,this.height=0},a.clone=function(){return new n(this.x,this.y,this.width,this.height)},a.containsPoint=function(t){return this.xt.x&&this.yt.y?!0:!1},a.containsRect=function(t){var e=t.x+t.width,i=t.y+t.height,n=this.x+this.width,r=this.y+this.height;return t.x>=this.x&&t.x=this.y&&t.ythis.x&&n>=e&&i>this.y&&r>=i},a.equals=function(t){return this===t?!0:this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height},a.inflatePoint=function(t){this.inflate(t.x,t.y)},a.offset=function(t,e){this.x+=t,this.y+=e},a.offsetPoint=function(t){this.offset(t.x,t.y)},a.toString=function(){return"(x="+this.x+", y="+this.y+", width="+this.width+", height="+this.height+")"},a.union=function(t){var e=this.clone();if(t.isEmpty())return e;if(e.isEmpty())return e.copyFrom(t),e;var i=Math.min(e.x,t.x),n=Math.min(e.y,t.y);return e.setTo(i,n,Math.max(e.right,t.right)-i,Math.max(e.bottom,t.bottom)-n),e},a.$getBaseWidth=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return e*this.width+i*this.height},a.$getBaseHeight=function(t){var e=Math.abs(Math.cos(t)),i=Math.abs(Math.sin(t));return i*this.width+e*this.height},n}(t.HashObject);t.Rectangle=i,t.registerClass(i,"egret.Rectangle"),t.$TempRectangle=new i}(egret||(egret={}));var egret;!function(t){function e(t){return t%=360,t>180?t-=360:-180>t&&(t+=360),t}var i=function(i){function n(){i.call(this),this.$children=null,this.$parent=null,this.$stage=null,this.$nestLevel=0,this.$visible=!0,this.$displayList=null,this.$alpha=1,this.$touchEnabled=n.defaultTouchEnabled,this.$scrollRect=null,this.$blendMode=0,this.$maskedObject=null,this.$mask=null,this.$maskRect=null,this.$parentDisplayList=null,this.$renderNode=null,this.$displayFlags=2032,this.$DisplayObject={0:1,1:1,2:0,3:0,4:0,5:"",6:new t.Matrix,7:new t.Matrix,8:new t.Matrix,9:new t.Rectangle,10:new t.Rectangle,11:!1,12:0,13:0,14:0/0,15:0/0,16:0,17:0,18:0,19:null}}__extends(n,i);var r=__define,s=n,a=s.prototype;return a.$setFlags=function(t){this.$displayFlags|=t},a.$removeFlags=function(t){this.$displayFlags&=~t},a.$removeFlagsUp=function(t){if(this.$hasAnyFlags(t)){this.$removeFlags(t);var e=this.$parent;e&&e.$removeFlagsUp(t)}},a.$hasFlags=function(t){return(this.$displayFlags&t)==t},a.$propagateFlagsUp=function(t){if(!this.$hasFlags(t)){this.$setFlags(t);var e=this.$parent;e&&e.$propagateFlagsUp(t)}},a.$propagateFlagsDown=function(t){this.$setFlags(t)},a.$hasAnyFlags=function(t){return!!(this.$displayFlags&t)},a.$invalidateMatrix=function(){this.$setFlags(8),this.$invalidatePosition()},a.$invalidatePosition=function(){var t=this;t.$invalidateTransform(),t.$propagateFlagsDown(48),t.$parent&&t.$parent.$propagateFlagsUp(4)},r(a,"name",function(){return this.$DisplayObject[5]},function(t){this.$DisplayObject[5]=t}),r(a,"parent",function(){return this.$parent}),a.$setParent=function(t){return this.$parent==t?!1:(this.$parent=t,!0)},a.$onAddToStage=function(e,i){this.$stage=e,this.$nestLevel=i,this.$hasAddToStage=!0,t.Sprite.$EVENT_ADD_TO_STAGE_LIST.push(this)},a.$onRemoveFromStage=function(){this.$nestLevel=0,t.Sprite.$EVENT_REMOVE_FROM_STAGE_LIST.push(this)},r(a,"stage",function(){return this.$stage}),r(a,"matrix",function(){return this.$getMatrix().clone()},function(t){this.$setMatrix(t)}),a.$getMatrix=function(){var t=this.$DisplayObject;return this.$hasFlags(8)&&(t[6].$updateScaleAndRotation(t[0],t[1],t[2],t[3]),this.$removeFlags(8)),t[6]},a.$setMatrix=function(t,i){void 0===i&&(i=!0);var n=this,r=n.$DisplayObject,s=r[6];return s.equals(t)?!1:(s.copyFrom(t),i&&(r[0]=s.$getScaleX(),r[1]=s.$getScaleY(),r[2]=t.$getSkewX(),r[3]=t.$getSkewY(),r[16]=e(180*r[2]/Math.PI),r[17]=e(180*r[3]/Math.PI),r[4]=e(180*r[3]/Math.PI)),n.$removeFlags(8),n.$invalidatePosition(),!0)},a.$getConcatenatedMatrix=function(){var e=this.$DisplayObject[7];if(this.$hasFlags(16)){this.$parent?this.$parent.$getConcatenatedMatrix().$preMultiplyInto(this.$getMatrix(),e):e.copyFrom(this.$getMatrix());var i=this.$DisplayObject,n=i[12],r=i[13],s=this.$scrollRect;s?e.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-s.x-n,-s.y-r),e):(0!=n||0!=r)&&e.$preMultiplyInto(t.$TempMatrix.setTo(1,0,0,1,-n,-r),e),this.$displayList&&(this.$displayList.$renderNode.moved=!0),this.$renderNode&&(this.$renderNode.moved=!0),this.$removeFlags(16)}return e},a.$getInvertedConcatenatedMatrix=function(){var t=this.$DisplayObject;return this.$hasFlags(32)&&(this.$getConcatenatedMatrix().$invertInto(t[8]),this.$removeFlags(32)),t[8]},r(a,"x",function(){return this.$getX()},function(t){this.$setX(t)}),a.$getX=function(){return this.$DisplayObject[6].tx},a.$setX=function(t){t=+t||0;var e=this.$DisplayObject[6];return t==e.tx?!1:(e.tx=t,this.$invalidatePosition(),!0)},r(a,"y",function(){return this.$getY()},function(t){this.$setY(t)}),a.$getY=function(){return this.$DisplayObject[6].ty},a.$setY=function(t){t=+t||0;var e=this.$DisplayObject[6];return t==e.ty?!1:(e.ty=t,this.$invalidatePosition(),!0)},r(a,"scaleX",function(){return this.$getScaleX()},function(t){this.$setScaleX(t)}),a.$getScaleX=function(){return this.$DisplayObject[0]},a.$setScaleX=function(t){t=+t||0;var e=this.$DisplayObject;return t==e[0]?!1:(e[0]=t,this.$invalidateMatrix(),!0)},r(a,"scaleY",function(){return this.$getScaleY()},function(t){this.$setScaleY(t)}),a.$getScaleY=function(){return this.$DisplayObject[1]},a.$setScaleY=function(t){return t=+t||0,t==this.$DisplayObject[1]?!1:(this.$DisplayObject[1]=t,this.$invalidateMatrix(),!0)},r(a,"rotation",function(){return this.$getRotation()},function(t){this.$setRotation(t)}),a.$getRotation=function(){return this.$DisplayObject[4]},a.$setRotation=function(t){t=+t||0,t=e(t);var i=this.$DisplayObject;if(t==i[4])return!1;var n=t-i[4],r=n/180*Math.PI;return i[2]+=r,i[3]+=r,i[4]=t,this.$invalidateMatrix(),!0},r(a,"skewX",function(){return this.$DisplayObject[16]},function(t){this.$setSkewX(t)}),a.$setSkewX=function(t){t=+t||0;var i=this.$DisplayObject;return t==i[16]?!1:(i[16]=t,t=e(t),t=t/180*Math.PI,i[2]=t,this.$invalidateMatrix(),!0)},r(a,"skewY",function(){return this.$DisplayObject[17]},function(t){this.$setSkewY(t)}),a.$setSkewY=function(t){t=+t||0;var i=this.$DisplayObject;return t==i[17]?!1:(i[17]=t,t=e(t),t=t/180*Math.PI,i[3]=t,this.$invalidateMatrix(),!0)},r(a,"width",function(){return this.$getWidth()},function(t){this.$setWidth(t)}),a.$getWidth=function(){return isNaN(this.$getExplicitWidth())?this.$getOriginalBounds().width:this.$getExplicitWidth()},a.$getExplicitWidth=function(){return this.$DisplayObject[14]},a.$setWidth=function(t){return this.$DisplayObject[14]=isNaN(t)?0/0:t,t=+t,0>t?!1:(this.$invalidateMatrix(),!0)},r(a,"height",function(){return this.$getHeight()},function(t){this.$setHeight(t)}),a.$getHeight=function(){return isNaN(this.$getExplicitHeight())?this.$getOriginalBounds().height:this.$getExplicitHeight()},a.$getExplicitHeight=function(){return this.$DisplayObject[15]},a.$setHeight=function(t){return this.$DisplayObject[15]=isNaN(t)?0/0:t,t=+t,0>t?!1:(this.$invalidateMatrix(),!0)},r(a,"measuredWidth",function(){return this.$getOriginalBounds().width}),r(a,"measuredHeight",function(){return this.$getOriginalBounds().height}),r(a,"anchorOffsetX",function(){return this.$DisplayObject[12]},function(t){this.$setAnchorOffsetX(t)}),a.$getAnchorOffsetX=function(){return this.$DisplayObject[12]},a.$setAnchorOffsetX=function(t){return t=+t||0,t==this.$DisplayObject[12]?!1:(this.$DisplayObject[12]=t,this.$invalidatePosition(),!0)},r(a,"anchorOffsetY",function(){return this.$DisplayObject[13]},function(t){this.$setAnchorOffsetY(t)}),a.$getAnchorOffsetY=function(){return this.$DisplayObject[13]},a.$setAnchorOffsetY=function(t){return t=+t||0,t==this.$DisplayObject[13]?!1:(this.$DisplayObject[13]=t,this.$invalidatePosition(),!0)},r(a,"visible",function(){return this.$visible},function(t){this.$setVisible(t)}),a.$setVisible=function(t){return t=!!t,t==this.$visible?!1:(this.$visible=t,this.$propagateFlagsDown(1024),this.$invalidateTransform(),!0)},a.$getConcatenatedVisible=function(){var t=this.$DisplayObject;if(this.$hasFlags(1024)){if(this.$parent){var e=this.$parent.$getConcatenatedVisible();t[19]=e&&this.$visible}else t[19]=this.$visible;this.$removeFlags(1024)}return t[19]},r(a,"cacheAsBitmap",function(){return this.$DisplayObject[11]},function(t){t=!!t,this.$DisplayObject[11]=t,this.$setHasDisplayList(t)}),a.$setHasDisplayList=function(e){var i=!!this.$displayList;if(i!=e)if(e){var n=t.sys.DisplayList.create(this);n&&(this.$displayList=n,this.$parentDisplayList&&this.$parentDisplayList.markDirty(n),this.$cacheAsBitmapChanged())}else this.$displayList=null,this.$cacheAsBitmapChanged()},a.$cacheAsBitmapChanged=function(){var t=this.$displayList||this.$parentDisplayList;this.$renderNode&&t&&t.markDirty(this),this.$propagateFlagsDown(48)},r(a,"alpha",function(){return this.$alpha},function(t){this.$setAlpha(t)}),a.$setAlpha=function(t){return t=+t||0,t==this.$alpha?!1:(this.$alpha=t,this.$propagateFlagsDown(64),this.$invalidate(),!0)},a.$getConcatenatedAlpha=function(){var t=this.$DisplayObject;if(this.$hasFlags(64)){if(this.$parent){var e=this.$parent.$getConcatenatedAlpha();t[18]=e*this.$alpha}else t[18]=this.$alpha;this.$removeFlags(64)}return t[18]},r(a,"touchEnabled",function(){return this.$getTouchEnabled()},function(t){this.$setTouchEnabled(t)}),a.$getTouchEnabled=function(){return this.$touchEnabled},a.$setTouchEnabled=function(t){return this.$touchEnabled==t?!1:(this.$touchEnabled=t,!0)},r(a,"scrollRect",function(){return this.$scrollRect},function(t){this.$setScrollRect(t)}),a.$setScrollRect=function(e){return e||this.$scrollRect?(e?(this.$scrollRect||(this.$scrollRect=new t.Rectangle),this.$scrollRect.copyFrom(e)):this.$scrollRect=null,this.$invalidatePosition(),!0):!1},r(a,"blendMode",function(){return t.sys.numberToBlendMode(this.$blendMode)},function(e){var i=t.sys.blendModeToNumber(e);i!=this.$blendMode&&(this.$blendMode=i,this.$invalidateTransform())}),r(a,"mask",function(){return this.$mask?this.$mask:this.$maskRect},function(t){if(t!==this){if(t)if(t instanceof n){if(t==this.$mask)return;t.$maskedObject&&(t.$maskedObject.mask=null),t.$maskedObject=this,t.$invalidateTransform(),this.$mask=t,this.$maskRect=null}else this.$setMaskRect(t),this.$mask&&(this.$mask.$maskedObject=null,this.$mask.$invalidateTransform()),this.$mask=null;else this.$mask&&(this.$mask.$maskedObject=null,this.$mask.$invalidateTransform()),this.$mask=null,this.$maskRect=null;this.$invalidateTransform()}}),a.$setMaskRect=function(e){return e||this.$maskRect?(e?(this.$maskRect||(this.$maskRect=new t.Rectangle),this.$maskRect.copyFrom(e)):this.$maskRect=null,this.$invalidatePosition(),!0):!1},r(a,"filters",function(){return this.$DisplayObject[20]},function(t){var e=this.$DisplayObject[20];if(!e&&!t)return void(this.$DisplayObject[20]=t);if(this.$invalidateContentBounds(),this.$invalidate(!0),e&&e.length)for(var i=e.length,n=0;i>n;n++)e[n].$removeTarget(this);if(this.$DisplayObject[20]=t,t&&t.length)for(i=t.length,n=0;i>n;n++)t[n].$addTarget(this)}),a.$getFilters=function(){return this.$DisplayObject[20]},a.getTransformedBounds=function(t,e){return t=t||this,this.$getTransformedBounds(t,e)},a.getBounds=function(t,e){if(void 0===e&&(e=!0),t=this.$getTransformedBounds(this,t),e){var i=this.$DisplayObject;(0!=i[12]||0!=i[13])&&(t.x-=i[12],t.y-=i[13])}return t},a.$getTransformedBounds=function(e,i){var n=this.$getOriginalBounds();if(i||(i=new t.Rectangle),i.copyFrom(n),e==this||i.isEmpty())return i;var r;if(e){r=t.$TempMatrix;var s=e.$getInvertedConcatenatedMatrix();s.$preMultiplyInto(this.$getConcatenatedMatrix(),r)}else r=this.$getConcatenatedMatrix();return r.$transformBounds(i),i},a.globalToLocal=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0);var n=this.$getInvertedConcatenatedMatrix();return n.transformPoint(t,e,i)},a.localToGlobal=function(t,e,i){void 0===t&&(t=0),void 0===e&&(e=0);var n=this.$getConcatenatedMatrix();return n.transformPoint(t,e,i)},a.$invalidateContentBounds=function(){this.$invalidate(),this.$setFlags(2),this.$propagateFlagsUp(4)},a.$getOriginalBounds=function(){var t=this.$DisplayObject[9];if(this.$hasFlags(4)){t.copyFrom(this.$getContentBounds()),this.$measureChildBounds(t),this.$removeFlags(4),this.$displayList&&(this.$displayList.$renderNode.moved=!0);var e=this.$measureFiltersBounds(t);t.copyFrom(e)}return t},a.$measureChildBounds=function(t){},a.$getContentBounds=function(){var t=this.$DisplayObject[10];return this.$hasFlags(2)&&(this.$measureContentBounds(t),this.$renderNode&&(this.$renderNode.moved=!0),this.$removeFlags(2)),t},a.$measureContentBounds=function(t){},a.$invalidate=function(t){if(this.$renderNode&&!this.$hasFlags(256)){this.$setFlags(384);var e=this.$displayList?this.$displayList:this.$parentDisplayList;e&&e.markDirty(this)}},a.$invalidateTransform=function(){var t=this;if(!t.$hasFlags(512)){t.$setFlags(512);var e=t.$displayList;(e||t.$renderNode)&&t.$parentDisplayList&&t.$parentDisplayList.markDirty(e||t)}},a.$getRenderNode=function(){var t=this.$renderNode;return t?(128&this.$displayFlags&&(t.cleanBeforeRender(),this.$render(),this.$removeFlags(128),t=this.$renderNode),t):null},a.$update=function(e,i){var n=this;n.$removeFlagsUp(768);var r=n.$renderNode;r.renderAlpha=n.$getConcatenatedAlpha();var s=n.$getConcatenatedMatrix();if(e==t.DirtyRegionPolicy.OFF){var a=n.$displayList||n.$parentDisplayList;if(!a)return!1;var o=r.renderMatrix;o.copyFrom(s);var h=a.root;h!==n.$stage&&n.$getConcatenatedMatrixAt(h,o)}else{var l=i||n.$getContentBounds();r.renderVisible=n.$getConcatenatedVisible();var a=n.$displayList||n.$parentDisplayList,u=r.renderRegion;if(!a)return u.setTo(0,0,0,0),r.moved=!1,!1;if(!r.moved)return!1;r.moved=!1;var o=r.renderMatrix;o.copyFrom(s);var h=a.root;h!==n.$stage&&n.$getConcatenatedMatrixAt(h,o),l=n.$measureFiltersBounds(l),u.updateRegion(l,o)}return!0},a.$measureFiltersBounds=function(e){var i=this.$DisplayObject[20];if(i&&i.length){var r=i.length;n.boundsForUpdate.copyFrom(e),e=n.boundsForUpdate;for(var s=e.x,a=e.y,o=e.width,h=e.height,l=0;r>l;l++){var u=i[l];if("blur"==u.type){var c=u.blurX,d=u.blurY;s-=c,a-=d,o+=2*c,h+=2*d}else if("glow"==u.type){var c=u.blurX,d=u.blurY;s-=c,a-=d,o+=2*c,h+=2*d;var f=u.distance||0,g=u.angle||0,p=0,v=0;0!=f&&(p=Math.ceil(f*t.NumberUtils.cos(g)),v=Math.ceil(f*t.NumberUtils.sin(g)),p>0?o+=p:0>p&&(s+=p,o-=p),v>0?h+=v:0>v&&(a+=v,h-=v))}}e.x=s,e.y=a,e.width=o,e.height=h}return e},a.$getConcatenatedMatrixAt=function(e,i){var n=e.$getInvertedConcatenatedMatrix();if(0===n.a||0===n.d){var r=this,s=e.$nestLevel;for(i.identity();r.$nestLevel>s;){var a=r.$scrollRect;a&&i.concat(t.$TempMatrix.setTo(1,0,0,1,-a.x,-a.y)),i.concat(r.$getMatrix()),r=r.$parent}}else n.$preMultiplyInto(i,i)},a.$getConcatenatedAlphaAt=function(t,e){var i=t.$getConcatenatedAlpha();if(0===i){e=1;for(var n=this,r=t.$nestLevel;n.$nestLevel>r;)e*=n.$alpha,n=n.$parent}else e/=i;return e},a.$render=function(){},a.$hitTest=function(t,e){var i=this.$DisplayObject;if(!this.$renderNode||!this.$visible||0==i[0]||0==i[1])return null;var n=this.$getInvertedConcatenatedMatrix();if(0==n.a&&0==n.b&&0==n.c&&0==n.d)return null;var r=this.$getContentBounds(),s=n.a*t+n.c*e+n.tx,a=n.b*t+n.d*e+n.ty;if(r.contains(s,a)){if(!this.$children){var o=this.$scrollRect?this.$scrollRect:this.$maskRect;if(o&&!o.contains(s,a))return null;if(this.$mask&&!this.$mask.$hitTest(t,e))return null}return this}return null},a.hitTestPoint=function(e,i,n){if(n){var r,s=this.$getInvertedConcatenatedMatrix(),a=s.a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty,h=this.$displayList;if(h){var l=h.renderBuffer;try{r=l.getPixel(a-h.offsetX,o-h.offsetY)}catch(u){throw new Error(t.sys.tr(1039))}}else{var l=t.sys.hitTestBuffer;l.resize(3,3);var c=t.Matrix.create();c.identity(),c.translate(1-a,1-o),t.sys.canvasRenderer.render(this,l,c,null,!0),t.Matrix.release(c);try{r=l.getPixel(1,1)}catch(u){throw new Error(t.sys.tr(1039))}}return 0===r[3]?!1:!0}var d=this.$DisplayObject;if(0==d[0]||0==d[1])return!1;var s=this.$getInvertedConcatenatedMatrix(),f=this.getBounds(null,!1),a=s.a*e+s.c*i+s.tx,o=s.b*e+s.d*i+s.ty;if(f.contains(a,o)){var g=this.$scrollRect?this.$scrollRect:this.$maskRect;return g&&!g.contains(a,o)?!1:!0}return!1},a.$addListener=function(e,r,s,a,o,h){i.prototype.$addListener.call(this,e,r,s,a,o,h);var l=e==t.Event.ENTER_FRAME;if(l||e==t.Event.RENDER){var u=l?n.$enterFrameCallBackList:n.$renderCallBackList;-1==u.indexOf(this)&&u.push(this)}},a.removeEventListener=function(e,r,s,a){i.prototype.removeEventListener.call(this,e,r,s,a);var o=e==t.Event.ENTER_FRAME;if((o||e==t.Event.RENDER)&&!this.hasEventListener(e)){var h=o?n.$enterFrameCallBackList:n.$renderCallBackList,l=h.indexOf(this);-1!==l&&h.splice(l,1)}},a.dispatchEvent=function(t){if(!t.$bubbles)return i.prototype.dispatchEvent.call(this,t);var e=this.$getPropagationList(this),n=.5*e.length;return t.$setTarget(this),this.$dispatchPropagationEvent(t,e,n),!t.$isDefaultPrevented},a.$getPropagationList=function(t){for(var e=[];t;)e.push(t),t=t.$parent;var i=e.concat();return i.reverse(),e=i.concat(e)},a.$dispatchPropagationEvent=function(t,e,i){for(var n=e.length,r=i-1,s=0;n>s;s++){var a=e[s];if(t.$currentTarget=a,r>s?t.$eventPhase=1:s==i||s==r?t.$eventPhase=2:t.$eventPhase=3,a.$notifyListener(t,i>s),t.$isPropagationStopped||t.$isPropagationImmediateStopped)return}},a.willTrigger=function(t){for(var e=this;e;){if(e.hasEventListener(t))return!0;e=e.$parent}return!1},n.defaultTouchEnabled=!1,n.boundsForUpdate=new t.Rectangle,n.$enterFrameCallBackList=[],n.$renderCallBackList=[],n}(t.EventDispatcher);t.DisplayObject=i,t.registerClass(i,"egret.DisplayObject",["egret.sys.Renderable"])}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(n){e.call(this),this.$scale9Grid=null,this.$fillMode="scale",this._pixelHitTest=!1,this.$renderNode=new t.sys.BitmapNode,this.$Bitmap={0:null,1:null,2:0,3:0,4:0,5:0,6:0,7:0,8:0,9:0,10:i.defaultSmoothing,11:0/0,12:0/0},this.$setBitmapData(n)}__extends(i,e);var n=__define,r=i,s=r.prototype;return s.$onAddToStage=function(i,n){e.prototype.$onAddToStage.call(this,i,n);var r=this.$Bitmap[0];r&&t.Texture.$addDisplayObject(this,r)},s.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);var i=this.$Bitmap[0];i&&t.Texture.$removeDisplayObject(this,i)},n(s,"bitmapData",function(){var e=this.$Bitmap[0];return e instanceof t.Texture?null:e},function(t){this.$setBitmapData(t)}),n(s,"texture",function(){var e=this.$Bitmap[0];return e instanceof t.Texture?e:null},function(t){this.$setBitmapData(t)}),s.$setBitmapData=function(e){var i=this.$Bitmap,n=i[0];if(e==n)return!1;if(i[0]=e,!e)return n&&t.Texture.$removeDisplayObject(this,n),this.setImageData(null,0,0,0,0,0,0,0,0,0,0),this.$invalidateContentBounds(),!0;if(this.$refreshImageData(),this.$stage){if(n){var r;r=n._bitmapData&&n._bitmapData.hashCode?n._bitmapData.hashCode:n.hashCode;var s;if(s=e._bitmapData&&e._bitmapData.hashCode?e._bitmapData.hashCode:e.hashCode,r==s)return this.$invalidateContentBounds(),!0;t.Texture.$removeDisplayObject(this,n)}t.Texture.$addDisplayObject(this,e)}return this.$invalidateContentBounds(),!0},s.$refreshImageData=function(){var e=this.$Bitmap,i=e[0];if(i)if(i instanceof t.Texture){var n=i;this.setImageData(n._bitmapData,n._bitmapX,n._bitmapY,n._bitmapWidth,n._bitmapHeight,n._offsetX,n._offsetY,n.$getTextureWidth(),n.$getTextureHeight(),n._sourceWidth,n._sourceHeight)}else{var r=i.width,s=i.height;this.setImageData(i,0,0,r,s,0,0,r,s,r,s)}},s.setImageData=function(t,e,i,n,r,s,a,o,h,l,u){var c=this.$Bitmap;c[1]=t,c[2]=e,c[3]=i,c[4]=n,c[5]=r,c[6]=s,c[7]=a,c[8]=o,c[9]=h,c[13]=l,c[14]=u},n(s,"scale9Grid",function(){return this.$scale9Grid},function(t){this.$scale9Grid=t,this.$invalidateContentBounds()}),n(s,"fillMode",function(){return this.$fillMode},function(t){this.$setFillMode(t)}),s.$setFillMode=function(t){return t==this.$fillMode?!1:(this.$fillMode=t,!0)},n(s,"smoothing",function(){var t=this.$Bitmap;return t[10]},function(t){t=!!t;var e=this.$Bitmap;t!=e[10]&&(e[10]=t,this.$invalidate())}),s.$setWidth=function(t){var e=this.$Bitmap;return 0>t||t==e[11]?!1:(e[11]=t,this.$invalidateContentBounds(),!0)},s.$setHeight=function(t){var e=this.$Bitmap;return 0>t||t==e[12]?!1:(e[12]=t,this.$invalidateContentBounds(),!0)},s.$getWidth=function(){var t=this.$Bitmap;return isNaN(t[11])?this.$getContentBounds().width:t[11]},s.$getHeight=function(){var t=this.$Bitmap;return isNaN(t[12])?this.$getContentBounds().height:t[12]},s.$measureContentBounds=function(t){var e=this.$Bitmap;if(e[1]){var e=this.$Bitmap,i=isNaN(e[11])?e[8]:e[11],n=isNaN(e[12])?e[9]:e[12];t.setTo(0,0,i,n)}else i=isNaN(e[11])?0:e[11],n=isNaN(e[12])?0:e[12],t.setTo(0,0,i,n)},s.$render=function(){var e=this.$Bitmap;if(e[1]){var i=isNaN(e[11])?e[8]:e[11],n=isNaN(e[12])?e[9]:e[12];t.sys.BitmapNode.$updateTextureData(this.$renderNode,e[1],e[2],e[3],e[4],e[5],e[6],e[7],e[8],e[9],i,n,e[13],e[14],this.scale9Grid||e[0].scale9Grid,this.fillMode,e[10])}},n(s,"pixelHitTest",function(){return this._pixelHitTest},function(t){this._pixelHitTest=!!t}),s.$hitTest=function(t,i){var n=e.prototype.$hitTest.call(this,t,i);return n&&this._pixelHitTest&&(n=this.hitTestPixel(t,i)),n},s.hitTestPixel=function(e,i){var n,r=this.$getInvertedConcatenatedMatrix(),s=r.a*e+r.c*i+r.tx,a=r.b*e+r.d*i+r.ty,o=this.$displayList;if(o){var h=o.renderBuffer;try{n=h.getPixel(s-o.offsetX,a-o.offsetY)}catch(l){throw console.log(this.$Bitmap[0]),new Error(t.sys.tr(1039))}}else{var h=t.sys.hitTestBuffer;h.resize(3,3);var u=this.$getRenderNode(),c=t.Matrix.create();c.identity(),c.translate(1-s,1-a),t.sys.canvasRenderer.drawNodeToBuffer(u,h,c,!0),t.Matrix.release(c);try{n=h.getPixel(1,1)}catch(l){throw console.log(this.$Bitmap[0]),new Error(t.sys.tr(1039))}}return 0===n[3]?null:this},i.$drawImage=function(e,i,n,r,s,a,o,h,l,u,c,d,f,g,p,v,$){console.warn("deprecated method : Bitmap.$drawImage,use egret.sys.BitmapNode.$drawImage instead of it"),t.sys.BitmapNode.$updateTextureData.call(this,arguments)},i.defaultSmoothing=!0,i}(t.DisplayObject);t.Bitmap=e,t.registerClass(e,"egret.Bitmap")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.REPEAT="repeat",t.SCALE="scale",t.CLIP="clip",t}();t.BitmapFillMode=e,t.registerClass(e,"egret.BitmapFillMode")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.NORMAL="normal",t.ADD="add",t.ERASE="erase",t}();t.BlendMode=e,t.registerClass(e,"egret.BlendMode")}(egret||(egret={}));var egret;!function(t){var e;!function(t){function e(t){var e=r[t];return void 0===e?0:e}function i(t){var e=n[t];return void 0===e?"normal":e}for(var n=["normal","add","erase"],r={},s=n.length,a=0;s>a;a++){var o=n[a];r[o]=a}t.blendModeToNumber=e,t.numberToBlendMode=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.NONE="none",t.ROUND="round",t.SQUARE="square",t}();t.CapsStyle=e,t.registerClass(e,"egret.CapsStyle")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.OFF="off",t.ON="on",t}();t.DirtyRegionPolicy=e,t.registerClass(e,"egret.DirtyRegionPolicy")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){e.call(this),this.$touchChildren=!0,this.$children=[]}__extends(i,e);var n=__define,r=i,s=r.prototype;return s.$propagateFlagsDown=function(t){if(!this.$hasFlags(t)){this.$setFlags(t);for(var e=this.$children,i=e.length,n=0;i>n;n++)e[n].$propagateFlagsDown(t)}},n(s,"numChildren",function(){return this.$children.length}),s.addChild=function(t){var e=this.$children.length;return t.$parent==this&&e--,this.$doAddChild(t,e)},s.addChildAt=function(t,e){return e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length,t.$parent==this&&e--),this.$doAddChild(t,e)},s.$doAddChild=function(e,n,r){void 0===r&&(r=!0);var s=e.$parent;if(s==this)return this.doSetChildIndex(e,n),e;s&&s.removeChild(e),this.$children.splice(n,0,e),e.$setParent(this);var a=this.$stage;if(a&&e.$onAddToStage(a,this.$nestLevel+1),r&&e.dispatchEventWith(t.Event.ADDED,!0),a)for(var o=i.$EVENT_ADD_TO_STAGE_LIST;o.length;){var h=o.shift();h.$stage&&r&&h.dispatchEventWith(t.Event.ADDED_TO_STAGE)}var l=this.$displayList||this.$parentDisplayList;return this.assignParentDisplayList(e,l,l),e.$propagateFlagsDown(1648),this.$propagateFlagsUp(4),this.$childAdded(e,n),e},s.contains=function(t){for(;t;){if(t==this)return!0;t=t.$parent}return!1},s.getChildAt=function(t){return t=0|+t,t>=0&&tr;r++)if(e=i[r],e.name==t)return e;return null},s.removeChild=function(t){var e=this.$children.indexOf(t);return e>=0?this.$doRemoveChild(e):null},s.removeChildAt=function(t){return t=0|+t,t>=0&&t0;){var o=a.shift();n&&o.$hasAddToStage&&(o.$hasAddToStage=!1,o.dispatchEventWith(t.Event.REMOVED_FROM_STAGE)),o.$hasAddToStage=!1,o.$stage=null}}var h=this.$displayList||this.$parentDisplayList;this.assignParentDisplayList(s,h,null),s.$propagateFlagsDown(1648),s.$setParent(null);var l=r.indexOf(s);return r.splice(l,1),this.$propagateFlagsUp(4),s},s.setChildIndex=function(t,e){e=0|+e,(0>e||e>=this.$children.length)&&(e=this.$children.length-1),this.doSetChildIndex(t,e)},s.doSetChildIndex=function(t,e){var i=this.$children.indexOf(t);i!=e&&(this.$childRemoved(t,i),this.$children.splice(i,1),this.$children.splice(e,0,t),this.$childAdded(t,e),t.$invalidateTransform(),this.$propagateFlagsUp(4))},s.swapChildrenAt=function(t,e){t=0|+t,e=0|+e,t>=0&&t=0&&ee){var i=e;e=t,t=i}else if(t==e)return;var n=this.$children,r=n[t],s=n[e];this.$childRemoved(r,t),this.$childRemoved(s,e),n[t]=s,n[e]=r,this.$childAdded(s,t),this.$childAdded(r,e),r.$invalidateTransform(),s.$invalidateTransform(),this.$propagateFlagsUp(4)},s.removeChildren=function(){for(var t=this.$children,e=t.length-1;e>=0;e--)this.$doRemoveChild(e)},s.$childAdded=function(t,e){},s.$childRemoved=function(t,e){},s.$onAddToStage=function(t,i){e.prototype.$onAddToStage.call(this,t,i);var n=this.$children,r=n.length;i++;for(var s=0;r>s;s++){var a=this.$children[s];a.$onAddToStage(t,i)}},s.$onRemoveFromStage=function(){e.prototype.$onRemoveFromStage.call(this);for(var t=this.$children,i=t.length,n=0;i>n;n++){var r=t[n]; r.$onRemoveFromStage()}},s.$measureChildBounds=function(e){var i=this.$children,n=i.length;if(0!=n){for(var r=0,s=0,a=0,o=0,h=!1,l=-1;n>l;l++){var u=-1==l?e:i[l].$getTransformedBounds(this,t.$TempRectangle);u.isEmpty()||(h?(r=Math.min(r,u.x),s=Math.max(s,u.x+u.width),a=Math.min(a,u.y),o=Math.max(o,u.y+u.height)):(h=!0,r=u.x,s=r+u.width,a=u.y,o=a+u.height))}e.setTo(r,a,s-r,o-a)}},n(s,"touchChildren",function(){return this.$getTouchChildren()},function(t){this.$setTouchChildren(!!t)}),s.$getTouchChildren=function(){return this.$touchChildren},s.$setTouchChildren=function(t){return this.$touchChildren==t?!1:(this.$touchChildren=t,!0)},s.$invalidate=function(t){if(e.prototype.$invalidate.call(this,t),t){var i=this.$displayList||this.$parentDisplayList,n=this.$children;if(n)for(var r=n.length-1;r>=0;r--)this.markChildDirty(n[r],i)}},s.$invalidateTransform=function(){this.markChildDirty(this,this.$parentDisplayList)},s.markChildDirty=function(t,e){if(!t.$hasFlags(512)){t.$setFlags(512);var i=t.$displayList;if((i||t.$renderNode)&&e&&e.markDirty(i||t),!i){var n=t.$children;if(n)for(var r=n.length-1;r>=0;r--)this.markChildDirty(n[r],e)}}},s.$cacheAsBitmapChanged=function(){e.prototype.$cacheAsBitmapChanged.call(this);for(var t=this.$displayList||this.$parentDisplayList,i=this.$children,n=i.length-1;n>=0;n--)this.assignParentDisplayList(i[n],t,t)},s.assignParentDisplayList=function(t,e,i){t.$parentDisplayList=i,t.$setFlags(512);var n=t.$displayList;if((t.$renderNode||n)&&e&&e.markDirty(n||t),!n){var r=t.$children;if(r)for(var s=r.length-1;s>=0;s--)this.assignParentDisplayList(r[s],e,i)}},s.$hitTest=function(t,i){if(!this.$visible)return null;var n=this.$getInvertedConcatenatedMatrix(),r=n.a*t+n.c*i+n.tx,s=n.b*t+n.d*i+n.ty,a=this.$scrollRect?this.$scrollRect:this.$maskRect;if(a&&!a.contains(r,s))return null;if(this.$mask&&!this.$mask.$hitTest(t,i))return null;for(var o=this.$children,h=!1,l=o.length-1;l>=0;l--){var u=o[l];if(!u.$maskedObject){var c=u.$hitTest(t,i);if(c){if(h=!0,c.$touchEnabled)break;c=null}}}return c?this.$touchChildren?c:this:h?this:e.prototype.$hitTest.call(this,t,i)},s.$setAlpha=function(t){return t=+t||0,t==this.$alpha?!1:(this.$alpha=t,this.$propagateFlagsDown(64),this.$invalidate(),this.$invalidateAllChildren(),!0)},s.$invalidateAllChildren=function(){var t=this.$children;if(t)for(var e=t.length-1;e>=0;e--){var i=t[e];i.$invalidate(),i.$children&&i.$invalidateAllChildren()}},i.$EVENT_ADD_TO_STAGE_LIST=[],i.$EVENT_REMOVE_FROM_STAGE_LIST=[],i}(t.DisplayObject);t.DisplayObjectContainer=e,t.registerClass(e,"egret.DisplayObjectContainer")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.LINEAR="linear",t.RADIAL="radial",t}();t.GradientType=e,t.registerClass(e,"egret.GradientType")}(egret||(egret={}));var egret;!function(t){function e(t){return t%=2*Math.PI,0>t&&(t+=2*Math.PI),t}var i=function(i){function n(){i.call(this),this.lastX=0,this.lastY=0,this.fillPath=null,this.strokePath=null,this.topLeftStrokeWidth=0,this.bottomRightStrokeWidth=0,this.minX=1/0,this.minY=1/0,this.maxX=-(1/0),this.maxY=-(1/0),this.includeLastPosition=!0,this.$renderNode=new t.sys.GraphicsNode}__extends(n,i);var r=n,s=r.prototype;return s.$setTarget=function(t){this.targetDisplay&&(this.targetDisplay.$renderNode=null),t.$renderNode=this.$renderNode,this.targetDisplay=t},s.setStrokeWidth=function(t){switch(t){case 1:this.topLeftStrokeWidth=0,this.bottomRightStrokeWidth=1;break;case 3:this.topLeftStrokeWidth=1,this.bottomRightStrokeWidth=2;break;default:var e=0|Math.ceil(.5*t);this.topLeftStrokeWidth=e,this.bottomRightStrokeWidth=e}},s.beginFill=function(t,e){void 0===e&&(e=1),t=+t||0,e=+e||0,this.fillPath=this.$renderNode.beginFill(t,e,this.strokePath),this.$renderNode.drawData.length>1&&this.fillPath.moveTo(this.lastX,this.lastY)},s.beginGradientFill=function(t,e,i,n,r){void 0===r&&(r=null),this.fillPath=this.$renderNode.beginGradientFill(t,e,i,n,r,this.strokePath),this.$renderNode.drawData.length>1&&this.fillPath.moveTo(this.lastX,this.lastY)},s.endFill=function(){this.fillPath=null},s.lineStyle=function(t,e,i,n,r,s,a,o){void 0===t&&(t=0/0),void 0===e&&(e=0),void 0===i&&(i=1),void 0===n&&(n=!1),void 0===r&&(r="normal"),void 0===s&&(s=null),void 0===a&&(a=null),void 0===o&&(o=3),t=+t||0,0>=t?(this.strokePath=null,this.setStrokeWidth(0)):(e=+e||0,i=+i||0,o=+o||0,this.setStrokeWidth(t),this.strokePath=this.$renderNode.lineStyle(t,e,i,s,a,o),this.$renderNode.drawData.length>1&&this.strokePath.moveTo(this.lastX,this.lastY))},s.drawRect=function(t,e,i,n){t=+t||0,e=+e||0,i=+i||0,n=+n||0;var r=this.fillPath,s=this.strokePath;r&&r.drawRect(t,e,i,n),s&&s.drawRect(t,e,i,n),this.extendBoundsByPoint(t+i,e+n),this.updatePosition(t,e),this.$renderNode.dirtyRender=!0},s.drawRoundRect=function(t,e,i,n,r,s){t=+t||0,e=+e||0,i=+i||0,n=+n||0,r=+r||0,s=+s||0;var a=this.fillPath,o=this.strokePath;a&&a.drawRoundRect(t,e,i,n,r,s),o&&o.drawRoundRect(t,e,i,n,r,s);var h=.5*r|0,l=s?.5*s|0:h,u=t+i,c=e+n,d=c-l;this.extendBoundsByPoint(t,e),this.extendBoundsByPoint(u,c),this.updatePosition(u,d),this.$renderNode.dirtyRender=!0},s.drawCircle=function(t,e,i){t=+t||0,e=+e||0,i=+i||0;var n=this.fillPath,r=this.strokePath;n&&n.drawCircle(t,e,i),r&&r.drawCircle(t,e,i),this.extendBoundsByPoint(t-i,e-i),this.extendBoundsByPoint(t+i,e+i),this.updatePosition(t+i,e),this.$renderNode.dirtyRender=!0},s.drawEllipse=function(t,e,i,n){t=+t||0,e=+e||0,i=+i||0,n=+n||0;var r=this.fillPath,s=this.strokePath;r&&r.drawEllipse(t,e,i,n),s&&s.drawEllipse(t,e,i,n),this.extendBoundsByPoint(t+i,e+n),this.updatePosition(t,e),this.$renderNode.dirtyRender=!0},s.moveTo=function(t,e){t=+t||0,e=+e||0;var i=this.fillPath,n=this.strokePath;i&&i.moveTo(t,e),n&&n.moveTo(t,e),this.includeLastPosition=!1,this.lastX=t,this.lastY=e,this.$renderNode.dirtyRender=!0},s.lineTo=function(t,e){t=+t||0,e=+e||0;var i=this.fillPath,n=this.strokePath;i&&i.lineTo(t,e),n&&n.lineTo(t,e),this.updatePosition(t,e),this.$renderNode.dirtyRender=!0},s.curveTo=function(t,e,i,n){t=+t||0,e=+e||0,i=+i||0,n=+n||0;var r=this.fillPath,s=this.strokePath;r&&r.curveTo(t,e,i,n),s&&s.curveTo(t,e,i,n),this.extendBoundsByPoint(t,e),this.extendBoundsByPoint(i,n),this.updatePosition(i,n),this.$renderNode.dirtyRender=!0},s.cubicCurveTo=function(t,e,i,n,r,s){t=+t||0,e=+e||0,i=+i||0,n=+n||0,r=+r||0,s=+s||0;var a=this.fillPath,o=this.strokePath;a&&a.cubicCurveTo(t,e,i,n,r,s),o&&o.cubicCurveTo(t,e,i,n,r,s),this.extendBoundsByPoint(t,e),this.extendBoundsByPoint(i,n),this.extendBoundsByPoint(r,s),this.updatePosition(r,s),this.$renderNode.dirtyRender=!0},s.drawArc=function(t,i,n,r,s,a){if(!(0>n||r===s)){t=+t||0,i=+i||0,n=+n||0,r=+r||0,s=+s||0,a=!!a,r=e(r),s=e(s);var o=this.fillPath,h=this.strokePath;o&&o.drawArc(t,i,n,r,s,a),h&&h.drawArc(t,i,n,r,s,a),a?this.arcBounds(t,i,n,s,r):this.arcBounds(t,i,n,r,s);var l=t+Math.cos(s)*n,u=i+Math.sin(s)*n;this.updatePosition(l,u),this.$renderNode.dirtyRender=!0}},s.arcBounds=function(t,e,i,n,r){var s=Math.PI;if(Math.abs(n-r)<.01)return this.extendBoundsByPoint(t-i,e-i),void this.extendBoundsByPoint(t+i,e+i);n>r&&(r+=2*s);for(var a=Math.cos(n)*i,o=Math.cos(r)*i,h=Math.min(a,o),l=Math.max(a,o),u=Math.sin(n)*i,c=Math.sin(r)*i,d=Math.min(u,c),f=Math.max(u,c),g=n/(.5*s),p=r/(.5*s),v=Math.ceil(g);p>=v;v++)switch(v%4){case 0:l=i;break;case 1:f=i;break;case 2:h=-i;break;case 3:d=-i}h=Math.floor(h),d=Math.floor(d),l=Math.ceil(l),f=Math.ceil(f),this.extendBoundsByPoint(h+t,d+e),this.extendBoundsByPoint(l+t,f+e)},s.clear=function(){this.$renderNode.clear(),this.updatePosition(0,0),this.minX=1/0,this.minY=1/0,this.maxX=-(1/0),this.maxY=-(1/0)},s.extendBoundsByPoint=function(t,e){this.extendBoundsByX(t),this.extendBoundsByY(e)},s.extendBoundsByX=function(t){this.minX=Math.min(this.minX,t-this.topLeftStrokeWidth),this.maxX=Math.max(this.maxX,t+this.bottomRightStrokeWidth),this.updateNodeBounds()},s.extendBoundsByY=function(t){this.minY=Math.min(this.minY,t-this.topLeftStrokeWidth),this.maxY=Math.max(this.maxY,t+this.bottomRightStrokeWidth),this.updateNodeBounds()},s.updateNodeBounds=function(){var t=this.$renderNode;t.x=this.minX,t.y=this.minY,t.width=Math.ceil(this.maxX-this.minX),t.height=Math.ceil(this.maxY-this.minY)},s.updatePosition=function(t,e){this.includeLastPosition||(this.extendBoundsByPoint(this.lastX,this.lastY),this.includeLastPosition=!0),this.lastX=t,this.lastY=e,this.extendBoundsByPoint(t,e),this.targetDisplay.$invalidateContentBounds()},s.$measureContentBounds=function(t){this.minX===1/0?t.setEmpty():t.setTo(this.minX,this.minY,this.maxX-this.minX,this.maxY-this.minY)},s.$hitTest=function(e,i){var n=this.targetDisplay,r=n.$getInvertedConcatenatedMatrix(),s=r.a*e+r.c*i+r.tx,a=r.b*e+r.d*i+r.ty,o=t.sys.hitTestBuffer;o.resize(3,3);var h=this.$renderNode,l=t.Matrix.create();l.identity(),l.translate(1-s,1-a),t.sys.canvasRenderer.drawNodeToBuffer(h,o,l,!0),t.Matrix.release(l);try{var u=o.getPixel(1,1)}catch(c){throw new Error(t.sys.tr(1039))}return 0===u[3]?null:n},n}(t.HashObject);t.Graphics=i,t.registerClass(i,"egret.Graphics")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.BEVEL="bevel",t.MITER="miter",t.ROUND="round",t}();t.JointStyle=e,t.registerClass(e,"egret.JointStyle")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(i){e.call(this,i),this._verticesDirty=!0,this._bounds=new t.Rectangle,this.$renderNode=new t.sys.MeshNode}__extends(i,e);var n=i,r=n.prototype;return r.$render=function(){var e=this.$Bitmap,i=e[1];if(i){var n=(t.$TextureScaleFactor,this.$renderNode);n.smoothing=e[10],n.image=i,n.imageWidth=e[13],n.imageHeight=e[14];var r=isNaN(e[11])?e[8]:e[11],s=isNaN(e[12])?e[9]:e[12],a=r/e[8],o=s/e[9],h=e[4],l=e[5];n.drawMesh(e[2],e[3],h,l,e[6]*a,e[7]*o,a*h,o*l)}},r.$updateVertices=function(){this._verticesDirty=!0,this.$invalidateContentBounds()},r.$measureContentBounds=function(t){if(this._verticesDirty){this._verticesDirty=!1;var e=this.$renderNode,i=e.vertices;if(i.length){this._bounds.setTo(Number.MAX_VALUE,Number.MAX_VALUE,Number.MIN_VALUE,Number.MIN_VALUE);for(var n=0,r=i.length;r>n;n+=2){var s=i[n],a=i[n+1];this._bounds.x>s&&(this._bounds.x=s),this._bounds.widtha&&(this._bounds.y=a),this._bounds.height=0&&r.splice(s)}},i.$invalidate=function(e){var n;if(n=e._bitmapData&&e._bitmapData.hashCode?e._bitmapData.hashCode:e.hashCode,n&&i._displayList[n])for(var r=i._displayList[n],s=0;s=0;l--){var u=o[l];if(!u.$maskedObject){var c=u.$hitTest(e,i);if(c){if(h=!0,c.$touchEnabled)break;c=null}}}return c?this.$touchChildren?c:this:h?this:(c=t.DisplayObject.prototype.$hitTest.call(this,e,i),c&&(c=this.$graphics.$hitTest(e,i)),c)},s.$measureContentBounds=function(t){this.$graphics.$measureContentBounds(t)},i}(t.DisplayObjectContainer);t.Sprite=e,t.registerClass(e,"egret.Sprite")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t){e.call(this),this._bitmapX=0,this._bitmapY=0,this._textureMap={},this.$texture=t,this._bitmapX=t._bitmapX-t._offsetX,this._bitmapY=t._bitmapY-t._offsetY}__extends(i,e);var n=i,r=n.prototype;return r.getTexture=function(t){return this._textureMap[t]},r.createTexture=function(e,i,n,r,s,a,o,h,l){void 0===a&&(a=0),void 0===o&&(o=0),void 0===h&&(h=a+r),void 0===l&&(l=o+s);var u=new t.Texture;return u._bitmapData=this.$texture._bitmapData,u.$initData(this._bitmapX+i,this._bitmapY+n,r,s,a,o,h,l,this.$texture._sourceWidth,this.$texture._sourceHeight),this._textureMap[e]=u,u},r.dispose=function(){this.$texture&&this.$texture.dispose()},i}(t.HashObject);t.SpriteSheet=e,t.registerClass(e,"egret.SpriteSheet")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){e.call(this),this.$stageWidth=0,this.$stageHeight=0,this.implMap={},this.$scaleMode=t.StageScaleMode.SHOW_ALL,this.$orientation=t.OrientationMode.AUTO,this.$maxTouches=99,this.$dirtyRegionPolicy=t.DirtyRegionPolicy.ON,this.$stage=this,this.$nestLevel=1}__extends(i,e);var n=__define,r=i,s=r.prototype;return n(s,"frameRate",function(){return t.sys.$ticker.$frameRate},function(e){t.sys.$ticker.$setFrameRate(e)}),n(s,"stageWidth",function(){return this.$stageWidth}),n(s,"stageHeight",function(){return this.$stageHeight}),s.invalidate=function(){t.sys.$invalidateRenderFlag=!0},s.registerImplementation=function(t,e){this.implMap[t]=e},s.getImplementation=function(t){return this.implMap[t]},n(s,"scaleMode",function(){return this.$scaleMode},function(t){this.$scaleMode!=t&&(this.$scaleMode=t,this.$screen.updateScreenSize())}),n(s,"orientation",function(){return this.$orientation},function(t){this.$orientation!=t&&(this.$orientation=t,this.$screen.updateScreenSize())}),n(s,"textureScaleFactor",function(){return t.$TextureScaleFactor},function(e){t.$TextureScaleFactor=e}),n(s,"maxTouches",function(){return this.$maxTouches},function(t){this.$maxTouches!=t&&(this.$maxTouches=t,this.$screen.updateMaxTouches())}),n(s,"dirtyRegionPolicy",function(){return this.$dirtyRegionPolicy},function(t){this.$dirtyRegionPolicy!=t&&(this.$dirtyRegionPolicy=t,this.$displayList.setDirtyRegionPolicy(t))}),s.setContentSize=function(t,e){this.$screen.setContentSize(t,e)},i}(t.DisplayObjectContainer);t.Stage=e,t.registerClass(e,"egret.Stage")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,n,r){t.call(this),this.$eventPhase=2,this.$currentTarget=null,this.$target=null,this.$isDefaultPrevented=!1,this.$isPropagationStopped=!1,this.$isPropagationImmediateStopped=!1,this.$type=e,this.$bubbles=!!i,this.$cancelable=!!n,this.data=r}__extends(e,t);var i=__define,n=e,r=n.prototype;return i(r,"type",function(){return this.$type}),i(r,"bubbles",function(){return this.$bubbles}),i(r,"cancelable",function(){return this.$cancelable}),i(r,"eventPhase",function(){return this.$eventPhase}),i(r,"currentTarget",function(){return this.$currentTarget}),i(r,"target",function(){return this.$target}),r.$setTarget=function(t){return this.$target=t,!0},r.isDefaultPrevented=function(){return this.$isDefaultPrevented},r.preventDefault=function(){this.$cancelable&&(this.$isDefaultPrevented=!0)},r.stopPropagation=function(){this.$bubbles&&(this.$isPropagationStopped=!0)},r.stopImmediatePropagation=function(){this.$bubbles&&(this.$isPropagationImmediateStopped=!0)},r.clean=function(){this.data=this.$currentTarget=null,this.$setTarget(null)},e.dispatchEvent=function(t,i,n,r){void 0===n&&(n=!1);var s=e.create(e,i,n),a=e._getPropertyData(e);void 0!=r&&(a.data=r);var o=t.dispatchEvent(s);return e.release(s),o},e._getPropertyData=function(t){var e=t._props;return e||(e=t._props={}),e},e.create=function(t,e,i,n){var r=t.eventPool;if(r||(r=t.eventPool=[]),r.length){var s=r.pop();return s.$type=e,s.$bubbles=!!i,s.$cancelable=!!n,s.$isDefaultPrevented=!1,s.$isPropagationStopped=!1,s.$isPropagationImmediateStopped=!1,s.$eventPhase=2,s}return new t(e,i,n)},e.release=function(t){t.clean();var e=Object.getPrototypeOf(t).constructor;e.eventPool.push(t)},e.ADDED_TO_STAGE="addedToStage",e.REMOVED_FROM_STAGE="removedFromStage",e.ADDED="added",e.REMOVED="removed",e.ENTER_FRAME="enterFrame",e.RENDER="render",e.RESIZE="resize",e.CHANGE="change",e.CHANGING="changing",e.COMPLETE="complete",e.LOOP_COMPLETE="loopComplete",e.FOCUS_IN="focusIn",e.FOCUS_OUT="focusOut",e.ENDED="ended",e.ACTIVATE="activate",e.DEACTIVATE="deactivate",e.CLOSE="close",e.CONNECT="connect",e.LEAVE_STAGE="leaveStage",e.SOUND_COMPLETE="soundComplete",e}(t.HashObject);t.Event=e,t.registerClass(e,"egret.Event")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1),t.call(this,e,i,n)}__extends(e,t);var i=e;i.prototype;return e.FOCUS_IN="focusIn",e.FOCUS_OUT="focusOut",e}(t.Event);t.FocusEvent=e,t.registerClass(e,"egret.FocusEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){t.apply(this,arguments)}__extends(e,t);var i=e;i.prototype;return e.PERMISSION_DENIED="permissionDenied",e.UNAVAILABLE="unavailable",e}(t.Event);t.GeolocationEvent=e,t.registerClass(e,"egret.GeolocationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1),e.call(this,t,i,n),this._status=0}__extends(i,e);var n=__define,r=i,s=r.prototype;return n(s,"status",function(){return this._status}),i.dispatchHTTPStatusEvent=function(e,n){var r=t.Event.create(i,i.HTTP_STATUS);r._status=n;var s=e.dispatchEvent(r);return t.Event.release(r),s},i.HTTP_STATUS="httpStatus",i}(t.Event);t.HTTPStatusEvent=e,t.registerClass(e,"egret.HTTPStatusEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1),e.call(this,t,i,n)}__extends(i,e);var n=i;n.prototype;return i.dispatchIOErrorEvent=function(e){var n=t.Event.create(i,i.IO_ERROR),r=e.dispatchEvent(n);return t.Event.release(n),r},i.IO_ERROR="ioError",i}(t.Event);t.IOErrorEvent=e,t.registerClass(e,"egret.IOErrorEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){t.apply(this,arguments)}__extends(e,t);var i=e;i.prototype;return e}(t.Event);t.MotionEvent=e,t.registerClass(e,"egret.MotionEvent")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){t.apply(this,arguments)}__extends(e,t);var i=e;i.prototype;return e}(t.Event);t.OrientationEvent=e,t.registerClass(e,"egret.OrientationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,n,r,s){void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===r&&(r=0),void 0===s&&(s=0),e.call(this,t,i,n),this.bytesLoaded=0,this.bytesTotal=0,this.bytesLoaded=r,this.bytesTotal=s}__extends(i,e);var n=i;n.prototype;return i.dispatchProgressEvent=function(e,n,r,s){void 0===r&&(r=0),void 0===s&&(s=0);var a=t.Event.create(i,n);a.bytesLoaded=r,a.bytesTotal=s;var o=e.dispatchEvent(a);return t.Event.release(a),o},i.PROGRESS="progress",i.SOCKET_DATA="socketData",i}(t.Event);t.ProgressEvent=e,t.registerClass(e,"egret.ProgressEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,n){void 0===i&&(i=!1),void 0===n&&(n=!1),e.call(this,t,i,n)}__extends(i,e);var n=i;n.prototype;return i.dispatchStageOrientationEvent=function(e,n){var r=t.Event.create(i,n),s=e.dispatchEvent(r);return t.Event.release(r),s},i.ORIENTATION_CHANGE="orientationChange",i}(t.Event);t.StageOrientationEvent=e,t.registerClass(e,"egret.StageOrientationEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,n,r){void 0===i&&(i=!1),void 0===n&&(n=!1),void 0===r&&(r=""),e.call(this,t,i,n),this.text=r}__extends(i,e);var n=i;n.prototype;return i.dispatchTextEvent=function(e,n,r){var s=t.Event.create(i,n);s.text=r;var a=e.dispatchEvent(s);return t.Event.release(s),a},i.LINK="link",i}(t.Event);t.TextEvent=e,t.registerClass(e,"egret.TextEvent")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i,n){e.call(this,t,i,n)}__extends(i,e);var n=i,r=n.prototype;return r.updateAfterEvent=function(){t.sys.$requestRenderingFlag=!0},i.dispatchTimerEvent=function(e,n,r,s){var a=t.Event.create(i,n,r,s),o=e.dispatchEvent(a);return t.Event.release(a),o},i.TIMER="timer",i.TIMER_COMPLETE="timerComplete",i}(t.Event);t.TimerEvent=e,t.registerClass(e,"egret.TimerEvent")}(egret||(egret={}));var egret;!function(t){var e=[],i=Math.PI/180,n=function(n){function r(t,e){void 0===t&&(t=0),void 0===e&&(e=0),n.call(this),this.x=t,this.y=e}__extends(r,n);var s=__define,a=r,o=a.prototype;return r.release=function(t){t&&e.push(t)},r.create=function(t,i){var n=e.pop();return n||(n=new r),n.setTo(t,i)},s(o,"length",function(){return Math.sqrt(this.x*this.x+this.y*this.y)}),o.setTo=function(t,e){return this.x=t,this.y=e,this},o.clone=function(){return new r(this.x,this.y)},o.equals=function(t){return this.x==t.x&&this.y==t.y},r.distance=function(t,e){return Math.sqrt((t.x-e.x)*(t.x-e.x)+(t.y-e.y)*(t.y-e.y))},o.copyFrom=function(t){this.x=t.x,this.y=t.y},o.add=function(t){return new r(this.x+t.x,this.y+t.y)},r.interpolate=function(t,e,i){var n=1-i;return new r(t.x*i+e.x*n,t.y*i+e.y*n)},o.normalize=function(t){if(0!=this.x||0!=this.y){var e=t/this.length;this.x*=e,this.y*=e}},o.offset=function(t,e){this.x+=t,this.y+=e},r.polar=function(e,n){return new r(e*t.NumberUtils.cos(n/i),e*t.NumberUtils.sin(n/i))},o.subtract=function(t){return new r(this.x-t.x,this.y-t.y)},o.toString=function(){return"(x="+this.x+", y="+this.y+")"},r}(t.HashObject);t.Point=n,t.registerClass(n,"egret.Point"),t.$TempPoint=new n}(egret||(egret={}));var egret;!function(t){var e=new t.Point,i=function(i){function n(t,e,n,r,s,a){i.call(this,t,e,n),this.targetChanged=!0,this.touchDown=!1,this.$initTo(r,s,a)}__extends(n,i);var r=__define,s=n,a=s.prototype;return a.$initTo=function(t,e,i){this.touchPointID=+i||0,this.$stageX=+t||0,this.$stageY=+e||0},r(a,"stageX",function(){return this.$stageX}),r(a,"stageY",function(){return this.$stageY}),r(a,"localX",function(){return this.targetChanged&&this.getLocalXY(),this._localX}),r(a,"localY",function(){return this.targetChanged&&this.getLocalXY(),this._localY}),a.getLocalXY=function(){this.targetChanged=!1;var t=this.$target.$getInvertedConcatenatedMatrix();t.transformPoint(this.$stageX,this.$stageY,e),this._localX=e.x,this._localY=e.y},a.$setTarget=function(t){return this.$target=t,this.targetChanged=!!t,!0},a.updateAfterEvent=function(){t.sys.$requestRenderingFlag=!0},n.dispatchTouchEvent=function(e,i,r,s,a,o,h,l){if(void 0===l&&(l=!1),!r&&!e.hasEventListener(i))return!0;var u=t.Event.create(n,i,r,s);u.$initTo(a,o,h),u.touchDown=l;var c=e.dispatchEvent(u);return t.Event.release(u),c},n.TOUCH_MOVE="touchMove",n.TOUCH_BEGIN="touchBegin",n.TOUCH_END="touchEnd",n.TOUCH_CANCEL="touchcancel",n.TOUCH_TAP="touchTap",n.TOUCH_RELEASE_OUTSIDE="touchReleaseOutside",n.TOUCH_ROLL_OUT="touchRollOut",n.TOUCH_ROLL_OVER="touchRollOver",n}(t.Event);t.TouchEvent=i,t.registerClass(i,"egret.TouchEvent")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(){t.apply(this,arguments),this.type=null,this.$targets=[]}__extends(e,t);var i=e,n=i.prototype;return n.$addTarget=function(t){for(var e=this.$targets.length,i=0;e>i;i++)if(this.$targets[i].$hashCode==t.$hashCode)return;this.$targets.push(t)},n.$removeTarget=function(t){for(var e=this.$targets.length,i=0;e>i;i++)if(this.$targets[i].$hashCode==t.$hashCode)return void this.$targets.splice(i,1)},n.invalidate=function(){for(var t=this.$targets.length,e=0;t>e;e++)this.$targets[e].$invalidateContentBounds()},e}(t.HashObject);t.Filter=e,t.registerClass(e,"egret.Filter")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,n){void 0===e&&(e=4),void 0===i&&(i=4),void 0===n&&(n=1),t.call(this),this.type="blur",this.$blurX=e,this.$blurY=i,this.$quality=n}__extends(e,t);var i=__define,n=e,r=n.prototype;return i(r,"blurX",function(){return this.$blurX},function(t){this.$blurX!=t&&(this.$blurX=t,this.invalidate())}),i(r,"blurY",function(){return this.$blurY},function(t){this.$blurY!=t&&(this.$blurY=t,this.invalidate())}),e}(t.Filter);t.BlurFilter=e,t.registerClass(e,"egret.BlurFilter")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e){void 0===e&&(e=null),t.call(this),this.$matrix=[],this.matrix2=[],this.type="colorTransform",this.setMatrix(e)}__extends(e,t);var i=__define,n=e,r=n.prototype;return i(r,"matrix",function(){for(var t=0;20>t;t++)this.matrix2[t]=this.$matrix[t];return this.matrix2},function(t){this.setMatrix(t),this.invalidate()}),r.setMatrix=function(t){if(t)for(var e=0;20>e;e++)this.$matrix[e]=t[e];else for(var e=0;20>e;e++)this.$matrix[e]=0==e||6==e||12==e||18==e?1:0},e}(t.Filter);t.ColorMatrixFilter=e,t.registerClass(e,"egret.ColorMatrixFilter")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,n,r,s,a,o,h){void 0===e&&(e=16711680),void 0===i&&(i=1),void 0===n&&(n=6),void 0===r&&(r=6),void 0===s&&(s=2),void 0===a&&(a=1),void 0===o&&(o=!1),void 0===h&&(h=!1),t.call(this),this.type="glow",this.$color=e,this.$blue=255&e,this.$green=(65280&e)>>8,this.$red=e>>16,this.$alpha=i,this.$blurX=n,this.$blurY=r,this.$strength=s,this.$quality=a,this.$inner=o,this.$knockout=h}__extends(e,t);var i=__define,n=e,r=n.prototype;return i(r,"color",function(){return this.$color},function(t){this.$color!=t&&(this.$color=t,this.$blue=255&t,this.$green=(65280&t)>>8,this.$red=t>>16,this.invalidate())}),i(r,"alpha",function(){return this.$alpha},function(t){this.$alpha!=t&&(this.$alpha=t,this.invalidate())}),i(r,"blurX",function(){return this.$blurX},function(t){this.$blurX!=t&&(this.$blurX=t,this.invalidate())}),i(r,"blurY",function(){return this.$blurY},function(t){this.$blurY!=t&&(this.$blurY=t,this.invalidate())}),i(r,"strength",function(){return this.$strength},function(t){this.$strength!=t&&(this.$strength=t,this.invalidate())}),i(r,"quality",function(){return this.$quality},function(t){this.$quality!=t&&(this.$quality=t,this.invalidate())}),i(r,"inner",function(){return this.$inner},function(t){this.$inner!=t&&(this.$inner=t,this.invalidate())}),i(r,"knockout",function(){return this.$knockout},function(t){this.$knockout!=t&&(this.$knockout=t,this.invalidate())}),e}(t.Filter);t.GlowFilter=e,t.registerClass(e,"egret.GlowFilter")}(egret||(egret={}));var egret;!function(t){var e=function(t){function e(e,i,n,r,s,a,o,h,l,u,c){void 0===e&&(e=4),void 0===i&&(i=45),void 0===n&&(n=0),void 0===r&&(r=1),void 0===s&&(s=4),void 0===a&&(a=4),void 0===o&&(o=1),void 0===h&&(h=1),void 0===l&&(l=!1),void 0===u&&(u=!1),void 0===c&&(c=!1),t.call(this,n,r,s,a,o,h,l,u),this.$distance=e,this.$angle=i,this.$hideObject=c}__extends(e,t);var i=__define,n=e,r=n.prototype;return i(r,"distance",function(){return this.$distance},function(t){this.$distance!=t&&(this.$distance=t,this.invalidate())}),i(r,"angle",function(){return this.$angle},function(t){this.$angle!=t&&(this.$angle=t,this.invalidate())}),i(r,"hideObject",function(){return this.$hideObject},function(t){this.$hideObject!=t&&(this.$hideObject=t,this.invalidate())}),e}(t.GlowFilter);t.DropShadowFilter=e,t.registerClass(e,"egret.DropShadowFilter")}(egret||(egret={}));var egret;!function(t){var e=Math.PI,i=2*e,n=e/180,r=[],s=function(s){function a(t,e,i,n,r,a){void 0===t&&(t=1),void 0===e&&(e=0),void 0===i&&(i=0),void 0===n&&(n=1),void 0===r&&(r=0),void 0===a&&(a=0),s.call(this),this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=a}__extends(a,s);var o=a,h=o.prototype;return a.release=function(t){t&&r.push(t)},a.create=function(){var t=r.pop();return t||(t=new a),t},h.clone=function(){return new a(this.a,this.b,this.c,this.d,this.tx,this.ty)},h.concat=function(t){var e=this.a*t.a,i=0,n=0,r=this.d*t.d,s=this.tx*t.a+t.tx,a=this.ty*t.d+t.ty;(0!==this.b||0!==this.c||0!==t.b||0!==t.c)&&(e+=this.b*t.c,r+=this.c*t.b,i+=this.a*t.b+this.b*t.d,n+=this.c*t.a+this.d*t.c,s+=this.ty*t.c,a+=this.tx*t.b),this.a=e,this.b=i,this.c=n,this.d=r,this.tx=s,this.ty=a +<<<<<<< HEAD },h.copyFrom=function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},h.identity=function(){this.a=this.d=1,this.b=this.c=this.tx=this.ty=0},h.invert=function(){this.$invertInto(this)},h.$invertInto=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=this.tx,a=this.ty;if(0==i&&0==n)return t.b=t.c=0,void(0==e||0==r?t.a=t.d=t.tx=t.ty=0:(e=t.a=1/e,r=t.d=1/r,t.tx=-e*s,t.ty=-r*a));var o=e*r-i*n;if(0==o)return void t.identity();o=1/o;var h=t.a=r*o;i=t.b=-i*o,n=t.c=-n*o,r=t.d=e*o,t.tx=-(h*s+n*a),t.ty=-(i*s+r*a)},h.rotate=function(e){if(e=+e,0!==e){e/=n;var i=t.NumberUtils.cos(e),r=t.NumberUtils.sin(e),s=this.a,a=this.b,o=this.c,h=this.d,l=this.tx,u=this.ty;this.a=s*i-a*r,this.b=s*r+a*i,this.c=o*i-h*r,this.d=o*r+h*i,this.tx=l*i-u*r,this.ty=l*r+u*i}},h.scale=function(t,e){1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e)},h.setTo=function(t,e,i,n,r,s){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s,this},h.transformPoint=function(e,i,n){var r=this.a*e+this.c*i+this.tx,s=this.b*e+this.d*i+this.ty;return n?(n.setTo(r,s),n):new t.Point(r,s)},h.translate=function(t,e){this.tx+=t,this.ty+=e},h.equals=function(t){return this.a==t.a&&this.b==t.b&&this.c==t.c&&this.d==t.d&&this.tx==t.tx&&this.ty==t.ty},h.prepend=function(t,e,i,n,r,s){var a=this.tx;if(1!=t||0!=e||0!=i||1!=n){var o=this.a,h=this.c;this.a=o*t+this.b*i,this.b=o*e+this.b*n,this.c=h*t+this.d*i,this.d=h*e+this.d*n}return this.tx=a*t+this.ty*i+r,this.ty=a*e+this.ty*n+s,this},h.append=function(t,e,i,n,r,s){var a=this.a,o=this.b,h=this.c,l=this.d;return(1!=t||0!=e||0!=i||1!=n)&&(this.a=t*a+e*h,this.b=t*o+e*l,this.c=i*a+n*h,this.d=i*o+n*l),this.tx=r*a+s*h+this.tx,this.ty=r*o+s*l+this.ty,this},h.deltaTransformPoint=function(e){var i=this,n=i.a*e.x+i.c*e.y,r=i.b*e.x+i.d*e.y;return new t.Point(n,r)},h.toString=function(){return"(a="+this.a+", b="+this.b+", c="+this.c+", d="+this.d+", tx="+this.tx+", ty="+this.ty+")"},h.createBox=function(e,i,r,s,a){void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0);var o=this;if(0!==r){r/=n;var h=t.NumberUtils.cos(r),l=t.NumberUtils.sin(r);o.a=h*e,o.b=l*i,o.c=-l*e,o.d=h*i}else o.a=e,o.b=0,o.c=0,o.d=i;o.tx=s,o.ty=a},h.createGradientBox=function(t,e,i,n,r){void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),this.createBox(t/1638.4,e/1638.4,i,n+t/2,r+e/2)},h.$transformBounds=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=this.tx,a=this.ty,o=t.x,h=t.y,l=o+t.width,u=h+t.height,c=e*o+n*h+s,d=i*o+r*h+a,f=e*l+n*h+s,g=i*l+r*h+a,p=e*l+n*u+s,v=i*l+r*u+a,$=e*o+n*u+s,y=i*o+r*u+a,m=0;c>f&&(m=c,c=f,f=m),p>$&&(m=p,p=$,$=m),t.x=Math.floor(p>c?c:p),t.width=Math.ceil((f>$?f:$)-t.x),d>g&&(m=d,d=g,g=m),v>y&&(m=v,v=y,y=m),t.y=Math.floor(v>d?d:v),t.height=Math.ceil((g>y?g:y)-t.y)},h.getDeterminant=function(){return this.a*this.d-this.b*this.c},h.$getScaleX=function(){var t=this;if(1==t.a&&0==t.b)return 1;var e=Math.sqrt(t.a*t.a+t.b*t.b);return this.getDeterminant()<0?-e:e},h.$getScaleY=function(){var t=this;if(0==t.c&&1==t.d)return 1;var e=Math.sqrt(t.c*t.c+t.d*t.d);return this.getDeterminant()<0?-e:e},h.$getSkewX=function(){return Math.atan2(this.d,this.c)-e/2},h.$getSkewY=function(){return Math.atan2(this.b,this.a)},h.$updateScaleAndRotation=function(e,r,s,a){if(!(0!=s&&s!=i||0!=a&&a!=i))return this.a=e,this.b=this.c=0,void(this.d=r);s/=n,a/=n;var o=t.NumberUtils.cos(s),h=t.NumberUtils.sin(s);s==a?(this.a=o*e,this.b=h*e):(this.a=t.NumberUtils.cos(a)*e,this.b=t.NumberUtils.sin(a)*e),this.c=-h*r,this.d=o*r},h.$preMultiplyInto=function(t,e){var i=t.a*this.a,n=0,r=0,s=t.d*this.d,a=t.tx*this.a+this.tx,o=t.ty*this.d+this.ty;(0!==t.b||0!==t.c||0!==this.b||0!==this.c)&&(i+=t.b*this.c,s+=t.c*this.b,n+=t.a*this.b+t.b*this.d,r+=t.c*this.a+t.d*this.c,a+=t.ty*this.c,o+=t.tx*this.b),e.a=i,e.b=n,e.c=r,e.d=s,e.tx=a,e.ty=o},a}(t.HashObject);t.Matrix=s,t.registerClass(s,"egret.Matrix"),t.$TempMatrix=new s}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.en_US=t.$locale_strings.en_US||{};var e=t.$locale_strings.en_US;e[1001]="Could not find Egret entry class: {0}。",e[1002]="Egret entry class '{0}' must inherit from egret.DisplayObject.",e[1003]="Parameter {0} must be non-null.",e[1004]="An object cannot be added as a child to one of it's children (or children's children, etc.).",e[1005]="An object cannot be added as a child of itself.",e[1006]="The supplied DisplayObject must be a child of the caller.",e[1007]="An index specified for a parameter was out of range.",e[1008]="Instantiate singleton error,singleton class {0} can not create multiple instances.",e[1009]='the Class {0} cannot use the property "{1}"',e[1010]='the property "{1}" of the Class "{0}" is readonly',e[1011]="Stream Error. URL: {0}",e[1012]="The type of parameter {0} must be Class.",e[1013]="Variable assignment is NaN, please see the code!",e[1014]='the constant "{1}" of the Class "{0}" is read-only',e[1015]="xml not found!",e[1016]="{0}has been obsoleted",e[1017]="The format of JSON file is incorrect: {0}\ndata: {1}",e[1018]="the scale9Grid is not correct",e[1019]="Network ab:{0}",e[1020]="Cannot initialize Shader",e[1021]="Current browser does not support webgl",e[1022]="{0} ArgumentError",e[1023]="This method is not available in the ScrollView!",e[1025]="end of the file",e[1026]="! EncodingError The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]=". called injection is not configured rule: {0}, please specify configuration during its initial years of injection rule, and then call the corresponding single case.",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="Photos can not be used across domains toDataURL to convert base64",e[1034]='Music file decoding failed: "{0}", please use the standard conversion tool reconversion under mp3.',e[1035]="Native does not support this feature!",e[1036]="Sound has stopped, please recall Sound.play () to play the sound!",e[1037]="Non-load the correct blob!",e[1038]="XML format error!",e[1039]="crossOrigin images can not set pixelHitTest property!",e[1040]="hitTestPoint can not detect crossOrigin images! Please check if the display object has crossOrigin elements.",e[1041]="egret.MainContext.runtimeType is deprecated, please use egret.Capabilities.runtimeType replace",e[1042]="The parameters passed in the region needs is an integer in drawToTexture method. Otherwise, some browsers will draw abnormal.",e[1043]="Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.",e[1044]="The current version of the Runtime does not support video playback, please use the latest version",e[1045]="The resource url is not found",e[1046]="BitmapText no corresponding characters: {0}, please check the configuration file",e[1047]="egret.localStorage.setItem save failed,key={0}&value={1}",e[1048]="Video loading failed",e[1049]="In the absence of sound is not allowed to play after loading",e[3e3]="Theme configuration file failed to load: {0}",e[3001]="Cannot find the skin name which is configured in Theme: {0}",e[3002]='Index:"{0}" is out of the collection element index range',e[3003]="Cannot be available in this component. If this component is container, please continue to use",e[3004]="addChild(){0}addElement() replace",e[3005]="addChildAt(){0}addElementAt() replace",e[3006]="removeChild(){0}removeElement() replace",e[3007]="removeChildAt(){0}removeElementAt() replace",e[3008]="setChildIndex(){0}setElementIndex() replace",e[3009]="swapChildren(){0}swapElements() replace",e[3010]="swapChildrenAt(){0}swapElementsAt() replace",e[3011]='Index:"{0}" is out of the visual element index range',e[3012]="This method is not available in Scroller component!",e[3013]="UIStage is GUI root container, and only one such instant is in the display list!",e[3014]="set fullscreen error",e[3100]="Current browser does not support WebSocket",e[3101]="Please connect Socket firstly",e[3102]="Please set the type of binary type",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!"}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$language="en_US"}(egret||(egret={}));var egret;!function(t){var e;!function(e){function i(e){for(var i=[],n=1;na;a++)r=r.replace("{"+a+"}",i[a]);return r}e.tr=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.zh_CN=t.$locale_strings.zh_CN||{};var e=t.$locale_strings.zh_CN;e[1001]="找不到Egret入口类: {0}。",e[1002]="Egret入口类 {0} 必须继承自egret.DisplayObject。",e[1003]="参数 {0} 不能为 null。",e[1004]="无法将对象添加为它的一个子对象(或子对象的子对象等)的子对象。",e[1005]="不能将对象添加为其自身的子对象。",e[1006]="提供的 DisplayObject 必须是调用者的子级。",e[1007]="为参数指定的索引不在范围内。",e[1008]="实例化单例出错,不允许实例化多个 {0} 对象。",e[1009]="类 {0} 不可以使用属性 {1}",e[1010]="类 {0} 属性 {1} 是只读的",e[1011]="流错误。URL: {0}",e[1012]="参数 {0} 的类型必须为 Class。",e[1013]="变量赋值为NaN,请查看代码!",e[1014]="类 {0} 常量 {1} 是只读的",e[1015]="xml not found!",e[1016]="{0}已经废弃",e[1017]="JSON文件格式不正确: {0}\ndata: {1}",e[1018]="9宫格设置错误",e[1019]="网络异常:{0}",e[1020]="无法初始化着色器",e[1021]="当前浏览器不支持webgl",e[1022]="{0} ArgumentError",e[1023]="此方法在ScrollView内不可用!",e[1025]="遇到文件尾",e[1026]="EncodingError! The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]="调用了未配置的注入规则:{0}。 请先在项目初始化里配置指定的注入规则,再调用对应单例。",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="跨域图片不可以使用toDataURL来转换成base64",e[1034]='音乐文件解码失败:"{0}",请使用标准的转换工具重新转换下mp3。',e[1035]="Native 下暂未实现此功能!",e[1036]="声音已停止,请重新调用 Sound.play() 来播放声音!",e[1037]="非正确的blob加载!",e[1038]="XML 格式错误!",e[1039]="跨域图片不能设置 pixelHitTest 属性!",e[1040]="hitTestPoint 不能对跨域图片进行检测! 请检查该显示对象内是否含有跨域元素",e[1041]="egret.MainContext.runtimeType 已废弃,请使用egret.Capabilities.runtimeType 代替",e[1042]="drawToTexture方法传入的区域各个参数需要为整数,否则某些浏览器绘制会出现异常",e[1043]="{0} 中存在编译错误,属性名 : {1},属性值 : {2}",e[1044]="当前的 runtime 版本不支持视频播放,请使用最新的版本",e[1045]="没有设置要加载的资源地址",e[1046]="BitmapText 找不到对应字符:{0},请检查配置文件",e[1047]="egret.localStorage.setItem保存失败,key={0}&value={1}",e[1048]="视频加载失败",e[1049]="声音在没有加载完之前不允许播放",e[3e3]="主题配置文件加载失败: {0}",e[3001]="找不到主题中所配置的皮肤类名: {0}",e[3002]='索引:"{0}"超出集合元素索引范围',e[3003]="在此组件中不可用,若此组件为容器类,请使用",e[3004]="addChild(){0}addElement()代替",e[3005]="addChildAt(){0}addElementAt()代替",e[3006]="removeChild(){0}removeElement()代替",e[3007]="removeChildAt(){0}removeElementAt()代替",e[3008]="setChildIndex(){0}setElementIndex()代替",e[3009]="swapChildren(){0}swapElements()代替",e[3010]="swapChildrenAt(){0}swapElementsAt()代替",e[3011]='索引:"{0}"超出可视元素索引范围',e[3012]="此方法在Scroller组件内不可用!",e[3013]="UIStage是GUI根容器,只能有一个此实例在显示列表中!",e[3014]="设置全屏模式失败",e[3100]="当前浏览器不支持WebSocket",e[3101]="请先连接WebSocket",e[3102]="请先设置type为二进制类型",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!"}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.localStorage||(t.localStorage={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){function e(t){n.indexOf(t)<0&&n.push(t)}function i(t){var e=n.indexOf(t);return e>=0?(n.splice(e,1),!0):!1}var n=[];t.$pushSoundChannel=e,t.$popSoundChannel=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this.onSuccessFunc=null,this.onSuccessThisObject=null,this.onErrorFunc=null,this.onErrorThisObject=null,this.downloadingSizeFunc=null,this.downloadingSizeThisObject=null,this.onResponseHeaderFunc=null,this.onResponseHeaderThisObject=null}var i=e,n=i.prototype;return e.create=function(){return e.promiseObjectList.length?e.promiseObjectList.pop():new t.PromiseObject},n.onSuccess=function(){for(var t=[],e=0;ee.maxX?t.maxX:e.maxX,s=t.maxY>e.maxY?t.maxY:e.maxY;return(r-i)*(s-n)}var n=function(){function n(e){this.dirtyList=[],this.hasClipRect=!1,this.clipWidth=0,this.clipHeight=0,this.clipArea=0,this.clipRectChanged=!1,this.$dirtyRegionPolicy=t.DirtyRegionPolicy.ON,this.root=e}var r=n,s=r.prototype;return s.setClipRect=function(t,e){this.hasClipRect=!0,this.clipRectChanged=!0,this.clipWidth=Math.ceil(t),this.clipHeight=Math.ceil(e),this.clipArea=this.clipWidth*this.clipHeight},s.addRegion=function(i){var n=i.minX,r=i.minY,s=i.maxX,a=i.maxY;if(this.hasClipRect&&(0>n&&(n=0),0>r&&(r=0),s>this.clipWidth&&(s=this.clipWidth),a>this.clipHeight&&(a=this.clipHeight)),n>=s||r>=a)return!1;if(this.clipRectChanged)return!0;var o=this.dirtyList,h=e.Region.create();return o.push(h.setTo(n,r,s,a)),this.$dirtyRegionPolicy!=t.DirtyRegionPolicy.OFF&&this.mergeDirtyList(o),!0},s.clear=function(){for(var t=this.dirtyList,i=t.length,n=0;i>n;n++)e.Region.release(t[n]);t.length=0},s.getDirtyRegions=function(){var i=this.dirtyList;if(this.$dirtyRegionPolicy==t.DirtyRegionPolicy.OFF||t.Capabilities.runtimeType==t.RuntimeType.NATIVE&&!t["native"].$supportCanvas){this.clipRectChanged=!0,this.clear();var n=e.Region.create();if(this.hasClipRect)i.push(n.setTo(0,0,this.clipWidth,this.clipHeight));else{var r=this.root.$getOriginalBounds();i.push(n.setTo(r.x,r.y,r.width,r.height))}}else if(this.clipRectChanged){this.clipRectChanged=!1,this.clear();var n=e.Region.create();i.push(n.setTo(0,0,this.clipWidth,this.clipHeight))}else for(;this.mergeDirtyList(i););var s=this.dirtyList.length;if(s>0)for(var a=0;s>a;a++)this.dirtyList[a].intValues();return this.dirtyList},s.mergeDirtyList=function(t){var n=t.length;if(2>n)return!1;for(var r=this.hasClipRect,s=n>3?Number.POSITIVE_INFINITY:0,a=0,o=0,h=0,l=0;n-1>l;l++){var u=t[l];r&&(h+=u.area);for(var c=l+1;n>c;c++){var d=t[c],f=i(u,d)-u.area-d.area;s>f&&(a=l,o=c,s=f)}}if(r&&h/this.clipArea>.95&&(this.clipRectChanged=!0),a!=o){var g=t[o];return t[a].union(g),e.Region.release(g),t.splice(o,1),!0}return!1},s.setDirtyRegionPolicy=function(t){this.$dirtyRegionPolicy=t},n}();e.DirtyRegion=n,t.registerClass(n,"egret.sys.DirtyRegion")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(i){function n(n){i.call(this),this.isStage=!1,this.$renderNode=new e.BitmapNode,this.renderBuffer=null,this.offsetX=0,this.offsetY=0,this.offsetMatrix=new t.Matrix,this.isDirty=!1,this.needUpdateRegions=!1,this.dirtyNodeList=[],this.dirtyList=null,this.sizeChanged=!1,this.$dirtyRegionPolicy=t.DirtyRegionPolicy.ON,this.root=n,this.dirtyRegion=new e.DirtyRegion(n),this.isStage=n instanceof t.Stage,this.dirtyNodes=t.createMap()}__extends(n,i);var r=n,s=r.prototype;return n.create=function(i){var n=new t.sys.DisplayList(i);try{var r=new e.RenderBuffer}catch(s){return null}return n.renderBuffer=r,n.root=i,n},s.$getRenderNode=function(){return this.$renderNode},s.$update=function(e){var i=this.root;if(null==i)return!1;i.$removeFlagsUp(768);var n=this.$renderNode,r=i.$getConcatenatedMatrix();if(e==t.DirtyRegionPolicy.OFF){var s=i.$parentDisplayList;if(this.needUpdateRegions&&this.updateDirtyRegions(),!s)return!1;var a=n.renderMatrix;a.copyFrom(r);var o=s.root;o!==i.$stage&&i.$getConcatenatedMatrixAt(o,a)}else{var h=i.$getOriginalBounds(),s=i.$parentDisplayList,l=n.renderRegion;if(this.needUpdateRegions&&this.updateDirtyRegions(),!s)return l.setTo(0,0,0,0),n.moved=!1,!1;if(!n.moved)return!1;n.moved=!1;var a=n.renderMatrix;a.copyFrom(r);var o=s.root;o!==i.$stage&&i.$getConcatenatedMatrixAt(o,a),l.updateRegion(h,a)}return!0},s.setClipRect=function(t,e){this.dirtyRegion.setClipRect(t,e),this.renderBuffer.resize(t,e)},s.markDirty=function(t){var e=t.$hashCode;if(!this.dirtyNodes[e]&&(this.dirtyNodes[e]=!0,this.dirtyNodeList.push(t),!this.needUpdateRegions)){this.needUpdateRegions=!0,this.isDirty=!0;var i=this.root.$parentDisplayList;i&&i.markDirty(this)}},s.updateDirtyRegions=function(){var e=this.dirtyNodeList;this.dirtyNodeList=[],this.dirtyNodes=t.createMap(),this.needUpdateRegions=!1;for(var i=this.dirtyRegion,n=e.length,r=0;n>r;r++){var s=e[r],a=s.$getRenderNode();if(a.needRedraw=!1,this.isStage){a.renderAlpha>0&&a.renderVisible&&i.addRegion(a.renderRegion)&&(a.needRedraw=!0);var o=s.$update(this.$dirtyRegionPolicy);a.renderAlpha>0&&a.renderVisible&&(o||!a.needRedraw)&&i.addRegion(a.renderRegion)&&(a.needRedraw=!0)}else{i.addRegion(a.renderRegion)&&(a.needRedraw=!0);var o=s.$update(this.$dirtyRegionPolicy);(o||!a.needRedraw)&&i.addRegion(a.renderRegion)&&(a.needRedraw=!0)}}return this.dirtyList=i.getDirtyRegions(),this.dirtyList},s.drawToSurface=function(){var i=0,n=this.dirtyList;if(n&&n.length>0){this.isStage||this.changeSurfaceSize();var r=this.renderBuffer;r.beginClip(this.dirtyList,this.offsetX,this.offsetY);var n=this.$dirtyRegionPolicy==t.DirtyRegionPolicy.OFF?null:this.dirtyList,i=e.systemRenderer.render(this.root,r,this.offsetMatrix,n);r.endClip();var s=r.surface,a=this.$renderNode;a.drawData.length=0,a.image=s;var o=s.width,h=s.height;a.imageWidth=o,a.imageHeight=h,a.drawImage(0,0,o,h,-this.offsetX,-this.offsetY,o,h)}return this.dirtyList=null,this.dirtyRegion.clear(),this.isDirty=!1,i},s.changeSurfaceSize=function(){var t=(this.root,this.offsetX),e=this.offsetY,i=this.root.$getOriginalBounds();this.offsetX=-i.x,this.offsetY=-i.y,this.offsetMatrix.setTo(1,0,0,1,this.offsetX,this.offsetY);var n=this.renderBuffer,r=Math.max(257,i.width),s=Math.max(257,i.height);(this.offsetX!=t||this.offsetY!=e||n.surface.width!=r||n.surface.height!=s)&&(this.sizeChanged?n.resizeTo(r,s,this.offsetX-t,this.offsetY-e):(this.sizeChanged=!0,n.resize(r,s)))},s.setDirtyRegionPolicy=function(t){this.$dirtyRegionPolicy=t,this.dirtyRegion.setDirtyRegionPolicy(t),this.renderBuffer.setDirtyRegionPolicy(t)},n}(t.HashObject);e.DisplayList=i,t.registerClass(i,"egret.sys.DisplayList",["egret.sys.Renderable"])}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(e){function i(i,n,r,s){if(n&&(t.log=function(){for(var t=arguments.length,i="",n=0;t>n;n++)i+=arguments[n]+" ";e.$logToFPS(i),console.log.apply(console,a(arguments))}),l=s?{}:s,n=!!n,this.showFPS=!!i,this.showLog=n,!this.fpsDisplay){var o=void 0===s.x?0:s.x,c=void 0===s.y?0:s.y;h=this.fpsDisplay=new FPS(this.stage,i,n,r,s),h.x=o,h.y=c;for(var d=u.length,f=0;d>f;f++)h.updateInfo(u[f]);u=null}}function n(t){t=!!t,this._showPaintRect!=t&&(this._showPaintRect=t,t?(this.stageDisplayList||(this.stageDisplayList=e.DisplayList.create(this.stage)),this.stage.$displayList=this.stageDisplayList):this.stage.$displayList=this.screenDisplayList)}function r(t){for(var e=t.length,i=[],n=0;e>n;n++){var r=t[n];i[n]=[r.minX,r.minY,r.width,r.height],r.width-=1,r.height-=1}var s=this.paintList;s.push(i),s.length>1&&s.shift();var a=this.screenDisplayList.renderBuffer,o=a.context;for(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,a.surface.width,a.surface.height),o.drawImage(this.stageDisplayList.renderBuffer.surface,0,0),e=s.length,n=0;e>n;n++){i=s[n];for(var h=i.length-1;h>=0;h--){var l=i[h];this.drawDirtyRect(l[0],l[1],l[2],l[3],o)}}o.save(),o.beginPath();for(var e=t.length,n=0;e>n;n++){var r=t[n];o.clearRect(r.minX,r.minY,r.width,r.height),o.rect(r.minX,r.minY,r.width,r.height)}o.clip(),o.drawImage(this.stageDisplayList.renderBuffer.surface,0,0),o.restore()}function s(t,e,i,n,r){r.strokeStyle="rgb(255,0,0)",r.lineWidth=5,r.strokeRect(t-.5,e-.5,i,n)}function a(t){for(var e=[],i=0;i0){for(var u=s.length,c=0,d=0;u>d;d++)c+=s[d].area;l=Math.ceil(1e3*c/(n.stageWidth*n.stageHeight))/10}this.fpsDisplay.update(o,l,a-r,h-a,i)}},l.callLaters=function(){if(t.$callLaterFunctionList.length>0){var e=t.$callLaterFunctionList;t.$callLaterFunctionList=[];var i=t.$callLaterThisList;t.$callLaterThisList=[];var n=t.$callLaterArgsList;t.$callLaterArgsList=[]}if(e)for(var r=e.length,s=0;r>s;s++){var a=e[s];null!=a&&a.apply(i[s],n[s])}},l.callLaterAsyncs=function(){if(t.$callAsyncFunctionList.length>0){var e=t.$callAsyncFunctionList,i=t.$callAsyncThisList,n=t.$callAsyncArgsList;t.$callAsyncFunctionList=[],t.$callAsyncThisList=[],t.$callAsyncArgsList=[];for(var r=0;r=1e3){var h=Math.min(Math.ceil(1e3*this.totalTick/this.totalTime),e.$ticker.$frameRate),l=Math.round(this.drawCalls/this.totalTick),u=Math.round(this.dirtyRatio/this.totalTick),c=Math.round(this.costDirty/this.totalTick),d=Math.round(this.costRender/this.totalTick),f=Math.round(this.costTicker/this.totalTick);this.fpsDisplay.update({fps:h,draw:l,dirty:u,costTicker:f,costDirty:c,costRender:d}),this.totalTick=0,this.totalTime=this.totalTime%500,this.drawCalls=0,this.dirtyRatio=0,this.costDirty=0,this.costRender=0,this.costTicker=0}},n.prototype.updateInfo=function(t){t&&this.showLog&&this.filter(t)&&this.fpsDisplay.updateInfo(t)},n}(t.Sprite),t.warn=function(){console.warn.apply(console,a(arguments))},t.error=function(){console.error.apply(console,a(arguments))},t.assert=function(){console.assert.apply(console,a(arguments))},t.log=function(){console.log.apply(console,a(arguments))}}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=[],n=function(){function t(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.width=0,this.height=0,this.area=0,this.moved=!1}var e=t,n=e.prototype;return t.release=function(t){i.push(t)},t.create=function(){var e=i.pop();return e||(e=new t),e},n.setTo=function(t,e,i,n){return this.minX=t,this.minY=e,this.maxX=i,this.maxY=n,this.updateArea(),this},n.intValues=function(){this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this.updateArea()},n.updateArea=function(){this.width=this.maxX-this.minX,this.height=this.maxY-this.minY,this.area=this.width*this.height},n.union=function(t){this.minX>t.minX&&(this.minX=t.minX),this.minY>t.minY&&(this.minY=t.minY),this.maxXt.maxX&&(this.maxX=t.maxX),this.minX>=this.maxX?void this.setEmpty():(this.minYt.maxY&&(this.maxY=t.maxY),this.minY>=this.maxY?void this.setEmpty():void this.updateArea())},n.setEmpty=function(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.width=0,this.height=0,this.area=0},n.isEmpty=function(){return this.width<=0||this.height<=0},n.intersects=function(t){if(this.isEmpty())return!1;var e=this.minX>t.minX?this.minX:t.minX,i=this.maxXi?!1:(e=this.minY>t.minY?this.minY:t.minY,i=this.maxY=e)},n.updateRegion=function(t,e){if(0==t.width||0==t.height)return void this.setEmpty();var i,n,r,s,a=e,o=a.a,h=a.b,l=a.c,u=a.d,c=a.tx,d=a.ty,f=t.x,g=t.y,p=f+t.width,v=g+t.height;if(1==o&&0==h&&0==l&&1==u)i=f+c-1,n=g+d-1,r=p+c+1,s=v+d+1;else{var $=o*f+l*g+c,y=h*f+u*g+d,m=o*p+l*g+c,T=h*p+u*g+d,x=o*p+l*v+c,b=h*p+u*v+d,_=o*f+l*v+c,E=h*f+u*v+d,F=0;$>m&&(F=$,$=m,m=F),x>_&&(F=x,x=_,_=F),i=(x>$?$:x)-1,r=(m>_?m:_)+1,y>T&&(F=y,y=T,T=F),b>E&&(F=b,b=E,E=F),n=(b>y?y:b)-1,s=(T>E?T:E)+1}this.minX=i,this.minY=n,this.maxX=r,this.maxY=s,this.width=r-i,this.height=s-n,this.area=this.width*this.height},t}();e.Region=n,t.registerClass(n,"egret.sys.Region")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){e.call(this)}__extends(i,e);var n=i,r=n.prototype;return r.calculateStageSize=function(e,i,n,r,s){var a=i,o=n,h=r,l=s,u=i/h||0,c=n/l||0;switch(e){case t.StageScaleMode.EXACT_FIT:break;case t.StageScaleMode.FIXED_HEIGHT:h=Math.round(i/c);break;case t.StageScaleMode.FIXED_WIDTH:l=Math.round(n/u);break;case t.StageScaleMode.NO_BORDER:u>c?o=Math.round(l*u):a=Math.round(h*c);break;case t.StageScaleMode.SHOW_ALL:u>c?a=Math.round(h*c):o=Math.round(l*u);break;case t.StageScaleMode.FIXED_NARROW:u>c?h=Math.round(i/c):l=Math.round(n/u);break;case t.StageScaleMode.FIXED_WIDE:u>c?l=Math.round(n/u):h=Math.round(i/c);break;default:h=i,l=n}return a%2!=0&&(a+=1),o%2!=0&&(o+=1),{stageWidth:h,stageHeight:l,displayWidth:a,displayHeight:o}},i}(t.HashObject);e.DefaultScreenAdapter=i,t.registerClass(i,"egret.sys.DefaultScreenAdapter",["egret.sys.IScreenAdapter"])}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.NO_SCALE="noScale",t.SHOW_ALL="showAll",t.NO_BORDER="noBorder",t.EXACT_FIT="exactFit",t.FIXED_WIDTH="fixedWidth",t.FIXED_HEIGHT="fixedHeight",t.FIXED_NARROW="fixedNarrow",t.FIXED_WIDE="fixedWide",t}();t.StageScaleMode=e,t.registerClass(e,"egret.StageScaleMode")}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){e.$START_TIME=0,e.$invalidateRenderFlag=!1,e.$requestRenderingFlag=!1;var i=function(){function i(){this.playerList=[],this.callBackList=[],this.thisObjectList=[],this.$frameRate=30,this.frameInterval=2e3,this.lastCount=2e3,this.costEnterFrame=0,e.$START_TIME=Date.now()}var n=i,r=n.prototype;return r.$addPlayer=function(t){-1==this.playerList.indexOf(t)&&(this.playerList=this.playerList.concat(),this.playerList.push(t))},r.$removePlayer=function(t){var e=this.playerList.indexOf(t);if(-1!==e){this.playerList=this.playerList.concat(),this.playerList.splice(e,1)}},r.$startTick=function(t,e){var i=this.getTickIndex(t,e);-1==i&&(this.concatTick(),this.callBackList.push(t),this.thisObjectList.push(e))},r.$stopTick=function(t,e){var i=this.getTickIndex(t,e);-1!=i&&(this.concatTick(),this.callBackList.splice(i,1),this.thisObjectList.splice(i,1))},r.getTickIndex=function(t,e){for(var i=this.callBackList,n=this.thisObjectList,r=i.length-1;r>=0;r--)if(i[r]==t&&n[r]==e)return r;return-1},r.concatTick=function(){this.callBackList=this.callBackList.concat(),this.thisObjectList=this.thisObjectList.concat()},r.$setFrameRate=function(e){return e=+e||0,0>=e?!1:this.$frameRate==e?!1:(this.$frameRate=e,e>60&&(e=60),t.Capabilities.runtimeType==t.RuntimeType.NATIVE&&(egret_native.setFrameRate(e),e=60),this.lastCount=this.frameInterval=Math.round(6e4/e),!0)},r.update=function(){for(var i=t.getTimer(),n=this.callBackList,r=this.thisObjectList,s=n.length,a=e.$requestRenderingFlag,o=t.getTimer(),h=0;s>h;h++)n[h].call(r[h],o)&&(a=!0);this.lastCount-=1e3;var l=t.getTimer();if(this.lastCount>0)return void(a&&this.render(!1,this.costEnterFrame+l-i));this.lastCount+=this.frameInterval,this.render(!0,this.costEnterFrame+l-i);var u=t.getTimer();this.broadcastEnterFrame();var c=t.getTimer();this.costEnterFrame=c-u},r.render=function(t,i){var n=this.playerList,r=n.length;if(0!=r){e.$invalidateRenderFlag&&(this.broadcastRender(),e.$invalidateRenderFlag=!1);for(var s=0;r>s;s++)n[s].$render(t,i);e.$requestRenderingFlag=!1}},r.broadcastEnterFrame=function(){var e=t.DisplayObject.$enterFrameCallBackList,i=e.length;if(0!=i){e=e.concat();for(var n=0;i>n;n++)e[n].dispatchEventWith(t.Event.ENTER_FRAME)}},r.broadcastRender=function(){var e=t.DisplayObject.$renderCallBackList,i=e.length;if(0!=i){e=e.concat();for(var n=0;i>n;n++)e[n].dispatchEventWith(t.Event.RENDER)}},i}();e.SystemTicker=i,t.registerClass(i,"egret.sys.SystemTicker"),e.$ticker=new e.SystemTicker}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret_stages,egret;!function(t){var e;!function(e){var i=function(e){function i(t){e.call(this),this.maxTouches=0,this.useTouchesCount=0,this.touchDownTarget={},this.lastTouchX=-1,this.lastTouchY=-1,this.stage=t }__extends(i,e);var n=i,r=n.prototype;return r.$initMaxTouches=function(){this.maxTouches=this.stage.$maxTouches},r.onTouchBegin=function(e,i,n){if(!(this.useTouchesCount>=this.maxTouches)){this.lastTouchX=e,this.lastTouchY=i;var r=this.findTarget(e,i);null==this.touchDownTarget[n]&&(this.touchDownTarget[n]=r,this.useTouchesCount++),t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_BEGIN,!0,!0,e,i,n,!0)}},r.onTouchMove=function(e,i,n){if(null!=this.touchDownTarget[n]&&(this.lastTouchX!=e||this.lastTouchY!=i)){this.lastTouchX=e,this.lastTouchY=i;var r=this.findTarget(e,i);t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_MOVE,!0,!0,e,i,n,!0)}},r.onTouchEnd=function(e,i,n){if(null!=this.touchDownTarget[n]){var r=this.findTarget(e,i),s=this.touchDownTarget[n];delete this.touchDownTarget[n],this.useTouchesCount--,t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_END,!0,!0,e,i,n,!1),s==r?t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_TAP,!0,!0,e,i,n,!1):t.TouchEvent.dispatchTouchEvent(s,t.TouchEvent.TOUCH_RELEASE_OUTSIDE,!0,!0,e,i,n,!1)}},r.findTarget=function(t,e){var i=this.stage.$hitTest(t,e);return i||(i=this.stage),i},i}(t.HashObject);e.TouchHandler=i,t.registerClass(i,"egret.sys.TouchHandler")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(){function i(){this.type=0,this.needRedraw=!1,this.renderAlpha=1,this.renderVisible=!0,this.renderMatrix=new t.Matrix,this.renderRegion=new e.Region,this.moved=!1,this.drawData=[],this.renderCount=0}var n=i,r=n.prototype;return r.cleanBeforeRender=function(){this.drawData.length=0,this.renderCount=0},r.$getRenderCount=function(){return this.renderCount},i}();e.RenderNode=i,t.registerClass(i,"egret.sys.RenderNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){e.call(this),this.image=null,this.smoothing=!0,this.blendMode=null,this.type=1}__extends(i,e);var n=i,r=n.prototype;return r.drawImage=function(t,e,i,n,r,s,a,o){this.drawData.push(t,e,i,n,r,s,a,o),this.renderCount++},r.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null},i.$updateTextureData=function(e,n,r,s,a,o,h,l,u,c,d,f,g,p,v,$,y){if(n){var m=t.$TextureScaleFactor;if(e.smoothing=y,e.image=n,e.imageWidth=g,e.imageHeight=p,v)i.$updateTextureDataWithScale9Grid(e,v,r,s,a,o,h,l,u,c,d,f);else if($==t.BitmapFillMode.SCALE){var T=d/u,x=f/c;e.drawImage(r,s,a,o,h*T,l*x,T*a,x*o)}else if($==t.BitmapFillMode.CLIP){var b=Math.min(u,d),_=Math.min(c,f),E=a*m,F=o*m;i.drawClipImage(e,m,r,s,E,F,h,l,b,_)}else for(var E=a*m,F=o*m,C=0;d>C;C+=u)for(var w=0;f>w;w+=c){var b=Math.min(d-C,u),_=Math.min(f-w,c);i.drawClipImage(e,m,r,s,E,F,h,l,b,_,C,w)}}},i.$updateTextureDataWithScale9Grid=function(e,i,n,r,s,a,o,h,l,u,c,d){var f=s,g=a;c-=l-s*t.$TextureScaleFactor,d-=u-a*t.$TextureScaleFactor;var p=i.x-o,v=i.y-h,$=p/t.$TextureScaleFactor,y=v/t.$TextureScaleFactor,m=i.width/t.$TextureScaleFactor,T=i.height/t.$TextureScaleFactor;0==T&&(T=1,y>=g&&y--),0==m&&(m=1,$>=f&&$--);var x=n,b=x+$,_=b+m,E=f-$-m,F=r,C=F+y,w=C+T,R=g-y-T,S=E*t.$TextureScaleFactor,D=R*t.$TextureScaleFactor;if(($+E)*t.$TextureScaleFactor>c||(y+R)*t.$TextureScaleFactor>d)return void e.drawImage(n,r,s,a,o,h,c,d);var O=o,L=O+p,N=O+(c-S),M=c-p-S,A=h,B=A+v,I=A+d-D,P=d-v-D;y>0&&($>0&&e.drawImage(x,F,$,y,O,A,p,v),m>0&&e.drawImage(b,F,m,y,L,A,M,v),E>0&&e.drawImage(_,F,E,y,N,A,S,v)),T>0&&($>0&&e.drawImage(x,C,$,T,O,B,p,P),m>0&&e.drawImage(b,C,m,T,L,B,M,P),E>0&&e.drawImage(_,C,E,T,N,B,S,P)),R>0&&($>0&&e.drawImage(x,w,$,R,O,I,p,D),m>0&&e.drawImage(b,w,m,R,L,I,M,D),E>0&&e.drawImage(_,w,E,R,N,I,S,D))},i.drawClipImage=function(t,e,i,n,r,s,a,o,h,l,u,c){void 0===u&&(u=0),void 0===c&&(c=0);var d=a+r-h;d>0&&(r-=d),d=o+s-l,d>0&&(s-=d),t.drawImage(i,n,r/e,s/e,u+a,c+o,r,s)},i}(e.RenderNode);e.BitmapNode=i,t.registerClass(i,"egret.sys.BitmapNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=["none","round","square"],n=["bevel","miter","round"],r=function(r){function s(){r.call(this),this.dirtyRender=!0,this.type=3}__extends(s,r);var a=s,o=a.prototype;return o.beginFill=function(t,i,n){void 0===i&&(i=1);var r=new e.FillPath;if(r.fillColor=t,r.fillAlpha=i,n){var s=this.drawData.lastIndexOf(n);this.drawData.splice(s,0,r)}else this.drawData.push(r);return r},o.beginGradientFill=function(i,n,r,s,a,o){var h=new t.Matrix;a?(h.a=819.2*a.a,h.b=819.2*a.b,h.c=819.2*a.c,h.d=819.2*a.d,h.tx=a.tx,h.ty=a.ty):(h.a=100,h.d=100);var l=new e.GradientFillPath;if(l.gradientType=i,l.colors=n,l.alphas=r,l.ratios=s,l.matrix=h,o){var u=this.drawData.lastIndexOf(o);this.drawData.splice(u,0,l)}else this.drawData.push(l);return l},o.lineStyle=function(r,s,a,o,h,l){void 0===a&&(a=1),void 0===l&&(l=3),-1==i.indexOf(o)&&(o="round"),-1==n.indexOf(h)&&(h="round");var u=new e.StrokePath;return u.lineWidth=r,u.lineColor=s,u.lineAlpha=a,u.caps=o||t.CapsStyle.ROUND,u.joints=h,u.miterLimit=l,this.drawData.push(u),u},o.clear=function(){this.drawData.length=0,this.dirtyRender=!0},o.cleanBeforeRender=function(){},s}(e.RenderNode);e.GraphicsNode=r,t.registerClass(r,"egret.sys.GraphicsNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=4}__extends(e,t);var i=e,n=i.prototype;return n.addNode=function(t){this.drawData.push(t)},n.cleanBeforeRender=function(){for(var t=this.drawData,e=t.length-1;e>=0;e--)t[e].cleanBeforeRender()},n.$getRenderCount=function(){for(var t=0,e=this.drawData,i=e.length-1;i>=0;i--)t+=e[i].$getRenderCount();return t},e}(e.RenderNode);e.GroupNode=i,t.registerClass(i,"egret.sys.GroupNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){e.call(this),this.image=null,this.smoothing=!0,this.bounds=new t.Rectangle,this.type=7,this.vertices=[],this.uvs=[],this.indices=[]}__extends(i,e);var n=i,r=n.prototype;return r.drawMesh=function(t,e,i,n,r,s,a,o){this.drawData.push(t,e,i,n,r,s,a,o),this.renderCount++},r.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null},i}(e.RenderNode);e.MeshNode=i,t.registerClass(i,"egret.sys.MeshNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=6}__extends(e,t);var i=e,n=i.prototype;return n.setAlpha=function(t){0!=this.drawData.length&&(this.drawData.length=0),this.drawData.push(t),this.renderCount++},e}(e.RenderNode);e.SetAlphaNode=i,t.registerClass(i,"egret.sys.SetAlphaNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.textColor=16777215,this.strokeColor=0,this.size=30,this.stroke=0,this.bold=!1,this.italic=!1,this.fontFamily="Arial",this.dirtyRender=!0,this.type=2}__extends(e,t);var i=e,n=i.prototype;return n.drawText=function(t,e,i,n){this.drawData.push(t,e,i,n),this.renderCount++,this.dirtyRender=!0},n.cleanBeforeRender=function(){t.prototype.cleanBeforeRender.call(this)},e}(e.RenderNode);e.TextNode=i,t.registerClass(i,"egret.sys.TextNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(){function t(){this.type=0,this.$commands=[],this.$data=[],this.commandPosition=0,this.dataPosition=0}var e=t,i=e.prototype;return i.moveTo=function(t,e){this.$commands[this.commandPosition++]=1;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},i.lineTo=function(t,e){this.$commands[this.commandPosition++]=2;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},i.curveTo=function(t,e,i,n){this.$commands[this.commandPosition++]=3;var r=this.dataPosition;this.$data[r++]=t,this.$data[r++]=e,this.$data[r++]=i,this.$data[r++]=n,this.dataPosition=r},i.cubicCurveTo=function(t,e,i,n,r,s){this.$commands[this.commandPosition++]=4;var a=this.dataPosition;this.$data[a++]=t,this.$data[a++]=e,this.$data[a++]=i,this.$data[a++]=n,this.$data[a++]=r,this.$data[a++]=s,this.dataPosition=a},i.drawRect=function(t,e,i,n){var r=t+i,s=e+n;this.moveTo(t,e),this.lineTo(r,e),this.lineTo(r,s),this.lineTo(t,s),this.lineTo(t,e)},i.drawRoundRect=function(t,e,i,n,r,s){var a=.5*r|0,o=s?.5*s|0:a;if(!a||!o)return void this.drawRect(t,e,i,n);var h=.5*i,l=.5*n;if(a>h&&(a=h),o>l&&(o=l),h===a&&l===o)return void(a===o?this.drawCircle(t+a,e+o,a):this.drawEllipse(t,e,2*a,2*o));var u=t+i,c=e+n,d=t+a,f=u-a,g=e+o,p=c-o;this.moveTo(u,p),this.curveTo(u,c,f,c),this.lineTo(d,c),this.curveTo(t,c,t,p),this.lineTo(t,g),this.curveTo(t,e,d,e),this.lineTo(f,e),this.curveTo(u,e,u,g),this.lineTo(u,p)},i.drawCircle=function(t,e,i){this.arcToBezier(t,e,i,i,0,2*Math.PI)},i.drawEllipse=function(t,e,i,n){var r=.5*i,s=.5*n;t+=r,e+=s,this.arcToBezier(t,e,r,s,0,2*Math.PI)},i.drawArc=function(t,e,i,n,r,s){s?r>=n&&(r-=2*Math.PI):n>=r&&(r+=2*Math.PI),this.arcToBezier(t,e,i,i,n,r,s)},i.arcToBezier=function(t,e,i,n,r,s,a){var o=.5*Math.PI,h=r,l=h;a?(l+=-o-h%o,s>l&&(l=s)):(l+=o-h%o,l>s&&(l=s));var u=t+Math.cos(h)*i,c=e+Math.sin(h)*n;this.moveTo(u,c);for(var d=Math.cos(h),f=Math.sin(h),g=0;4>g;g++){var p=l-h,v=4*Math.tan(p/4)/3,$=u-f*v*i,y=c+d*v*n;d=Math.cos(l),f=Math.sin(l),u=t+d*i,c=e+f*n;var m=u+f*v*i,T=c-d*v*n;if(this.cubicCurveTo($,y,m,T,u,c),l===s)break;h=l,a?(l=h-o,s>l&&(l=s)):(l=h+o,l>s&&(l=s))}},t}();e.Path2D=i,t.registerClass(i,"egret.sys.Path2D")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=1}__extends(e,t);var i=e;i.prototype;return e}(e.Path2D);e.FillPath=i,t.registerClass(i,"egret.sys.FillPath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=2}__extends(e,t);var i=e;i.prototype;return e}(e.Path2D);e.GradientFillPath=i,t.registerClass(i,"egret.sys.GradientFillPath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=3}__extends(e,t);var i=e;i.prototype;return e}(e.Path2D);e.StrokePath=i,t.registerClass(i,"egret.sys.StrokePath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){function e(t,e){var i=null==e.italic?t.italic:e.italic,n=null==e.bold?t.bold:e.bold,r=null==e.size?t.size:e.size,s=e.fontFamily||t.fontFamily,a=i?"italic ":"normal ";return a+=n?"bold ":"normal ",a+=r+"px "+s}function i(t,e){var i=t>>16,n=t>>8&255,r=255&t;return"rgba("+i+","+n+","+r+","+e+")"}function n(e,n,r,s,a,o){var h;h=n==t.GradientType.LINEAR?e.createLinearGradient(-1,0,1,0):e.createRadialGradient(0,0,0,0,0,1);for(var l=r.length,u=0;l>u;u++)h.addColorStop(a[u]/255,i(r[u],s[u]));return h}var r=["source-over","lighter","destination-out"],s="source-over",a="#000000",o={none:"butt",square:"square",round:"round"},h=[],l=function(){function l(){this.nestLevel=0,this.renderingMask=!1}var u=l,c=u.prototype;return c.render=function(t,e,i,n,r){this.nestLevel++;var s=e.context,a=r?t:null,o=this.drawDisplayObject(t,s,n,i,null,null,a);if(this.nestLevel--,0===this.nestLevel){h.length>6&&(h.length=6);for(var l=h.length,u=0;l>u;u++)h[u].resize(0,0)}return o},c.drawDisplayObject=function(e,i,n,r,s,a,o){var h,l=0;if(s&&!o?(s.isDirty&&(l+=s.drawToSurface()),h=s.$renderNode):h=e.$getRenderNode(),h){if(n){var u=h.renderRegion;if(a&&!a.intersects(u))h.needRedraw=!1;else if(!h.needRedraw)for(var c=n.length,d=0;c>d;d++)if(u.intersects(n[d])){h.needRedraw=!0;break}}else h.needRedraw=!0;if(h.needRedraw){var f,g;o?(f=e.$getConcatenatedAlphaAt(o,e.$getConcatenatedAlpha()),g=t.Matrix.create().copyFrom(e.$getConcatenatedMatrix()),e.$getConcatenatedMatrixAt(o,g),r.$preMultiplyInto(g,g),i.setTransform(g.a,g.b,g.c,g.d,g.tx,g.ty),t.Matrix.release(g)):(f=h.renderAlpha,g=h.renderMatrix,i.setTransform(g.a,g.b,g.c,g.d,g.tx+r.tx,g.ty+r.ty)),i.globalAlpha=f,l+=this.renderNode(h,i),h.needRedraw=!1}}if(s&&!o)return l;var p=e.$children;if(p)for(var v=p.length,$=0;v>$;$++){var y=p[$];!y.$visible||y.$alpha<=0||y.$maskedObject||(0!==y.$blendMode||y.$mask&&(y.$mask.$parentDisplayList||o)?l+=this.drawWithClip(y,i,n,r,a,o):y.$scrollRect||y.$maskRect?l+=this.drawWithScrollRect(y,i,n,r,a,o):y.isFPS?this.drawDisplayObject(y,i,n,r,y.$displayList,a,o):l+=this.drawDisplayObject(y,i,n,r,y.$displayList,a,o))}return l},c.drawWithClip=function(e,i,n,a,o,l){var u=0,c=0!==e.$blendMode;if(c){var d=r[e.$blendMode];d||(d=s)}var f=e.$scrollRect?e.$scrollRect:e.$maskRect,g=e.$mask;if(g){var p=g.$getRenderNode();if(p){var v=p.renderMatrix;if(0==v.a&&0==v.b||0==v.c&&0==v.d)return u}}var $,y=t.Matrix.create();if(y.copyFrom(e.$getConcatenatedMatrix()),e.$parentDisplayList){var m,T=e.$parentDisplayList.root;T!==e.$stage&&e.$getConcatenatedMatrixAt(T,y)}if(g){var x=g.$getOriginalBounds();$=t.sys.Region.create();var b=t.Matrix.create();b.copyFrom(g.$getConcatenatedMatrix()),m&&m.$preMultiplyInto(b,b),$.updateRegion(x,b),t.Matrix.release(b)}var _;if(f&&(_=t.sys.Region.create(),_.updateRegion(f,y)),_&&$?(_.intersect($),t.sys.Region.release($)):!_&&$&&(_=$),_){if(_.isEmpty()||o&&!o.intersects(_))return t.sys.Region.release(_),t.Matrix.release(y),u}else _=t.sys.Region.create(),x=e.$getOriginalBounds(),_.updateRegion(x,y);var E=!1;if(n){for(var F=n.length,C=0;F>C;C++)if(_.intersects(n[C])){E=!0;break}}else E=!0;if(!E)return t.sys.Region.release(_),t.Matrix.release(y),u;if(!(g||e.$children&&0!=e.$children.length)){if(f){var b=y;i.save(),i.setTransform(b.a,b.b,b.c,b.d,b.tx-_.minX,b.ty-_.minY),i.beginPath(),i.rect(f.x,f.y,f.width,f.height),i.clip()}return c&&(i.globalCompositeOperation=d),u+=this.drawDisplayObject(e,i,n,a,e.$displayList,o,l),c&&(i.globalCompositeOperation=s),f&&i.restore(),u}if(g&&t.Capabilities.$runtimeType==t.RuntimeType.WEB&&(!g.$children||0==g.$children.length)&&p&&3==p.type&&1==p.drawData.length&&1==p.drawData[0].type&&1==p.drawData[0].fillAlpha){this.renderingMask=!0,i.save();var w=this.drawDisplayObject(g,i,n,a,g.$displayList,o,l);if(this.renderingMask=!1,f){var b=y;i.setTransform(b.a,b.b,b.c,b.d,b.tx-_.minX,b.ty-_.minY),i.beginPath(),i.rect(f.x,f.y,f.width,f.height),i.clip()}return w+=this.drawDisplayObject(e,i,n,a,e.$displayList,o,l),i.restore(),w}var R=this.createRenderBuffer(_.width,_.height),S=R.context;if(!S)return u+=this.drawDisplayObject(e,i,n,a,e.$displayList,o,l),t.sys.Region.release(_),t.Matrix.release(y),u;S.setTransform(1,0,0,1,-_.minX,-_.minY);var D=t.Matrix.create().setTo(1,0,0,1,-_.minX,-_.minY);if(u+=this.drawDisplayObject(e,S,n,D,e.$displayList,_,l),g)if(t.Capabilities.$runtimeType==t.RuntimeType.WEB&&p&&1==p.$getRenderCount()||g.$displayList)S.globalCompositeOperation="destination-in",u+=this.drawDisplayObject(g,S,n,D,g.$displayList,_,l);else{var O=this.createRenderBuffer(_.width,_.height),L=O.context;if(!L)return u+=this.drawDisplayObject(e,i,n,a,e.$displayList,o,l),h.push(R),t.sys.Region.release(_),t.Matrix.release(y),u;L.setTransform(1,0,0,1,-_.minX,-_.minY),D=t.Matrix.create().setTo(1,0,0,1,-_.minX,-_.minY);var w=this.drawDisplayObject(g,L,n,D,g.$displayList,_,l);w>0&&(u+=w,S.globalCompositeOperation="destination-in",S.setTransform(1,0,0,1,0,0),S.globalAlpha=1,S.drawImage(O.surface,0,0)),h.push(O)}if(t.Matrix.release(D),u>0){if(u++,c&&(i.globalCompositeOperation=d),f){var b=y;i.save(),i.setTransform(b.a,b.b,b.c,b.d,b.tx-_.minX,b.ty-_.minY),i.beginPath(),i.rect(f.x,f.y,f.width,f.height),i.clip()}i.globalAlpha=1,i.setTransform(1,0,0,1,_.minX+a.tx,_.minY+a.ty),i.drawImage(R.surface,0,0),f&&i.restore(),c&&(i.globalCompositeOperation=s)}return h.push(R),t.sys.Region.release(_),t.Matrix.release(y),u},c.drawWithScrollRect=function(e,i,n,r,s,a){var o=0,h=e.$scrollRect?e.$scrollRect:e.$maskRect;if(0==h.width||0==h.height)return o;var l=t.Matrix.create();if(l.copyFrom(e.$getConcatenatedMatrix()),a)e.$getConcatenatedMatrixAt(a,l);else if(e.$parentDisplayList){var u=e.$parentDisplayList.root;u!==e.$stage&&e.$getConcatenatedMatrixAt(u,l)}var c=t.sys.Region.create();if(h.isEmpty()||c.updateRegion(h,l),c.isEmpty()||s&&!s.intersects(c))return t.sys.Region.release(c),t.Matrix.release(l),o;var d=!1;if(n){for(var f=n.length,g=0;f>g;g++)if(c.intersects(n[g])){d=!0;break}}else d=!0;return d?(i.save(),i.setTransform(l.a,l.b,l.c,l.d,l.tx+r.tx,l.ty+r.ty),i.beginPath(),i.rect(h.x,h.y,h.width,h.height),i.clip(),o+=this.drawDisplayObject(e,i,n,r,e.$displayList,c,a),i.restore(),t.sys.Region.release(c),t.Matrix.release(l),o):(t.sys.Region.release(c),t.Matrix.release(l),o)},c.drawNodeToBuffer=function(t,e,i,n){var r=e.context;r.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),this.renderNode(t,r,n)},c.renderNode=function(t,e,i){var n=0;switch(t.type){case 1:n=this.renderBitmap(t,e);break;case 2:n=1,this.renderText(t,e);break;case 3:n=1,this.renderGraphics(t,e,i);break;case 4:n=this.renderGroup(t,e);break;case 6:e.globalAlpha=t.drawData[0]}return n},c.renderBitmap=function(t,e){var i=t.image;e.$imageSmoothingEnabled!=t.smoothing&&(e.imageSmoothingEnabled=t.smoothing,e.$imageSmoothingEnabled=t.smoothing);var n=t.drawData,a=n.length,o=0,h=t.matrix,l=t.blendMode,u=!1;h&&(e.saveTransform?e.saveTransform():e.save(),u=!0,e.transform(h.a,h.b,h.c,h.d,h.tx,h.ty)),l&&(e.globalCompositeOperation=r[l]);for(var c=0;a>o;)c++,e.drawImage(i,n[o++],n[o++],n[o++],n[o++],n[o++],n[o++],n[o++],n[o++]);return u?e.restoreTransform?(e.restoreTransform(),l&&(e.globalCompositeOperation=s)):e.restore():l&&(e.globalCompositeOperation=s),c},c.renderText=function(i,n){n.textAlign="left",n.textBaseline="middle",n.lineJoin="round";for(var r=i.drawData,s=r.length,a=0;s>a;){var o=r[a++],h=r[a++],l=r[a++],u=r[a++];n.font=e(i,u);var c=null==u.textColor?i.textColor:u.textColor,d=null==u.strokeColor?i.strokeColor:u.strokeColor,f=null==u.stroke?i.stroke:u.stroke;n.fillStyle=t.toColorString(c),n.strokeStyle=t.toColorString(d),f&&(n.lineWidth=2*f,n.strokeText(l,o,h)),n.fillText(l,o,h)}},c.renderGraphics=function(t,e,r){var s=t.drawData,h=s.length;r=!!r;for(var l=0;h>l;l++){var u=s[l];switch(u.type){case 1:var c=u;e.fillStyle=r?a:i(c.fillColor,c.fillAlpha),this.renderPath(u,e),this.renderingMask?e.clip():e.fill();break;case 2:var d=u;e.fillStyle=r?a:n(e,d.gradientType,d.colors,d.alphas,d.ratios,d.matrix),e.save();var f=d.matrix;this.renderPath(u,e),e.transform(f.a,f.b,f.c,f.d,f.tx,f.ty),e.fill(),e.restore();break;case 3:var g=u,p=g.lineWidth;e.lineWidth=p,e.strokeStyle=r?a:i(g.lineColor,g.lineAlpha),e.lineCap=o[g.caps],e.lineJoin=g.joints,e.miterLimit=g.miterLimit;var v=1===p||3===p;v&&e.translate(.5,.5),this.renderPath(u,e),e.stroke(),v&&e.translate(-.5,-.5)}}},c.renderPath=function(t,e){e.beginPath();for(var i=t.$data,n=t.$commands,r=n.length,s=0,a=0;r>a;a++){var o=n[a];switch(o){case 4:e.bezierCurveTo(i[s++],i[s++],i[s++],i[s++],i[s++],i[s++]);break;case 3:e.quadraticCurveTo(i[s++],i[s++],i[s++],i[s++]);break;case 2:e.lineTo(i[s++],i[s++]);break;case 1:e.moveTo(i[s++],i[s++])}}},c.renderGroup=function(t,e){for(var i=0,n=t.drawData,r=n.length,s=0;r>s;s++){var a=n[s];i+=this.renderNode(a,e)}return i},c.createRenderBuffer=function(e,i){var n=h.pop();return n?n.resize(e,i,!0):n=new t.sys.RenderBuffer(e,i),n},l}();t.CanvasRenderer=l,t.registerClass(l,"egret.CanvasRenderer",["egret.sys.SystemRenderer"])}(egret||(egret={}));var egret;!function(t){t.DeviceOrientation=null}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.WEB="web",t.NATIVE="native",t}();t.RuntimeType=e,t.registerClass(e,"egret.RuntimeType");var i=function(){function t(){}var e=__define,i=t;i.prototype;return e(t,"language",function(){return t.$language}),e(t,"isMobile",function(){return t.$isMobile}),e(t,"os",function(){return t.$os}),e(t,"runtimeType",function(){return t.$runtimeType}),e(t,"supportVersion",function(){return t.$supportVersion}),t.$setNativeCapabilities=function(e){var i=e.split("-");if(i.length<=4){var n=i[0];switch(n){case"android":n="Android";break;case"ios":n="iOS"}t.$os=n;var r=i[2].substring(1,i[2].length);t.$supportVersion=r}},e(t,"renderMode",function(){return t.$renderMode}),e(t,"boundingClientWidth",function(){return t.$boundingClientWidth}),e(t,"boundingClientHeight",function(){return t.$boundingClientHeight}),t.$language="zh-CN",t.$os="Unknown",t.$runtimeType="Unknown",t.$supportVersion="Unknown",t.$renderMode="Unknown",t.$boundingClientWidth=0,t.$boundingClientHeight=0,t}();t.Capabilities=i,t.registerClass(i,"egret.Capabilities")}(egret||(egret={}));var testDeviceType=function(){if(!this.navigator)return!0;var t=navigator.userAgent.toLowerCase();return-1!=t.indexOf("mobile")||-1!=t.indexOf("android")},testRuntimeType=function(){return this.navigator?!0:!1};egret.Capabilities.$isMobile=testDeviceType(),egret.Capabilities.$runtimeType=testRuntimeType()?egret.RuntimeType.WEB:egret.RuntimeType.NATIVE;var egret;!function(t){var e=function(t){function e(e,i){t.call(this,e),this.firstCharHeight=0,"string"==typeof i?this.charList=this.parseConfig(i):i&&i.hasOwnProperty("frames")?this.charList=i.frames:this.charList={}}__extends(e,t);var i=e,n=i.prototype;return n.getTexture=function(t){var e=this._textureMap[t];if(!e){var i=this.charList[t];if(!i)return null;e=this.createTexture(t,i.x,i.y,i.w,i.h,i.offX,i.offY,i.sourceW,i.sourceH),this._textureMap[t]=e}return e},n.getConfig=function(t,e){return this.charList[t]?this.charList[t][e]:0},n._getFirstCharHeight=function(){if(0==this.firstCharHeight)for(var t in this.charList){var e=this.charList[t];if(e){var i=e.sourceH;if(void 0===i){var n=e.h;void 0===n&&(n=0);var r=e.offY;void 0===r&&(r=0),i=n+r}if(0>=i)continue;this.firstCharHeight=i;break}}return this.firstCharHeight},n.parseConfig=function(t){t=t.split("\r\n").join("\n");for(var e=t.split("\n"),i=this.getConfigByKey(e[3],"count"),n={},r=4;4+i>r;r++){var s=e[r],a=String.fromCharCode(this.getConfigByKey(s,"id")),o={};n[a]=o,o.x=this.getConfigByKey(s,"x"),o.y=this.getConfigByKey(s,"y"),o.w=this.getConfigByKey(s,"width"),o.h=this.getConfigByKey(s,"height"),o.offX=this.getConfigByKey(s,"xoffset"),o.offY=this.getConfigByKey(s,"yoffset"),o.xadvance=this.getConfigByKey(s,"xadvance")}return n},n.getConfigByKey=function(t,e){for(var i=t.split(" "),n=0,r=i.length;r>n;n++){var s=i[n];if(e==s.substring(0,e.length)){var a=s.substring(e.length+1);return parseInt(a)}}return 0},e}(t.SpriteSheet);t.BitmapFont=e,t.registerClass(e,"egret.BitmapFont")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){e.call(this),this.$textOffsetX=0,this.$textOffsetY=0,this.$textStartX=0,this.$textStartY=0,this.$lineHeights=[],this.$renderNode=new t.sys.BitmapNode,this.$BitmapText={0:0/0,1:0/0,2:"",3:0,4:0,5:null,6:!1,7:!1,8:!1,9:!1,10:"left",11:"top",12:t.Bitmap.defaultSmoothing}}__extends(i,e);var n=__define,r=i,s=r.prototype;return n(s,"smoothing",function(){var t=this.$BitmapText;return t[12]},function(t){t=!!t;var e=this.$BitmapText;t!=e[12]&&(e[12]=t,this.$invalidate())}),n(s,"text",function(){return this.$BitmapText[2]},function(t){this.$setText(t)}),s.$setText=function(t){t=String(t);var e=this.$BitmapText;return t==e[2]?!1:(e[2]=t,this.$invalidateContentBounds(),!0)},s.$getWidth=function(){var t=this.$BitmapText[0];return isNaN(t)?this.$getContentBounds().width:t},s.$setWidth=function(t){var e=this.$BitmapText;return 0>t||t==e[0]?!1:(e[0]=t,this.$invalidateContentBounds(),!0)},s.$invalidateContentBounds=function(){e.prototype.$invalidateContentBounds.call(this),this.$BitmapText[7]=!0},s.$getHeight=function(){var t=this.$BitmapText[1];return isNaN(t)?this.$getContentBounds().height:t},s.$setHeight=function(t){var e=this.$BitmapText;return 0>t||t==e[1]?!1:(e[1]=t,this.$invalidateContentBounds(),!0)},n(s,"font",function(){return this.$BitmapText[5]},function(t){this.$setFont(t)}),s.$setFont=function(t){var e=this.$BitmapText;return e[5]==t?!1:(e[5]=t,this.$BitmapText[6]=!0,this.$invalidateContentBounds(),!0)},n(s,"lineSpacing",function(){return this.$BitmapText[3]},function(t){this.$setLineSpacing(t)}),s.$setLineSpacing=function(t){t=+t||0;var e=this.$BitmapText;return e[3]==t?!1:(e[3]=t,this.$invalidateContentBounds(),!0)},n(s,"letterSpacing",function(){return this.$BitmapText[4]},function(t){this.$setLetterSpacing(t)}),s.$setLetterSpacing=function(t){t=+t||0;var e=this.$BitmapText;return e[4]==t?!1:(e[4]=t,this.$invalidateContentBounds(),!0)},n(s,"textAlign",function(){return this.$BitmapText[10]},function(t){this.$setTextAlign(t)}),s.$setTextAlign=function(t){var e=this.$BitmapText;return e[10]==t?!1:(e[10]=t,this.$invalidateContentBounds(),!0)},n(s,"verticalAlign",function(){return this.$BitmapText[11]},function(t){this.$setVerticalAlign(t)}),s.$setVerticalAlign=function(t){var e=this.$BitmapText;return e[11]==t?!1:(e[11]=t,this.$invalidateContentBounds(),!0)},s.$render=function(){var e=this.$BitmapText,n=this.$getTextLines(),r=n.length;if(0!=r){var s=this.$textLinesWidth,a=e[5],o=this.$renderNode;a.$texture&&(o.image=a.$texture._bitmapData),o.smoothing=e[12];for(var h=a._getFirstCharHeight(),l=Math.ceil(h*i.EMPTY_FACTOR),u=!isNaN(e[1]),c=e[8],d=e[0],f=e[1],g=e[10],p=this.$textOffsetY+this.$textStartY,v=this.$lineHeights,$=0;r>$;$++){var y=v[$];if(u&&$>0&&p+y>f)break;var m=n[$],T=m.length,x=this.$textOffsetX;if(g!=t.HorizontalAlign.LEFT){var b=d>c?d:c;g==t.HorizontalAlign.RIGHT?x+=b-s[$]:g==t.HorizontalAlign.CENTER&&(x+=Math.floor((b-s[$])/2))}for(var _=0;T>_;_++){var E=m.charAt(_),F=a.getTexture(E);if(F){var C=F._bitmapWidth,w=F._bitmapHeight;o.imageWidth=F._sourceWidth,o.imageHeight=F._sourceHeight,o.drawImage(F._bitmapX,F._bitmapY,C,w,x+F._offsetX,p+F._offsetY,F.$getScaleBitmapWidth(),F.$getScaleBitmapHeight()),x+=a.getConfig(E,"xadvance")||F.$getTextureWidth()+e[4]}else" "==E?x+=l:t.$warn(1046,E)}p+=y+e[3]}}},s.$measureContentBounds=function(t){var e=this.$getTextLines();0==e.length?t.setEmpty():t.setTo(this.$textOffsetX+this.$textStartX,this.$textOffsetY+this.$textStartY,this.$BitmapText[8]-this.$textOffsetX,this.$BitmapText[9]-this.$textOffsetY)},n(s,"textWidth",function(){return this.$getTextLines(),this.$BitmapText[8]}),n(s,"textHeight",function(){return this.$getTextLines(),this.$BitmapText[9]}),s.$getTextLines=function(){function e(t){return p&&r.length>0&&u>p?!1:(u+=C+o,R||S||(w-=h),r.push(t),a.push(C),s.push(w),l=Math.max(w,l),!0)}var n=this.$BitmapText;if(!n[7])return this.textLines;var r=[];this.textLines=r;var s=[];this.$textLinesWidth=s,n[7]=!1;var a=[];if(this.$lineHeights=a,!n[2]||!n[5])return r;for(var o=n[3],h=n[4],l=0,u=0,c=0,d=0,f=!isNaN(n[0]),g=n[0],p=n[1],v=n[5],$=v._getFirstCharHeight(),y=Math.ceil($*i.EMPTY_FACTOR),m=n[2],T=m.split(/(?:\r\n|\r|\n)/),x=T.length,b=!0,_=0;x>_;_++){for(var E=T[_],F=E.length,C=0,w=0,R=!0,S=!1,D=0;F>D;D++){R||(w+=h);var O,L,N=E.charAt(D),M=0,A=0,B=v.getTexture(N);if(B)O=B.$getTextureWidth(),L=B.$getTextureHeight(),M=B._offsetX,A=B._offsetY;else{if(" "!=N){t.$warn(1046,N),R&&(R=!1);continue}O=y,L=$}if(R&&(R=!1,c=Math.min(M,c)),b&&(b=!1,d=Math.min(A,d)),f&&D>0&&w+O>g){if(!e(E.substring(0,D)))break;E=E.substring(D),F=E.length,D=0,w=D==F-1?O:v.getConfig(N,"xadvance")||O,C=L}else w+=D==F-1?O:v.getConfig(N,"xadvance")||O,C=Math.max(L,C)}if(p&&_>0&&u>p)break;if(S=!0,!e(E))break}u-=o,n[8]=l,n[9]=u,this.$textOffsetX=c,this.$textOffsetY=d,this.$textStartX=0,this.$textStartY=0;var I;return g>l&&(I=n[10],I==t.HorizontalAlign.RIGHT?this.$textStartX=g-l:I==t.HorizontalAlign.CENTER&&(this.$textStartX=Math.floor((g-l)/2))),p>u&&(I=n[11],I==t.VerticalAlign.BOTTOM?this.$textStartY=p-u:I==t.VerticalAlign.MIDDLE&&(this.$textStartY=Math.floor((p-u)/2))),r},i.EMPTY_FACTOR=.33,i}(t.DisplayObject);t.BitmapText=e,t.registerClass(e,"egret.BitmapText")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.LEFT="left",t.RIGHT="right",t.CENTER="center",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.HorizontalAlign=e,t.registerClass(e,"egret.HorizontalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this.replaceArr=[],this.resutlArr=[],this.initReplaceArr()}var i=e,n=i.prototype;return n.initReplaceArr=function(){this.replaceArr=[],this.replaceArr.push([/</g,"<"]),this.replaceArr.push([/>/g,">"]),this.replaceArr.push([/&/g,"&"]),this.replaceArr.push([/"/g,'"']),this.replaceArr.push([/'/g,"'"])},n.replaceSpecial=function(t){for(var e=0;ei;){var r=e.indexOf("<",i);if(0>r)this.addToResultArr(e.substring(i)),i=n;else{this.addToResultArr(e.substring(i,r));var s=e.indexOf(">",r);-1==s?(t.$error(1038),s=r):"/"==e.charAt(r+1)?this.stackArray.pop():this.addToArray(e.substring(r+1,s)),i=s+1}}return this.resutlArr},n.addToResultArr=function(t){""!=t&&(t=this.replaceSpecial(t),this.stackArray.length>0?this.resutlArr.push({text:t,style:this.stackArray[this.stackArray.length-1]}):this.resutlArr.push({text:t}))},n.changeStringToObject=function(t){t=t.trim();var e={},i=[];if("i"==t.charAt(0)||"b"==t.charAt(0)||"u"==t.charAt(0))this.addProperty(e,t,"true");else if(i=t.match(/^(font|a)\s/)){t=t.substring(i[0].length).trim();for(var n,r=0;n=t.match(this.getHeadReg());){var s=n[0],a="",t=t.substring(s.length).trim();if('"'==t.charAt(0)){var r=t.indexOf('"',1);a=t.substring(1,r),r+=1}else if("'"==t.charAt(0)){var r=t.indexOf("'",1);a=t.substring(1,r),r+=1}else a=t.match(/(\S)+/)[0],r=a.length;this.addProperty(e,s.substring(0,s.length-1).trim(),a.trim()),t=t.substring(r).trim()}}return e},n.getHeadReg=function(){return/^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/},n.addProperty=function(t,e,i){switch(e.toLowerCase()){case"color":case"textcolor":i=i.replace(/#/,"0x"),t.textColor=parseInt(i);break;case"strokecolor":i=i.replace(/#/,"0x"),t.strokeColor=parseInt(i);break;case"stroke":t.stroke=parseInt(i);break;case"b":case"bold":t.bold="true"==i;break;case"u":t.underline="true"==i;break;case"i":case"italic":t.italic="true"==i;break;case"size":t.size=parseInt(i);break;case"fontfamily":t.fontFamily=i;break;case"href":t.href=this.replaceSpecial(i);break;case"target":t.target=this.replaceSpecial(i)}},n.addToArray=function(t){var e=this.changeStringToObject(t);if(0==this.stackArray.length)this.stackArray.push(e);else{var i=this.stackArray[this.stackArray.length-1];for(var n in i)null==e[n]&&(e[n]=i[n]);this.stackArray.push(e)}},e}();t.HtmlTextParser=e,t.registerClass(e,"egret.HtmlTextParser")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){e.call(this),this._text=null,this._isFocus=!1}__extends(i,e);var n=i,r=n.prototype;return r.init=function(e){this._text=e,this.stageText=new t.StageText,this.stageText.$setTextField(this._text)},r._addStageText=function(){this._text.$inputEnabled||(this._text.$touchEnabled=!0),this.tempStage=this._text.stage,this.stageText.$addToStage(),this.stageText.addEventListener("updateText",this.updateTextHandler,this),this._text.addEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.stageText.addEventListener("blur",this.blurHandler,this),this.stageText.addEventListener("focus",this.focusHandler,this)},r._removeStageText=function(){this._text.$inputEnabled||(this._text.$touchEnabled=!1),this.stageText.$removeFromStage(),this.stageText.removeEventListener("updateText",this.updateTextHandler,this),this._text.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this.stageText.removeEventListener("blur",this.blurHandler,this),this.stageText.removeEventListener("focus",this.focusHandler,this)},r._getText=function(){return this.stageText.$getText()},r._setText=function(t){this.stageText.$setText(t)},r._setColor=function(t){this.stageText.$setColor(t) },r.focusHandler=function(e){this._isFocus||(this._isFocus=!0,e.showing||(this._text.$isTyping=!0),this._text.$invalidateContentBounds(),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_IN,!0)))},r.blurHandler=function(e){this._isFocus&&(this._isFocus=!1,this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this._text.$isTyping=!1,this._text.$invalidateContentBounds(),this.stageText.$onBlur(),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_OUT,!0)))},r.onMouseDownHandler=function(t){t.stopPropagation(),this.$onFocus()},r.$onFocus=function(){this._text.visible&&(this._isFocus||(this.tempStage.addEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this.stageText.$show()))},r.onStageDownHandler=function(t){this.stageText.$hide()},r.updateTextHandler=function(e){var i=this._text.$TextField,n=this.stageText.$getText(),r=!1;if(null!=i[35]){var s=new RegExp("["+i[35]+"]","g"),a=n.match(s);n=a?a.join(""):"",r=!0}null!=i[36]&&(s=new RegExp("[^"+i[36]+"]","g"),a=n.match(s),n=a?a.join(""):"",r=!0),r&&this.stageText.$getText()!=n&&this.stageText.$setText(n),this.resetText(),this._text.dispatchEvent(new t.Event(t.Event.CHANGE,!0))},r.resetText=function(){this._text.$setBaseText(this.stageText.$getText())},r._hideInput=function(){this.stageText.$removeFromStage()},r.updateInput=function(){!this._text.$visible&&this.stageText&&this._hideInput()},r._updateProperties=function(){if(this._isFocus)return this.stageText.$resetStageText(),void this.updateInput();var t=this._text.$stage;if(null==t);else for(var e=this._text,i=e.$visible;;){if(!i)break;if(e=e.parent,e==t)break;i=e.$visible}this.stageText.$setText(this._text.$TextField[13]),this.stageText.$resetStageText(),this.updateInput()},i}(t.HashObject);t.InputController=e,t.registerClass(e,"egret.InputController")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(e,i,r){r=r||{};var s=null==r.italic?i[16]:r.italic,a=null==r.bold?i[15]:r.bold,o=null==r.size?i[0]:r.size,h=r.fontFamily||i[8]||n.default_fontFamily;return t.sys.measureText(e,h,o,a,s)}var i=new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"),n=function(n){function r(){n.call(this),this.$inputEnabled=!1,this.inputUtils=null,this.graphicsNode=null,this.isFlow=!1,this.textArr=[],this.linesArr=[],this.$isTyping=!1;var e=new t.sys.TextNode;e.fontFamily=r.default_fontFamily,this.textNode=e,this.$renderNode=e,this.$TextField={0:30,1:0,2:16777215,3:0/0,4:0/0,5:0,6:0,7:0,8:r.default_fontFamily,9:"left",10:"top",11:"#ffffff",12:"",13:"",14:[],15:!1,16:!1,17:!0,18:!1,19:!1,20:!1,21:0,22:0,23:0,24:t.TextFieldType.DYNAMIC,25:0,26:"#000000",27:0,28:-1,29:0,30:!1,31:!1,32:0,33:!1,34:16777215,35:null,36:null,37:t.TextFieldInputType.TEXT}}__extends(r,n);var s=__define,a=r,o=a.prototype;return o.isInput=function(){return this.$TextField[24]==t.TextFieldType.INPUT},o.$setTouchEnabled=function(t){var e=n.prototype.$setTouchEnabled.call(this,t);return this.isInput()&&(this.$inputEnabled=!0),e},s(o,"fontFamily",function(){return this.$TextField[8]},function(t){this.$setFontFamily(t)}),o.$setFontFamily=function(t){var e=this.$TextField;return e[8]==t?!1:(e[8]=t,this.invalidateFontString(),!0)},s(o,"size",function(){return this.$TextField[0]},function(t){this.$setSize(t)}),o.$setSize=function(t){t=+t||0;var e=this.$TextField;return e[0]==t?!1:(e[0]=t,this.invalidateFontString(),!0)},s(o,"bold",function(){return this.$TextField[15]},function(t){this.$setBold(t)}),o.$setBold=function(t){t=!!t;var e=this.$TextField;return t==e[15]?!1:(e[15]=t,this.invalidateFontString(),!0)},s(o,"italic",function(){return this.$TextField[16]},function(t){this.$setItalic(t)}),o.$setItalic=function(t){t=!!t;var e=this.$TextField;return t==e[16]?!1:(e[16]=t,this.invalidateFontString(),!0)},o.invalidateFontString=function(){this.$TextField[17]=!0,this.$invalidateTextField()},s(o,"textAlign",function(){return this.$TextField[9]},function(t){this.$setTextAlign(t)}),o.$setTextAlign=function(t){var e=this.$TextField;return e[9]==t?!1:(e[9]=t,this.$invalidateTextField(),!0)},s(o,"verticalAlign",function(){return this.$TextField[10]},function(t){this.$setVerticalAlign(t)}),o.$setVerticalAlign=function(t){var e=this.$TextField;return e[10]==t?!1:(e[10]=t,this.$invalidateTextField(),!0)},s(o,"lineSpacing",function(){return this.$TextField[1]},function(t){this.$setLineSpacing(t)}),o.$setLineSpacing=function(t){t=+t||0;var e=this.$TextField;return e[1]==t?!1:(e[1]=t,this.$invalidateTextField(),!0)},s(o,"textColor",function(){return this.$TextField[2]},function(t){this.$setTextColor(t)}),o.$setTextColor=function(t){t=0|+t;var e=this.$TextField;return e[2]==t?!1:(e[2]=t,this.inputUtils&&this.inputUtils._setColor(this.$TextField[2]),this.$invalidate(),!0)},s(o,"wordWrap",function(){return this.$TextField[19]},function(t){t=!!t;var e=this.$TextField;t!=e[19]&&(e[20]||(e[19]=t,this.$invalidateTextField()))}),s(o,"type",function(){return this.$TextField[24]},function(t){this.$setType(t)}),o.$setType=function(e){var i=this.$TextField;return i[24]!=e?(i[24]=e,e==t.TextFieldType.INPUT?(isNaN(i[3])&&this.$setWidth(100),isNaN(i[4])&&this.$setHeight(30),this.$setTouchEnabled(!0),null==this.inputUtils&&(this.inputUtils=new t.InputController),this.inputUtils.init(this),this.$invalidateTextField(),this.$stage&&this.inputUtils._addStageText()):(this.inputUtils&&(this.inputUtils._removeStageText(),this.inputUtils=null),this.$setTouchEnabled(!1)),!0):!1},s(o,"inputType",function(){return this.$TextField[37]},function(t){this.$TextField[37]=t}),s(o,"text",function(){return this.$getText()},function(t){this.$setText(t)}),o.$getText=function(){return this.$TextField[24]==t.TextFieldType.INPUT?this.inputUtils._getText():this.$TextField[13]},o.$setBaseText=function(t){null==t&&(t=""),t=t.toString(),this.isFlow=!1;var e=this.$TextField;if(e[13]!=t){this.$invalidateTextField(),e[13]=t;var i="";return i=e[20]?this.changeToPassText(t):t,this.setMiddleStyle([{text:i}]),!0}return!1},o.$setText=function(t){null==t&&(t="");var e=this.$setBaseText(t);return this.inputUtils&&this.inputUtils._setText(this.$TextField[13]),e},s(o,"displayAsPassword",function(){return this.$TextField[20]},function(t){this.$setDisplayAsPassword(t)}),o.$setDisplayAsPassword=function(t){var e=this.$TextField;if(e[20]!=t){e[20]=t,this.$invalidateTextField();var i="";return i=t?this.changeToPassText(e[13]):e[13],this.setMiddleStyle([{text:i}]),!0}return!1},s(o,"strokeColor",function(){return this.$TextField[25]},function(t){t=+t||0,this.$setStrokeColor(t)}),o.$setStrokeColor=function(e){var i=this.$TextField;return i[25]!=e?(this.$invalidateTextField(),i[25]=e,i[26]=t.toColorString(e),!0):!1},s(o,"stroke",function(){return this.$TextField[27]},function(t){this.$setStroke(t)}),o.$setStroke=function(t){return this.$TextField[27]!=t?(this.$invalidateTextField(),this.$TextField[27]=t,!0):!1},s(o,"maxChars",function(){return this.$TextField[21]},function(t){this.$setMaxChars(t)}),o.$setMaxChars=function(t){return this.$TextField[21]!=t?(this.$TextField[21]=t,!0):!1},s(o,"scrollV",function(){return Math.min(Math.max(this.$TextField[28],1),this.maxScrollV)},function(t){this.$TextField[28]=Math.max(t,1),this.$invalidateTextField()}),s(o,"maxScrollV",function(){return this.$getLinesArr(),Math.max(this.$TextField[29]-t.TextFieldUtils.$getScrollNum(this)+1,1)}),s(o,"selectionBeginIndex",function(){return 0}),s(o,"selectionEndIndex",function(){return 0}),s(o,"caretIndex",function(){return 0}),o.$setSelection=function(t,e){return!1},o.$getLineHeight=function(){return this.$TextField[1]+this.$TextField[0]},s(o,"numLines",function(){return this.$getLinesArr(),this.$TextField[29]}),s(o,"multiline",function(){return this.$TextField[30]},function(t){this.$setMultiline(t)}),o.$setMultiline=function(t){return this.$TextField[30]=t,this.$invalidateTextField(),!0},s(o,"restrict",function(){var t=this.$TextField,e=null;return null!=t[35]&&(e=t[35]),null!=t[36]&&(null==e&&(e=""),e+="^"+t[36]),e},function(t){var e=this.$TextField;if(null==t)e[35]=null,e[36]=null;else{for(var i=-1;i0&&"\\"==t.charAt(i-1);)i++;0==i?(e[35]=null,e[36]=t.substring(i+1)):i>0?(e[35]=t.substring(0,i),e[36]=t.substring(i+1)):(e[35]=t,e[36]=null)}}),o.$setWidth=function(t){var e=this.$TextField;if(isNaN(t)){if(isNaN(e[3]))return!1;e[3]=0/0}else{if(e[3]==t)return!1;e[3]=t}return t=+t,0>t?!1:(this.$invalidateTextField(),!0)},o.$setHeight=function(t){var e=this.$TextField;if(isNaN(t)){if(isNaN(e[4]))return!1;e[4]=0/0}else{if(e[4]==t)return!1;e[4]=t}return t=+t,0>t?!1:(this.$invalidateTextField(),!0)},o.$getWidth=function(){var t=this.$TextField;return isNaN(t[3])?this.$getContentBounds().width:t[3]},o.$getHeight=function(){var t=this.$TextField;return isNaN(t[4])?this.$getContentBounds().height:t[4]},s(o,"border",function(){return this.$TextField[31]},function(t){this.$TextField[31]=!!t,this.$invalidate()}),s(o,"borderColor",function(){return this.$TextField[32]},function(t){this.$TextField[32]=+t||0,this.$invalidate()}),s(o,"background",function(){return this.$TextField[33]},function(t){this.$TextField[33]=t,this.$invalidate()}),s(o,"backgroundColor",function(){return this.$TextField[34]},function(t){this.$TextField[34]=t,this.$invalidate()}),o.fillBackground=function(e){var i=this.graphicsNode;i&&i.clear();var n=this.$TextField;if(n[33]||n[31]||e.length>0){if(!i){i=this.graphicsNode=new t.sys.GraphicsNode;var r=new t.sys.GroupNode;r.addNode(i),r.addNode(this.textNode),this.$renderNode=r}var s,a;if(n[33]&&(s=i.beginFill(n[34]),s.drawRect(0,0,this.$getWidth(),this.$getHeight())),n[31]&&(a=i.lineStyle(1,n[32]),a.drawRect(0,0,this.$getWidth()-1,this.$getHeight()-1)),e.length>0)for(var o=n[2],h=-1,l=e.length,u=0;l>u;u+=4){var c=e[u],d=e[u+1],f=e[u+2],g=e[u+3]||o;(0>h||h!=g)&&(h=g,a=i.lineStyle(2,g,1,t.CapsStyle.NONE)),a.moveTo(c,d),a.lineTo(c+f,d)}}if(i){var p=this.$getRenderBounds();i.x=p.x,i.y=p.y,i.width=p.width,i.height=p.height,t.Rectangle.release(p)}},o.setFocus=function(){this.type==t.TextFieldType.INPUT&&this.$stage&&this.inputUtils.$onFocus()},o.$onRemoveFromStage=function(){n.prototype.$onRemoveFromStage.call(this),this.removeEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._removeStageText()},o.$onAddToStage=function(e,i){n.prototype.$onAddToStage.call(this,e,i),this.addEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._addStageText()},o.$invalidateTextField=function(){this.$invalidateContentBounds(),this.$TextField[18]=!0},o.$update=function(e,i){var r=this.$getRenderBounds(),s=n.prototype.$update.call(this,e,r);return t.Rectangle.release(r),s},o.$getRenderBounds=function(){var e=this.$getContentBounds(),i=t.Rectangle.create();i.copyFrom(e),this.$TextField[31]&&(i.width+=2,i.height+=2);var n=2*this.$TextField[27];return n>0&&(i.width+=2*n,i.height+=2*n),i.x-=n+2,i.y-=n+2,i.width=Math.ceil(i.width)+4,i.height=Math.ceil(i.height)+4,i},o.$measureContentBounds=function(e){this.$getLinesArr();var i=isNaN(this.$TextField[3])?this.$TextField[5]:this.$TextField[3],n=isNaN(this.$TextField[4])?t.TextFieldUtils.$getTextHeight(this):this.$TextField[4];e.setTo(0,0,i,n)},o.$render=function(){if(this.$TextField[24]==t.TextFieldType.INPUT){if((this.$hasAnyFlags(2032)||this.$hasAnyFlags(1648))&&this.inputUtils._updateProperties(),this.$isTyping)return}else if(0==this.$TextField[3])return;var e=this.drawText();this.fillBackground(e);var i=this.$getRenderBounds(),n=this.textNode;n.x=i.x,n.y=i.y,n.width=Math.ceil(i.width),n.height=Math.ceil(i.height),t.Rectangle.release(i)},s(o,"textFlow",function(){return this.textArr},function(t){this.isFlow=!0;var e="";null==t&&(t=[]);for(var i=0;ii;i++)switch(t.charAt(i)){case"\n":e+="\n";break;case"\r":break;default:e+="*"}return e}return t},o.setMiddleStyle=function(t){this.$TextField[18]=!0,this.textArr=t,this.$invalidateTextField()},s(o,"textWidth",function(){return this.$getLinesArr(),this.$TextField[5]}),s(o,"textHeight",function(){return this.$getLinesArr(),t.TextFieldUtils.$getTextHeight(this)}),o.appendText=function(t){this.appendElement({text:t})},o.appendElement=function(t){var e=this.$TextField[13]+t.text;this.$TextField[20]?this.$setBaseText(e):(this.$TextField[13]=e,this.textArr.push(t),this.setMiddleStyle(this.textArr))},o.$getLinesArr=function(){var n=this.$TextField;if(!n[18])return this.linesArr;n[18]=!1;var r=this.textArr;this.linesArr.length=0,n[6]=0,n[5]=0;var s=n[3];if(!isNaN(s)&&0==s)return n[29]=0,[{width:0,height:0,charNum:0,elements:[],hasNextLine:!1}];for(var a,o=this.linesArr,h=0,l=0,u=0,c=0,d=0,f=r.length;f>d;d++){var g=r[d];if(g.text){g.style=g.style||{};for(var p=g.text.toString(),v=p.split(/(?:\r\n|\r|\n)/),$=0,y=v.length;y>$;$++){null==o[c]&&(a={width:0,height:0,elements:[],charNum:0,hasNextLine:!1},o[c]=a,h=0,u=0,l=0),u=n[24]==t.TextFieldType.INPUT?n[0]:Math.max(u,g.style.size||n[0]);var m=!0;if(""==v[$])$==y-1&&(m=!1);else{var T=e(v[$],n,g.style);if(isNaN(s))h+=T,l+=v[$].length,a.elements.push({width:T,text:v[$],style:g.style}),$==y-1&&(m=!1);else if(s>=h+T)a.elements.push({width:T,text:v[$],style:g.style}),h+=T,l+=v[$].length,$==y-1&&(m=!1);else{var x=0,b=0,_=v[$];if(n[19])var E=_.split(i);else E=_.match(/./g);for(var F=E.length,C=0;F>x&&(T=e(E[x],n,g.style),!(0!=h&&h+T>s&&h+x!=0));x++)if(b+T>s)for(var w=E[x].match(/./g),R=0,S=w.length;S>R&&(T=e(w[R],n,g.style),!(R>0&&h+T>s));R++)C+=w[R].length,b+=T,h+=T,l+=C;else C+=E[x].length,b+=T,h+=T,l+=C;if(x>0){a.elements.push({width:b,text:_.substring(0,C),style:g.style});for(var D=_.substring(C),O=0,L=D.length;L>O&&" "==D.charAt(O);O++);v[$]=D.substring(O)}""!=v[$]&&($--,m=!1)}}m&&(l++,a.hasNextLine=!0),$a){var u=t.TextFieldUtils.$getValign(this);o+=u*(l-a)}o=Math.round(o);for(var c=t.TextFieldUtils.$getHalign(this),d=0,f=[],g=h,p=i[29];p>g;g++){var v=n[g],$=v.height;if(o+=$/2,g!=h){if(i[24]==t.TextFieldType.INPUT&&!i[30])break;if(!isNaN(l)&&o>l)break}d=Math.round((s-v.width)*c);for(var y=0,m=v.elements.length;m>y;y++){var T=v.elements[y],x=T.style.size||i[0];e.drawText(d,o+($-x)/2,T.text,T.style),T.style.underline&&f.push(d,o+$/2,T.width,T.style.textColor),d+=T.width}o+=$/2+i[1]}return f},o.addEvent=function(){this.addEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},o.removeEvent=function(){this.removeEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},o.onTapHandler=function(e){if(this.$TextField[24]!=t.TextFieldType.INPUT){var i=t.TextFieldUtils.$getTextElement(this,e.localX,e.localY);if(null!=i){var n=i.style;if(n&&n.href)if(n.href.match(/^event:/)){var r=n.href.match(/^event:/)[0];t.TextEvent.dispatchTextEvent(this,t.TextEvent.LINK,n.href.substring(r.length))}else open(n.href,n.target||"_blank")}}},r.default_fontFamily="Arial",r}(t.DisplayObject);t.TextField=n,t.registerClass(n,"egret.TextField")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.TEXT="text",t.TEL="tel",t.PASSWORD="password",t}();t.TextFieldInputType=e,t.registerClass(e,"egret.TextFieldInputType")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.DYNAMIC="dynamic",t.INPUT="input",t}();t.TextFieldType=e,t.registerClass(e,"egret.TextFieldType")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}var i=e;i.prototype;return e.$getStartLine=function(t){var i=t.$TextField,n=e.$getTextHeight(t),r=0,s=i[4];return isNaN(s)||(s>n||n>s&&(r=Math.max(i[28]-1,0),r=Math.min(i[29]-1,r)),i[30]||(r=Math.max(i[28]-1,0),i[29]>0&&(r=Math.min(i[29]-1,r)))),r},e.$getHalign=function(e){var i=e.$getLinesArr(),n=0;return e.$TextField[9]==t.HorizontalAlign.CENTER?n=.5:e.$TextField[9]==t.HorizontalAlign.RIGHT&&(n=1),e.$TextField[24]==t.TextFieldType.INPUT&&!e.$TextField[30]&&i.length>1&&(n=0),n},e.$getTextHeight=function(e){var i=t.TextFieldType.INPUT!=e.$TextField[24]||e.$TextField[30]?e.$TextField[6]+(e.$TextField[29]-1)*e.$TextField[1]:e.$TextField[0];return i},e.$getValign=function(i){var n=e.$getTextHeight(i),r=i.$TextField[4];if(!isNaN(r)&&r>n){var s=0;return i.$TextField[10]==t.VerticalAlign.MIDDLE?s=.5:i.$TextField[10]==t.VerticalAlign.BOTTOM&&(s=1),s}return 0},e.$getTextElement=function(t,i,n){var r=e.$getHit(t,i,n),s=t.$getLinesArr();return r&&s[r.lineIndex]&&s[r.lineIndex].elements[r.textElementIndex]?s[r.lineIndex].elements[r.textElementIndex]:null},e.$getHit=function(t,i,n){var r=t.$getLinesArr();if(0==t.$TextField[3])return null;var s=0,a=e.$getTextHeight(t),o=0,h=t.$TextField[4];if(!isNaN(h)&&h>a){var l=e.$getValign(t);o=l*(h-a),0!=o&&(n-=o)}for(var u=e.$getStartLine(t),c=0,d=u;d=n){s=d+1;break}if(c+=f.height,c+t.$TextField[1]>n)return null;c+=t.$TextField[1]}if(0==s)return null;var g=r[s-1],p=0;for(d=0;dn/2&&e++}return e},e}();t.TextFieldUtils=e,t.registerClass(e,"egret.TextFieldUtils")}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.TOP="top",t.BOTTOM="bottom",t.MIDDLE="middle",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.VerticalAlign=e,t.registerClass(e,"egret.VerticalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.LITTLE_ENDIAN="littleEndian",t.BIG_ENDIAN="bigEndian",t}();t.Endian=e,t.registerClass(e,"egret.Endian");var i=function(){function i(t){this.BUFFER_EXT_SIZE=0,this.EOF_byte=-1,this.EOF_code_point=-1,this._setArrayBuffer(t||new ArrayBuffer(this.BUFFER_EXT_SIZE)),this.endian=e.BIG_ENDIAN}var n=__define,r=i,s=r.prototype;return s._setArrayBuffer=function(t){this.write_position=t.byteLength,this.data=new DataView(t),this._position=0},s.setArrayBuffer=function(t){},n(s,"buffer",function(){return this.data.buffer},function(t){this.data=new DataView(t)}),n(s,"dataView",function(){return this.data},function(t){this.data=t,this.write_position=t.byteLength}),n(s,"bufferOffset",function(){return this.data.byteOffset}),n(s,"position",function(){return this._position},function(t){this._position=t,this.write_position=t>this.write_position?t:this.write_position}),n(s,"length",function(){return this.write_position},function(t){this.write_position=t;var e=new Uint8Array(new ArrayBuffer(t)),i=this.data.buffer.byteLength;i>t&&(this._position=t);var n=Math.min(i,t);e.set(new Uint8Array(this.data.buffer,0,n)),this.buffer=e.buffer}),n(s,"bytesAvailable",function(){return this.data.byteLength-this._position}),s.clear=function(){this._setArrayBuffer(new ArrayBuffer(this.BUFFER_EXT_SIZE))},s.readBoolean=function(){return this.validate(i.SIZE_OF_BOOLEAN)?0!=this.data.getUint8(this.position++):null},s.readByte=function(){return this.validate(i.SIZE_OF_INT8)?this.data.getInt8(this.position++):null},s.readBytes=function(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=0),0==n)n=this.bytesAvailable;else if(!this.validate(n))return null;t?t.validateBuffer(e+n):t=new i(new ArrayBuffer(e+n));for(var r=0;n>r;r++)t.data.setUint8(r+e,this.data.getUint8(this.position++))},s.readDouble=function(){if(!this.validate(i.SIZE_OF_FLOAT64))return null;var t=this.data.getFloat64(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_FLOAT64,t},s.readFloat=function(){if(!this.validate(i.SIZE_OF_FLOAT32))return null;var t=this.data.getFloat32(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_FLOAT32,t},s.readInt=function(){if(!this.validate(i.SIZE_OF_INT32))return null;var t=this.data.getInt32(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_INT32,t},s.readShort=function(){if(!this.validate(i.SIZE_OF_INT16))return null;var t=this.data.getInt16(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_INT16,t},s.readUnsignedByte=function(){return this.validate(i.SIZE_OF_UINT8)?this.data.getUint8(this.position++):null},s.readUnsignedInt=function(){if(!this.validate(i.SIZE_OF_UINT32))return null;var t=this.data.getUint32(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_UINT32,t},s.readUnsignedShort=function(){if(!this.validate(i.SIZE_OF_UINT16))return null;var t=this.data.getUint16(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_UINT16,t},s.readUTF=function(){if(!this.validate(i.SIZE_OF_UINT16))return null;var t=this.data.getUint16(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_UINT16,t>0?this.readUTFBytes(t):""},s.readUTFBytes=function(t){if(!this.validate(t))return null;var e=new Uint8Array(this.buffer,this.bufferOffset+this.position,t);return this.position+=t,this.decodeUTF8(e)},s.writeBoolean=function(t){this.validateBuffer(i.SIZE_OF_BOOLEAN),this.data.setUint8(this.position++,t?1:0)},s.writeByte=function(t){this.validateBuffer(i.SIZE_OF_INT8),this.data.setInt8(this.position++,t)},s.writeBytes=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var n;if(!(0>e)&&!(0>i)&&(n=0==i?t.length-e:Math.min(t.length-e,i),n>0)){this.validateBuffer(n);for(var r=new DataView(t.buffer),i=n,s=4;i>s;i-=s)this.data.setUint32(this._position,r.getUint32(e)),this.position+=s,e+=s;for(;i>0;i--)this.data.setUint8(this.position++,r.getUint8(e++))}},s.writeDouble=function(t){this.validateBuffer(i.SIZE_OF_FLOAT64),this.data.setFloat64(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_FLOAT64},s.writeFloat=function(t){this.validateBuffer(i.SIZE_OF_FLOAT32),this.data.setFloat32(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_FLOAT32},s.writeInt=function(t){this.validateBuffer(i.SIZE_OF_INT32),this.data.setInt32(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_INT32},s.writeShort=function(t){this.validateBuffer(i.SIZE_OF_INT16),this.data.setInt16(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_INT16},s.writeUnsignedInt=function(t){this.validateBuffer(i.SIZE_OF_UINT32),this.data.setUint32(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_UINT32},s.writeUnsignedShort=function(t){this.validateBuffer(i.SIZE_OF_UINT16),this.data.setUint16(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_UINT16},s.writeUTF=function(t){var n=this.encodeUTF8(t),r=n.length;this.validateBuffer(i.SIZE_OF_UINT16+r),this.data.setUint16(this.position,r,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_UINT16,this._writeUint8Array(n,!1)},s.writeUTFBytes=function(t){this._writeUint8Array(this.encodeUTF8(t))},s.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},s._writeUint8Array=function(t,e){void 0===e&&(e=!0),e&&this.validateBuffer(this.position+t.length);for(var i=0;i0&&this._position+e<=this.data.byteLength?!0:void t.$error(1025)},s.validateBuffer=function(t,e){if(void 0===e&&(e=!1),this.write_position=t>this.write_position?t:this.write_position,t+=this._position,this.data.byteLengthe;){var r=i[e++];if(this.inRange(r,55296,57343))this.encoderError(r);else if(this.inRange(r,0,127))n.push(r);else{var s,a;for(this.inRange(r,128,2047)?(s=1,a=192):this.inRange(r,2048,65535)?(s=2,a=224):this.inRange(r,65536,1114111)&&(s=3,a=240),n.push(this.div(r,Math.pow(64,s))+a);s>0;){var o=this.div(r,Math.pow(64,s-1));n.push(128+o%64),s-=1}}}return new Uint8Array(n)},s.decodeUTF8=function(t){for(var e,i=!1,n=0,r="",s=0,a=0,o=0,h=0;t.length>n;){var l=t[n++];if(l==this.EOF_byte)e=0!=a?this.decoderError(i):this.EOF_code_point;else if(0==a)this.inRange(l,0,127)?e=l:(this.inRange(l,194,223)?(a=1,h=128,s=l-192):this.inRange(l,224,239)?(a=2,h=2048,s=l-224):this.inRange(l,240,244)?(a=3,h=65536,s=l-240):this.decoderError(i),s*=Math.pow(64,a),e=null);else if(this.inRange(l,128,191))if(o+=1,s+=(l-128)*Math.pow(64,a-o),o!==a)e=null;else{var u=s,c=h;s=0,a=0,o=0,h=0,e=this.inRange(u,c,1114111)&&!this.inRange(u,55296,57343)?u:this.decoderError(i,l)}else s=0,a=0,o=0,h=0,n--,e=this.decoderError(i,l);null!==e&&e!==this.EOF_code_point&&(65535>=e?e>0&&(r+=String.fromCharCode(e)):(e-=65536,r+=String.fromCharCode(55296+(e>>10&1023)),r+=String.fromCharCode(56320+(1023&e))))}return r},s.encoderError=function(e){t.$error(1026,e)},s.decoderError=function(e,i){return e&&t.$error(1027),i||65533},s.inRange=function(t,e,i){return t>=e&&i>=t},s.div=function(t,e){return Math.floor(t/e)},s.stringToCodePoints=function(t){for(var e=[],i=0,n=t.length;it&&(t+=360),egret_sin_map[t]},t.cos=function(e){var i=Math.floor(e),n=i+1,r=t.cosInt(i);if(i==e)return r;var s=t.cosInt(n);return(e-i)*s+(n-e)*r},t.cosInt=function(t){return t%=360,0>t&&(t+=360),egret_cos_map[t]},t}();t.NumberUtils=e,t.registerClass(e,"egret.NumberUtils")}(egret||(egret={}));for(var egret_sin_map={},egret_cos_map={},DEG_TO_RAD=Math.PI/180,NumberUtils_i=0;360>NumberUtils_i;NumberUtils_i++)egret_sin_map[NumberUtils_i]=Math.sin(NumberUtils_i*DEG_TO_RAD),egret_cos_map[NumberUtils_i]=Math.cos(NumberUtils_i*DEG_TO_RAD);egret_sin_map[90]=1,egret_cos_map[90]=0,egret_sin_map[180]=0,egret_cos_map[180]=-1,egret_sin_map[270]=-1,egret_cos_map[270]=0,Function.prototype.bind||(Function.prototype.bind=function(t){"function"!=typeof this&&egret.$error(1029);var e=Array.prototype.slice.call(arguments,1),i=this,n=function(){},r=function(){return i.apply(this instanceof n&&t?this:t,e.concat(Array.prototype.slice.call(arguments)))};return n.prototype=this.prototype,r.prototype=new n,r});var egret;!function(t){var e=function(e){function i(t,i){void 0===i&&(i=0),e.call(this),this._delay=0,this._currentCount=0,this._running=!1,this.updateInterval=1e3,this.lastCount=1e3,this.delay=t,this.repeatCount=0|+i}__extends(i,e);var n=__define,r=i,s=r.prototype;return n(s,"delay",function(){return this._delay},function(t){1>t&&(t=1),this._delay!=t&&(this._delay=t,this.lastCount=this.updateInterval=Math.round(60*t))}),n(s,"currentCount",function(){return this._currentCount}),n(s,"running",function(){return this._running}),s.reset=function(){this.stop(),this._currentCount=0},s.start=function(){this._running||(this.lastCount=this.updateInterval,t.sys.$ticker.$startTick(this.$update,this),this._running=!0)},s.stop=function(){this._running&&(t.stopTick(this.$update,this),this._running=!1)},s.$update=function(e){if(this.lastCount-=1e3,this.lastCount>0)return!1;this.lastCount+=this.updateInterval,this._currentCount++;var i=this.repeatCount>0&&this._currentCount>=this.repeatCount;return t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER),i&&(this.stop(),t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER_COMPLETE)),!1},i}(t.EventDispatcher);t.Timer=e,t.registerClass(e,"egret.Timer")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(e,i){for(var n=[],r=2;rs;s++){var a=n[s];if(e=e[a],!e)return null}return i[t]=e,e}var i={};t.getDefinitionByName=e}(egret||(egret={}));var __global=__global||this,egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(t){var e=typeof t;if(!t||"object"!=e&&!t.prototype)return e;var i=t.prototype?t.prototype:Object.getPrototypeOf(t);if(i.hasOwnProperty("__class__"))return i.__class__;var n=i.constructor.toString().trim(),r=n.indexOf("("),s=n.substring(9,r);return Object.defineProperty(i,"__class__",{value:s,enumerable:!1,writable:!0}),s}t.getQualifiedClassName=e}(egret||(egret={}));var egret;!function(t){function e(e){if(!e||"object"!=typeof e&&!e.prototype)return null;var i=e.prototype?e.prototype:Object.getPrototypeOf(e),n=Object.getPrototypeOf(i);if(!n)return null;var r=t.getQualifiedClassName(n.constructor);return r?r:null}t.getQualifiedSuperclassName=e}(egret||(egret={}));var egret;!function(t){function e(){return Date.now()-t.sys.$START_TIME}t.getTimer=e}(egret||(egret={}));var egret;!function(t){function e(e){var i=t.getDefinitionByName(e);return i?!0:!1}t.hasDefinition=e -}(egret||(egret={}));var egret;!function(t){function e(t,e){if(!t||"object"!=typeof t)return!1;var i=Object.getPrototypeOf(t),n=i?i.__types__:null;return n?-1!==n.indexOf(e):!1}t.is=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.sys.$ticker.$startTick(e,i)}t.startTick=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.sys.$ticker.$stopTick(e,i)}t.stopTick=e}(egret||(egret={}));var egret;!function(t){function e(t){0>t&&(t=0),t>16777215&&(t=16777215);for(var e=t.toString(16).toUpperCase();e.length>6;)e=e.slice(1,e.length);for(;e.length<6;)e="0"+e;return"#"+e}t.toColorString=e}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}var i=e;i.prototype;return e.compileProgram=function(i,n,r){var s=e.compileFragmentShader(i,r),a=e.compileVertexShader(i,n),o=i.createProgram();return i.attachShader(o,a),i.attachShader(o,s),i.linkProgram(o),i.getProgramParameter(o,i.LINK_STATUS)||t.$warn(1020),o},e.compileFragmentShader=function(t,i){return e._compileShader(t,i,t.FRAGMENT_SHADER)},e.compileVertexShader=function(t,i){return e._compileShader(t,i,t.VERTEX_SHADER)},e._compileShader=function(t,e,i){var n=t.createShader(i);return t.shaderSource(n,e),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:null},e.checkCanUseWebGL=function(){if(void 0==e.canUseWebGL)try{var t=document.createElement("canvas");e.canUseWebGL=!(!window.WebGLRenderingContext||!t.getContext("webgl")&&!t.getContext("experimental-webgl"))}catch(i){e.canUseWebGL=!1}return e.canUseWebGL},e.deleteWebGLTexture=function(t){if(t){var e=t.webGLTexture;if(e)for(var i in e){var n=e[i],r=n.glContext;r.deleteTexture(n)}t.webGLTexture=null}},e}();t.WebGLUtils=e,t.registerClass(e,"egret.WebGLUtils")}(egret||(egret={})); \ No newline at end of file +}(egret||(egret={}));var egret;!function(t){function e(t,e){if(!t||"object"!=typeof t)return!1;var i=Object.getPrototypeOf(t),n=i?i.__types__:null;return n?-1!==n.indexOf(e):!1}t.is=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.sys.$ticker.$startTick(e,i)}t.startTick=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.sys.$ticker.$stopTick(e,i)}t.stopTick=e}(egret||(egret={}));var egret;!function(t){function e(t){0>t&&(t=0),t>16777215&&(t=16777215);for(var e=t.toString(16).toUpperCase();e.length>6;)e=e.slice(1,e.length);for(;e.length<6;)e="0"+e;return"#"+e}t.toColorString=e}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}var i=e;i.prototype;return e.compileProgram=function(i,n,r){var s=e.compileFragmentShader(i,r),a=e.compileVertexShader(i,n),o=i.createProgram();return i.attachShader(o,a),i.attachShader(o,s),i.linkProgram(o),i.getProgramParameter(o,i.LINK_STATUS)||t.$warn(1020),o},e.compileFragmentShader=function(t,i){return e._compileShader(t,i,t.FRAGMENT_SHADER)},e.compileVertexShader=function(t,i){return e._compileShader(t,i,t.VERTEX_SHADER)},e._compileShader=function(t,e,i){var n=t.createShader(i);return t.shaderSource(n,e),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:null},e.checkCanUseWebGL=function(){if(void 0==e.canUseWebGL)try{var t=document.createElement("canvas");e.canUseWebGL=!(!window.WebGLRenderingContext||!t.getContext("webgl")&&!t.getContext("experimental-webgl"))}catch(i){e.canUseWebGL=!1}return e.canUseWebGL},e.deleteWebGLTexture=function(t){if(t){var e=t.webGLTexture;if(e)for(var i in e){var n=e[i],r=n.glContext;r.deleteTexture(n)}t.webGLTexture=null}},e}();t.WebGLUtils=e,t.registerClass(e,"egret.WebGLUtils")}(egret||(egret={})); +======= +},h.copyFrom=function(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this},h.identity=function(){this.a=this.d=1,this.b=this.c=this.tx=this.ty=0},h.invert=function(){this.$invertInto(this)},h.$invertInto=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=this.tx,a=this.ty;if(0==i&&0==n)return t.b=t.c=0,void(0==e||0==r?t.a=t.d=t.tx=t.ty=0:(e=t.a=1/e,r=t.d=1/r,t.tx=-e*s,t.ty=-r*a));var o=e*r-i*n;if(0==o)return void t.identity();o=1/o;var h=t.a=r*o;i=t.b=-i*o,n=t.c=-n*o,r=t.d=e*o,t.tx=-(h*s+n*a),t.ty=-(i*s+r*a)},h.rotate=function(e){if(e=+e,0!==e){e/=n;var i=t.NumberUtils.cos(e),r=t.NumberUtils.sin(e),s=this.a,a=this.b,o=this.c,h=this.d,l=this.tx,u=this.ty;this.a=s*i-a*r,this.b=s*r+a*i,this.c=o*i-h*r,this.d=o*r+h*i,this.tx=l*i-u*r,this.ty=l*r+u*i}},h.scale=function(t,e){1!==t&&(this.a*=t,this.c*=t,this.tx*=t),1!==e&&(this.b*=e,this.d*=e,this.ty*=e)},h.setTo=function(t,e,i,n,r,s){return this.a=t,this.b=e,this.c=i,this.d=n,this.tx=r,this.ty=s,this},h.transformPoint=function(e,i,n){var r=this.a*e+this.c*i+this.tx,s=this.b*e+this.d*i+this.ty;return n?(n.setTo(r,s),n):new t.Point(r,s)},h.translate=function(t,e){this.tx+=t,this.ty+=e},h.equals=function(t){return this.a==t.a&&this.b==t.b&&this.c==t.c&&this.d==t.d&&this.tx==t.tx&&this.ty==t.ty},h.prepend=function(t,e,i,n,r,s){var a=this.tx;if(1!=t||0!=e||0!=i||1!=n){var o=this.a,h=this.c;this.a=o*t+this.b*i,this.b=o*e+this.b*n,this.c=h*t+this.d*i,this.d=h*e+this.d*n}return this.tx=a*t+this.ty*i+r,this.ty=a*e+this.ty*n+s,this},h.append=function(t,e,i,n,r,s){var a=this.a,o=this.b,h=this.c,l=this.d;return(1!=t||0!=e||0!=i||1!=n)&&(this.a=t*a+e*h,this.b=t*o+e*l,this.c=i*a+n*h,this.d=i*o+n*l),this.tx=r*a+s*h+this.tx,this.ty=r*o+s*l+this.ty,this},h.deltaTransformPoint=function(e){var i=this,n=i.a*e.x+i.c*e.y,r=i.b*e.x+i.d*e.y;return new t.Point(n,r)},h.toString=function(){return"(a="+this.a+", b="+this.b+", c="+this.c+", d="+this.d+", tx="+this.tx+", ty="+this.ty+")"},h.createBox=function(e,i,r,s,a){void 0===r&&(r=0),void 0===s&&(s=0),void 0===a&&(a=0);var o=this;if(0!==r){r/=n;var h=t.NumberUtils.cos(r),l=t.NumberUtils.sin(r);o.a=h*e,o.b=l*i,o.c=-l*e,o.d=h*i}else o.a=e,o.b=0,o.c=0,o.d=i;o.tx=s,o.ty=a},h.createGradientBox=function(t,e,i,n,r){void 0===i&&(i=0),void 0===n&&(n=0),void 0===r&&(r=0),this.createBox(t/1638.4,e/1638.4,i,n+t/2,r+e/2)},h.$transformBounds=function(t){var e=this.a,i=this.b,n=this.c,r=this.d,s=this.tx,a=this.ty,o=t.x,h=t.y,l=o+t.width,u=h+t.height,c=e*o+n*h+s,d=i*o+r*h+a,f=e*l+n*h+s,g=i*l+r*h+a,p=e*l+n*u+s,v=i*l+r*u+a,$=e*o+n*u+s,y=i*o+r*u+a,m=0;c>f&&(m=c,c=f,f=m),p>$&&(m=p,p=$,$=m),t.x=Math.floor(p>c?c:p),t.width=Math.ceil((f>$?f:$)-t.x),d>g&&(m=d,d=g,g=m),v>y&&(m=v,v=y,y=m),t.y=Math.floor(v>d?d:v),t.height=Math.ceil((g>y?g:y)-t.y)},h.getDeterminant=function(){return this.a*this.d-this.b*this.c},h.$getScaleX=function(){var t=this;if(1==t.a&&0==t.b)return 1;var e=Math.sqrt(t.a*t.a+t.b*t.b);return this.getDeterminant()<0?-e:e},h.$getScaleY=function(){var t=this;if(0==t.c&&1==t.d)return 1;var e=Math.sqrt(t.c*t.c+t.d*t.d);return this.getDeterminant()<0?-e:e},h.$getSkewX=function(){return Math.atan2(this.d,this.c)-e/2},h.$getSkewY=function(){return Math.atan2(this.b,this.a)},h.$updateScaleAndRotation=function(e,r,s,a){if(!(0!=s&&s!=i||0!=a&&a!=i))return this.a=e,this.b=this.c=0,void(this.d=r);s/=n,a/=n;var o=t.NumberUtils.cos(s),h=t.NumberUtils.sin(s);s==a?(this.a=o*e,this.b=h*e):(this.a=t.NumberUtils.cos(a)*e,this.b=t.NumberUtils.sin(a)*e),this.c=-h*r,this.d=o*r},h.$preMultiplyInto=function(t,e){var i=t.a*this.a,n=0,r=0,s=t.d*this.d,a=t.tx*this.a+this.tx,o=t.ty*this.d+this.ty;(0!==t.b||0!==t.c||0!==this.b||0!==this.c)&&(i+=t.b*this.c,s+=t.c*this.b,n+=t.a*this.b+t.b*this.d,r+=t.c*this.a+t.d*this.c,a+=t.ty*this.c,o+=t.tx*this.b),e.a=i,e.b=n,e.c=r,e.d=s,e.tx=a,e.ty=o},a}(t.HashObject);t.Matrix=s,t.registerClass(s,"egret.Matrix"),t.$TempMatrix=new s}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.en_US=t.$locale_strings.en_US||{};var e=t.$locale_strings.en_US;e[1001]="Could not find Egret entry class: {0}。",e[1002]="Egret entry class '{0}' must inherit from egret.DisplayObject.",e[1003]="Parameter {0} must be non-null.",e[1004]="An object cannot be added as a child to one of it's children (or children's children, etc.).",e[1005]="An object cannot be added as a child of itself.",e[1006]="The supplied DisplayObject must be a child of the caller.",e[1007]="An index specified for a parameter was out of range.",e[1008]="Instantiate singleton error,singleton class {0} can not create multiple instances.",e[1009]='the Class {0} cannot use the property "{1}"',e[1010]='the property "{1}" of the Class "{0}" is readonly',e[1011]="Stream Error. URL: {0}",e[1012]="The type of parameter {0} must be Class.",e[1013]="Variable assignment is NaN, please see the code!",e[1014]='the constant "{1}" of the Class "{0}" is read-only',e[1015]="xml not found!",e[1016]="{0}has been obsoleted",e[1017]="The format of JSON file is incorrect: {0}\ndata: {1}",e[1018]="the scale9Grid is not correct",e[1019]="Network ab:{0}",e[1020]="Cannot initialize Shader",e[1021]="Current browser does not support webgl",e[1022]="{0} ArgumentError",e[1023]="This method is not available in the ScrollView!",e[1025]="end of the file",e[1026]="! EncodingError The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]=". called injection is not configured rule: {0}, please specify configuration during its initial years of injection rule, and then call the corresponding single case.",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="Photos can not be used across domains toDataURL to convert base64",e[1034]='Music file decoding failed: "{0}", please use the standard conversion tool reconversion under mp3.',e[1035]="Native does not support this feature!",e[1036]="Sound has stopped, please recall Sound.play () to play the sound!",e[1037]="Non-load the correct blob!",e[1038]="XML format error!",e[1039]="crossOrigin images can not set pixelHitTest property!",e[1040]="hitTestPoint can not detect crossOrigin images! Please check if the display object has crossOrigin elements.",e[1041]="egret.MainContext.runtimeType is deprecated, please use egret.Capabilities.runtimeType replace",e[1042]="The parameters passed in the region needs is an integer in drawToTexture method. Otherwise, some browsers will draw abnormal.",e[1043]="Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.",e[1044]="The current version of the Runtime does not support video playback, please use the latest version",e[1045]="The resource url is not found",e[1046]="BitmapText no corresponding characters: {0}, please check the configuration file",e[1047]="egret.localStorage.setItem save failed,key={0}&value={1}",e[1048]="Video loading failed",e[1049]="In the absence of sound is not allowed to play after loading",e[3e3]="Theme configuration file failed to load: {0}",e[3001]="Cannot find the skin name which is configured in Theme: {0}",e[3002]='Index:"{0}" is out of the collection element index range',e[3003]="Cannot be available in this component. If this component is container, please continue to use",e[3004]="addChild(){0}addElement() replace",e[3005]="addChildAt(){0}addElementAt() replace",e[3006]="removeChild(){0}removeElement() replace",e[3007]="removeChildAt(){0}removeElementAt() replace",e[3008]="setChildIndex(){0}setElementIndex() replace",e[3009]="swapChildren(){0}swapElements() replace",e[3010]="swapChildrenAt(){0}swapElementsAt() replace",e[3011]='Index:"{0}" is out of the visual element index range',e[3012]="This method is not available in Scroller component!",e[3013]="UIStage is GUI root container, and only one such instant is in the display list!",e[3014]="set fullscreen error",e[3100]="Current browser does not support WebSocket",e[3101]="Please connect Socket firstly",e[3102]="Please set the type of binary type",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!"}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$language="en_US"}(egret||(egret={}));var egret;!function(t){var e;!function(e){function i(e){for(var i=[],n=1;na;a++)r=r.replace("{"+a+"}",i[a]);return r}e.tr=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.$locale_strings=t.$locale_strings||{},t.$locale_strings.zh_CN=t.$locale_strings.zh_CN||{};var e=t.$locale_strings.zh_CN;e[1001]="找不到Egret入口类: {0}。",e[1002]="Egret入口类 {0} 必须继承自egret.DisplayObject。",e[1003]="参数 {0} 不能为 null。",e[1004]="无法将对象添加为它的一个子对象(或子对象的子对象等)的子对象。",e[1005]="不能将对象添加为其自身的子对象。",e[1006]="提供的 DisplayObject 必须是调用者的子级。",e[1007]="为参数指定的索引不在范围内。",e[1008]="实例化单例出错,不允许实例化多个 {0} 对象。",e[1009]="类 {0} 不可以使用属性 {1}",e[1010]="类 {0} 属性 {1} 是只读的",e[1011]="流错误。URL: {0}",e[1012]="参数 {0} 的类型必须为 Class。",e[1013]="变量赋值为NaN,请查看代码!",e[1014]="类 {0} 常量 {1} 是只读的",e[1015]="xml not found!",e[1016]="{0}已经废弃",e[1017]="JSON文件格式不正确: {0}\ndata: {1}",e[1018]="9宫格设置错误",e[1019]="网络异常:{0}",e[1020]="无法初始化着色器",e[1021]="当前浏览器不支持webgl",e[1022]="{0} ArgumentError",e[1023]="此方法在ScrollView内不可用!",e[1025]="遇到文件尾",e[1026]="EncodingError! The code point {0} could not be encoded.",e[1027]="DecodingError",e[1028]="调用了未配置的注入规则:{0}。 请先在项目初始化里配置指定的注入规则,再调用对应单例。",e[1029]="Function.prototype.bind - what is trying to be bound is not callable",e[1033]="跨域图片不可以使用toDataURL来转换成base64",e[1034]='音乐文件解码失败:"{0}",请使用标准的转换工具重新转换下mp3。',e[1035]="Native 下暂未实现此功能!",e[1036]="声音已停止,请重新调用 Sound.play() 来播放声音!",e[1037]="非正确的blob加载!",e[1038]="XML 格式错误!",e[1039]="跨域图片不能设置 pixelHitTest 属性!",e[1040]="hitTestPoint 不能对跨域图片进行检测! 请检查该显示对象内是否含有跨域元素",e[1041]="egret.MainContext.runtimeType 已废弃,请使用egret.Capabilities.runtimeType 代替",e[1042]="drawToTexture方法传入的区域各个参数需要为整数,否则某些浏览器绘制会出现异常",e[1043]="{0} 中存在编译错误,属性名 : {1},属性值 : {2}",e[1044]="当前的 runtime 版本不支持视频播放,请使用最新的版本",e[1045]="没有设置要加载的资源地址",e[1046]="BitmapText 找不到对应字符:{0},请检查配置文件",e[1047]="egret.localStorage.setItem保存失败,key={0}&value={1}",e[1048]="视频加载失败",e[1049]="声音在没有加载完之前不允许播放",e[3e3]="主题配置文件加载失败: {0}",e[3001]="找不到主题中所配置的皮肤类名: {0}",e[3002]='索引:"{0}"超出集合元素索引范围',e[3003]="在此组件中不可用,若此组件为容器类,请使用",e[3004]="addChild(){0}addElement()代替",e[3005]="addChildAt(){0}addElementAt()代替",e[3006]="removeChild(){0}removeElement()代替",e[3007]="removeChildAt(){0}removeElementAt()代替",e[3008]="setChildIndex(){0}setElementIndex()代替",e[3009]="swapChildren(){0}swapElements()代替",e[3010]="swapChildrenAt(){0}swapElementsAt()代替",e[3011]='索引:"{0}"超出可视元素索引范围',e[3012]="此方法在Scroller组件内不可用!",e[3013]="UIStage是GUI根容器,只能有一个此实例在显示列表中!",e[3014]="设置全屏模式失败",e[3100]="当前浏览器不支持WebSocket",e[3101]="请先连接WebSocket",e[3102]="请先设置type为二进制类型",e[4e3]="An Bone cannot be added as a child to itself or one of its children (or children's children, etc.)",e[4001]="Abstract class can not be instantiated!",e[4002]="Unnamed data!",e[4003]="Nonsupport version!"}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.localStorage||(t.localStorage={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){function e(t){n.indexOf(t)<0&&n.push(t)}function i(t){var e=n.indexOf(t);return e>=0?(n.splice(e,1),!0):!1}var n=[];t.$pushSoundChannel=e,t.$popSoundChannel=i}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this.onSuccessFunc=null,this.onSuccessThisObject=null,this.onErrorFunc=null,this.onErrorThisObject=null,this.downloadingSizeFunc=null,this.downloadingSizeThisObject=null,this.onResponseHeaderFunc=null,this.onResponseHeaderThisObject=null}var i=e,n=i.prototype;return e.create=function(){return e.promiseObjectList.length?e.promiseObjectList.pop():new t.PromiseObject},n.onSuccess=function(){for(var t=[],e=0;ee.maxX?t.maxX:e.maxX,s=t.maxY>e.maxY?t.maxY:e.maxY;return(r-i)*(s-n)}var n=function(){function n(e){this.dirtyList=[],this.hasClipRect=!1,this.clipWidth=0,this.clipHeight=0,this.clipArea=0,this.clipRectChanged=!1,this.$dirtyRegionPolicy=t.DirtyRegionPolicy.ON,this.root=e}var r=n,s=r.prototype;return s.setClipRect=function(t,e){this.hasClipRect=!0,this.clipRectChanged=!0,this.clipWidth=Math.ceil(t),this.clipHeight=Math.ceil(e),this.clipArea=this.clipWidth*this.clipHeight},s.addRegion=function(i){var n=i.minX,r=i.minY,s=i.maxX,a=i.maxY;if(this.hasClipRect&&(0>n&&(n=0),0>r&&(r=0),s>this.clipWidth&&(s=this.clipWidth),a>this.clipHeight&&(a=this.clipHeight)),n>=s||r>=a)return!1;if(this.clipRectChanged)return!0;var o=this.dirtyList,h=e.Region.create();return o.push(h.setTo(n,r,s,a)),this.$dirtyRegionPolicy!=t.DirtyRegionPolicy.OFF&&this.mergeDirtyList(o),!0},s.clear=function(){for(var t=this.dirtyList,i=t.length,n=0;i>n;n++)e.Region.release(t[n]);t.length=0},s.getDirtyRegions=function(){var i=this.dirtyList;if(this.$dirtyRegionPolicy==t.DirtyRegionPolicy.OFF||t.Capabilities.runtimeType==t.RuntimeType.NATIVE&&!t["native"].$supportCanvas){this.clipRectChanged=!0,this.clear();var n=e.Region.create();if(this.hasClipRect)i.push(n.setTo(0,0,this.clipWidth,this.clipHeight));else{var r=this.root.$getOriginalBounds();i.push(n.setTo(r.x,r.y,r.width,r.height))}}else if(this.clipRectChanged){this.clipRectChanged=!1,this.clear();var n=e.Region.create();i.push(n.setTo(0,0,this.clipWidth,this.clipHeight))}else for(;this.mergeDirtyList(i););var s=this.dirtyList.length;if(s>0)for(var a=0;s>a;a++)this.dirtyList[a].intValues();return this.dirtyList},s.mergeDirtyList=function(t){var n=t.length;if(2>n)return!1;for(var r=this.hasClipRect,s=n>3?Number.POSITIVE_INFINITY:0,a=0,o=0,h=0,l=0;n-1>l;l++){var u=t[l];r&&(h+=u.area);for(var c=l+1;n>c;c++){var d=t[c],f=i(u,d)-u.area-d.area;s>f&&(a=l,o=c,s=f)}}if(r&&h/this.clipArea>.95&&(this.clipRectChanged=!0),a!=o){var g=t[o];return t[a].union(g),e.Region.release(g),t.splice(o,1),!0}return!1},s.setDirtyRegionPolicy=function(t){this.$dirtyRegionPolicy=t},n}();e.DirtyRegion=n,t.registerClass(n,"egret.sys.DirtyRegion")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(i){function n(n){i.call(this),this.isStage=!1,this.$renderNode=new e.BitmapNode,this.renderBuffer=null,this.offsetX=0,this.offsetY=0,this.offsetMatrix=new t.Matrix,this.isDirty=!1,this.needUpdateRegions=!1,this.dirtyNodes={},this.dirtyNodeList=[],this.dirtyList=null,this.sizeChanged=!1,this.$dirtyRegionPolicy=t.DirtyRegionPolicy.ON,this.root=n,this.dirtyRegion=new e.DirtyRegion(n),this.isStage=n instanceof t.Stage}__extends(n,i);var r=n,s=r.prototype;return n.create=function(i){var n=new t.sys.DisplayList(i);try{var r=new e.RenderBuffer}catch(s){return null}return n.renderBuffer=r,n.root=i,n},s.$getRenderNode=function(){return this.$renderNode},s.$update=function(e){var i=this.root;if(null==i)return!1;i.$removeFlagsUp(768);var n=this.$renderNode,r=i.$getConcatenatedMatrix();if(e==t.DirtyRegionPolicy.OFF){var s=i.$parentDisplayList;if(this.needUpdateRegions&&this.updateDirtyRegions(),!s)return!1;var a=n.renderMatrix;a.copyFrom(r);var o=s.root;o!==i.$stage&&i.$getConcatenatedMatrixAt(o,a)}else{var h=i.$getOriginalBounds(),s=i.$parentDisplayList,l=n.renderRegion;if(this.needUpdateRegions&&this.updateDirtyRegions(),!s)return l.setTo(0,0,0,0),n.moved=!1,!1;if(!n.moved)return!1;n.moved=!1;var a=n.renderMatrix;a.copyFrom(r);var o=s.root;o!==i.$stage&&i.$getConcatenatedMatrixAt(o,a),l.updateRegion(h,a)}return!0},s.setClipRect=function(t,e){this.dirtyRegion.setClipRect(t,e),this.renderBuffer.resize(t,e)},s.markDirty=function(t){var e=t.$hashCode;if(!this.dirtyNodes[e]&&(this.dirtyNodes[e]=!0,this.dirtyNodeList.push(t),!this.needUpdateRegions)){this.needUpdateRegions=!0,this.isDirty=!0;var i=this.root.$parentDisplayList;i&&i.markDirty(this)}},s.updateDirtyRegions=function(){var t=this.dirtyNodeList;this.dirtyNodeList=[],this.dirtyNodes={},this.needUpdateRegions=!1;for(var e=this.dirtyRegion,i=t.length,n=0;i>n;n++){var r=t[n],s=r.$getRenderNode();if(s.needRedraw=!1,this.isStage){s.renderAlpha>0&&s.renderVisible&&e.addRegion(s.renderRegion)&&(s.needRedraw=!0);var a=r.$update(this.$dirtyRegionPolicy);s.renderAlpha>0&&s.renderVisible&&(a||!s.needRedraw)&&e.addRegion(s.renderRegion)&&(s.needRedraw=!0)}else{e.addRegion(s.renderRegion)&&(s.needRedraw=!0);var a=r.$update(this.$dirtyRegionPolicy);(a||!s.needRedraw)&&e.addRegion(s.renderRegion)&&(s.needRedraw=!0)}}return this.dirtyList=e.getDirtyRegions(),this.dirtyList},s.drawToSurface=function(){var i=0,n=this.dirtyList;if(n&&n.length>0){this.isStage||this.changeSurfaceSize();var r=this.renderBuffer;r.beginClip(this.dirtyList,this.offsetX,this.offsetY);var n=this.$dirtyRegionPolicy==t.DirtyRegionPolicy.OFF?null:this.dirtyList,i=e.systemRenderer.render(this.root,r,this.offsetMatrix,n);r.endClip();var s=r.surface,a=this.$renderNode;a.drawData.length=0,a.image=s;var o=s.width,h=s.height;a.imageWidth=o,a.imageHeight=h,a.drawImage(0,0,o,h,-this.offsetX,-this.offsetY,o,h)}return this.dirtyList=null,this.dirtyRegion.clear(),this.isDirty=!1,i},s.changeSurfaceSize=function(){var t=(this.root,this.offsetX),e=this.offsetY,i=this.root.$getOriginalBounds();this.offsetX=-i.x,this.offsetY=-i.y,this.offsetMatrix.setTo(1,0,0,1,this.offsetX,this.offsetY);var n=this.renderBuffer,r=Math.max(257,i.width),s=Math.max(257,i.height);(this.offsetX!=t||this.offsetY!=e||n.surface.width!=r||n.surface.height!=s)&&(this.sizeChanged?n.resizeTo(r,s,this.offsetX-t,this.offsetY-e):(this.sizeChanged=!0,n.resize(r,s)))},s.setDirtyRegionPolicy=function(t){this.$dirtyRegionPolicy=t,this.dirtyRegion.setDirtyRegionPolicy(t),this.renderBuffer.setDirtyRegionPolicy(t)},n}(t.HashObject);e.DisplayList=i,t.registerClass(i,"egret.sys.DisplayList",["egret.sys.Renderable"])}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(){function i(){this.type=0,this.needRedraw=!1,this.renderAlpha=1,this.renderVisible=!0,this.renderMatrix=new t.Matrix,this.renderRegion=new e.Region,this.moved=!1,this.drawData=[],this.renderCount=0}var n=i,r=n.prototype;return r.cleanBeforeRender=function(){this.drawData.length=0,this.renderCount=0},r.$getRenderCount=function(){return this.renderCount},i}();e.RenderNode=i,t.registerClass(i,"egret.sys.RenderNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){e.call(this),this.image=null,this.smoothing=!0,this.blendMode=null,this.type=1}__extends(i,e);var n=i,r=n.prototype;return r.drawImage=function(t,e,i,n,r,s,a,o){this.drawData.push(t,e,i,n,r,s,a,o),this.renderCount++},r.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null},i.$updateTextureData=function(e,n,r,s,a,o,h,l,u,c,d,f,g,p,v,$,y){if(n){var m=t.$TextureScaleFactor;if(e.smoothing=y,e.image=n,e.imageWidth=g,e.imageHeight=p,v)i.$updateTextureDataWithScale9Grid(e,v,r,s,a,o,h,l,u,c,d,f);else if($==t.BitmapFillMode.SCALE){var T=d/u,x=f/c;e.drawImage(r,s,a,o,h*T,l*x,T*a,x*o)}else if($==t.BitmapFillMode.CLIP){var b=Math.min(u,d),_=Math.min(c,f),E=a*m,C=o*m;i.drawClipImage(e,m,r,s,E,C,h,l,b,_)}else for(var E=a*m,C=o*m,F=0;d>F;F+=u)for(var w=0;f>w;w+=c){var b=Math.min(d-F,u),_=Math.min(f-w,c);i.drawClipImage(e,m,r,s,E,C,h,l,b,_,F,w)}}},i.$updateTextureDataWithScale9Grid=function(e,i,n,r,s,a,o,h,l,u,c,d){var f=s,g=a;c-=l-s*t.$TextureScaleFactor,d-=u-a*t.$TextureScaleFactor;var p=i.x-o,v=i.y-h,$=p/t.$TextureScaleFactor,y=v/t.$TextureScaleFactor,m=i.width/t.$TextureScaleFactor,T=i.height/t.$TextureScaleFactor;0==T&&(T=1,y>=g&&y--),0==m&&(m=1,$>=f&&$--);var x=n,b=x+$,_=b+m,E=f-$-m,C=r,F=C+y,w=F+T,R=g-y-T,S=E*t.$TextureScaleFactor,D=R*t.$TextureScaleFactor;if(($+E)*t.$TextureScaleFactor>c||(y+R)*t.$TextureScaleFactor>d)return void e.drawImage(n,r,s,a,o,h,c,d);var O=o,L=O+p,M=O+(c-S),N=c-p-S,A=h,B=A+v,I=A+d-D,P=d-v-D;y>0&&($>0&&e.drawImage(x,C,$,y,O,A,p,v),m>0&&e.drawImage(b,C,m,y,L,A,N,v),E>0&&e.drawImage(_,C,E,y,M,A,S,v)),T>0&&($>0&&e.drawImage(x,F,$,T,O,B,p,P),m>0&&e.drawImage(b,F,m,T,L,B,N,P),E>0&&e.drawImage(_,F,E,T,M,B,S,P)),R>0&&($>0&&e.drawImage(x,w,$,R,O,I,p,D),m>0&&e.drawImage(b,w,m,R,L,I,N,D),E>0&&e.drawImage(_,w,E,R,M,I,S,D))},i.drawClipImage=function(t,e,i,n,r,s,a,o,h,l,u,c){void 0===u&&(u=0),void 0===c&&(c=0);var d=a+r-h;d>0&&(r-=d),d=o+s-l,d>0&&(s-=d),t.drawImage(i,n,r/e,s/e,u+a,c+o,r,s)},i}(e.RenderNode);e.BitmapNode=i,t.registerClass(i,"egret.sys.BitmapNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=["none","round","square"],n=["bevel","miter","round"],r=function(r){function s(){r.call(this),this.dirtyRender=!0,this.type=3}__extends(s,r);var a=s,o=a.prototype;return o.beginFill=function(t,i,n){void 0===i&&(i=1);var r=new e.FillPath;if(r.fillColor=t,r.fillAlpha=i,n){var s=this.drawData.lastIndexOf(n);this.drawData.splice(s,0,r)}else this.drawData.push(r);return r},o.beginGradientFill=function(i,n,r,s,a,o){var h=new t.Matrix;a?(h.a=819.2*a.a,h.b=819.2*a.b,h.c=819.2*a.c,h.d=819.2*a.d,h.tx=a.tx,h.ty=a.ty):(h.a=100,h.d=100);var l=new e.GradientFillPath;if(l.gradientType=i,l.colors=n,l.alphas=r,l.ratios=s,l.matrix=h,o){var u=this.drawData.lastIndexOf(o);this.drawData.splice(u,0,l)}else this.drawData.push(l);return l},o.lineStyle=function(r,s,a,o,h,l){void 0===a&&(a=1),void 0===l&&(l=3),-1==i.indexOf(o)&&(o="round"),-1==n.indexOf(h)&&(h="round");var u=new e.StrokePath;return u.lineWidth=r,u.lineColor=s,u.lineAlpha=a,u.caps=o||t.CapsStyle.ROUND,u.joints=h,u.miterLimit=l,this.drawData.push(u),u},o.clear=function(){this.drawData.length=0,this.dirtyRender=!0},o.cleanBeforeRender=function(){},s}(e.RenderNode);e.GraphicsNode=r,t.registerClass(r,"egret.sys.GraphicsNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=4}__extends(e,t);var i=e,n=i.prototype;return n.addNode=function(t){this.drawData.push(t)},n.cleanBeforeRender=function(){for(var t=this.drawData,e=t.length-1;e>=0;e--)t[e].cleanBeforeRender()},n.$getRenderCount=function(){for(var t=0,e=this.drawData,i=e.length-1;i>=0;i--)t+=e[i].$getRenderCount();return t},e}(e.RenderNode);e.GroupNode=i,t.registerClass(i,"egret.sys.GroupNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){e.call(this),this.image=null,this.smoothing=!0,this.bounds=new t.Rectangle,this.type=7,this.vertices=[],this.uvs=[],this.indices=[]}__extends(i,e);var n=i,r=n.prototype;return r.drawMesh=function(t,e,i,n,r,s,a,o){this.drawData.push(t,e,i,n,r,s,a,o),this.renderCount++},r.cleanBeforeRender=function(){e.prototype.cleanBeforeRender.call(this),this.image=null,this.matrix=null},i}(e.RenderNode);e.MeshNode=i,t.registerClass(i,"egret.sys.MeshNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=6}__extends(e,t);var i=e,n=i.prototype;return n.setAlpha=function(t){0!=this.drawData.length&&(this.drawData.length=0),this.drawData.push(t),this.renderCount++},e}(e.RenderNode);e.SetAlphaNode=i,t.registerClass(i,"egret.sys.SetAlphaNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.textColor=16777215,this.strokeColor=0,this.size=30,this.stroke=0,this.bold=!1,this.italic=!1,this.fontFamily="Arial",this.dirtyRender=!0,this.type=2}__extends(e,t);var i=e,n=i.prototype;return n.drawText=function(t,e,i,n){this.drawData.push(t,e,i,n),this.renderCount++,this.dirtyRender=!0},n.cleanBeforeRender=function(){t.prototype.cleanBeforeRender.call(this)},e}(e.RenderNode);e.TextNode=i,t.registerClass(i,"egret.sys.TextNode")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(){function t(){this.type=0,this.$commands=[],this.$data=[],this.commandPosition=0,this.dataPosition=0}var e=t,i=e.prototype;return i.moveTo=function(t,e){this.$commands[this.commandPosition++]=1;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},i.lineTo=function(t,e){this.$commands[this.commandPosition++]=2;var i=this.dataPosition;this.$data[i++]=t,this.$data[i++]=e,this.dataPosition=i},i.curveTo=function(t,e,i,n){this.$commands[this.commandPosition++]=3;var r=this.dataPosition;this.$data[r++]=t,this.$data[r++]=e,this.$data[r++]=i,this.$data[r++]=n,this.dataPosition=r},i.cubicCurveTo=function(t,e,i,n,r,s){this.$commands[this.commandPosition++]=4;var a=this.dataPosition;this.$data[a++]=t,this.$data[a++]=e,this.$data[a++]=i,this.$data[a++]=n,this.$data[a++]=r,this.$data[a++]=s,this.dataPosition=a},i.drawRect=function(t,e,i,n){var r=t+i,s=e+n;this.moveTo(t,e),this.lineTo(r,e),this.lineTo(r,s),this.lineTo(t,s),this.lineTo(t,e)},i.drawRoundRect=function(t,e,i,n,r,s){var a=.5*r|0,o=s?.5*s|0:a;if(!a||!o)return void this.drawRect(t,e,i,n);var h=.5*i,l=.5*n;if(a>h&&(a=h),o>l&&(o=l),h===a&&l===o)return void(a===o?this.drawCircle(t+a,e+o,a):this.drawEllipse(t,e,2*a,2*o));var u=t+i,c=e+n,d=t+a,f=u-a,g=e+o,p=c-o;this.moveTo(u,p),this.curveTo(u,c,f,c),this.lineTo(d,c),this.curveTo(t,c,t,p),this.lineTo(t,g),this.curveTo(t,e,d,e),this.lineTo(f,e),this.curveTo(u,e,u,g),this.lineTo(u,p)},i.drawCircle=function(t,e,i){this.arcToBezier(t,e,i,i,0,2*Math.PI)},i.drawEllipse=function(t,e,i,n){var r=.5*i,s=.5*n;t+=r,e+=s,this.arcToBezier(t,e,r,s,0,2*Math.PI)},i.drawArc=function(t,e,i,n,r,s){s?r>=n&&(r-=2*Math.PI):n>=r&&(r+=2*Math.PI),this.arcToBezier(t,e,i,i,n,r,s)},i.arcToBezier=function(t,e,i,n,r,s,a){var o=.5*Math.PI,h=r,l=h;a?(l+=-o-h%o,s>l&&(l=s)):(l+=o-h%o,l>s&&(l=s));var u=t+Math.cos(h)*i,c=e+Math.sin(h)*n;this.moveTo(u,c);for(var d=Math.cos(h),f=Math.sin(h),g=0;4>g;g++){var p=l-h,v=4*Math.tan(p/4)/3,$=u-f*v*i,y=c+d*v*n;d=Math.cos(l),f=Math.sin(l),u=t+d*i,c=e+f*n;var m=u+f*v*i,T=c-d*v*n;if(this.cubicCurveTo($,y,m,T,u,c),l===s)break;h=l,a?(l=h-o,s>l&&(l=s)):(l=h+o,l>s&&(l=s))}},t}();e.Path2D=i,t.registerClass(i,"egret.sys.Path2D")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=1}__extends(e,t);var i=e;i.prototype;return e}(e.Path2D);e.FillPath=i,t.registerClass(i,"egret.sys.FillPath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=2}__extends(e,t);var i=e;i.prototype;return e}(e.Path2D);e.GradientFillPath=i,t.registerClass(i,"egret.sys.GradientFillPath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(t){function e(){t.call(this),this.type=3}__extends(e,t);var i=e;i.prototype;return e}(e.Path2D);e.StrokePath=i,t.registerClass(i,"egret.sys.StrokePath")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){function i(i,n,r,s){if(n&&(t.log=function(){for(var t=arguments.length,i="",n=0;t>n;n++)i+=arguments[n]+" ";e.$logToFPS(i),console.log.apply(console,a(arguments))}),l=s?{}:s,n=!!n,this.showFPS=!!i,this.showLog=n,!this.fpsDisplay){var o=void 0===s.x?0:s.x,c=void 0===s.y?0:s.y;h=this.fpsDisplay=new FPS(this.stage,i,n,r,s),h.x=o,h.y=c;for(var d=u.length,f=0;d>f;f++)h.updateInfo(u[f]);u=null}}function n(t){t=!!t,this._showPaintRect!=t&&(this._showPaintRect=t,t?(this.stageDisplayList||(this.stageDisplayList=e.DisplayList.create(this.stage)),this.stage.$displayList=this.stageDisplayList):this.stage.$displayList=this.screenDisplayList)}function r(t){for(var e=t.length,i=[],n=0;e>n;n++){var r=t[n];i[n]=[r.minX,r.minY,r.width,r.height],r.width-=1,r.height-=1}var s=this.paintList;s.push(i),s.length>1&&s.shift();var a=this.screenDisplayList.renderBuffer,o=a.context;for(o.setTransform(1,0,0,1,0,0),o.clearRect(0,0,a.surface.width,a.surface.height),o.drawImage(this.stageDisplayList.renderBuffer.surface,0,0),e=s.length,n=0;e>n;n++){i=s[n];for(var h=i.length-1;h>=0;h--){var l=i[h];this.drawDirtyRect(l[0],l[1],l[2],l[3],o)}}o.save(),o.beginPath();for(var e=t.length,n=0;e>n;n++){var r=t[n];o.clearRect(r.minX,r.minY,r.width,r.height),o.rect(r.minX,r.minY,r.width,r.height)}o.clip(),o.drawImage(this.stageDisplayList.renderBuffer.surface,0,0),o.restore()}function s(t,e,i,n,r){r.strokeStyle="rgb(255,0,0)",r.lineWidth=5,r.strokeRect(t-.5,e-.5,i,n)}function a(t){for(var e=[],i=0;i0){for(var u=s.length,c=0,d=0;u>d;d++)c+=s[d].area;l=Math.ceil(1e3*c/(n.stageWidth*n.stageHeight))/10}this.fpsDisplay.update(o,l,a-r,h-a,i)}},l.callLaters=function(){if(t.$callLaterFunctionList.length>0){var e=t.$callLaterFunctionList;t.$callLaterFunctionList=[];var i=t.$callLaterThisList;t.$callLaterThisList=[]; +var n=t.$callLaterArgsList;t.$callLaterArgsList=[]}if(e)for(var r=e.length,s=0;r>s;s++){var a=e[s];null!=a&&a.apply(i[s],n[s])}},l.callLaterAsyncs=function(){if(t.$callAsyncFunctionList.length>0){var e=t.$callAsyncFunctionList,i=t.$callAsyncThisList,n=t.$callAsyncArgsList;t.$callAsyncFunctionList=[],t.$callAsyncThisList=[],t.$callAsyncArgsList=[];for(var r=0;r=1e3){var h=Math.min(Math.ceil(1e3*this.totalTick/this.totalTime),e.$ticker.$frameRate),l=Math.round(this.drawCalls/this.totalTick),u=Math.round(this.dirtyRatio/this.totalTick),c=Math.round(this.costDirty/this.totalTick),d=Math.round(this.costRender/this.totalTick),f=Math.round(this.costTicker/this.totalTick);this.fpsDisplay.update({fps:h,draw:l,dirty:u,costTicker:f,costDirty:c,costRender:d}),this.totalTick=0,this.totalTime=this.totalTime%1e3,this.drawCalls=0,this.dirtyRatio=0,this.costDirty=0,this.costRender=0,this.costTicker=0}},n.prototype.updateInfo=function(t){t&&this.showLog&&this.filter(t)&&this.fpsDisplay.updateInfo(t)},n}(t.Sprite),t.warn=function(){console.warn.apply(console,a(arguments))},t.error=function(){console.error.apply(console,a(arguments))},t.assert=function(){console.assert.apply(console,a(arguments))},t.log=function(){console.log.apply(console,a(arguments))}}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=[],n=function(){function t(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.width=0,this.height=0,this.area=0,this.moved=!1}var e=t,n=e.prototype;return t.release=function(t){i.push(t)},t.create=function(){var e=i.pop();return e||(e=new t),e},n.setTo=function(t,e,i,n){return this.minX=t,this.minY=e,this.maxX=i,this.maxY=n,this.updateArea(),this},n.intValues=function(){this.minX=Math.floor(this.minX),this.minY=Math.floor(this.minY),this.maxX=Math.ceil(this.maxX),this.maxY=Math.ceil(this.maxY),this.updateArea()},n.updateArea=function(){this.width=this.maxX-this.minX,this.height=this.maxY-this.minY,this.area=this.width*this.height},n.union=function(t){this.minX>t.minX&&(this.minX=t.minX),this.minY>t.minY&&(this.minY=t.minY),this.maxXt.maxX&&(this.maxX=t.maxX),this.minX>=this.maxX?void this.setEmpty():(this.minYt.maxY&&(this.maxY=t.maxY),this.minY>=this.maxY?void this.setEmpty():void this.updateArea())},n.setEmpty=function(){this.minX=0,this.minY=0,this.maxX=0,this.maxY=0,this.width=0,this.height=0,this.area=0},n.isEmpty=function(){return this.width<=0||this.height<=0},n.intersects=function(t){if(this.isEmpty())return!1;var e=this.minX>t.minX?this.minX:t.minX,i=this.maxXi?!1:(e=this.minY>t.minY?this.minY:t.minY,i=this.maxY=e)},n.updateRegion=function(t,e){if(0==t.width||0==t.height)return void this.setEmpty();var i,n,r,s,a=e,o=a.a,h=a.b,l=a.c,u=a.d,c=a.tx,d=a.ty,f=t.x,g=t.y,p=f+t.width,v=g+t.height;if(1==o&&0==h&&0==l&&1==u)i=f+c-1,n=g+d-1,r=p+c+1,s=v+d+1;else{var $=o*f+l*g+c,y=h*f+u*g+d,m=o*p+l*g+c,T=h*p+u*g+d,x=o*p+l*v+c,b=h*p+u*v+d,_=o*f+l*v+c,E=h*f+u*v+d,C=0;$>m&&(C=$,$=m,m=C),x>_&&(C=x,x=_,_=C),i=(x>$?$:x)-1,r=(m>_?m:_)+1,y>T&&(C=y,y=T,T=C),b>E&&(C=b,b=E,E=C),n=(b>y?y:b)-1,s=(T>E?T:E)+1}this.minX=i,this.minY=n,this.maxX=r,this.maxY=s,this.width=r-i,this.height=s-n,this.area=this.width*this.height},t}();e.Region=n,t.registerClass(n,"egret.sys.Region")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){function e(t,e){var i=null==e.italic?t.italic:e.italic,n=null==e.bold?t.bold:e.bold,r=null==e.size?t.size:e.size,s=e.fontFamily||t.fontFamily,a=i?"italic ":"normal ";return a+=n?"bold ":"normal ",a+=r+"px "+s}function i(t,e){var i=t>>16,n=t>>8&255,r=255&t;return"rgba("+i+","+n+","+r+","+e+")"}function n(e,n,r,s,a,o){var h;h=n==t.GradientType.LINEAR?e.createLinearGradient(-1,0,1,0):e.createRadialGradient(0,0,0,0,0,1);for(var l=r.length,u=0;l>u;u++)h.addColorStop(a[u]/255,i(r[u],s[u]));return h}function r(t,e,i,n){for(var r=n[0],s=n[1],a=n[2],o=n[3],h=n[4],l=n[5],u=n[6],c=n[7],d=n[8],f=n[9],g=n[10],p=n[11],v=n[12],$=n[13],y=n[14],m=n[15],T=n[16],x=n[17],b=n[18],_=n[19],E=0,C=e*i*4;C>E;E+=4){var F=t[E+0],w=t[E+1],R=t[E+2],S=t[E+3];t[E+0]=r*F+s*w+a*R+o*S+h,t[E+1]=l*F+u*w+c*R+d*S+f,t[E+2]=g*F+p*w+v*R+$*S+y,t[E+3]=m*F+T*w+x*R+b*S+_}}function s(t,e,i,n,r){a(t,e,i,n),o(t,e,i,r)}function a(t,e,i,n){for(var r=new Uint8ClampedArray(4*e),s=4*e,a=2*n+1,o=0;i>o;o++){for(var h=o*s,l=0,u=0,c=0,d=0,f=0,g=0,p=4*-n,v=4*n+4;v>p;p+=4){var $=h+p;h>$||$>=h+s||(f=t[$+3],l+=t[$+0]*f,u+=t[$+1]*f,c+=t[$+2]*f,d+=f)}for(var p=h,v=h+s,y=0,m=p-4*n,T=p+4*(n+1);v>p;p+=4,y+=4,T+=4,m+=4)r[y+0]=l/d,r[y+1]=u/d,r[y+2]=c/d,r[y+3]=d/a,f=t[T+3],g=t[m+3],f||0==f?g||0==g?(l+=t[T+0]*f-t[m+0]*g,u+=t[T+1]*f-t[m+1]*g,c+=t[T+2]*f-t[m+2]*g,d+=f-g):(l+=t[T+0]*f,u+=t[T+1]*f,c+=t[T+2]*f,d+=f):(g||0==g)&&(l+=-t[m+0]*g,u+=-t[m+1]*g,c+=-t[m+2]*g,d+=-g);t.set(r,h)}}function o(t,e,i,n){for(var r=new Uint8ClampedArray(4*i),s=4*e,a=2*n+1,o=0;e>o;o++){for(var h=4*o,l=0,u=0,c=0,d=0,f=0,g=0,p=-n*s,v=n*s+s;v>p;p+=s){var $=h+p;h>$||$>=h+i*s||(f=t[$+3],l+=t[$+0]*f,u+=t[$+1]*f,c+=t[$+2]*f,d+=f)}for(var p=h,v=h+i*s,y=0,m=h-n*s,T=h+(n+1)*s;v>p;p+=s,y+=4,T+=s,m+=s)r[y+0]=l/d,r[y+1]=u/d,r[y+2]=c/d,r[y+3]=d/a,f=t[T+3],g=t[m+3],f||0==f?g||0==g?(l+=t[T+0]*f-t[m+0]*g,u+=t[T+1]*f-t[m+1]*g,c+=t[T+2]*f-t[m+2]*g,d+=f-g):(l+=t[T+0]*f,u+=t[T+1]*f,c+=t[T+2]*f,d+=f):(g||0==g)&&(l+=-t[m+0]*g,u+=-t[m+1]*g,c+=-t[m+2]*g,d+=-g);for(var x=4*o,v=x+i*s,b=0;v>x;x+=s,b+=4)t[x+0]=r[b+0],t[x+1]=r[b+1],t[x+2]=r[b+2],t[x+3]=r[b+3]}}function h(t,e,i,n,r,a,o,h,f){var g=l(t,n);u(g,e,i,o,h),s(g,e,i,r,a),c(g,f),d(g,t),t.set(g)}function l(t,e){e||(e=[0,0,0,0]);for(var i=new Uint8ClampedArray(t),n=0,r=i.length;r>n;n+=4){var s=i[n+3];i[n+0]=e[0]*s,i[n+1]=e[1]*s,i[n+2]=e[2]*s}return i}function u(t,e,i,n,r){for(var s=Math.sin(n)*r|0,a=Math.cos(n)*r|0,o=new Int32Array(t.buffer),h=new Int32Array(o.length),l=0;i>l;l++){var u=l+s;if(!(0>u||u>i))for(var c=0;e>c;c++){var d=c+a;0>d||d>e||(h[u*e+d]=o[l*e+c])}}o.set(h)}function c(t,e){for(var i=0,n=t.length;n>i;i+=4)t[i+3]*=e}function d(t,e){for(var i=0,n=t.length;n>i;i+=4){var r=t[i+0],s=t[i+1],a=t[i+2],o=t[i+3]/255,h=e[i+0],l=e[i+1],u=e[i+2],c=e[i+3]/255;t[i+0]=h+r*(1-c),t[i+1]=l+s*(1-c),t[i+2]=u+a*(1-c),t[i+3]=255*(c+o*(1-c))}}var f=["source-over","lighter","destination-out"],g="source-over",p="#000000",v={none:"butt",square:"square",round:"round"},$=[],y=function(){function a(){this.nestLevel=0,this.renderingMask=!1}var o=a,l=o.prototype;return l.render=function(t,e,i,n,r){this.nestLevel++;var s=e.context,a=r?t:null,o=this.drawDisplayObject(t,s,n,i,null,null,a);if(this.nestLevel--,0===this.nestLevel){$.length>6&&($.length=6);for(var h=$.length,l=0;h>l;l++)$[l].resize(0,0)}return o},l.drawDisplayObject=function(e,i,n,r,s,a,o){var h,l=0;if(s&&!o?(s.isDirty&&(l+=s.drawToSurface()),h=s.$renderNode):h=e.$getRenderNode(),h){if(n){var u=h.renderRegion;if(a&&!a.intersects(u))h.needRedraw=!1;else if(!h.needRedraw)for(var c=n.length,d=0;c>d;d++)if(u.intersects(n[d])){h.needRedraw=!0;break}}else h.needRedraw=!0;if(h.needRedraw){var f,g;o?(f=e.$getConcatenatedAlphaAt(o,e.$getConcatenatedAlpha()),g=t.Matrix.create().copyFrom(e.$getConcatenatedMatrix()),e.$getConcatenatedMatrixAt(o,g),r.$preMultiplyInto(g,g),i.setTransform(g.a,g.b,g.c,g.d,g.tx,g.ty),t.Matrix.release(g)):(f=h.renderAlpha,g=h.renderMatrix,i.setTransform(g.a,g.b,g.c,g.d,g.tx+r.tx,g.ty+r.ty)),i.globalAlpha=f,l+=this.renderNode(h,i),h.needRedraw=!1}}if(s&&!o)return l;var p=e.$children;if(p)for(var v=p.length,$=0;v>$;$++){var y=p[$];if(!(!y.$visible||y.$alpha<=0||y.$maskedObject)){var m=y.$getFilters();m&&m.length>0?l+=this.drawWithFilter(y,i,n,r,a,o):0!==y.$blendMode||y.$mask&&(y.$mask.$parentDisplayList||o)?l+=this.drawWithClip(y,i,n,r,a,o):y.$scrollRect||y.$maskRect?l+=this.drawWithScrollRect(y,i,n,r,a,o):y.isFPS?this.drawDisplayObject(y,i,n,r,y.$displayList,a,o):l+=this.drawDisplayObject(y,i,n,r,y.$displayList,a,o)}}return l},l.drawWithFilter=function(e,i,n,a,o,l){var u=0,c=e.$getFilters(),d=c.length,p=0!==e.$blendMode;if(p){var v=f[e.$blendMode];v||(v=g)}var y=t.Matrix.create();y.copyFrom(e.$getConcatenatedMatrix());var m;m=t.sys.Region.create();var T=e.$getOriginalBounds();m.updateRegion(T,y);var x=this.createRenderBuffer(m.width,m.height),b=x.context;b.setTransform(1,0,0,1,-m.minX,-m.minY);var _=t.Matrix.create().setTo(1,0,0,1,-m.minX,-m.minY);if(u+=this.drawDisplayObject(e,b,n,_,e.$displayList,m,l),t.Matrix.release(_),u>0){p&&(i.globalCompositeOperation=v),u++,i.globalAlpha=1,i.setTransform(1,0,0,1,m.minX+a.tx,m.minY+a.ty);for(var E=b.getImageData(0,0,x.surface.width,x.surface.height),C=0;d>C;C++){var F=c[C];if("colorTransform"==F.type)r(E.data,x.surface.width,x.surface.height,F.$matrix);else if("blur"==F.type)s(E.data,x.surface.width,x.surface.height,F.$blurX,F.$blurY);else if("glow"==F.type){var w=F.$red,R=F.$green,S=F.$blue,D=F.$alpha;h(E.data,x.surface.width,x.surface.height,[w,R,S,D],F.$blurX,F.$blurY,F.$angle||0,F.$distance||0,F.$strength)}}b.putImageData(E,0,0),i.drawImage(x.surface,0,0),p&&(i.globalCompositeOperation=g)}return $.push(x),t.sys.Region.release(m),t.Matrix.release(y),u},l.drawWithClip=function(e,i,n,r,s,a){var o=0,h=0!==e.$blendMode;if(h){var l=f[e.$blendMode];l||(l=g)}var u=e.$scrollRect?e.$scrollRect:e.$maskRect,c=e.$mask;if(c){var d=c.$getRenderNode();if(d){var p=d.renderMatrix;if(0==p.a&&0==p.b||0==p.c&&0==p.d)return o}}var v,y=t.Matrix.create();if(y.copyFrom(e.$getConcatenatedMatrix()),e.$parentDisplayList){var m,T=e.$parentDisplayList.root;T!==e.$stage&&e.$getConcatenatedMatrixAt(T,y)}if(c){var x=c.$getOriginalBounds();v=t.sys.Region.create();var b=t.Matrix.create();b.copyFrom(c.$getConcatenatedMatrix()),m&&m.$preMultiplyInto(b,b),v.updateRegion(x,b),t.Matrix.release(b)}var _;if(u&&(_=t.sys.Region.create(),_.updateRegion(u,y)),_&&v?(_.intersect(v),t.sys.Region.release(v)):!_&&v&&(_=v),_){if(_.isEmpty()||s&&!s.intersects(_))return t.sys.Region.release(_),t.Matrix.release(y),o}else _=t.sys.Region.create(),x=e.$getOriginalBounds(),_.updateRegion(x,y);var E=!1;if(n){for(var C=n.length,F=0;C>F;F++)if(_.intersects(n[F])){E=!0;break}}else E=!0;if(!E)return t.sys.Region.release(_),t.Matrix.release(y),o;if(!(c||e.$children&&0!=e.$children.length)){if(u){var b=y;i.save(),i.setTransform(b.a,b.b,b.c,b.d,b.tx-_.minX,b.ty-_.minY),i.beginPath(),i.rect(u.x,u.y,u.width,u.height),i.clip()}return h&&(i.globalCompositeOperation=l),o+=this.drawDisplayObject(e,i,n,r,e.$displayList,s,a),h&&(i.globalCompositeOperation=g),u&&i.restore(),o}if(c&&t.Capabilities.$runtimeType==t.RuntimeType.WEB&&(!c.$children||0==c.$children.length)&&d&&3==d.type&&1==d.drawData.length&&1==d.drawData[0].type&&1==d.drawData[0].fillAlpha){this.renderingMask=!0,i.save();var w=this.drawDisplayObject(c,i,n,r,c.$displayList,s,a);if(this.renderingMask=!1,u){var b=y;i.setTransform(b.a,b.b,b.c,b.d,b.tx-_.minX,b.ty-_.minY),i.beginPath(),i.rect(u.x,u.y,u.width,u.height),i.clip()}return w+=this.drawDisplayObject(e,i,n,r,e.$displayList,s,a),i.restore(),w}var R=this.createRenderBuffer(_.width,_.height),S=R.context;if(!S)return o+=this.drawDisplayObject(e,i,n,r,e.$displayList,s,a),t.sys.Region.release(_),t.Matrix.release(y),o;S.setTransform(1,0,0,1,-_.minX,-_.minY);var D=t.Matrix.create().setTo(1,0,0,1,-_.minX,-_.minY);if(o+=this.drawDisplayObject(e,S,n,D,e.$displayList,_,a),c)if(t.Capabilities.$runtimeType==t.RuntimeType.WEB&&d&&1==d.$getRenderCount()||c.$displayList)S.globalCompositeOperation="destination-in",o+=this.drawDisplayObject(c,S,n,D,c.$displayList,_,a);else{var O=this.createRenderBuffer(_.width,_.height),L=O.context;if(!L)return o+=this.drawDisplayObject(e,i,n,r,e.$displayList,s,a),$.push(R),t.sys.Region.release(_),t.Matrix.release(y),o;L.setTransform(1,0,0,1,-_.minX,-_.minY),D=t.Matrix.create().setTo(1,0,0,1,-_.minX,-_.minY);var w=this.drawDisplayObject(c,L,n,D,c.$displayList,_,a);w>0&&(o+=w,S.globalCompositeOperation="destination-in",S.setTransform(1,0,0,1,0,0),S.globalAlpha=1,S.drawImage(O.surface,0,0)),$.push(O)}if(t.Matrix.release(D),o>0){if(o++,h&&(i.globalCompositeOperation=l),u){var b=y;i.save(),i.setTransform(b.a,b.b,b.c,b.d,b.tx-_.minX,b.ty-_.minY),i.beginPath(),i.rect(u.x,u.y,u.width,u.height),i.clip()}i.globalAlpha=1,i.setTransform(1,0,0,1,_.minX+r.tx,_.minY+r.ty),i.drawImage(R.surface,0,0),u&&i.restore(),h&&(i.globalCompositeOperation=g)}return $.push(R),t.sys.Region.release(_),t.Matrix.release(y),o},l.drawWithScrollRect=function(e,i,n,r,s,a){var o=0,h=e.$scrollRect?e.$scrollRect:e.$maskRect;if(0==h.width||0==h.height)return o;var l=t.Matrix.create();if(l.copyFrom(e.$getConcatenatedMatrix()),a)e.$getConcatenatedMatrixAt(a,l);else if(e.$parentDisplayList){var u=e.$parentDisplayList.root;u!==e.$stage&&e.$getConcatenatedMatrixAt(u,l)}var c=t.sys.Region.create();if(h.isEmpty()||c.updateRegion(h,l),c.isEmpty()||s&&!s.intersects(c))return t.sys.Region.release(c),t.Matrix.release(l),o;var d=!1;if(n){for(var f=n.length,g=0;f>g;g++)if(c.intersects(n[g])){d=!0;break}}else d=!0;return d?(i.save(),i.setTransform(l.a,l.b,l.c,l.d,l.tx+r.tx,l.ty+r.ty),i.beginPath(),i.rect(h.x,h.y,h.width,h.height),i.clip(),o+=this.drawDisplayObject(e,i,n,r,e.$displayList,c,a),i.restore(),t.sys.Region.release(c),t.Matrix.release(l),o):(t.sys.Region.release(c),t.Matrix.release(l),o)},l.drawNodeToBuffer=function(t,e,i,n){var r=e.context;r.setTransform(i.a,i.b,i.c,i.d,i.tx,i.ty),this.renderNode(t,r,n)},l.renderNode=function(t,e,i){var n=0;switch(t.type){case 1:n=this.renderBitmap(t,e);break;case 2:n=1,this.renderText(t,e);break;case 3:n=1,this.renderGraphics(t,e,i);break;case 4:n=this.renderGroup(t,e);break;case 6:e.globalAlpha=t.drawData[0]}return n},l.renderBitmap=function(t,e){var i=t.image;e.$imageSmoothingEnabled!=t.smoothing&&(e.imageSmoothingEnabled=t.smoothing,e.$imageSmoothingEnabled=t.smoothing);var n=t.drawData,r=n.length,s=0,a=t.matrix,o=t.blendMode,h=!1;a&&(e.saveTransform?e.saveTransform():e.save(),h=!0,e.transform(a.a,a.b,a.c,a.d,a.tx,a.ty)),o&&(e.globalCompositeOperation=f[o]);for(var l=0;r>s;)l++,e.drawImage(i,n[s++],n[s++],n[s++],n[s++],n[s++],n[s++],n[s++],n[s++]);return h?e.restoreTransform?(e.restoreTransform(),o&&(e.globalCompositeOperation=g)):e.restore():o&&(e.globalCompositeOperation=g),l},l.renderText=function(i,n){n.textAlign="left",n.textBaseline="middle",n.lineJoin="round";for(var r=i.drawData,s=r.length,a=0;s>a;){var o=r[a++],h=r[a++],l=r[a++],u=r[a++];n.font=e(i,u);var c=null==u.textColor?i.textColor:u.textColor,d=null==u.strokeColor?i.strokeColor:u.strokeColor,f=null==u.stroke?i.stroke:u.stroke;n.fillStyle=t.toColorString(c),n.strokeStyle=t.toColorString(d),f&&(n.lineWidth=2*f,n.strokeText(l,o,h)),n.fillText(l,o,h)}},l.renderGraphics=function(t,e,r){var s=t.drawData,a=s.length;r=!!r;for(var o=0;a>o;o++){var h=s[o];switch(h.type){case 1:var l=h;e.fillStyle=r?p:i(l.fillColor,l.fillAlpha),this.renderPath(h,e),this.renderingMask?e.clip():e.fill();break;case 2:var u=h;e.fillStyle=r?p:n(e,u.gradientType,u.colors,u.alphas,u.ratios,u.matrix),e.save();var c=u.matrix;this.renderPath(h,e),e.transform(c.a,c.b,c.c,c.d,c.tx,c.ty),e.fill(),e.restore();break;case 3:var d=h,f=d.lineWidth;e.lineWidth=f,e.strokeStyle=r?p:i(d.lineColor,d.lineAlpha),e.lineCap=v[d.caps],e.lineJoin=d.joints,e.miterLimit=d.miterLimit;var g=1===f||3===f;g&&e.translate(.5,.5),this.renderPath(h,e),e.stroke(),g&&e.translate(-.5,-.5)}}},l.renderPath=function(t,e){e.beginPath();for(var i=t.$data,n=t.$commands,r=n.length,s=0,a=0;r>a;a++){var o=n[a];switch(o){case 4:e.bezierCurveTo(i[s++],i[s++],i[s++],i[s++],i[s++],i[s++]);break;case 3:e.quadraticCurveTo(i[s++],i[s++],i[s++],i[s++]);break;case 2:e.lineTo(i[s++],i[s++]);break;case 1:e.moveTo(i[s++],i[s++])}}},l.renderGroup=function(t,e){for(var i=0,n=t.drawData,r=n.length,s=0;r>s;s++){var a=n[s];i+=this.renderNode(a,e)}return i},l.createRenderBuffer=function(e,i){var n=$.pop();return n?n.resize(e,i,!0):n=new t.sys.RenderBuffer(e,i),n},a}();t.CanvasRenderer=y,t.registerClass(y,"egret.CanvasRenderer",["egret.sys.SystemRenderer"])}(egret||(egret={}));var egret;!function(t){var e;!function(e){var i=function(e){function i(){e.call(this)}__extends(i,e);var n=i,r=n.prototype;return r.calculateStageSize=function(e,i,n,r,s){var a=i,o=n,h=r,l=s,u=i/h||0,c=n/l||0;switch(e){case t.StageScaleMode.EXACT_FIT:break;case t.StageScaleMode.FIXED_HEIGHT:h=Math.round(i/c);break;case t.StageScaleMode.FIXED_WIDTH:l=Math.round(n/u);break;case t.StageScaleMode.NO_BORDER:u>c?o=Math.round(l*u):a=Math.round(h*c);break;case t.StageScaleMode.SHOW_ALL:u>c?a=Math.round(h*c):o=Math.round(l*u);break;case t.StageScaleMode.FIXED_NARROW:u>c?h=Math.round(i/c):l=Math.round(n/u);break;case t.StageScaleMode.FIXED_WIDE:u>c?l=Math.round(n/u):h=Math.round(i/c);break;default:h=i,l=n}return a%2!=0&&(a+=1),o%2!=0&&(o+=1),{stageWidth:h,stageHeight:l,displayWidth:a,displayHeight:o}},i}(t.HashObject);e.DefaultScreenAdapter=i,t.registerClass(i,"egret.sys.DefaultScreenAdapter",["egret.sys.IScreenAdapter"])}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.NO_SCALE="noScale",t.SHOW_ALL="showAll",t.NO_BORDER="noBorder",t.EXACT_FIT="exactFit",t.FIXED_WIDTH="fixedWidth",t.FIXED_HEIGHT="fixedHeight",t.FIXED_NARROW="fixedNarrow",t.FIXED_WIDE="fixedWide",t}();t.StageScaleMode=e,t.registerClass(e,"egret.StageScaleMode")}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e;!function(e){e.$START_TIME=0,e.$invalidateRenderFlag=!1,e.$requestRenderingFlag=!1;var i=function(){function i(){this.playerList=[],this.callBackList=[],this.thisObjectList=[],this.$frameRate=30,this.lastTimeStamp=0,this.costEnterFrame=0,e.$START_TIME=Date.now(),this.frameDeltaTime=1e3/this.$frameRate,this.lastCount=this.frameInterval=Math.round(6e4/this.$frameRate)}var n=i,r=n.prototype;return r.$addPlayer=function(t){-1==this.playerList.indexOf(t)&&(this.playerList=this.playerList.concat(),this.playerList.push(t))},r.$removePlayer=function(t){var e=this.playerList.indexOf(t);if(-1!==e){this.playerList=this.playerList.concat(),this.playerList.splice(e,1)}},r.$startTick=function(t,e){var i=this.getTickIndex(t,e);-1==i&&(this.concatTick(),this.callBackList.push(t),this.thisObjectList.push(e))},r.$stopTick=function(t,e){var i=this.getTickIndex(t,e);-1!=i&&(this.concatTick(),this.callBackList.splice(i,1),this.thisObjectList.splice(i,1))},r.getTickIndex=function(t,e){for(var i=this.callBackList,n=this.thisObjectList,r=i.length-1;r>=0;r--)if(i[r]==t&&n[r]==e)return r;return-1},r.concatTick=function(){this.callBackList=this.callBackList.concat(),this.thisObjectList=this.thisObjectList.concat()},r.$setFrameRate=function(e){return e=+e||0,0>=e?!1:this.$frameRate==e?!1:(this.$frameRate=e,e>60&&(e=60),t.Capabilities.runtimeType==t.RuntimeType.NATIVE&&(egret_native.setFrameRate(e),e=60),this.frameDeltaTime=1e3/e,this.lastCount=this.frameInterval=Math.round(6e4/e),!0)},r.update=function(){for(var i=t.getTimer(),n=this.callBackList,r=this.thisObjectList,s=n.length,a=e.$requestRenderingFlag,o=t.getTimer(),h=0;s>h;h++)n[h].call(r[h],o)&&(a=!0);var l=t.getTimer(),u=o-this.lastTimeStamp;if(u>=this.frameDeltaTime)this.lastCount=this.frameInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return void(a&&this.render(!1,this.costEnterFrame+l-i));this.lastCount+=this.frameInterval}this.lastTimeStamp=o,this.render(!0,this.costEnterFrame+l-i);var c=t.getTimer();this.broadcastEnterFrame();var d=t.getTimer();this.costEnterFrame=d-c},r.render=function(t,i){var n=this.playerList,r=n.length;if(0!=r){e.$invalidateRenderFlag&&(this.broadcastRender(),e.$invalidateRenderFlag=!1);for(var s=0;r>s;s++)n[s].$render(t,i);e.$requestRenderingFlag=!1}},r.broadcastEnterFrame=function(){var e=t.DisplayObject.$enterFrameCallBackList,i=e.length;if(0!=i){e=e.concat();for(var n=0;i>n;n++)e[n].dispatchEventWith(t.Event.ENTER_FRAME)}},r.broadcastRender=function(){var e=t.DisplayObject.$renderCallBackList,i=e.length;if(0!=i){e=e.concat();for(var n=0;i>n;n++)e[n].dispatchEventWith(t.Event.RENDER)}},i}();e.SystemTicker=i,t.registerClass(i,"egret.sys.SystemTicker"),e.$ticker=new e.SystemTicker}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret_stages,egret;!function(t){var e;!function(e){var i=function(e){function i(t){e.call(this),this.maxTouches=0,this.useTouchesCount=0,this.touchDownTarget={},this.lastTouchX=-1,this.lastTouchY=-1,this.stage=t}__extends(i,e);var n=i,r=n.prototype;return r.$initMaxTouches=function(){this.maxTouches=this.stage.$maxTouches},r.onTouchBegin=function(e,i,n){if(!(this.useTouchesCount>=this.maxTouches)){this.lastTouchX=e,this.lastTouchY=i;var r=this.findTarget(e,i);null==this.touchDownTarget[n]&&(this.touchDownTarget[n]=r,this.useTouchesCount++),t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_BEGIN,!0,!0,e,i,n,!0)}},r.onTouchMove=function(e,i,n){if(null!=this.touchDownTarget[n]&&(this.lastTouchX!=e||this.lastTouchY!=i)){this.lastTouchX=e,this.lastTouchY=i;var r=this.findTarget(e,i);t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_MOVE,!0,!0,e,i,n,!0)}},r.onTouchEnd=function(e,i,n){if(null!=this.touchDownTarget[n]){var r=this.findTarget(e,i),s=this.touchDownTarget[n];delete this.touchDownTarget[n],this.useTouchesCount--,t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_END,!0,!0,e,i,n,!1),s==r?t.TouchEvent.dispatchTouchEvent(r,t.TouchEvent.TOUCH_TAP,!0,!0,e,i,n,!1):t.TouchEvent.dispatchTouchEvent(s,t.TouchEvent.TOUCH_RELEASE_OUTSIDE,!0,!0,e,i,n,!1)}},r.findTarget=function(t,e){var i=this.stage.$hitTest(t,e);return i||(i=this.stage),i},i}(t.HashObject);e.TouchHandler=i,t.registerClass(i,"egret.sys.TouchHandler")}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){t.DeviceOrientation=null}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.WEB="web",t.NATIVE="native",t}();t.RuntimeType=e,t.registerClass(e,"egret.RuntimeType");var i=function(){function t(){}var e=__define,i=t;i.prototype;return e(t,"language",function(){return t.$language}),e(t,"isMobile",function(){return t.$isMobile}),e(t,"os",function(){return t.$os}),e(t,"runtimeType",function(){return t.$runtimeType}),e(t,"supportVersion",function(){return t.$supportVersion}),t.$setNativeCapabilities=function(e){var i=e.split("-");if(i.length<=4){var n=i[0];switch(n){case"android":n="Android";break;case"ios":n="iOS"}t.$os=n;var r=i[2].substring(1,i[2].length);t.$supportVersion=r}},e(t,"renderMode",function(){return t.$renderMode}),e(t,"boundingClientWidth",function(){return t.$boundingClientWidth}),e(t,"boundingClientHeight",function(){return t.$boundingClientHeight}),t.$language="zh-CN",t.$os="Unknown",t.$runtimeType="Unknown",t.$supportVersion="Unknown",t.$renderMode="Unknown",t.$boundingClientWidth=0,t.$boundingClientHeight=0,t}();t.Capabilities=i,t.registerClass(i,"egret.Capabilities")}(egret||(egret={}));var testDeviceType=function(){if(!this.navigator)return!0;var t=navigator.userAgent.toLowerCase();return-1!=t.indexOf("mobile")||-1!=t.indexOf("android")},testRuntimeType=function(){return this.navigator?!0:!1};egret.Capabilities.$isMobile=testDeviceType(),egret.Capabilities.$runtimeType=testRuntimeType()?egret.RuntimeType.WEB:egret.RuntimeType.NATIVE;var egret;!function(t){var e=function(t){function e(e,i){t.call(this,e),this.firstCharHeight=0,"string"==typeof i?this.charList=this.parseConfig(i):i&&i.hasOwnProperty("frames")?this.charList=i.frames:this.charList={}}__extends(e,t);var i=e,n=i.prototype;return n.getTexture=function(t){var e=this._textureMap[t];if(!e){var i=this.charList[t];if(!i)return null;e=this.createTexture(t,i.x,i.y,i.w,i.h,i.offX,i.offY,i.sourceW,i.sourceH),this._textureMap[t]=e}return e},n.getConfig=function(t,e){return this.charList[t]?this.charList[t][e]:0},n._getFirstCharHeight=function(){if(0==this.firstCharHeight)for(var t in this.charList){var e=this.charList[t];if(e){var i=e.sourceH;if(void 0===i){var n=e.h;void 0===n&&(n=0);var r=e.offY;void 0===r&&(r=0),i=n+r}if(0>=i)continue;this.firstCharHeight=i;break}}return this.firstCharHeight},n.parseConfig=function(t){t=t.split("\r\n").join("\n");for(var e=t.split("\n"),i=this.getConfigByKey(e[3],"count"),n={},r=4;4+i>r;r++){var s=e[r],a=String.fromCharCode(this.getConfigByKey(s,"id")),o={};n[a]=o,o.x=this.getConfigByKey(s,"x"),o.y=this.getConfigByKey(s,"y"),o.w=this.getConfigByKey(s,"width"),o.h=this.getConfigByKey(s,"height"),o.offX=this.getConfigByKey(s,"xoffset"),o.offY=this.getConfigByKey(s,"yoffset"),o.xadvance=this.getConfigByKey(s,"xadvance")}return n},n.getConfigByKey=function(t,e){for(var i=t.split(" "),n=0,r=i.length;r>n;n++){var s=i[n];if(e==s.substring(0,e.length)){var a=s.substring(e.length+1);return parseInt(a)}}return 0},e}(t.SpriteSheet);t.BitmapFont=e,t.registerClass(e,"egret.BitmapFont")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){e.call(this),this.$textOffsetX=0,this.$textOffsetY=0,this.$textStartX=0,this.$textStartY=0,this.$lineHeights=[],this.$renderNode=new t.sys.BitmapNode,this.$BitmapText={0:0/0,1:0/0,2:"",3:0,4:0,5:null,6:!1,7:!1,8:!1,9:!1,10:"left",11:"top",12:t.Bitmap.defaultSmoothing}}__extends(i,e);var n=__define,r=i,s=r.prototype;return n(s,"smoothing",function(){var t=this.$BitmapText;return t[12]},function(t){t=!!t;var e=this.$BitmapText;t!=e[12]&&(e[12]=t,this.$invalidate())}),n(s,"text",function(){return this.$BitmapText[2]},function(t){this.$setText(t)}),s.$setText=function(t){t=String(t);var e=this.$BitmapText;return t==e[2]?!1:(e[2]=t,this.$invalidateContentBounds(),!0)},s.$getWidth=function(){var t=this.$BitmapText[0];return isNaN(t)?this.$getContentBounds().width:t},s.$setWidth=function(t){var e=this.$BitmapText;return 0>t||t==e[0]?!1:(e[0]=t,this.$invalidateContentBounds(),!0)},s.$invalidateContentBounds=function(){e.prototype.$invalidateContentBounds.call(this),this.$BitmapText[7]=!0},s.$getHeight=function(){var t=this.$BitmapText[1];return isNaN(t)?this.$getContentBounds().height:t},s.$setHeight=function(t){var e=this.$BitmapText;return 0>t||t==e[1]?!1:(e[1]=t,this.$invalidateContentBounds(),!0)},n(s,"font",function(){return this.$BitmapText[5]},function(t){this.$setFont(t)}),s.$setFont=function(t){var e=this.$BitmapText;return e[5]==t?!1:(e[5]=t,this.$BitmapText[6]=!0,this.$invalidateContentBounds(),!0)},n(s,"lineSpacing",function(){return this.$BitmapText[3]},function(t){this.$setLineSpacing(t)}),s.$setLineSpacing=function(t){t=+t||0;var e=this.$BitmapText;return e[3]==t?!1:(e[3]=t,this.$invalidateContentBounds(),!0)},n(s,"letterSpacing",function(){return this.$BitmapText[4]},function(t){this.$setLetterSpacing(t)}),s.$setLetterSpacing=function(t){t=+t||0;var e=this.$BitmapText;return e[4]==t?!1:(e[4]=t,this.$invalidateContentBounds(),!0)},n(s,"textAlign",function(){return this.$BitmapText[10]},function(t){this.$setTextAlign(t)}),s.$setTextAlign=function(t){var e=this.$BitmapText;return e[10]==t?!1:(e[10]=t,this.$invalidateContentBounds(),!0)},n(s,"verticalAlign",function(){return this.$BitmapText[11]},function(t){this.$setVerticalAlign(t)}),s.$setVerticalAlign=function(t){var e=this.$BitmapText;return e[11]==t?!1:(e[11]=t,this.$invalidateContentBounds(),!0)},s.$render=function(){var e=this.$BitmapText,n=this.$getTextLines(),r=n.length;if(0!=r){var s=this.$textLinesWidth,a=e[5],o=this.$renderNode;a.$texture&&(o.image=a.$texture._bitmapData),o.smoothing=e[12];for(var h=a._getFirstCharHeight(),l=Math.ceil(h*i.EMPTY_FACTOR),u=!isNaN(e[1]),c=e[8],d=e[0],f=e[1],g=e[10],p=this.$textOffsetY+this.$textStartY,v=this.$lineHeights,$=0;r>$;$++){var y=v[$];if(u&&$>0&&p+y>f)break;var m=n[$],T=m.length,x=this.$textOffsetX;if(g!=t.HorizontalAlign.LEFT){var b=d>c?d:c;g==t.HorizontalAlign.RIGHT?x+=b-s[$]:g==t.HorizontalAlign.CENTER&&(x+=Math.floor((b-s[$])/2))}for(var _=0;T>_;_++){var E=m.charAt(_),C=a.getTexture(E);if(C){var F=C._bitmapWidth,w=C._bitmapHeight;o.imageWidth=C._sourceWidth,o.imageHeight=C._sourceHeight,o.drawImage(C._bitmapX,C._bitmapY,F,w,x+C._offsetX,p+C._offsetY,C.$getScaleBitmapWidth(),C.$getScaleBitmapHeight()),x+=a.getConfig(E,"xadvance")||C.$getTextureWidth()+e[4]}else" "==E?x+=l:t.$warn(1046,E)}p+=y+e[3]}}},s.$measureContentBounds=function(t){var e=this.$getTextLines();0==e.length?t.setEmpty():t.setTo(this.$textOffsetX+this.$textStartX,this.$textOffsetY+this.$textStartY,this.$BitmapText[8]-this.$textOffsetX,this.$BitmapText[9]-this.$textOffsetY)},n(s,"textWidth",function(){return this.$getTextLines(),this.$BitmapText[8]}),n(s,"textHeight",function(){return this.$getTextLines(),this.$BitmapText[9]}),s.$getTextLines=function(){function e(t){return p&&r.length>0&&u>p?!1:(u+=F+o,R||S||(w-=h),r.push(t),a.push(F),s.push(w),l=Math.max(w,l),!0)}var n=this.$BitmapText;if(!n[7])return this.textLines;var r=[];this.textLines=r;var s=[];this.$textLinesWidth=s,n[7]=!1;var a=[];if(this.$lineHeights=a,!n[2]||!n[5])return r;for(var o=n[3],h=n[4],l=0,u=0,c=0,d=0,f=!isNaN(n[0]),g=n[0],p=n[1],v=n[5],$=v._getFirstCharHeight(),y=Math.ceil($*i.EMPTY_FACTOR),m=n[2],T=m.split(/(?:\r\n|\r|\n)/),x=T.length,b=!0,_=0;x>_;_++){for(var E=T[_],C=E.length,F=0,w=0,R=!0,S=!1,D=0;C>D;D++){R||(w+=h);var O,L,M=E.charAt(D),N=0,A=0,B=v.getTexture(M);if(B)O=B.$getTextureWidth(),L=B.$getTextureHeight(),N=B._offsetX,A=B._offsetY;else{if(" "!=M){t.$warn(1046,M),R&&(R=!1);continue}O=y,L=$}if(R&&(R=!1,c=Math.min(N,c)),b&&(b=!1,d=Math.min(A,d)),f&&D>0&&w+O>g){if(!e(E.substring(0,D)))break;E=E.substring(D),C=E.length,D=0,w=D==C-1?O:v.getConfig(M,"xadvance")||O,F=L}else w+=D==C-1?O:v.getConfig(M,"xadvance")||O,F=Math.max(L,F)}if(p&&_>0&&u>p)break;if(S=!0,!e(E))break}u-=o,n[8]=l,n[9]=u,this.$textOffsetX=c,this.$textOffsetY=d,this.$textStartX=0,this.$textStartY=0;var I;return g>l&&(I=n[10],I==t.HorizontalAlign.RIGHT?this.$textStartX=g-l:I==t.HorizontalAlign.CENTER&&(this.$textStartX=Math.floor((g-l)/2))),p>u&&(I=n[11],I==t.VerticalAlign.BOTTOM?this.$textStartY=p-u:I==t.VerticalAlign.MIDDLE&&(this.$textStartY=Math.floor((p-u)/2))),r},i.EMPTY_FACTOR=.33,i}(t.DisplayObject);t.BitmapText=e,t.registerClass(e,"egret.BitmapText")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.LEFT="left",t.RIGHT="right",t.CENTER="center",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.HorizontalAlign=e,t.registerClass(e,"egret.HorizontalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){this.replaceArr=[],this.resutlArr=[],this.initReplaceArr()}var i=e,n=i.prototype;return n.initReplaceArr=function(){this.replaceArr=[],this.replaceArr.push([/</g,"<"]),this.replaceArr.push([/>/g,">"]),this.replaceArr.push([/&/g,"&"]),this.replaceArr.push([/"/g,'"']),this.replaceArr.push([/'/g,"'"]) +},n.replaceSpecial=function(t){for(var e=0;ei;){var r=e.indexOf("<",i);if(0>r)this.addToResultArr(e.substring(i)),i=n;else{this.addToResultArr(e.substring(i,r));var s=e.indexOf(">",r);-1==s?(t.$error(1038),s=r):"/"==e.charAt(r+1)?this.stackArray.pop():this.addToArray(e.substring(r+1,s)),i=s+1}}return this.resutlArr},n.addToResultArr=function(t){""!=t&&(t=this.replaceSpecial(t),this.stackArray.length>0?this.resutlArr.push({text:t,style:this.stackArray[this.stackArray.length-1]}):this.resutlArr.push({text:t}))},n.changeStringToObject=function(t){t=t.trim();var e={},i=[];if("i"==t.charAt(0)||"b"==t.charAt(0)||"u"==t.charAt(0))this.addProperty(e,t,"true");else if(i=t.match(/^(font|a)\s/)){t=t.substring(i[0].length).trim();for(var n,r=0;n=t.match(this.getHeadReg());){var s=n[0],a="",t=t.substring(s.length).trim();if('"'==t.charAt(0)){var r=t.indexOf('"',1);a=t.substring(1,r),r+=1}else if("'"==t.charAt(0)){var r=t.indexOf("'",1);a=t.substring(1,r),r+=1}else a=t.match(/(\S)+/)[0],r=a.length;this.addProperty(e,s.substring(0,s.length-1).trim(),a.trim()),t=t.substring(r).trim()}}return e},n.getHeadReg=function(){return/^(color|textcolor|strokecolor|stroke|b|bold|i|italic|u|size|fontfamily|href|target)(\s)*=/},n.addProperty=function(t,e,i){switch(e.toLowerCase()){case"color":case"textcolor":i=i.replace(/#/,"0x"),t.textColor=parseInt(i);break;case"strokecolor":i=i.replace(/#/,"0x"),t.strokeColor=parseInt(i);break;case"stroke":t.stroke=parseInt(i);break;case"b":case"bold":t.bold="true"==i;break;case"u":t.underline="true"==i;break;case"i":case"italic":t.italic="true"==i;break;case"size":t.size=parseInt(i);break;case"fontfamily":t.fontFamily=i;break;case"href":t.href=this.replaceSpecial(i);break;case"target":t.target=this.replaceSpecial(i)}},n.addToArray=function(t){var e=this.changeStringToObject(t);if(0==this.stackArray.length)this.stackArray.push(e);else{var i=this.stackArray[this.stackArray.length-1];for(var n in i)null==e[n]&&(e[n]=i[n]);this.stackArray.push(e)}},e}();t.HtmlTextParser=e,t.registerClass(e,"egret.HtmlTextParser")}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(){e.call(this),this._text=null,this._isFocus=!1}__extends(i,e);var n=i,r=n.prototype;return r.init=function(e){this._text=e,this.stageText=new t.StageText,this.stageText.$setTextField(this._text)},r._addStageText=function(){this._text.$inputEnabled||(this._text.$touchEnabled=!0),this.tempStage=this._text.stage,this.stageText.$addToStage(),this.stageText.addEventListener("updateText",this.updateTextHandler,this),this._text.addEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.stageText.addEventListener("blur",this.blurHandler,this),this.stageText.addEventListener("focus",this.focusHandler,this)},r._removeStageText=function(){this._text.$inputEnabled||(this._text.$touchEnabled=!1),this.stageText.$removeFromStage(),this.stageText.removeEventListener("updateText",this.updateTextHandler,this),this._text.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onMouseDownHandler,this),this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this.stageText.removeEventListener("blur",this.blurHandler,this),this.stageText.removeEventListener("focus",this.focusHandler,this)},r._getText=function(){return this.stageText.$getText()},r._setText=function(t){this.stageText.$setText(t)},r._setColor=function(t){this.stageText.$setColor(t)},r.focusHandler=function(e){this._isFocus||(this._isFocus=!0,e.showing||(this._text.$isTyping=!0),this._text.$invalidateContentBounds(),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_IN,!0)))},r.blurHandler=function(e){this._isFocus&&(this._isFocus=!1,this.tempStage.removeEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this._text.$isTyping=!1,this._text.$invalidateContentBounds(),this.stageText.$onBlur(),this._text.dispatchEvent(new t.FocusEvent(t.FocusEvent.FOCUS_OUT,!0)))},r.onMouseDownHandler=function(t){t.stopPropagation(),this.$onFocus()},r.$onFocus=function(){this._text.visible&&(this._isFocus||(this.tempStage.addEventListener(t.TouchEvent.TOUCH_BEGIN,this.onStageDownHandler,this),this.stageText.$show()))},r.onStageDownHandler=function(t){this.stageText.$hide()},r.updateTextHandler=function(e){var i=this._text.$TextField,n=this.stageText.$getText(),r=!1;if(null!=i[35]){var s=new RegExp("["+i[35]+"]","g"),a=n.match(s);n=a?a.join(""):"",r=!0}null!=i[36]&&(s=new RegExp("[^"+i[36]+"]","g"),a=n.match(s),n=a?a.join(""):"",r=!0),r&&this.stageText.$getText()!=n&&this.stageText.$setText(n),this.resetText(),this._text.dispatchEvent(new t.Event(t.Event.CHANGE,!0))},r.resetText=function(){this._text.$setBaseText(this.stageText.$getText())},r._hideInput=function(){this.stageText.$removeFromStage()},r.updateInput=function(){!this._text.$visible&&this.stageText&&this._hideInput()},r._updateProperties=function(){if(this._isFocus)return this.stageText.$resetStageText(),void this.updateInput();var t=this._text.$stage;if(null==t);else for(var e=this._text,i=e.$visible;;){if(!i)break;if(e=e.parent,e==t)break;i=e.$visible}this.stageText.$setText(this._text.$TextField[13]),this.stageText.$resetStageText(),this.updateInput()},i}(t.HashObject);t.InputController=e,t.registerClass(e,"egret.InputController")}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(e,i,r){r=r||{};var s=null==r.italic?i[16]:r.italic,a=null==r.bold?i[15]:r.bold,o=null==r.size?i[0]:r.size,h=r.fontFamily||i[8]||n.default_fontFamily;return t.sys.measureText(e,h,o,a,s)}var i=new RegExp("(?=[\\u00BF-\\u1FFF\\u2C00-\\uD7FF]|\\b|\\s)(?![。,!、》…))}”】\\.\\,\\!\\?\\]\\:])"),n=function(n){function r(){n.call(this),this.$inputEnabled=!1,this.inputUtils=null,this.graphicsNode=null,this.isFlow=!1,this.textArr=[],this.linesArr=[],this.$isTyping=!1;var e=new t.sys.TextNode;e.fontFamily=r.default_fontFamily,this.textNode=e,this.$renderNode=e,this.$TextField={0:30,1:0,2:16777215,3:0/0,4:0/0,5:0,6:0,7:0,8:r.default_fontFamily,9:"left",10:"top",11:"#ffffff",12:"",13:"",14:[],15:!1,16:!1,17:!0,18:!1,19:!1,20:!1,21:0,22:0,23:0,24:t.TextFieldType.DYNAMIC,25:0,26:"#000000",27:0,28:-1,29:0,30:!1,31:!1,32:0,33:!1,34:16777215,35:null,36:null,37:t.TextFieldInputType.TEXT}}__extends(r,n);var s=__define,a=r,o=a.prototype;return o.isInput=function(){return this.$TextField[24]==t.TextFieldType.INPUT},o.$setTouchEnabled=function(t){var e=n.prototype.$setTouchEnabled.call(this,t);return this.isInput()&&(this.$inputEnabled=!0),e},s(o,"fontFamily",function(){return this.$TextField[8]},function(t){this.$setFontFamily(t)}),o.$setFontFamily=function(t){var e=this.$TextField;return e[8]==t?!1:(e[8]=t,this.invalidateFontString(),!0)},s(o,"size",function(){return this.$TextField[0]},function(t){this.$setSize(t)}),o.$setSize=function(t){t=+t||0;var e=this.$TextField;return e[0]==t?!1:(e[0]=t,this.invalidateFontString(),!0)},s(o,"bold",function(){return this.$TextField[15]},function(t){this.$setBold(t)}),o.$setBold=function(t){t=!!t;var e=this.$TextField;return t==e[15]?!1:(e[15]=t,this.invalidateFontString(),!0)},s(o,"italic",function(){return this.$TextField[16]},function(t){this.$setItalic(t)}),o.$setItalic=function(t){t=!!t;var e=this.$TextField;return t==e[16]?!1:(e[16]=t,this.invalidateFontString(),!0)},o.invalidateFontString=function(){this.$TextField[17]=!0,this.$invalidateTextField()},s(o,"textAlign",function(){return this.$TextField[9]},function(t){this.$setTextAlign(t)}),o.$setTextAlign=function(t){var e=this.$TextField;return e[9]==t?!1:(e[9]=t,this.$invalidateTextField(),!0)},s(o,"verticalAlign",function(){return this.$TextField[10]},function(t){this.$setVerticalAlign(t)}),o.$setVerticalAlign=function(t){var e=this.$TextField;return e[10]==t?!1:(e[10]=t,this.$invalidateTextField(),!0)},s(o,"lineSpacing",function(){return this.$TextField[1]},function(t){this.$setLineSpacing(t)}),o.$setLineSpacing=function(t){t=+t||0;var e=this.$TextField;return e[1]==t?!1:(e[1]=t,this.$invalidateTextField(),!0)},s(o,"textColor",function(){return this.$TextField[2]},function(t){this.$setTextColor(t)}),o.$setTextColor=function(t){t=0|+t;var e=this.$TextField;return e[2]==t?!1:(e[2]=t,this.inputUtils&&this.inputUtils._setColor(this.$TextField[2]),this.$invalidate(),!0)},s(o,"wordWrap",function(){return this.$TextField[19]},function(t){t=!!t;var e=this.$TextField;t!=e[19]&&(e[20]||(e[19]=t,this.$invalidateTextField()))}),s(o,"type",function(){return this.$TextField[24]},function(t){this.$setType(t)}),o.$setType=function(e){var i=this.$TextField;return i[24]!=e?(i[24]=e,e==t.TextFieldType.INPUT?(isNaN(i[3])&&this.$setWidth(100),isNaN(i[4])&&this.$setHeight(30),this.$setTouchEnabled(!0),null==this.inputUtils&&(this.inputUtils=new t.InputController),this.inputUtils.init(this),this.$invalidateTextField(),this.$stage&&this.inputUtils._addStageText()):(this.inputUtils&&(this.inputUtils._removeStageText(),this.inputUtils=null),this.$setTouchEnabled(!1)),!0):!1},s(o,"inputType",function(){return this.$TextField[37]},function(t){this.$TextField[37]=t}),s(o,"text",function(){return this.$getText()},function(t){this.$setText(t)}),o.$getText=function(){return this.$TextField[24]==t.TextFieldType.INPUT?this.inputUtils._getText():this.$TextField[13]},o.$setBaseText=function(t){null==t&&(t=""),t=t.toString(),this.isFlow=!1;var e=this.$TextField;if(e[13]!=t){this.$invalidateTextField(),e[13]=t;var i="";return i=e[20]?this.changeToPassText(t):t,this.setMiddleStyle([{text:i}]),!0}return!1},o.$setText=function(t){null==t&&(t="");var e=this.$setBaseText(t);return this.inputUtils&&this.inputUtils._setText(this.$TextField[13]),e},s(o,"displayAsPassword",function(){return this.$TextField[20]},function(t){this.$setDisplayAsPassword(t)}),o.$setDisplayAsPassword=function(t){var e=this.$TextField;if(e[20]!=t){e[20]=t,this.$invalidateTextField();var i="";return i=t?this.changeToPassText(e[13]):e[13],this.setMiddleStyle([{text:i}]),!0}return!1},s(o,"strokeColor",function(){return this.$TextField[25]},function(t){t=+t||0,this.$setStrokeColor(t)}),o.$setStrokeColor=function(e){var i=this.$TextField;return i[25]!=e?(this.$invalidateTextField(),i[25]=e,i[26]=t.toColorString(e),!0):!1},s(o,"stroke",function(){return this.$TextField[27]},function(t){this.$setStroke(t)}),o.$setStroke=function(t){return this.$TextField[27]!=t?(this.$invalidateTextField(),this.$TextField[27]=t,!0):!1},s(o,"maxChars",function(){return this.$TextField[21]},function(t){this.$setMaxChars(t)}),o.$setMaxChars=function(t){return this.$TextField[21]!=t?(this.$TextField[21]=t,!0):!1},s(o,"scrollV",function(){return Math.min(Math.max(this.$TextField[28],1),this.maxScrollV)},function(t){this.$TextField[28]=Math.max(t,1),this.$invalidateTextField()}),s(o,"maxScrollV",function(){return this.$getLinesArr(),Math.max(this.$TextField[29]-t.TextFieldUtils.$getScrollNum(this)+1,1)}),s(o,"selectionBeginIndex",function(){return 0}),s(o,"selectionEndIndex",function(){return 0}),s(o,"caretIndex",function(){return 0}),o.$setSelection=function(t,e){return!1},o.$getLineHeight=function(){return this.$TextField[1]+this.$TextField[0]},s(o,"numLines",function(){return this.$getLinesArr(),this.$TextField[29]}),s(o,"multiline",function(){return this.$TextField[30]},function(t){this.$setMultiline(t)}),o.$setMultiline=function(t){return this.$TextField[30]=t,this.$invalidateTextField(),!0},s(o,"restrict",function(){var t=this.$TextField,e=null;return null!=t[35]&&(e=t[35]),null!=t[36]&&(null==e&&(e=""),e+="^"+t[36]),e},function(t){var e=this.$TextField;if(null==t)e[35]=null,e[36]=null;else{for(var i=-1;i0&&"\\"==t.charAt(i-1);)i++;0==i?(e[35]=null,e[36]=t.substring(i+1)):i>0?(e[35]=t.substring(0,i),e[36]=t.substring(i+1)):(e[35]=t,e[36]=null)}}),o.$setWidth=function(t){var e=this.$TextField;if(isNaN(t)){if(isNaN(e[3]))return!1;e[3]=0/0}else{if(e[3]==t)return!1;e[3]=t}return t=+t,0>t?!1:(this.$invalidateTextField(),!0)},o.$setHeight=function(t){var e=this.$TextField;if(isNaN(t)){if(isNaN(e[4]))return!1;e[4]=0/0}else{if(e[4]==t)return!1;e[4]=t}return t=+t,0>t?!1:(this.$invalidateTextField(),!0)},o.$getWidth=function(){var t=this.$TextField;return isNaN(t[3])?this.$getContentBounds().width:t[3]},o.$getHeight=function(){var t=this.$TextField;return isNaN(t[4])?this.$getContentBounds().height:t[4]},s(o,"border",function(){return this.$TextField[31]},function(t){this.$TextField[31]=!!t,this.$invalidate()}),s(o,"borderColor",function(){return this.$TextField[32]},function(t){this.$TextField[32]=+t||0,this.$invalidate()}),s(o,"background",function(){return this.$TextField[33]},function(t){this.$TextField[33]=t,this.$invalidate()}),s(o,"backgroundColor",function(){return this.$TextField[34]},function(t){this.$TextField[34]=t,this.$invalidate()}),o.fillBackground=function(e){var i=this.graphicsNode;i&&i.clear();var n=this.$TextField;if(n[33]||n[31]||e.length>0){if(!i){i=this.graphicsNode=new t.sys.GraphicsNode;var r=new t.sys.GroupNode;r.addNode(i),r.addNode(this.textNode),this.$renderNode=r}var s,a;if(n[33]&&(s=i.beginFill(n[34]),s.drawRect(0,0,this.$getWidth(),this.$getHeight())),n[31]&&(a=i.lineStyle(1,n[32]),a.drawRect(0,0,this.$getWidth()-1,this.$getHeight()-1)),e.length>0)for(var o=n[2],h=-1,l=e.length,u=0;l>u;u+=4){var c=e[u],d=e[u+1],f=e[u+2],g=e[u+3]||o;(0>h||h!=g)&&(h=g,a=i.lineStyle(2,g,1,t.CapsStyle.NONE)),a.moveTo(c,d),a.lineTo(c+f,d)}}if(i){var p=this.$getRenderBounds();i.x=p.x,i.y=p.y,i.width=p.width,i.height=p.height,t.Rectangle.release(p)}},o.setFocus=function(){this.type==t.TextFieldType.INPUT&&this.$stage&&this.inputUtils.$onFocus()},o.$onRemoveFromStage=function(){n.prototype.$onRemoveFromStage.call(this),this.removeEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._removeStageText()},o.$onAddToStage=function(e,i){n.prototype.$onAddToStage.call(this,e,i),this.addEvent(),this.$TextField[24]==t.TextFieldType.INPUT&&this.inputUtils._addStageText()},o.$invalidateTextField=function(){this.$invalidateContentBounds(),this.$TextField[18]=!0},o.$update=function(e,i){var r=this.$getRenderBounds(),s=n.prototype.$update.call(this,e,r);return t.Rectangle.release(r),s},o.$getRenderBounds=function(){var e=this.$getContentBounds(),i=t.Rectangle.create();i.copyFrom(e),this.$TextField[31]&&(i.width+=2,i.height+=2);var n=2*this.$TextField[27];return n>0&&(i.width+=2*n,i.height+=2*n),i.x-=n+2,i.y-=n+2,i.width=Math.ceil(i.width)+4,i.height=Math.ceil(i.height)+4,i},o.$measureContentBounds=function(e){this.$getLinesArr();var i=isNaN(this.$TextField[3])?this.$TextField[5]:this.$TextField[3],n=isNaN(this.$TextField[4])?t.TextFieldUtils.$getTextHeight(this):this.$TextField[4];e.setTo(0,0,i,n)},o.$render=function(){if(this.$TextField[24]==t.TextFieldType.INPUT){if((this.$hasAnyFlags(2032)||this.$hasAnyFlags(1648))&&this.inputUtils._updateProperties(),this.$isTyping)return}else if(0==this.$TextField[3])return;var e=this.drawText();this.fillBackground(e);var i=this.$getRenderBounds(),n=this.textNode;n.x=i.x,n.y=i.y,n.width=Math.ceil(i.width),n.height=Math.ceil(i.height),t.Rectangle.release(i)},s(o,"textFlow",function(){return this.textArr},function(t){this.isFlow=!0;var e="";null==t&&(t=[]);for(var i=0;ii;i++)switch(t.charAt(i)){case"\n":e+="\n";break;case"\r":break;default:e+="*"}return e}return t},o.setMiddleStyle=function(t){this.$TextField[18]=!0,this.textArr=t,this.$invalidateTextField()},s(o,"textWidth",function(){return this.$getLinesArr(),this.$TextField[5]}),s(o,"textHeight",function(){return this.$getLinesArr(),t.TextFieldUtils.$getTextHeight(this)}),o.appendText=function(t){this.appendElement({text:t})},o.appendElement=function(t){var e=this.$TextField[13]+t.text;this.$TextField[20]?this.$setBaseText(e):(this.$TextField[13]=e,this.textArr.push(t),this.setMiddleStyle(this.textArr))},o.$getLinesArr=function(){var n=this.$TextField;if(!n[18])return this.linesArr;n[18]=!1;var r=this.textArr;this.linesArr.length=0,n[6]=0,n[5]=0;var s=n[3];if(!isNaN(s)&&0==s)return n[29]=0,[{width:0,height:0,charNum:0,elements:[],hasNextLine:!1}];for(var a,o=this.linesArr,h=0,l=0,u=0,c=0,d=0,f=r.length;f>d;d++){var g=r[d];if(g.text){g.style=g.style||{};for(var p=g.text.toString(),v=p.split(/(?:\r\n|\r|\n)/),$=0,y=v.length;y>$;$++){null==o[c]&&(a={width:0,height:0,elements:[],charNum:0,hasNextLine:!1},o[c]=a,h=0,u=0,l=0),u=n[24]==t.TextFieldType.INPUT?n[0]:Math.max(u,g.style.size||n[0]);var m=!0;if(""==v[$])$==y-1&&(m=!1);else{var T=e(v[$],n,g.style);if(isNaN(s))h+=T,l+=v[$].length,a.elements.push({width:T,text:v[$],style:g.style}),$==y-1&&(m=!1);else if(s>=h+T)a.elements.push({width:T,text:v[$],style:g.style}),h+=T,l+=v[$].length,$==y-1&&(m=!1);else{var x=0,b=0,_=v[$];if(n[19])var E=_.split(i);else E=_.match(/./g);for(var C=E.length,F=0;C>x&&(T=e(E[x],n,g.style),!(0!=h&&h+T>s&&h+x!=0));x++)if(b+T>s)for(var w=E[x].match(/./g),R=0,S=w.length;S>R&&(T=e(w[R],n,g.style),!(R>0&&h+T>s));R++)F+=w[R].length,b+=T,h+=T,l+=F;else F+=E[x].length,b+=T,h+=T,l+=F;if(x>0){a.elements.push({width:b,text:_.substring(0,F),style:g.style});for(var D=_.substring(F),O=0,L=D.length;L>O&&" "==D.charAt(O);O++);v[$]=D.substring(O)}""!=v[$]&&($--,m=!1)}}m&&(l++,a.hasNextLine=!0),$a){var u=t.TextFieldUtils.$getValign(this);o+=u*(l-a)}o=Math.round(o);for(var c=t.TextFieldUtils.$getHalign(this),d=0,f=[],g=h,p=i[29];p>g;g++){var v=n[g],$=v.height;if(o+=$/2,g!=h){if(i[24]==t.TextFieldType.INPUT&&!i[30])break;if(!isNaN(l)&&o>l)break}d=Math.round((s-v.width)*c);for(var y=0,m=v.elements.length;m>y;y++){var T=v.elements[y],x=T.style.size||i[0];e.drawText(d,o+($-x)/2,T.text,T.style),T.style.underline&&f.push(d,o+$/2,T.width,T.style.textColor),d+=T.width}o+=$/2+i[1]}return f},o.addEvent=function(){this.addEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},o.removeEvent=function(){this.removeEventListener(t.TouchEvent.TOUCH_TAP,this.onTapHandler,this)},o.onTapHandler=function(e){if(this.$TextField[24]!=t.TextFieldType.INPUT){var i=t.TextFieldUtils.$getTextElement(this,e.localX,e.localY);if(null!=i){var n=i.style;if(n&&n.href)if(n.href.match(/^event:/)){var r=n.href.match(/^event:/)[0];t.TextEvent.dispatchTextEvent(this,t.TextEvent.LINK,n.href.substring(r.length))}else open(n.href,n.target||"_blank")}}},r.default_fontFamily="Arial",r}(t.DisplayObject);t.TextField=n,t.registerClass(n,"egret.TextField")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.TEXT="text",t.TEL="tel",t.PASSWORD="password",t}();t.TextFieldInputType=e,t.registerClass(e,"egret.TextFieldInputType")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.DYNAMIC="dynamic",t.INPUT="input",t}();t.TextFieldType=e,t.registerClass(e,"egret.TextFieldType")}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}var i=e;i.prototype;return e.$getStartLine=function(t){var i=t.$TextField,n=e.$getTextHeight(t),r=0,s=i[4];return isNaN(s)||(s>n||n>s&&(r=Math.max(i[28]-1,0),r=Math.min(i[29]-1,r)),i[30]||(r=Math.max(i[28]-1,0),i[29]>0&&(r=Math.min(i[29]-1,r)))),r},e.$getHalign=function(e){var i=e.$getLinesArr(),n=0;return e.$TextField[9]==t.HorizontalAlign.CENTER?n=.5:e.$TextField[9]==t.HorizontalAlign.RIGHT&&(n=1),e.$TextField[24]==t.TextFieldType.INPUT&&!e.$TextField[30]&&i.length>1&&(n=0),n},e.$getTextHeight=function(e){var i=t.TextFieldType.INPUT!=e.$TextField[24]||e.$TextField[30]?e.$TextField[6]+(e.$TextField[29]-1)*e.$TextField[1]:e.$TextField[0];return i},e.$getValign=function(i){var n=e.$getTextHeight(i),r=i.$TextField[4];if(!isNaN(r)&&r>n){var s=0;return i.$TextField[10]==t.VerticalAlign.MIDDLE?s=.5:i.$TextField[10]==t.VerticalAlign.BOTTOM&&(s=1),s}return 0},e.$getTextElement=function(t,i,n){var r=e.$getHit(t,i,n),s=t.$getLinesArr();return r&&s[r.lineIndex]&&s[r.lineIndex].elements[r.textElementIndex]?s[r.lineIndex].elements[r.textElementIndex]:null},e.$getHit=function(t,i,n){var r=t.$getLinesArr();if(0==t.$TextField[3])return null;var s=0,a=e.$getTextHeight(t),o=0,h=t.$TextField[4];if(!isNaN(h)&&h>a){var l=e.$getValign(t);o=l*(h-a),0!=o&&(n-=o)}for(var u=e.$getStartLine(t),c=0,d=u;d=n){s=d+1;break}if(c+=f.height,c+t.$TextField[1]>n)return null;c+=t.$TextField[1]}if(0==s)return null;var g=r[s-1],p=0;for(d=0;dn/2&&e++}return e},e}();t.TextFieldUtils=e,t.registerClass(e,"egret.TextFieldUtils")}(egret||(egret={}));var egret;!function(t){var e;!function(t){}(e=t.sys||(t.sys={}))}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.TOP="top",t.BOTTOM="bottom",t.MIDDLE="middle",t.JUSTIFY="justify",t.CONTENT_JUSTIFY="contentJustify",t}();t.VerticalAlign=e,t.registerClass(e,"egret.VerticalAlign")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.LITTLE_ENDIAN="littleEndian",t.BIG_ENDIAN="bigEndian",t}();t.Endian=e,t.registerClass(e,"egret.Endian");var i=function(){function i(t){this.BUFFER_EXT_SIZE=0,this.EOF_byte=-1,this.EOF_code_point=-1,this._setArrayBuffer(t||new ArrayBuffer(this.BUFFER_EXT_SIZE)),this.endian=e.BIG_ENDIAN}var n=__define,r=i,s=r.prototype;return s._setArrayBuffer=function(t){this.write_position=t.byteLength,this.data=new DataView(t),this._position=0},s.setArrayBuffer=function(t){},n(s,"buffer",function(){return this.data.buffer},function(t){this.data=new DataView(t)}),n(s,"dataView",function(){return this.data},function(t){this.data=t,this.write_position=t.byteLength}),n(s,"bufferOffset",function(){return this.data.byteOffset}),n(s,"position",function(){return this._position},function(t){this._position=t,this.write_position=t>this.write_position?t:this.write_position}),n(s,"length",function(){return this.write_position},function(t){this.write_position=t;var e=new Uint8Array(new ArrayBuffer(t)),i=this.data.buffer.byteLength;i>t&&(this._position=t);var n=Math.min(i,t);e.set(new Uint8Array(this.data.buffer,0,n)),this.buffer=e.buffer}),n(s,"bytesAvailable",function(){return this.data.byteLength-this._position}),s.clear=function(){this._setArrayBuffer(new ArrayBuffer(this.BUFFER_EXT_SIZE))},s.readBoolean=function(){return this.validate(i.SIZE_OF_BOOLEAN)?0!=this.data.getUint8(this.position++):null},s.readByte=function(){return this.validate(i.SIZE_OF_INT8)?this.data.getInt8(this.position++):null},s.readBytes=function(t,e,n){if(void 0===e&&(e=0),void 0===n&&(n=0),0==n)n=this.bytesAvailable;else if(!this.validate(n))return null;t?t.validateBuffer(e+n):t=new i(new ArrayBuffer(e+n));for(var r=0;n>r;r++)t.data.setUint8(r+e,this.data.getUint8(this.position++))},s.readDouble=function(){if(!this.validate(i.SIZE_OF_FLOAT64))return null;var t=this.data.getFloat64(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_FLOAT64,t},s.readFloat=function(){if(!this.validate(i.SIZE_OF_FLOAT32))return null;var t=this.data.getFloat32(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_FLOAT32,t},s.readInt=function(){if(!this.validate(i.SIZE_OF_INT32))return null;var t=this.data.getInt32(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_INT32,t},s.readShort=function(){if(!this.validate(i.SIZE_OF_INT16))return null;var t=this.data.getInt16(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_INT16,t},s.readUnsignedByte=function(){return this.validate(i.SIZE_OF_UINT8)?this.data.getUint8(this.position++):null},s.readUnsignedInt=function(){if(!this.validate(i.SIZE_OF_UINT32))return null;var t=this.data.getUint32(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_UINT32,t},s.readUnsignedShort=function(){if(!this.validate(i.SIZE_OF_UINT16))return null;var t=this.data.getUint16(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_UINT16,t},s.readUTF=function(){if(!this.validate(i.SIZE_OF_UINT16))return null;var t=this.data.getUint16(this.position,this.endian==e.LITTLE_ENDIAN);return this.position+=i.SIZE_OF_UINT16,t>0?this.readUTFBytes(t):""},s.readUTFBytes=function(t){if(!this.validate(t))return null;var e=new Uint8Array(this.buffer,this.bufferOffset+this.position,t);return this.position+=t,this.decodeUTF8(e)},s.writeBoolean=function(t){this.validateBuffer(i.SIZE_OF_BOOLEAN),this.data.setUint8(this.position++,t?1:0)},s.writeByte=function(t){this.validateBuffer(i.SIZE_OF_INT8),this.data.setInt8(this.position++,t)},s.writeBytes=function(t,e,i){void 0===e&&(e=0),void 0===i&&(i=0);var n;if(!(0>e)&&!(0>i)&&(n=0==i?t.length-e:Math.min(t.length-e,i),n>0)){this.validateBuffer(n);for(var r=new DataView(t.buffer),i=n,s=4;i>s;i-=s)this.data.setUint32(this._position,r.getUint32(e)),this.position+=s,e+=s;for(;i>0;i--)this.data.setUint8(this.position++,r.getUint8(e++))}},s.writeDouble=function(t){this.validateBuffer(i.SIZE_OF_FLOAT64),this.data.setFloat64(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_FLOAT64},s.writeFloat=function(t){this.validateBuffer(i.SIZE_OF_FLOAT32),this.data.setFloat32(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_FLOAT32},s.writeInt=function(t){this.validateBuffer(i.SIZE_OF_INT32),this.data.setInt32(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_INT32},s.writeShort=function(t){this.validateBuffer(i.SIZE_OF_INT16),this.data.setInt16(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_INT16},s.writeUnsignedInt=function(t){this.validateBuffer(i.SIZE_OF_UINT32),this.data.setUint32(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_UINT32},s.writeUnsignedShort=function(t){this.validateBuffer(i.SIZE_OF_UINT16),this.data.setUint16(this.position,t,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_UINT16},s.writeUTF=function(t){var n=this.encodeUTF8(t),r=n.length;this.validateBuffer(i.SIZE_OF_UINT16+r),this.data.setUint16(this.position,r,this.endian==e.LITTLE_ENDIAN),this.position+=i.SIZE_OF_UINT16,this._writeUint8Array(n,!1)},s.writeUTFBytes=function(t){this._writeUint8Array(this.encodeUTF8(t))},s.toString=function(){return"[ByteArray] length:"+this.length+", bytesAvailable:"+this.bytesAvailable},s._writeUint8Array=function(t,e){void 0===e&&(e=!0),e&&this.validateBuffer(this.position+t.length);for(var i=0;i0&&this._position+e<=this.data.byteLength?!0:void t.$error(1025)},s.validateBuffer=function(t,e){if(void 0===e&&(e=!1),this.write_position=t>this.write_position?t:this.write_position,t+=this._position,this.data.byteLengthe;){var r=i[e++];if(this.inRange(r,55296,57343))this.encoderError(r);else if(this.inRange(r,0,127))n.push(r);else{var s,a;for(this.inRange(r,128,2047)?(s=1,a=192):this.inRange(r,2048,65535)?(s=2,a=224):this.inRange(r,65536,1114111)&&(s=3,a=240),n.push(this.div(r,Math.pow(64,s))+a);s>0;){var o=this.div(r,Math.pow(64,s-1));n.push(128+o%64),s-=1}}}return new Uint8Array(n)},s.decodeUTF8=function(t){for(var e,i=!1,n=0,r="",s=0,a=0,o=0,h=0;t.length>n;){var l=t[n++];if(l==this.EOF_byte)e=0!=a?this.decoderError(i):this.EOF_code_point;else if(0==a)this.inRange(l,0,127)?e=l:(this.inRange(l,194,223)?(a=1,h=128,s=l-192):this.inRange(l,224,239)?(a=2,h=2048,s=l-224):this.inRange(l,240,244)?(a=3,h=65536,s=l-240):this.decoderError(i),s*=Math.pow(64,a),e=null);else if(this.inRange(l,128,191))if(o+=1,s+=(l-128)*Math.pow(64,a-o),o!==a)e=null;else{var u=s,c=h;s=0,a=0,o=0,h=0,e=this.inRange(u,c,1114111)&&!this.inRange(u,55296,57343)?u:this.decoderError(i,l)}else s=0,a=0,o=0,h=0,n--,e=this.decoderError(i,l);null!==e&&e!==this.EOF_code_point&&(65535>=e?e>0&&(r+=String.fromCharCode(e)):(e-=65536,r+=String.fromCharCode(55296+(e>>10&1023)),r+=String.fromCharCode(56320+(1023&e))))}return r},s.encoderError=function(e){t.$error(1026,e)},s.decoderError=function(e,i){return e&&t.$error(1027),i||65533},s.inRange=function(t,e,i){return t>=e&&i>=t},s.div=function(t,e){return Math.floor(t/e)},s.stringToCodePoints=function(t){for(var e=[],i=0,n=t.length;is;s++){var a=n[s];if(e=e[a],!e)return null}return i[t]=e,e}var i={};t.getDefinitionByName=e}(egret||(egret={}));var __global=__global||this,egret;!function(t){}(egret||(egret={}));var egret;!function(t){function e(t){var e=typeof t;if(!t||"object"!=e&&!t.prototype)return e;var i=t.prototype?t.prototype:Object.getPrototypeOf(t);if(i.hasOwnProperty("__class__"))return i.__class__;var n=i.constructor.toString().trim(),r=n.indexOf("("),s=n.substring(9,r); +return Object.defineProperty(i,"__class__",{value:s,enumerable:!1,writable:!0}),s}t.getQualifiedClassName=e}(egret||(egret={}));var egret;!function(t){function e(e){if(!e||"object"!=typeof e&&!e.prototype)return null;var i=e.prototype?e.prototype:Object.getPrototypeOf(e),n=Object.getPrototypeOf(i);if(!n)return null;var r=t.getQualifiedClassName(n.constructor);return r?r:null}t.getQualifiedSuperclassName=e}(egret||(egret={}));var egret;!function(t){function e(){return Date.now()-t.sys.$START_TIME}t.getTimer=e}(egret||(egret={}));var egret;!function(t){function e(e){var i=t.getDefinitionByName(e);return i?!0:!1}t.hasDefinition=e}(egret||(egret={}));var egret;!function(t){function e(t,e){if(!t||"object"!=typeof t)return!1;var i=Object.getPrototypeOf(t),n=i?i.__types__:null;return n?-1!==n.indexOf(e):!1}t.is=e}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=__define,i=t;i.prototype;return e(t,"logLevel",void 0,function(t){}),t.ALL="all",t.DEBUG="debug",t.INFO="info",t.WARN="warn",t.ERROR="error",t.OFF="off",t}();t.Logger=e,t.registerClass(e,"egret.Logger")}(egret||(egret={}));var egret;!function(t){var e=function(){function t(){}var e=t;e.prototype;return t.isNumber=function(t){return"number"==typeof t&&!isNaN(t)},t.sin=function(e){var i=Math.floor(e),n=i+1,r=t.sinInt(i);if(i==e)return r;var s=t.sinInt(n);return(e-i)*s+(n-e)*r},t.sinInt=function(t){return t%=360,0>t&&(t+=360),egret_sin_map[t]},t.cos=function(e){var i=Math.floor(e),n=i+1,r=t.cosInt(i);if(i==e)return r;var s=t.cosInt(n);return(e-i)*s+(n-e)*r},t.cosInt=function(t){return t%=360,0>t&&(t+=360),egret_cos_map[t]},t}();t.NumberUtils=e,t.registerClass(e,"egret.NumberUtils")}(egret||(egret={}));for(var egret_sin_map={},egret_cos_map={},DEG_TO_RAD=Math.PI/180,NumberUtils_i=0;360>NumberUtils_i;NumberUtils_i++)egret_sin_map[NumberUtils_i]=Math.sin(NumberUtils_i*DEG_TO_RAD),egret_cos_map[NumberUtils_i]=Math.cos(NumberUtils_i*DEG_TO_RAD);egret_sin_map[90]=1,egret_cos_map[90]=0,egret_sin_map[180]=0,egret_cos_map[180]=-1,egret_sin_map[270]=-1,egret_cos_map[270]=0,Function.prototype.bind||(Function.prototype.bind=function(t){"function"!=typeof this&&egret.$error(1029);var e=Array.prototype.slice.call(arguments,1),i=this,n=function(){},r=function(){return i.apply(this instanceof n&&t?this:t,e.concat(Array.prototype.slice.call(arguments)))};return n.prototype=this.prototype,r.prototype=new n,r});var egret;!function(t){function e(e,i){t.sys.$ticker.$startTick(e,i)}t.startTick=e}(egret||(egret={}));var egret;!function(t){function e(e,i){t.sys.$ticker.$stopTick(e,i)}t.stopTick=e}(egret||(egret={}));var egret;!function(t){var e=function(e){function i(t,i){void 0===i&&(i=0),e.call(this),this._delay=0,this._currentCount=0,this._running=!1,this.updateInterval=1e3,this.lastCount=1e3,this.lastTimeStamp=0,this.delay=t,this.repeatCount=0|+i}__extends(i,e);var n=__define,r=i,s=r.prototype;return n(s,"delay",function(){return this._delay},function(t){1>t&&(t=1),this._delay!=t&&(this._delay=t,this.lastCount=this.updateInterval=Math.round(60*t))}),n(s,"currentCount",function(){return this._currentCount}),n(s,"running",function(){return this._running}),s.reset=function(){this.stop(),this._currentCount=0},s.start=function(){this._running||(this.lastCount=this.updateInterval,this.lastTimeStamp=t.getTimer(),t.sys.$ticker.$startTick(this.$update,this),this._running=!0)},s.stop=function(){this._running&&(t.stopTick(this.$update,this),this._running=!1)},s.$update=function(e){var i=e-this.lastTimeStamp;if(i>=this._delay)this.lastCount=this.updateInterval;else{if(this.lastCount-=1e3,this.lastCount>0)return!1;this.lastCount+=this.updateInterval}this.lastTimeStamp=e,this._currentCount++;var n=this.repeatCount>0&&this._currentCount>=this.repeatCount;return t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER),n&&(this.stop(),t.TimerEvent.dispatchTimerEvent(this,t.TimerEvent.TIMER_COMPLETE)),!1},i}(t.EventDispatcher);t.Timer=e,t.registerClass(e,"egret.Timer")}(egret||(egret={}));var egret;!function(t){function e(t){0>t&&(t=0),t>16777215&&(t=16777215);for(var e=t.toString(16).toUpperCase();e.length>6;)e=e.slice(1,e.length);for(;e.length<6;)e="0"+e;return"#"+e}t.toColorString=e}(egret||(egret={}));var egret;!function(t){}(egret||(egret={}));var egret;!function(t){var e=function(){function e(){}var i=e;i.prototype;return e.compileProgram=function(i,n,r){var s=e.compileFragmentShader(i,r),a=e.compileVertexShader(i,n),o=i.createProgram();return i.attachShader(o,a),i.attachShader(o,s),i.linkProgram(o),i.getProgramParameter(o,i.LINK_STATUS)||t.$warn(1020),o},e.compileFragmentShader=function(t,i){return e._compileShader(t,i,t.FRAGMENT_SHADER)},e.compileVertexShader=function(t,i){return e._compileShader(t,i,t.VERTEX_SHADER)},e._compileShader=function(t,e,i){var n=t.createShader(i);return t.shaderSource(n,e),t.compileShader(n),t.getShaderParameter(n,t.COMPILE_STATUS)?n:null},e.checkCanUseWebGL=function(){if(void 0==e.canUseWebGL)try{var t=document.createElement("canvas");e.canUseWebGL=!(!window.WebGLRenderingContext||!t.getContext("webgl")&&!t.getContext("experimental-webgl"))}catch(i){e.canUseWebGL=!1}return e.canUseWebGL},e.deleteWebGLTexture=function(t){if(t){var e=t.webGLTexture;if(e)for(var i in e){var n=e[i],r=n.glContext;r.deleteTexture(n)}t.webGLTexture=null}},e}();t.WebGLUtils=e,t.registerClass(e,"egret.WebGLUtils")}(egret||(egret={})); +>>>>>>> 4b8c5c4a241e7d9bd1c1bd245f7622d16a8879b6 diff --git a/build/eui/eui.d.ts b/build/eui/eui.d.ts index 4b2d3ad9b6..3238644cfe 100644 --- a/build/eui/eui.d.ts +++ b/build/eui/eui.d.ts @@ -887,7 +887,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - left: number; + left: number | string; /** * @language en_US * The horizontal distance in pixels from the right edge of the component to the @@ -909,7 +909,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - right: number; + right: number | string; /** * @language en_US * The vertical distance in pixels from the top edge of the component to the @@ -931,7 +931,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - top: number; + top: number | string; /** * @language en_US * The vertical distance in pixels from the bottom edge of the component to the @@ -953,7 +953,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - bottom: number; + bottom: number | string; /** * @language en_US * The horizontal distance in pixels from the center of the component to the @@ -975,7 +975,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @language en_US * The vertical distance in pixels from the center of the component to the @@ -997,7 +997,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter: number; + verticalCenter: number | string; /** * @language en_US * Specifies the width of a component as a percentage @@ -1594,32 +1594,32 @@ declare module eui.sys { * @private * 距父级容器离左边距离 */ - left: number; + left: number | string; /** * @private * 距父级容器右边距离 */ - right: number; + right: number | string; /** * @private * 距父级容器顶部距离 */ - top: number; + top: number | string; /** * @private * 距父级容器底部距离 */ - bottom: number; + bottom: number | string; /** * @private * 在父级容器中距水平中心位置的距离 */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @private * 在父级容器中距竖直中心位置的距离 */ - verticalCenter: number; + verticalCenter: number | string; /** * @private * 相对父级容器宽度的百分比 @@ -1667,20 +1667,6 @@ declare module eui.sys { * @param value */ $setHeight(value: number): boolean; - /** - * @private - * - * @param value - * @returns - */ - $setScaleX(value: number): boolean; - /** - * @private - * - * @param value - * @returns - */ - $setScaleY(value: number): boolean; /** * @private * 组件的最小宽度,此属性设置为大于maxWidth的值时无效。同时影响测量和自动布局的尺寸。 @@ -1714,6 +1700,22 @@ declare module eui.sys { * 不会影响显式标记尺寸属性 */ private setActualSize(w, h); + /** + * @private + */ + $invalidateMatrix(): void; + /** + * @private + */ + $setMatrix(matrix: egret.Matrix, needUpdateProperties?: boolean): boolean; + /** + * @private + */ + $setAnchorOffsetX(value: number): boolean; + /** + * @private + */ + $setAnchorOffsetY(value: number): boolean; /** * @private * @@ -1822,6 +1824,10 @@ declare module eui.sys { * @param h */ private applyMatrix(bounds, w, h); + /** + * @private + */ + private getAnchorMatrix(); } /** * @private @@ -1975,7 +1981,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - left: number; + left: number | string; /** * @copy eui.UIComponent#right * @@ -1983,7 +1989,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - right: number; + right: number | string; /** * @copy eui.UIComponent#top * @@ -1991,7 +1997,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - top: number; + top: number | string; /** * @copy eui.UIComponent#bottom * @@ -1999,7 +2005,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - bottom: number; + bottom: number | string; /** * @copy eui.UIComponent#horizontalCenter * @@ -2007,7 +2013,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @copy eui.UIComponent#verticalCenter * @@ -2015,7 +2021,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter: number; + verticalCenter: number | string; /** * @copy eui.UIComponent#percentWidth * @@ -2619,7 +2625,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - left: number; + left: number | string; /** * @inheritDoc * @@ -2627,7 +2633,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - right: number; + right: number | string; /** * @inheritDoc * @@ -2635,7 +2641,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - top: number; + top: number | string; /** * @inheritDoc * @@ -2643,7 +2649,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - bottom: number; + bottom: number | string; /** * @inheritDoc * @@ -2651,7 +2657,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @inheritDoc * @@ -2659,7 +2665,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter: number; + verticalCenter: number | string; /** * @inheritDoc * @@ -3751,7 +3757,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - left: number; + left: number | string; /** * @inheritDoc * @@ -3759,7 +3765,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - right: number; + right: number | string; /** * @inheritDoc * @@ -3767,7 +3773,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - top: number; + top: number | string; /** * @inheritDoc * @@ -3775,7 +3781,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - bottom: number; + bottom: number | string; /** * @inheritDoc * @@ -3783,7 +3789,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @inheritDoc * @@ -3791,7 +3797,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter: number; + verticalCenter: number | string; /** * @inheritDoc * @@ -4688,7 +4694,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - left: number; + left: number | string; /** * @inheritDoc * @@ -4696,7 +4702,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - right: number; + right: number | string; /** * @inheritDoc * @@ -4704,7 +4710,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - top: number; + top: number | string; /** * @inheritDoc * @@ -4712,7 +4718,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - bottom: number; + bottom: number | string; /** * @inheritDoc * @@ -4720,7 +4726,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @inheritDoc * @@ -4728,7 +4734,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter: number; + verticalCenter: number | string; /** * @inheritDoc * @@ -6117,7 +6123,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - left: number; + left: number | string; /** * @copy eui.UIComponent#right * @@ -6125,7 +6131,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - right: number; + right: number | string; /** * @copy eui.UIComponent#top * @@ -6133,7 +6139,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - top: number; + top: number | string; /** * @copy eui.UIComponent#bottom * @@ -6141,7 +6147,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - bottom: number; + bottom: number | string; /** * @copy eui.UIComponent#horizontalCenter * @@ -6149,7 +6155,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @copy eui.UIComponent#verticalCenter * @@ -6157,7 +6163,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter: number; + verticalCenter: number | string; /** * @copy eui.UIComponent#percentWidth * @@ -6667,7 +6673,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - left: number; + left: number | string; /** * @copy eui.UIComponent#right * @@ -6675,7 +6681,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - right: number; + right: number | string; /** * @copy eui.UIComponent#top * @@ -6683,7 +6689,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - top: number; + top: number | string; /** * @copy eui.UIComponent#bottom * @@ -6691,7 +6697,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - bottom: number; + bottom: number | string; /** * @copy eui.UIComponent#horizontalCenter * @@ -6699,7 +6705,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter: number; + horizontalCenter: number | string; /** * @copy eui.UIComponent#verticalCenter * @@ -6707,7 +6713,7 @@ declare module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter: number; + verticalCenter: number | string; /** * @copy eui.UIComponent#percentWidth * @@ -9404,378 +9410,288 @@ declare module eui { private commitCurrentState; } } -declare module eui { - /** - * @language en_US - * The TabBar class displays a set of identical tabs. - * One tab can be selected at a time, and the first tab is selected by default. - *

        The set of tabs is defined by the dataProvider property. - * The appearance of each tab is defined by the ItemRenderer class.

        - *

        You can use the TabBar control to set the active child of a ViewStack container, - * as the following example shows:

        - *
        -     *       
        -     *       
        -     *          
        -     *          
        -     *          
        -     *       
        -     * 
        - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts - */ +declare module eui.sys { /** - * @language zh_CN - * TabBar 类显示一组相同的选项卡。一次可以选择一个选项卡,且默认情况下选择第一个选项卡。 - *

        该组选项卡由 dataProvider 属性定义。 - * 每个选项卡的外观由 ItemRenderer 定义。

        - *

        可以使用 TabBar 控件设置 ViewStack 容器的活动子代,如下例所示:

        - *
        -     *       
        -     *       
        -     *          
        -     *          
        -     *          
        -     *       
        -     * 
        - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts + * @private + * 数值缓动工具类 */ - class TabBar extends ListBase { + class Animation { /** - * @language en_US - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @private */ + constructor(updateFunction: (animation: Animation) => void, thisObject: any); /** - * @language zh_CN - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @private + * 此动画的缓动行为。设置为null意味着不使用缓动,默认值为 sineInOut */ - constructor(); + easerFunction: (fraction: number) => number; /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @private */ - protected createChildren(): void; + private thisObject; /** * @private - * - * @param value + * 是否正在播放动画,不包括延迟等待和暂停的阶段 */ - $setDataProvider(value: ICollection): boolean; + isPlaying: boolean; /** * @private + * 动画持续时间,单位毫秒,默认值500 */ - private indexBeingUpdated; + duration: number; /** * @private - * 触摸点击的选中项改变 + * 动画到当前时间对应的值。 */ - private onIndexChanged(event); + currentValue: number; /** * @private - * ViewStack选中项发生改变 + * 起始值 */ - private onViewStackIndexChange(event); - } -} -declare module eui.sys { - /** - * @private - */ - const enum TextInputKeys { - prompt = 0, - displayAsPassword = 1, - textColor = 2, - maxChars = 3, - maxWidth = 4, - maxHeight = 5, - text = 6, - restrict = 7, - inputType = 8, + from: number; + /** + * @private + * 终点值。 + */ + to: number; + /** + * @private + * 动画启动时刻 + */ + private startTime; + /** + * @private + * 动画播放结束时的回调函数 + */ + endFunction: (animation: Animation) => void; + /** + * @private + * 动画更新时的回调函数 + */ + updateFunction: Function; + /** + * @private + * 开始正向播放动画,无论何时调用都重新从零时刻开始,若设置了延迟会首先进行等待。 + */ + play(): void; + /** + * @private + * 开始播放动画 + */ + private start(); + /** + * @private + * 停止播放动画 + */ + stop(): void; + /** + * @private + * 计算当前值并返回动画是否结束 + */ + private doInterval(currentTime); } } declare module eui { - /** - * - */ /** * @language en_US - * The TextInput is a textfield input component, the user can input and edit the text. - * - * @version Egret 2.5.7 + * Default instance of interface IThemeAdapter. + * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts */ /** * @language zh_CN - * TextInput 是一个文本输入控件,供用户输入和编辑统一格式文本 - * - * @version Egret 2.5.7 + * 默认的IThemeAdapter接口实现。 + * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts */ - class TextInput extends Component { - constructor(); + class DefaultThemeAdapter implements IThemeAdapter { + /** + * 解析主题 + * @param url 待解析的主题url + * @param compFunc 解析完成回调函数,示例:compFunc(e:egret.Event):void; + * @param errorFunc 解析失败回调函数,示例:errorFunc():void; + * @param thisObject 回调的this引用 + */ + getTheme(url: string, compFunc: Function, errorFunc: Function, thisObject: any): void; + } +} +declare module eui.sys { + /** + * @private + * 一个工具类,用于容器的滚屏拖动操作,计算在一段时间持续滚动后释放,应该继续滚动到的值和缓动时间。 + * 使用此工具类,您需要创建一个 ScrollThrown 实例,并在滚动发生时调用start()方法,然后在触摸移动过程中调用update()更新当前舞台坐标。 + * 内部将会启动一个计时器定时根据当前位置计算出速度值,并缓存下来最后4个值。当停止滚动时,再调用finish()方法, + * 将立即停止记录位移,并将计算出的最终结果存储到 Thrown.scrollTo 和 Thrown.duration 属性上。 + */ + class TouchScroll { /** * @private + * 创建一个 TouchScroll 实例 + * @param updateFunction 滚动位置更新回调函数 */ - $TextInput: Object; + constructor(updateFunction: (scrollPos: number) => void, endFunction: () => void, target: egret.IEventDispatcher); /** - * @language en_US - * [SkinPart] The TextInput display - * @skinPart - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private + * 当前容器滚动外界可调节的系列 */ + $scrollFactor: number; /** - * @language zh_CN - * [SkinPart] 实体文本输入组件 - * @skinPart - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ - textDisplay: EditableText; + private target; /** - * @language zh_CN - * [SkinPart] When the property of the text is empty, it will show the defalut string. - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @private */ + private updateFunction; /** - * @language zh_CN - * [SkinPart] 当text属性为空字符串时要显示的文本。 - * @skinPart - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @private */ - promptDisplay: Label; + private endFunction; /** - * @copy eui.EditableText#prompt - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ + private previousTime; /** - * @copy eui.EditableText#prompt - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - prompt: string; - /** - * @copy egret.TextField#displayAsPassword - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#displayAsPassword - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - displayAsPassword: boolean; - /** - * @copy egret.TextField#inputType - * - * @version Egret 3.1.6 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#inputType - * - * @version Egret 3.1.6 - * @version eui 1.0 - * @platform Web,Native - */ - inputType: string; - /** - * @copy egret.TextField#textColor - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @copy egret.TextField#textColor - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - */ - textColor: number; - /** - * @copy egret.TextField#maxChars - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ + private velocity; /** - * @copy egret.TextField#maxChars - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ - maxChars: number; + private previousVelocity; /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ + private currentPosition; /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ - maxWidth: number; + private previousPosition; /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ + private currentScrollPos; /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private */ - maxHeight: number; + private maxScrollPos; /** - * @copy egret.TextField#text - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private + * 触摸按下时的偏移量 */ + private offsetPoint; /** - * @copy egret.TextField#text - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private + * 停止触摸时继续滚动的动画实例 */ - text: string; + private animation; + $bounces: boolean; /** - * @copy egret.TextField#restrict - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private + * 正在播放缓动动画的标志。 */ + isPlaying(): boolean; /** - * @copy egret.TextField#restrict - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private + * 如果正在执行缓动滚屏,停止缓动。 */ - restrict: string; + stop(): void; + private started; /** * @private + * true表示已经调用过start方法。 */ - private isFocus; + isStarted(): boolean; /** * @private - * 焦点移入 + * 开始记录位移变化。注意:当使用完毕后,必须调用 finish() 方法结束记录,否则该对象将无法被回收。 + * @param touchPoint 起始触摸位置,以像素为单位,通常是stageX或stageY。 */ - private focusInHandler(event); + start(touchPoint: number): void; /** * @private - * 焦点移出 + * 更新当前移动到的位置 + * @param touchPoint 当前触摸位置,以像素为单位,通常是stageX或stageY。 */ - private focusOutHandler(event); + update(touchPoint: number, maxScrollValue: number, scrollValue: any): void; /** - * @inheritDoc - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @private + * 停止记录位移变化,并计算出目标值和继续缓动的时间。 + * @param currentScrollPos 容器当前的滚动值。 + * @param maxScrollPos 容器可以滚动的最大值。当目标值不在 0~maxValue之间时,将会应用更大的摩擦力,从而影响缓动时间的长度。 */ - protected getCurrentState(): string; + finish(currentScrollPos: number, maxScrollPos: number): void; /** - * @inheritDoc + * @private * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @param timeStamp + * @returns */ - protected partAdded(partName: string, instance: any): void; + private onTick(timeStamp); /** - * @inheritDoc + * @private * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + * @param animation */ - protected partRemoved(partName: string, instance: any): void; + private finishScrolling(animation?); /** * @private + * 缓动到水平滚动位置 */ - private textDisplayAdded(); + private throwTo(hspTo, duration?); /** * @private + * 更新水平滚动位置 */ - private textDisplayRemoved(); + private onScrollingUpdate(animation); } } declare module eui { /** * @language en_US - * The ToggleSwitch control defines an on-off control. + * The TabBar class displays a set of identical tabs. + * One tab can be selected at a time, and the first tab is selected by default. + *

        The set of tabs is defined by the dataProvider property. + * The appearance of each tab is defined by the ItemRenderer class.

        + *

        You can use the TabBar control to set the active child of a ViewStack container, + * as the following example shows:

        + *
        +     *       
        +     *       
        +     *          
        +     *          
        +     *          
        +     *       
        +     * 
        * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/ToggleSwitchExample.ts + * @includeExample extension/eui/components/TabBarExample.ts */ /** * @language zh_CN - * ToggleSwitch 表示一个开关组件。 + * TabBar 类显示一组相同的选项卡。一次可以选择一个选项卡,且默认情况下选择第一个选项卡。 + *

        该组选项卡由 dataProvider 属性定义。 + * 每个选项卡的外观由 ItemRenderer 定义。

        + *

        可以使用 TabBar 控件设置 ViewStack 容器的活动子代,如下例所示:

        + *
        +     *       
        +     *       
        +     *          
        +     *          
        +     *          
        +     *       
        +     * 
        * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/ToggleSwitchExample.ts + * @includeExample extension/eui/components/TabBarExample.ts */ - class ToggleSwitch extends ToggleButton { + class TabBar extends ListBase { /** * @language en_US * Constructor. @@ -9793,605 +9709,695 @@ declare module eui { * @platform Web,Native */ constructor(); - } -} -declare module eui { - /** - * @language en_US - * The UILayer class is the subclass of the Group class.It not only has the standard function of the Group class,but also - * can keep its size the same to the stage size (Stage.stageWidth,Stage.stageHeight).Its size will changes as the stage size changes. - * like any normal container class,you can create multiple instance of the UILayer class,but it is usually used as the root of the UI display list. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @language zh_CN - * UILayer 是 Group 的子类,它除了具有容器的所有标准功能,还能够自动保持自身尺寸始终与舞台尺寸相同(Stage.stageWidth,Stage.stageHeight)。 - * 当舞台尺寸发生改变时,它会跟随舞台尺寸改变。UILayer 跟普通容器一样,允许创建多个实例,但通常都将它作为UI显示列表的根节点使用。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - class UILayer extends Group { /** - * @language en_US - * Constructor. + * @inheritDoc * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native */ + protected createChildren(): void; /** - * @language zh_CN - * 构造函数。 + * @private * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @param value */ - constructor(); + $setDataProvider(value: ICollection): boolean; /** * @private - * 添加到舞台 */ - private onAddToStage(event?); + private indexBeingUpdated; /** * @private - * 从舞台移除 + * 触摸点击的选中项改变 */ - private onRemoveFromStage(event); + private onIndexChanged(event); /** * @private - * 舞台尺寸改变 + * ViewStack选中项发生改变 */ - private onResize(event?); + private onViewStackIndexChange(event); + } +} +declare module eui.sys { + /** + * @private + */ + const enum TextInputKeys { + prompt = 0, + displayAsPassword = 1, + textColor = 2, + maxChars = 3, + maxWidth = 4, + maxHeight = 5, + text = 6, + restrict = 7, + inputType = 8, } } declare module eui { /** - * @language en_US - * The VScrollBar (vertical scrollbar) control lets you control - * the portion of data that is displayed when there is too much data - * to fit vertically in a display area. * - *

        Although you can use the VScrollBar control as a stand-alone control, - * you usually combine it as part of another group of components to - * provide scrolling functionality.

        + */ + /** + * @language en_US + * The TextInput is a textfield input component, the user can input and edit the text. * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts + * @includeExample extension/eui/components/TextInputExample.ts */ /** * @language zh_CN - * VScrollBar(垂直 ScrollBar)控件可以在因数据太多而不能在显示区域中以垂直方向完全显示时控制显示的数据部分。 - *

        虽然 VScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

        + * TextInput 是一个文本输入控件,供用户输入和编辑统一格式文本 * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts + * @includeExample extension/eui/components/TextInputExample.ts */ - class VScrollBar extends ScrollBarBase { + class TextInput extends Component { + constructor(); /** - * @inheritDoc - * - * @version Egret 2.4 + * @private + */ + $TextInput: Object; + /** + * @language en_US + * [SkinPart] The TextInput display + * @skinPart + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; /** - * @inheritDoc - * - * @version Egret 2.4 + * @language zh_CN + * [SkinPart] 实体文本输入组件 + * @skinPart + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - protected onPropertyChanged(event: eui.PropertyEvent): void; - } -} -declare module eui { - /** - * @language en_US - * The VSlider (vertical slider) control lets users select a value - * by moving a slider thumb between the end points of the slider track. - * The current value of the slider is determined by the relative location of the thumb between - * the end points of the slider, corresponding to the slider's minimum and maximum values. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts - */ - /** - * @language zh_CN - * 使用 VSlider(垂直滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts - */ - class VSlider extends SliderBase { + textDisplay: EditableText; /** - * @language en_US - * Constructor. - * + * @language zh_CN + * [SkinPart] When the property of the text is empty, it will show the defalut string. + * @skinPart * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native */ /** * @language zh_CN - * 构造函数。 - * + * [SkinPart] 当text属性为空字符串时要显示的文本。 + * @skinPart * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native */ - constructor(); + promptDisplay: Label; /** - * @inheritDoc + * @copy eui.EditableText#prompt * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - protected pointToValue(x: number, y: number): number; /** - * @private + * @copy eui.EditableText#prompt * - * @returns + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native */ - private getThumbRange(); + prompt: string; /** - * @inheritDoc + * @copy egret.TextField#displayAsPassword * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - updateSkinDisplayList(): void; - } -} -declare module eui { - /** - * @language en_US - * An ViewStack navigator container consists of a collection of child - * containers stacked on top of each other, where only one child - * at a time is visible. - * When a different child container is selected, it seems to replace - * the old one because it appears in the same location. - * However, the old child container still exists; it is just invisible. - * - * @event eui.CollectionEvent.COLLECTION_CHANGE Dispatched when the ICollection has been updated in some way. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ViewStackExample.ts - */ - /** - * @language zh_CN - * ViewStack 导航器容器由一组彼此上下堆叠的子容器组成,其中一次只可以显示一个子容器。 - * 选择另一个子容器后,它将显示在原来子容器的位置处,所以看起来好像此子容器替换了原来的子容器。 - * 但是,原来的子容器仍然存在,只不过它现在处于不可见状态。 - * - * @event eui.CollectionEvent.COLLECTION_CHANGE 以某种方式更新 ICollection 后分派。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/ViewStackExample.ts - */ - class ViewStack extends Group implements ICollection { /** - * @language en_US - * Constructor. + * @copy egret.TextField#displayAsPassword * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ + displayAsPassword: boolean; /** - * @language zh_CN - * 构造函数。 + * @copy egret.TextField#inputType * - * @version Egret 2.4 + * @version Egret 3.1.6 * @version eui 1.0 * @platform Web,Native */ - constructor(); /** - * @language en_US - * The layout object for this container. - * This object is responsible for the measurement and layout of - * the visual elements in the container. - * - * @default eui.BasicLayout + * @copy egret.TextField#inputType * - * @version Egret 2.4 + * @version Egret 3.1.6 * @version eui 1.0 * @platform Web,Native */ + inputType: string; /** - * @language zh_CN - * 此容器的 layout 对象。此对象负责容器中可视元素的测量和布局。 - * - * @default eui.BasicLayout + * @copy egret.TextField#textColor * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - layout: LayoutBase; - /** - * @private - */ - private _selectedChild; /** - * @language en_US - * A reference to the currently visible child container. - * The default is a reference to the first child. - * If there are no children, this property is null. + * @copy egret.TextField#textColor * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ + textColor: number; /** - * @language zh_CN - * 对当前可见子容器的引用。默认设置为对第一个子容器的引用。如果没有子项,则此属性为 null。 + * @copy egret.TextField#maxChars * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - selectedChild: egret.DisplayObject; - /** - * @private - * 在属性提交前缓存选中项索引 - */ - private proposedSelectedIndex; - /** - * @private - */ - _selectedIndex: number; /** - * @language en_US - * The zero-based index of the currently visible child container. - * Child indexes are in the range 0, 1, 2, ..., n - 1, - * where n is the number of children. - * The default value is 0, corresponding to the first child. - * If there are no children, the value of this property is -1. + * @copy egret.TextField#maxChars * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ + maxChars: number; /** - * @language zh_CN - * 当前可见子容器的从零开始的索引。子索引的范围是 0、1、2、...、n - 1,其中 n 是子项的数目。 - * 默认值是 0,对应于第一个子项。如果不存在子容器,则此属性的值为 -1。 + * @inheritDoc * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - selectedIndex: number; - /** - * @private - * 设置选中项索引 - */ - private setSelectedIndex(value); /** - * @private - * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 + * @inheritDoc + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native */ - $childAdded(child: egret.DisplayObject, index: number): void; + maxWidth: number; /** - * @private - * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 - * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 + * @inheritDoc + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native */ - $childRemoved(child: egret.DisplayObject, index: number): void; /** * @inheritDoc * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - protected commitProperties(): void; + maxHeight: number; /** - * @private - * - * @param newIndex - */ - private commitSelection(newIndex); - /** - * @private - * - * @param child - * @param visible - */ - private showOrHide(child, visible); - /** - * @language en_US - * number of children + * @copy egret.TextField#text * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ /** - * @language zh_CN - * 子项数量 + * @copy egret.TextField#text * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - length: number; + text: string; /** - * @inheritDoc + * @copy egret.TextField#restrict * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - getItemAt(index: number): any; /** - * @inheritDoc + * @copy egret.TextField#restrict * - * @version Egret 2.4 + * @version Egret 2.5.7 * @version eui 1.0 * @platform Web,Native */ - getItemIndex(item: any): number; - } -} -declare module eui.sys { - /** - * @private - * 数值缓动工具类 - */ - class Animation { + restrict: string; /** * @private */ - constructor(updateFunction: (animation: Animation) => void, thisObject: any); + private isFocus; /** * @private - * 此动画的缓动行为。设置为null意味着不使用缓动,默认值为 sineInOut + * 焦点移入 */ - easerFunction: (fraction: number) => number; + private focusInHandler(event); /** * @private + * 焦点移出 */ - private thisObject; + private focusOutHandler(event); /** - * @private - * 是否正在播放动画,不包括延迟等待和暂停的阶段 + * @inheritDoc + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native */ - isPlaying: boolean; + protected getCurrentState(): string; /** - * @private - * 动画持续时间,单位毫秒,默认值500 + * @inheritDoc + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native */ - duration: number; + protected partAdded(partName: string, instance: any): void; /** - * @private - * 动画到当前时间对应的值。 + * @inheritDoc + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native */ - currentValue: number; + protected partRemoved(partName: string, instance: any): void; /** * @private - * 起始值 */ - from: number; + private textDisplayAdded(); /** * @private - * 终点值。 */ - to: number; + private textDisplayRemoved(); + } +} +declare module eui { + /** + * @language en_US + * The ToggleSwitch control defines an on-off control. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/ToggleSwitchExample.ts + */ + /** + * @language zh_CN + * ToggleSwitch 表示一个开关组件。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/ToggleSwitchExample.ts + */ + class ToggleSwitch extends ToggleButton { /** - * @private - * 动画启动时刻 + * @language en_US + * Constructor. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private startTime; /** - * @private - * 动画播放结束时的回调函数 + * @language zh_CN + * 构造函数。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - endFunction: (animation: Animation) => void; + constructor(); + } +} +declare module eui { + /** + * @language en_US + * The UILayer class is the subclass of the Group class.It not only has the standard function of the Group class,but also + * can keep its size the same to the stage size (Stage.stageWidth,Stage.stageHeight).Its size will changes as the stage size changes. + * like any normal container class,you can create multiple instance of the UILayer class,but it is usually used as the root of the UI display list. + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + /** + * @language zh_CN + * UILayer 是 Group 的子类,它除了具有容器的所有标准功能,还能够自动保持自身尺寸始终与舞台尺寸相同(Stage.stageWidth,Stage.stageHeight)。 + * 当舞台尺寸发生改变时,它会跟随舞台尺寸改变。UILayer 跟普通容器一样,允许创建多个实例,但通常都将它作为UI显示列表的根节点使用。 + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + class UILayer extends Group { /** - * @private - * 动画更新时的回调函数 + * @language en_US + * Constructor. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - updateFunction: Function; /** - * @private - * 开始正向播放动画,无论何时调用都重新从零时刻开始,若设置了延迟会首先进行等待。 + * @language zh_CN + * 构造函数。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - play(): void; + constructor(); /** * @private - * 开始播放动画 + * 添加到舞台 */ - private start(); + private onAddToStage(event?); /** * @private - * 停止播放动画 + * 从舞台移除 */ - stop(): void; + private onRemoveFromStage(event); /** * @private - * 计算当前值并返回动画是否结束 + * 舞台尺寸改变 */ - private doInterval(currentTime); + private onResize(event?); } } declare module eui { /** * @language en_US - * Default instance of interface IThemeAdapter. + * An ViewStack navigator container consists of a collection of child + * containers stacked on top of each other, where only one child + * at a time is visible. + * When a different child container is selected, it seems to replace + * the old one because it appears in the same location. + * However, the old child container still exists; it is just invisible. + * + * @event eui.CollectionEvent.COLLECTION_CHANGE Dispatched when the ICollection has been updated in some way. + * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native + * @includeExample extension/eui/components/ViewStackExample.ts */ /** * @language zh_CN - * 默认的IThemeAdapter接口实现。 + * ViewStack 导航器容器由一组彼此上下堆叠的子容器组成,其中一次只可以显示一个子容器。 + * 选择另一个子容器后,它将显示在原来子容器的位置处,所以看起来好像此子容器替换了原来的子容器。 + * 但是,原来的子容器仍然存在,只不过它现在处于不可见状态。 + * + * @event eui.CollectionEvent.COLLECTION_CHANGE 以某种方式更新 ICollection 后分派。 + * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native + * @includeExample extension/eui/components/ViewStackExample.ts */ - class DefaultThemeAdapter implements IThemeAdapter { + class ViewStack extends Group implements ICollection { /** - * 解析主题 - * @param url 待解析的主题url - * @param compFunc 解析完成回调函数,示例:compFunc(e:egret.Event):void; - * @param errorFunc 解析失败回调函数,示例:errorFunc():void; - * @param thisObject 回调的this引用 + * @language en_US + * Constructor. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - getTheme(url: string, compFunc: Function, errorFunc: Function, thisObject: any): void; - } -} -declare module eui.sys { - /** - * @private - * 一个工具类,用于容器的滚屏拖动操作,计算在一段时间持续滚动后释放,应该继续滚动到的值和缓动时间。 - * 使用此工具类,您需要创建一个 ScrollThrown 实例,并在滚动发生时调用start()方法,然后在触摸移动过程中调用update()更新当前舞台坐标。 - * 内部将会启动一个计时器定时根据当前位置计算出速度值,并缓存下来最后4个值。当停止滚动时,再调用finish()方法, - * 将立即停止记录位移,并将计算出的最终结果存储到 Thrown.scrollTo 和 Thrown.duration 属性上。 - */ - class TouchScroll { /** - * @private - * 创建一个 TouchScroll 实例 - * @param updateFunction 滚动位置更新回调函数 + * @language zh_CN + * 构造函数。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - constructor(updateFunction: (scrollPos: number) => void, endFunction: () => void, target: egret.IEventDispatcher); + constructor(); /** - * @private - * 当前容器滚动外界可调节的系列 + * @language en_US + * The layout object for this container. + * This object is responsible for the measurement and layout of + * the visual elements in the container. + * + * @default eui.BasicLayout + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - $scrollFactor: number; /** - * @private + * @language zh_CN + * 此容器的 layout 对象。此对象负责容器中可视元素的测量和布局。 + * + * @default eui.BasicLayout + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private target; + layout: LayoutBase; /** * @private */ - private updateFunction; + private _selectedChild; /** - * @private + * @language en_US + * A reference to the currently visible child container. + * The default is a reference to the first child. + * If there are no children, this property is null. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private endFunction; /** - * @private + * @language zh_CN + * 对当前可见子容器的引用。默认设置为对第一个子容器的引用。如果没有子项,则此属性为 null。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private previousTime; + selectedChild: egret.DisplayObject; /** * @private + * 在属性提交前缓存选中项索引 */ - private velocity; + private proposedSelectedIndex; /** * @private */ - private previousVelocity; + _selectedIndex: number; /** - * @private + * @language en_US + * The zero-based index of the currently visible child container. + * Child indexes are in the range 0, 1, 2, ..., n - 1, + * where n is the number of children. + * The default value is 0, corresponding to the first child. + * If there are no children, the value of this property is -1. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private currentPosition; /** - * @private + * @language zh_CN + * 当前可见子容器的从零开始的索引。子索引的范围是 0、1、2、...、n - 1,其中 n 是子项的数目。 + * 默认值是 0,对应于第一个子项。如果不存在子容器,则此属性的值为 -1。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private previousPosition; + selectedIndex: number; /** * @private + * 设置选中项索引 */ - private currentScrollPos; + private setSelectedIndex(value); /** * @private + * 一个子项被添加到容器内,此方法不仅在操作addChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 + * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 */ - private maxScrollPos; + $childAdded(child: egret.DisplayObject, index: number): void; /** * @private - * 触摸按下时的偏移量 + * 一个子项从容器内移除,此方法不仅在操作removeChild()时会被回调,在操作setChildIndex()或swapChildren时也会回调。 + * 当子项索引发生改变时,会先触发$childRemoved()方法,然后触发$childAdded()方法。 */ - private offsetPoint; + $childRemoved(child: egret.DisplayObject, index: number): void; /** - * @private - * 停止触摸时继续滚动的动画实例 + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private animation; - $bounces: boolean; + protected commitProperties(): void; /** * @private - * 正在播放缓动动画的标志。 + * + * @param newIndex */ - isPlaying(): boolean; + private commitSelection(newIndex); /** * @private - * 如果正在执行缓动滚屏,停止缓动。 + * + * @param child + * @param visible */ - stop(): void; - private started; + private showOrHide(child, visible); /** - * @private - * true表示已经调用过start方法。 + * @language en_US + * number of children + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - isStarted(): boolean; /** - * @private - * 开始记录位移变化。注意:当使用完毕后,必须调用 finish() 方法结束记录,否则该对象将无法被回收。 - * @param touchPoint 起始触摸位置,以像素为单位,通常是stageX或stageY。 + * @language zh_CN + * 子项数量 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - start(touchPoint: number): void; + length: number; /** - * @private - * 更新当前移动到的位置 - * @param touchPoint 当前触摸位置,以像素为单位,通常是stageX或stageY。 + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - update(touchPoint: number, maxScrollValue: number, scrollValue: any): void; + getItemAt(index: number): any; /** - * @private - * 停止记录位移变化,并计算出目标值和继续缓动的时间。 - * @param currentScrollPos 容器当前的滚动值。 - * @param maxScrollPos 容器可以滚动的最大值。当目标值不在 0~maxValue之间时,将会应用更大的摩擦力,从而影响缓动时间的长度。 + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - finish(currentScrollPos: number, maxScrollPos: number): void; + getItemIndex(item: any): number; + } +} +declare module eui { + /** + * @language en_US + * The VScrollBar (vertical scrollbar) control lets you control + * the portion of data that is displayed when there is too much data + * to fit vertically in a display area. + * + *

        Although you can use the VScrollBar control as a stand-alone control, + * you usually combine it as part of another group of components to + * provide scrolling functionality.

        + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/VScrollBarExample.ts + */ + /** + * @language zh_CN + * VScrollBar(垂直 ScrollBar)控件可以在因数据太多而不能在显示区域中以垂直方向完全显示时控制显示的数据部分。 + *

        虽然 VScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

        + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/VScrollBarExample.ts + */ + class VScrollBar extends ScrollBarBase { /** - * @private + * @inheritDoc * - * @param timeStamp - * @returns + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private onTick(timeStamp); + protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void; /** - * @private + * @inheritDoc * - * @param animation + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private finishScrolling(animation?); + protected onPropertyChanged(event: eui.PropertyEvent): void; + } +} +declare module eui { + /** + * @language en_US + * The VSlider (vertical slider) control lets users select a value + * by moving a slider thumb between the end points of the slider track. + * The current value of the slider is determined by the relative location of the thumb between + * the end points of the slider, corresponding to the slider's minimum and maximum values. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/VSliderExample.ts + */ + /** + * @language zh_CN + * 使用 VSlider(垂直滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 + * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/VSliderExample.ts + */ + class VSlider extends SliderBase { /** - * @private - * 缓动到水平滚动位置 + * @language en_US + * Constructor. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - private throwTo(hspTo, duration?); + /** + * @language zh_CN + * 构造函数。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + constructor(); + /** + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + protected pointToValue(x: number, y: number): number; /** * @private - * 更新水平滚动位置 + * + * @returns */ - private onScrollingUpdate(animation); + private getThumbRange(); + /** + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + updateSkinDisplayList(): void; } } declare module eui { diff --git a/build/eui/eui.js b/build/eui/eui.js index 2ad17c38d9..0b0fb055ab 100644 --- a/build/eui/eui.js +++ b/build/eui/eui.js @@ -1876,7 +1876,12 @@ var eui; return this.$UIComponent[0 /* left */]; } ,function (value) { - value = +value; + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[0 /* left */] === value) return; @@ -1893,7 +1898,12 @@ var eui; return this.$UIComponent[1 /* right */]; } ,function (value) { - value = +value; + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[1 /* right */] === value) return; @@ -1910,7 +1920,12 @@ var eui; return this.$UIComponent[2 /* top */]; } ,function (value) { - value = +value; + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[2 /* top */] === value) return; @@ -1927,7 +1942,12 @@ var eui; return this.$UIComponent[3 /* bottom */]; } ,function (value) { - value = +value; + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[3 /* bottom */] == value) return; @@ -1944,7 +1964,12 @@ var eui; return this.$UIComponent[4 /* horizontalCenter */]; } ,function (value) { - value = +value; + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[4 /* horizontalCenter */] === value) return; @@ -1961,7 +1986,12 @@ var eui; return this.$UIComponent[5 /* verticalCenter */]; } ,function (value) { - value = +value; + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[5 /* verticalCenter */] === value) return; @@ -2081,32 +2111,6 @@ var eui; this.invalidateParentLayout(); return true; }; - /** - * @private - * - * @param value - * @returns - */ - p.$setScaleX = function (value) { - var change = this.$super.$setScaleX.call(this, value); - if (change) { - this.invalidateParentLayout(); - } - return change; - }; - /** - * @private - * - * @param value - * @returns - */ - p.$setScaleY = function (value) { - var change = this.$super.$setScaleY.call(this, value); - if (change) { - this.invalidateParentLayout(); - } - return change; - }; d(p, "minWidth" /** * @private @@ -2215,6 +2219,38 @@ var eui; this.dispatchEventWith(egret.Event.RESIZE); } }; + /** + * @private + */ + p.$invalidateMatrix = function () { + this.$super.$invalidateMatrix.call(this); + this.invalidateParentLayout(); + }; + /** + * @private + */ + p.$setMatrix = function (matrix, needUpdateProperties) { + if (needUpdateProperties === void 0) { needUpdateProperties = true; } + this.$super.$setMatrix.call(this, matrix, needUpdateProperties); + this.invalidateParentLayout(); + return true; + }; + /** + * @private + */ + p.$setAnchorOffsetX = function (value) { + this.$super.$setAnchorOffsetX.call(this, value); + this.invalidateParentLayout(); + return true; + }; + /** + * @private + */ + p.$setAnchorOffsetY = function (value) { + this.$super.$setAnchorOffsetY.call(this, value); + this.invalidateParentLayout(); + return true; + }; /** * @private * @@ -2224,7 +2260,6 @@ var eui; p.$setX = function (value) { var change = this.$super.$setX.call(this, value); if (change) { - this.invalidateParentLayout(); this.invalidateProperties(); } return change; @@ -2238,7 +2273,6 @@ var eui; p.$setY = function (value) { var change = this.$super.$setY.call(this, value); if (change) { - this.invalidateParentLayout(); this.invalidateProperties(); } return change; @@ -2443,7 +2477,7 @@ var eui; values[28 /* layoutHeightExplicitlySet */] = true; height = Math.max(minHeight, Math.min(maxHeight, layoutHeight)); } - var matrix = this.$getMatrix(); + var matrix = this.getAnchorMatrix(); if (isDeltaIdentity(matrix)) { this.setActualSize(width, height); return; @@ -2461,7 +2495,7 @@ var eui; */ p.setLayoutBoundsPosition = function (x, y) { var matrix = this.$getMatrix(); - if (!isDeltaIdentity(matrix)) { + if (!isDeltaIdentity(matrix) || this.anchorOffsetX != 0 || this.anchorOffsetY != 0) { var bounds = egret.$TempRectangle; this.getLayoutBounds(bounds); x += this.$getX() - bounds.x; @@ -2542,7 +2576,7 @@ var eui; */ p.applyMatrix = function (bounds, w, h) { var bounds = bounds.setTo(0, 0, w, h); - var matrix = this.$getMatrix(); + var matrix = this.getAnchorMatrix(); if (isDeltaIdentity(matrix)) { bounds.x += matrix.tx; bounds.y += matrix.ty; @@ -2551,6 +2585,20 @@ var eui; matrix.$transformBounds(bounds); } }; + /** + * @private + */ + p.getAnchorMatrix = function () { + var matrix = this.$getMatrix(); + var offsetX = this.anchorOffsetX; + var offsetY = this.anchorOffsetY; + if (offsetX != 0 || offsetY != 0) { + var tempM = egret.$TempMatrix; + matrix.$preMultiplyInto(tempM.setTo(1, 0, 0, 1, -offsetX, -offsetY), tempM); + return tempM; + } + return matrix; + }; return UIComponentImpl; }(egret.DisplayObject)); sys.UIComponentImpl = UIComponentImpl; @@ -2610,6 +2658,12 @@ var eui; mixin(descendant, UIComponentImpl); var prototype = descendant.prototype; prototype.$super = base.prototype; + eui.registerProperty(descendant, "left", "any"); + eui.registerProperty(descendant, "right", "any"); + eui.registerProperty(descendant, "top", "any"); + eui.registerProperty(descendant, "bottom", "any"); + eui.registerProperty(descendant, "horizontalCenter", "any"); + eui.registerProperty(descendant, "verticalCenter", "any"); if (isContainer) { prototype.$childAdded = function (child, index) { this.invalidateSize(); @@ -12713,21 +12767,21 @@ var eui; if (this.$strokeWeight > 0) { g.beginFill(this.$fillColor, 0); g.lineStyle(this.$strokeWeight, this.$strokeColor, this.$strokeAlpha, true, "normal", "square", "miter"); - if (this.$ellipseWidth == 0) { + if (this.$ellipseWidth == 0 && this.$ellipseHeight == 0) { g.drawRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight); } else { - g.drawRoundRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight, this.$ellipseWidth, 0); + g.drawRoundRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight, this.$ellipseWidth, this.$ellipseHeight); } g.endFill(); } g.beginFill(this.$fillColor, this.$fillAlpha); g.lineStyle(this.$strokeWeight, this.$strokeColor, 0, true, "normal", "square", "miter"); - if (this.$ellipseWidth == 0) { + if (this.$ellipseWidth == 0 && this.$ellipseHeight == 0) { g.drawRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2); } else { - g.drawRoundRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2, this.$ellipseWidth, 0); + g.drawRoundRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2, this.$ellipseWidth, this.$ellipseHeight); } g.endFill(); this.$invalidateContentBounds(); @@ -13869,185 +13923,756 @@ var eui; ////////////////////////////////////////////////////////////////////////////////////// var eui; (function (eui) { - /** - * @language en_US - * The TabBar class displays a set of identical tabs. - * One tab can be selected at a time, and the first tab is selected by default. - *

        The set of tabs is defined by the dataProvider property. - * The appearance of each tab is defined by the ItemRenderer class.

        - *

        You can use the TabBar control to set the active child of a ViewStack container, - * as the following example shows:

        - *
        -     *       
        -     *       
        -     *          
        -     *          
        -     *          
        -     *       
        -     * 
        - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts - */ - /** - * @language zh_CN - * TabBar 类显示一组相同的选项卡。一次可以选择一个选项卡,且默认情况下选择第一个选项卡。 - *

        该组选项卡由 dataProvider 属性定义。 - * 每个选项卡的外观由 ItemRenderer 定义。

        - *

        可以使用 TabBar 控件设置 ViewStack 容器的活动子代,如下例所示:

        - *
        -     *       
        -     *       
        -     *          
        -     *          
        -     *          
        -     *       
        -     * 
        - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TabBarExample.ts - */ - var TabBar = (function (_super) { - __extends(TabBar, _super); - /** - * @language en_US - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @language zh_CN - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - function TabBar() { - _super.call(this); - /** - * @private - */ - this.indexBeingUpdated = false; - this.requireSelection = true; - this.useVirtualLayout = false; - } - var d = __define,c=TabBar,p=c.prototype; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - p.createChildren = function () { - if (!this.$layout) { - var layout = new eui.HorizontalLayout(); - layout.gap = 0; - layout.horizontalAlign = eui.JustifyAlign.JUSTIFY; - layout.verticalAlign = eui.JustifyAlign.CONTENT_JUSTIFY; - this.$setLayout(layout); - } - _super.prototype.createChildren.call(this); - }; + var sys; + (function (sys) { /** * @private * - * @param value - */ - p.$setDataProvider = function (value) { - var dp = this.$dataProvider; - if (dp && dp instanceof eui.ViewStack) { - dp.removeEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onViewStackIndexChange, this); - this.removeEventListener(egret.Event.CHANGE, this.onIndexChanged, this); - } - if (value && value instanceof eui.ViewStack) { - value.addEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onViewStackIndexChange, this); - this.addEventListener(egret.Event.CHANGE, this.onIndexChanged, this); - } - return _super.prototype.$setDataProvider.call(this, value); - }; - /** - * @private - * 触摸点击的选中项改变 + * @param fraction + * @returns */ - p.onIndexChanged = function (event) { - this.indexBeingUpdated = true; - (this.$dataProvider).selectedIndex = this.selectedIndex; - this.indexBeingUpdated = false; - }; + function sineInOut(fraction) { + return -0.5 * (Math.cos(Math.PI * fraction) - 1); + } /** * @private - * ViewStack选中项发生改变 + * 数值缓动工具类 */ - p.onViewStackIndexChange = function (event) { - if (event.property == "selectedIndex" && !this.indexBeingUpdated) { - this.setSelectedIndex((this.$dataProvider).selectedIndex, false); - } - }; - return TabBar; - }(eui.ListBase)); - eui.TabBar = TabBar; - egret.registerClass(TabBar,'eui.TabBar'); -})(eui || (eui = {})); -var eui; -(function (eui) { - var FocusEvent = egret.FocusEvent; - /** - * - */ - /** - * @language en_US - * The TextInput is a textfield input component, the user can input and edit the text. - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts - */ - /** - * @language zh_CN - * TextInput 是一个文本输入控件,供用户输入和编辑统一格式文本 - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/TextInputExample.ts - */ - var TextInput = (function (_super) { - __extends(TextInput, _super); - function TextInput() { - _super.call(this); + var Animation = (function () { /** * @private */ - this.isFocus = false; - this.$TextInput = { - 0: null, - 1: null, - 2: null, - 3: null, - 4: null, - 5: null, - 6: "", - 7: null, - 8: egret.TextFieldInputType.TEXT //inputType - }; - } - var d = __define,c=TextInput,p=c.prototype; - d(p, "prompt" - /** - * @copy eui.EditableText#prompt - * - * @version Egret 2.5.7 - * @version eui 1.0 - * @platform Web,Native + function Animation(updateFunction, thisObject) { + /** + * @private + * 此动画的缓动行为。设置为null意味着不使用缓动,默认值为 sineInOut + */ + this.easerFunction = sineInOut; + /** + * @private + * 是否正在播放动画,不包括延迟等待和暂停的阶段 + */ + this.isPlaying = false; + /** + * @private + * 动画持续时间,单位毫秒,默认值500 + */ + this.duration = 500; + /** + * @private + * 动画到当前时间对应的值。 + */ + this.currentValue = 0; + /** + * @private + * 起始值 + */ + this.from = 0; + /** + * @private + * 终点值。 + */ + this.to = 0; + /** + * @private + * 动画启动时刻 + */ + this.startTime = 0; + /** + * @private + * 动画播放结束时的回调函数 + */ + this.endFunction = null; + this.updateFunction = updateFunction; + this.thisObject = thisObject; + } + var d = __define,c=Animation,p=c.prototype; + /** + * @private + * 开始正向播放动画,无论何时调用都重新从零时刻开始,若设置了延迟会首先进行等待。 + */ + p.play = function () { + this.stop(); + this.start(); + }; + /** + * @private + * 开始播放动画 + */ + p.start = function () { + this.isPlaying = false; + this.currentValue = 0; + this.startTime = egret.getTimer(); + this.doInterval(this.startTime); + egret.startTick(this.doInterval, this); + }; + /** + * @private + * 停止播放动画 + */ + p.stop = function () { + this.isPlaying = false; + this.startTime = 0; + egret.stopTick(this.doInterval, this); + }; + /** + * @private + * 计算当前值并返回动画是否结束 + */ + p.doInterval = function (currentTime) { + var runningTime = currentTime - this.startTime; + if (!this.isPlaying) { + this.isPlaying = true; + } + var duration = this.duration; + var fraction = duration == 0 ? 1 : Math.min(runningTime, duration) / duration; + if (this.easerFunction) { + fraction = this.easerFunction(fraction); + } + this.currentValue = this.from + (this.to - this.from) * fraction; + if (this.updateFunction) + this.updateFunction.call(this.thisObject, this); + var isEnded = runningTime >= duration; + if (isEnded) { + this.stop(); + } + if (isEnded && this.endFunction) { + this.endFunction.call(this.thisObject, this); + } + return true; + }; + return Animation; + }()); + sys.Animation = Animation; + egret.registerClass(Animation,'eui.sys.Animation'); + })(sys = eui.sys || (eui.sys = {})); +})(eui || (eui = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var eui; +(function (eui) { + /** + * @language en_US + * Default instance of interface IThemeAdapter. + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + /** + * @language zh_CN + * 默认的IThemeAdapter接口实现。 + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + var DefaultThemeAdapter = (function () { + function DefaultThemeAdapter() { + } + var d = __define,c=DefaultThemeAdapter,p=c.prototype; + /** + * 解析主题 + * @param url 待解析的主题url + * @param compFunc 解析完成回调函数,示例:compFunc(e:egret.Event):void; + * @param errorFunc 解析失败回调函数,示例:errorFunc():void; + * @param thisObject 回调的this引用 + */ + p.getTheme = function (url, compFunc, errorFunc, thisObject) { + function onGet(event) { + var loader = (event.target); + compFunc.call(thisObject, loader.response); + } + function onError(event) { + errorFunc.call(thisObject); + } + var loader = new egret.HttpRequest(); + loader.addEventListener(egret.Event.COMPLETE, onGet, thisObject); + loader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, thisObject); + loader.responseType = egret.HttpResponseType.TEXT; + loader.open(url); + loader.send(); + }; + return DefaultThemeAdapter; + }()); + eui.DefaultThemeAdapter = DefaultThemeAdapter; + egret.registerClass(DefaultThemeAdapter,'eui.DefaultThemeAdapter',["eui.IThemeAdapter"]); +})(eui || (eui = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var eui; +(function (eui) { + var sys; + (function (sys) { + /** + * @private + * 需要记录的历史速度的最大次数。 + */ + var MAX_VELOCITY_COUNT = 4; + /** + * @private + * 记录的历史速度的权重列表。 + */ + var VELOCITY_WEIGHTS = [1, 1.33, 1.66, 2]; + /** + * @private + * 当前速度所占的权重。 + */ + var CURRENT_VELOCITY_WEIGHT = 2.33; + /** + * @private + * 最小的改变速度,解决浮点数精度问题。 + */ + var MINIMUM_VELOCITY = 0.02; + /** + * @private + * 当容器自动滚动时要应用的摩擦系数 + */ + var FRICTION = 0.998; + /** + * @private + * 当容器自动滚动时并且滚动位置超出容器范围时要额外应用的摩擦系数 + */ + var EXTRA_FRICTION = 0.95; + /** + * @private + * 摩擦系数的自然对数 + */ + var FRICTION_LOG = Math.log(FRICTION); + /** + * @private + * + * @param ratio + * @returns + */ + function easeOut(ratio) { + var invRatio = ratio - 1.0; + return invRatio * invRatio * invRatio + 1; + } + /** + * @private + * 一个工具类,用于容器的滚屏拖动操作,计算在一段时间持续滚动后释放,应该继续滚动到的值和缓动时间。 + * 使用此工具类,您需要创建一个 ScrollThrown 实例,并在滚动发生时调用start()方法,然后在触摸移动过程中调用update()更新当前舞台坐标。 + * 内部将会启动一个计时器定时根据当前位置计算出速度值,并缓存下来最后4个值。当停止滚动时,再调用finish()方法, + * 将立即停止记录位移,并将计算出的最终结果存储到 Thrown.scrollTo 和 Thrown.duration 属性上。 + */ + var TouchScroll = (function () { + /** + * @private + * 创建一个 TouchScroll 实例 + * @param updateFunction 滚动位置更新回调函数 + */ + function TouchScroll(updateFunction, endFunction, target) { + /** + * @private + * 当前容器滚动外界可调节的系列 + */ + this.$scrollFactor = 1.0; + /** + * @private + */ + this.previousTime = 0; + /** + * @private + */ + this.velocity = 0; + /** + * @private + */ + this.previousVelocity = []; + /** + * @private + */ + this.currentPosition = 0; + /** + * @private + */ + this.previousPosition = 0; + /** + * @private + */ + this.currentScrollPos = 0; + /** + * @private + */ + this.maxScrollPos = 0; + /** + * @private + * 触摸按下时的偏移量 + */ + this.offsetPoint = 0; + this.$bounces = true; + this.started = true; + if (DEBUG && !updateFunction) { + egret.$error(1003, "updateFunction"); + } + this.updateFunction = updateFunction; + this.endFunction = endFunction; + this.target = target; + this.animation = new sys.Animation(this.onScrollingUpdate, this); + this.animation.endFunction = this.finishScrolling; + this.animation.easerFunction = easeOut; + } + var d = __define,c=TouchScroll,p=c.prototype; + /** + * @private + * 正在播放缓动动画的标志。 + */ + p.isPlaying = function () { + return this.animation.isPlaying; + }; + /** + * @private + * 如果正在执行缓动滚屏,停止缓动。 + */ + p.stop = function () { + this.animation.stop(); + egret.stopTick(this.onTick, this); + this.started = false; + }; + /** + * @private + * true表示已经调用过start方法。 + */ + p.isStarted = function () { + return this.started; + }; + /** + * @private + * 开始记录位移变化。注意:当使用完毕后,必须调用 finish() 方法结束记录,否则该对象将无法被回收。 + * @param touchPoint 起始触摸位置,以像素为单位,通常是stageX或stageY。 + */ + p.start = function (touchPoint) { + this.started = true; + this.velocity = 0; + this.previousVelocity.length = 0; + this.previousTime = egret.getTimer(); + this.previousPosition = this.currentPosition = touchPoint; + this.offsetPoint = touchPoint; + egret.startTick(this.onTick, this); + }; + /** + * @private + * 更新当前移动到的位置 + * @param touchPoint 当前触摸位置,以像素为单位,通常是stageX或stageY。 + */ + p.update = function (touchPoint, maxScrollValue, scrollValue) { + maxScrollValue = Math.max(maxScrollValue, 0); + this.currentPosition = touchPoint; + this.maxScrollPos = maxScrollValue; + var disMove = this.offsetPoint - touchPoint; + var scrollPos = disMove + scrollValue; + this.offsetPoint = touchPoint; + if (scrollPos < 0) { + if (!this.$bounces) { + scrollPos = 0; + } + else { + scrollPos -= disMove * 0.5; + } + } + if (scrollPos > maxScrollValue) { + if (!this.$bounces) { + scrollPos = maxScrollValue; + } + else { + scrollPos -= disMove * 0.5; + } + } + this.currentScrollPos = scrollPos; + this.updateFunction.call(this.target, scrollPos); + }; + /** + * @private + * 停止记录位移变化,并计算出目标值和继续缓动的时间。 + * @param currentScrollPos 容器当前的滚动值。 + * @param maxScrollPos 容器可以滚动的最大值。当目标值不在 0~maxValue之间时,将会应用更大的摩擦力,从而影响缓动时间的长度。 + */ + p.finish = function (currentScrollPos, maxScrollPos) { + egret.stopTick(this.onTick, this); + this.started = false; + var sum = this.velocity * CURRENT_VELOCITY_WEIGHT; + var previousVelocityX = this.previousVelocity; + var length = previousVelocityX.length; + var totalWeight = CURRENT_VELOCITY_WEIGHT; + for (var i = 0; i < length; i++) { + var weight = VELOCITY_WEIGHTS[i]; + sum += previousVelocityX[0] * weight; + totalWeight += weight; + } + var pixelsPerMS = sum / totalWeight; + var absPixelsPerMS = Math.abs(pixelsPerMS); + var duration = 0; + var posTo = 0; + if (absPixelsPerMS > MINIMUM_VELOCITY) { + posTo = currentScrollPos + (pixelsPerMS - MINIMUM_VELOCITY) / FRICTION_LOG * 2 * this.$scrollFactor; + if (posTo < 0 || posTo > maxScrollPos) { + posTo = currentScrollPos; + while (Math.abs(pixelsPerMS) > MINIMUM_VELOCITY) { + posTo -= pixelsPerMS; + if (posTo < 0 || posTo > maxScrollPos) { + pixelsPerMS *= FRICTION * EXTRA_FRICTION; + } + else { + pixelsPerMS *= FRICTION; + } + duration++; + } + } + else { + duration = Math.log(MINIMUM_VELOCITY / absPixelsPerMS) / FRICTION_LOG; + } + } + else { + posTo = currentScrollPos; + } + if (this.target["$getThrowInfo"]) { + var event = this.target["$getThrowInfo"](currentScrollPos, posTo); + posTo = event.toPos; + } + if (duration > 0) { + //如果取消了回弹,保证动画之后不会超出边界 + if (!this.$bounces) { + if (posTo < 0) { + posTo = 0; + } + else if (posTo > maxScrollPos) { + posTo = maxScrollPos; + } + } + this.throwTo(posTo, duration); + } + else { + this.finishScrolling(); + } + }; + /** + * @private + * + * @param timeStamp + * @returns + */ + p.onTick = function (timeStamp) { + var timeOffset = timeStamp - this.previousTime; + if (timeOffset > 10) { + var previousVelocity = this.previousVelocity; + if (previousVelocity.length >= MAX_VELOCITY_COUNT) { + previousVelocity.shift(); + } + this.velocity = (this.currentPosition - this.previousPosition) / timeOffset; + previousVelocity.push(this.velocity); + this.previousTime = timeStamp; + this.previousPosition = this.currentPosition; + } + return true; + }; + /** + * @private + * + * @param animation + */ + p.finishScrolling = function (animation) { + var hsp = this.currentScrollPos; + var maxHsp = this.maxScrollPos; + var hspTo = hsp; + if (hsp < 0) { + hspTo = 0; + } + if (hsp > maxHsp) { + hspTo = maxHsp; + } + this.throwTo(hspTo, 300); + }; + /** + * @private + * 缓动到水平滚动位置 + */ + p.throwTo = function (hspTo, duration) { + if (duration === void 0) { duration = 500; } + var hsp = this.currentScrollPos; + if (hsp == hspTo) { + this.endFunction.call(this.target); + return; + } + var animation = this.animation; + animation.duration = duration; + animation.from = hsp; + animation.to = hspTo; + animation.play(); + }; + /** + * @private + * 更新水平滚动位置 + */ + p.onScrollingUpdate = function (animation) { + this.currentScrollPos = animation.currentValue; + this.updateFunction.call(this.target, animation.currentValue); + }; + return TouchScroll; + }()); + sys.TouchScroll = TouchScroll; + egret.registerClass(TouchScroll,'eui.sys.TouchScroll'); + })(sys = eui.sys || (eui.sys = {})); +})(eui || (eui = {})); +////////////////////////////////////////////////////////////////////////////////////// +// +// Copyright (c) 2014-present, Egret Technology. +// All rights reserved. +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright +// notice, this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// * Neither the name of the Egret nor the +// names of its contributors may be used to endorse or promote products +// derived from this software without specific prior written permission. +// +// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS +// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, +// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +// +////////////////////////////////////////////////////////////////////////////////////// +var eui; +(function (eui) { + /** + * @language en_US + * The TabBar class displays a set of identical tabs. + * One tab can be selected at a time, and the first tab is selected by default. + *

        The set of tabs is defined by the dataProvider property. + * The appearance of each tab is defined by the ItemRenderer class.

        + *

        You can use the TabBar control to set the active child of a ViewStack container, + * as the following example shows:

        + *
        +     *       
        +     *       
        +     *          
        +     *          
        +     *          
        +     *       
        +     * 
        + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/TabBarExample.ts + */ + /** + * @language zh_CN + * TabBar 类显示一组相同的选项卡。一次可以选择一个选项卡,且默认情况下选择第一个选项卡。 + *

        该组选项卡由 dataProvider 属性定义。 + * 每个选项卡的外观由 ItemRenderer 定义。

        + *

        可以使用 TabBar 控件设置 ViewStack 容器的活动子代,如下例所示:

        + *
        +     *       
        +     *       
        +     *          
        +     *          
        +     *          
        +     *       
        +     * 
        + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/TabBarExample.ts + */ + var TabBar = (function (_super) { + __extends(TabBar, _super); + /** + * @language en_US + * Constructor. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + /** + * @language zh_CN + * 构造函数。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + function TabBar() { + _super.call(this); + /** + * @private + */ + this.indexBeingUpdated = false; + this.requireSelection = true; + this.useVirtualLayout = false; + } + var d = __define,c=TabBar,p=c.prototype; + /** + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + p.createChildren = function () { + if (!this.$layout) { + var layout = new eui.HorizontalLayout(); + layout.gap = 0; + layout.horizontalAlign = eui.JustifyAlign.JUSTIFY; + layout.verticalAlign = eui.JustifyAlign.CONTENT_JUSTIFY; + this.$setLayout(layout); + } + _super.prototype.createChildren.call(this); + }; + /** + * @private + * + * @param value + */ + p.$setDataProvider = function (value) { + var dp = this.$dataProvider; + if (dp && dp instanceof eui.ViewStack) { + dp.removeEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onViewStackIndexChange, this); + this.removeEventListener(egret.Event.CHANGE, this.onIndexChanged, this); + } + if (value && value instanceof eui.ViewStack) { + value.addEventListener(eui.PropertyEvent.PROPERTY_CHANGE, this.onViewStackIndexChange, this); + this.addEventListener(egret.Event.CHANGE, this.onIndexChanged, this); + } + return _super.prototype.$setDataProvider.call(this, value); + }; + /** + * @private + * 触摸点击的选中项改变 + */ + p.onIndexChanged = function (event) { + this.indexBeingUpdated = true; + (this.$dataProvider).selectedIndex = this.selectedIndex; + this.indexBeingUpdated = false; + }; + /** + * @private + * ViewStack选中项发生改变 + */ + p.onViewStackIndexChange = function (event) { + if (event.property == "selectedIndex" && !this.indexBeingUpdated) { + this.setSelectedIndex((this.$dataProvider).selectedIndex, false); + } + }; + return TabBar; + }(eui.ListBase)); + eui.TabBar = TabBar; + egret.registerClass(TabBar,'eui.TabBar'); +})(eui || (eui = {})); +var eui; +(function (eui) { + var FocusEvent = egret.FocusEvent; + /** + * + */ + /** + * @language en_US + * The TextInput is a textfield input component, the user can input and edit the text. + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/TextInputExample.ts + */ + /** + * @language zh_CN + * TextInput 是一个文本输入控件,供用户输入和编辑统一格式文本 + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/TextInputExample.ts + */ + var TextInput = (function (_super) { + __extends(TextInput, _super); + function TextInput() { + _super.call(this); + /** + * @private + */ + this.isFocus = false; + this.$TextInput = { + 0: null, + 1: null, + 2: null, + 3: null, + 4: null, + 5: null, + 6: "", + 7: null, + 8: egret.TextFieldInputType.TEXT //inputType + }; + } + var d = __define,c=TextInput,p=c.prototype; + d(p, "prompt" + /** + * @copy eui.EditableText#prompt + * + * @version Egret 2.5.7 + * @version eui 1.0 + * @platform Web,Native */ ,function () { if (this.promptDisplay) { @@ -14515,228 +15140,8 @@ var eui; var d = __define,c=ToggleSwitch,p=c.prototype; return ToggleSwitch; }(eui.ToggleButton)); - eui.ToggleSwitch = ToggleSwitch; - egret.registerClass(ToggleSwitch,'eui.ToggleSwitch'); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * @language en_US - * The UILayer class is the subclass of the Group class.It not only has the standard function of the Group class,but also - * can keep its size the same to the stage size (Stage.stageWidth,Stage.stageHeight).Its size will changes as the stage size changes. - * like any normal container class,you can create multiple instance of the UILayer class,but it is usually used as the root of the UI display list. - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @language zh_CN - * UILayer 是 Group 的子类,它除了具有容器的所有标准功能,还能够自动保持自身尺寸始终与舞台尺寸相同(Stage.stageWidth,Stage.stageHeight)。 - * 当舞台尺寸发生改变时,它会跟随舞台尺寸改变。UILayer 跟普通容器一样,允许创建多个实例,但通常都将它作为UI显示列表的根节点使用。 - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - var UILayer = (function (_super) { - __extends(UILayer, _super); - /** - * @language en_US - * Constructor. - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - /** - * @language zh_CN - * 构造函数。 - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - function UILayer() { - _super.call(this); - this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); - this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.onRemoveFromStage, this); - } - var d = __define,c=UILayer,p=c.prototype; - /** - * @private - * 添加到舞台 - */ - p.onAddToStage = function (event) { - this.$stage.addEventListener(egret.Event.RESIZE, this.onResize, this); - this.onResize(); - }; - /** - * @private - * 从舞台移除 - */ - p.onRemoveFromStage = function (event) { - this.$stage.removeEventListener(egret.Event.RESIZE, this.onResize, this); - }; - /** - * @private - * 舞台尺寸改变 - */ - p.onResize = function (event) { - var stage = this.$stage; - this.$setWidth(stage.$stageWidth); - this.$setHeight(stage.$stageHeight); - }; - return UILayer; - }(eui.Group)); - eui.UILayer = UILayer; - egret.registerClass(UILayer,'eui.UILayer'); -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - /** - * @language en_US - * The VScrollBar (vertical scrollbar) control lets you control - * the portion of data that is displayed when there is too much data - * to fit vertically in a display area. - * - *

        Although you can use the VScrollBar control as a stand-alone control, - * you usually combine it as part of another group of components to - * provide scrolling functionality.

        - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts - */ - /** - * @language zh_CN - * VScrollBar(垂直 ScrollBar)控件可以在因数据太多而不能在显示区域中以垂直方向完全显示时控制显示的数据部分。 - *

        虽然 VScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

        - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - * @includeExample extension/eui/components/VScrollBarExample.ts - */ - var VScrollBar = (function (_super) { - __extends(VScrollBar, _super); - function VScrollBar() { - _super.apply(this, arguments); - } - var d = __define,c=VScrollBar,p=c.prototype; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - p.updateDisplayList = function (unscaledWidth, unscaledHeight) { - _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); - var thumb = this.thumb; - var viewport = this.$viewport; - if (!thumb || !viewport) { - return; - } - var bounds = egret.$TempRectangle; - thumb.getPreferredBounds(bounds); - var thumbHeight = bounds.height; - var thumbX = bounds.x; - var vsp = viewport.scrollV; - var contentHeight = viewport.contentHeight; - var height = viewport.height; - if (vsp <= 0) { - var scaleHeight = thumbHeight * (1 - (-vsp) / (height * 0.5)); - scaleHeight = Math.max(5, Math.round(scaleHeight)); - thumb.setLayoutBoundsSize(NaN, scaleHeight); - thumb.setLayoutBoundsPosition(thumbX, 0); - } - else if (vsp >= contentHeight - height) { - scaleHeight = thumbHeight * (1 - (vsp - contentHeight + height) / (height * 0.5)); - scaleHeight = Math.max(5, Math.round(scaleHeight)); - thumb.setLayoutBoundsSize(NaN, scaleHeight); - thumb.setLayoutBoundsPosition(thumbX, unscaledHeight - scaleHeight); - } - else { - var thumbY = (unscaledHeight - thumbHeight) * vsp / (contentHeight - height); - thumb.setLayoutBoundsSize(NaN, NaN); - thumb.setLayoutBoundsPosition(thumbX, thumbY); - } - }; - /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native - */ - p.onPropertyChanged = function (event) { - switch (event.property) { - case "scrollV": - case "contentHeight": - this.invalidateDisplayList(); - break; - } - }; - return VScrollBar; - }(eui.ScrollBarBase)); - eui.VScrollBar = VScrollBar; - egret.registerClass(VScrollBar,'eui.VScrollBar'); + eui.ToggleSwitch = ToggleSwitch; + egret.registerClass(ToggleSwitch,'eui.ToggleSwitch'); })(eui || (eui = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -14770,28 +15175,23 @@ var eui; (function (eui) { /** * @language en_US - * The VSlider (vertical slider) control lets users select a value - * by moving a slider thumb between the end points of the slider track. - * The current value of the slider is determined by the relative location of the thumb between - * the end points of the slider, corresponding to the slider's minimum and maximum values. - * + * The UILayer class is the subclass of the Group class.It not only has the standard function of the Group class,but also + * can keep its size the same to the stage size (Stage.stageWidth,Stage.stageHeight).Its size will changes as the stage size changes. + * like any normal container class,you can create multiple instance of the UILayer class,but it is usually used as the root of the UI display list. * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts */ /** * @language zh_CN - * 使用 VSlider(垂直滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 - * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 - * + * UILayer 是 Group 的子类,它除了具有容器的所有标准功能,还能够自动保持自身尺寸始终与舞台尺寸相同(Stage.stageWidth,Stage.stageHeight)。 + * 当舞台尺寸发生改变时,它会跟随舞台尺寸改变。UILayer 跟普通容器一样,允许创建多个实例,但通常都将它作为UI显示列表的根节点使用。 * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native - * @includeExample extension/eui/components/VSliderExample.ts */ - var VSlider = (function (_super) { - __extends(VSlider, _super); + var UILayer = (function (_super) { + __extends(UILayer, _super); /** * @language en_US * Constructor. @@ -14808,69 +15208,40 @@ var eui; * @version eui 1.0 * @platform Web,Native */ - function VSlider() { + function UILayer() { _super.call(this); + this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this); + this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.onRemoveFromStage, this); } - var d = __define,c=VSlider,p=c.prototype; + var d = __define,c=UILayer,p=c.prototype; /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @private + * 添加到舞台 */ - p.pointToValue = function (x, y) { - if (!this.thumb || !this.track) - return 0; - var values = this.$Range; - var range = values[0 /* maximum */] - values[2 /* minimum */]; - var thumbRange = this.getThumbRange(); - return values[2 /* minimum */] + ((thumbRange != 0) ? ((thumbRange - y) / thumbRange) * range : 0); + p.onAddToStage = function (event) { + this.$stage.addEventListener(egret.Event.RESIZE, this.onResize, this); + this.onResize(); }; /** * @private - * - * @returns + * 从舞台移除 */ - p.getThumbRange = function () { - var bounds = egret.$TempRectangle; - this.track.getLayoutBounds(bounds); - var thumbRange = bounds.height; - this.thumb.getLayoutBounds(bounds); - return thumbRange - bounds.height; + p.onRemoveFromStage = function (event) { + this.$stage.removeEventListener(egret.Event.RESIZE, this.onResize, this); }; /** - * @inheritDoc - * - * @version Egret 2.4 - * @version eui 1.0 - * @platform Web,Native + * @private + * 舞台尺寸改变 */ - p.updateSkinDisplayList = function () { - if (!this.thumb || !this.track) - return; - var values = this.$Range; - var thumbRange = this.getThumbRange(); - var range = values[0 /* maximum */] - values[2 /* minimum */]; - var thumbPosTrackY = (range > 0) ? thumbRange - (((this.pendingValue - values[2 /* minimum */]) / range) * thumbRange) : 0; - var thumbPos = this.track.localToGlobal(0, thumbPosTrackY, egret.$TempPoint); - var thumbPosX = thumbPos.x; - var thumbPosY = thumbPos.y; - var thumbPosParentY = this.thumb.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).y; - var bounds = egret.$TempRectangle; - var thumbHeight = bounds.height; - this.thumb.getLayoutBounds(bounds); - this.thumb.setLayoutBoundsPosition(bounds.x, Math.round(thumbPosParentY)); - if (this.trackHighlight) { - var trackHighlightY = this.trackHighlight.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).y; - this.trackHighlight.y = Math.round(trackHighlightY + thumbHeight); - this.trackHighlight.height = Math.round(thumbRange - trackHighlightY); - } + p.onResize = function (event) { + var stage = this.$stage; + this.$setWidth(stage.$stageWidth); + this.$setHeight(stage.$stageHeight); }; - return VSlider; - }(eui.SliderBase)); - eui.VSlider = VSlider; - egret.registerClass(VSlider,'eui.VSlider'); + return UILayer; + }(eui.Group)); + eui.UILayer = UILayer; + egret.registerClass(UILayer,'eui.UILayer'); })(eui || (eui = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -15206,168 +15577,14 @@ var eui; return -1; }; return ViewStack; - }(eui.Group)); - eui.ViewStack = ViewStack; - egret.registerClass(ViewStack,'eui.ViewStack',["eui.ICollection","egret.IEventDispatcher"]); - eui.registerBindable(ViewStack.prototype, "selectedIndex"); - if (DEBUG) { - egret.$markReadOnly(ViewStack, "length"); - egret.$markReadOnly(ViewStack, "layout"); - } -})(eui || (eui = {})); -////////////////////////////////////////////////////////////////////////////////////// -// -// Copyright (c) 2014-present, Egret Technology. -// All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// * Neither the name of the Egret nor the -// names of its contributors may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY EGRET AND CONTRIBUTORS "AS IS" AND ANY EXPRESS -// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES -// OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -// IN NO EVENT SHALL EGRET AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, -// OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, -// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -////////////////////////////////////////////////////////////////////////////////////// -var eui; -(function (eui) { - var sys; - (function (sys) { - /** - * @private - * - * @param fraction - * @returns - */ - function sineInOut(fraction) { - return -0.5 * (Math.cos(Math.PI * fraction) - 1); - } - /** - * @private - * 数值缓动工具类 - */ - var Animation = (function () { - /** - * @private - */ - function Animation(updateFunction, thisObject) { - /** - * @private - * 此动画的缓动行为。设置为null意味着不使用缓动,默认值为 sineInOut - */ - this.easerFunction = sineInOut; - /** - * @private - * 是否正在播放动画,不包括延迟等待和暂停的阶段 - */ - this.isPlaying = false; - /** - * @private - * 动画持续时间,单位毫秒,默认值500 - */ - this.duration = 500; - /** - * @private - * 动画到当前时间对应的值。 - */ - this.currentValue = 0; - /** - * @private - * 起始值 - */ - this.from = 0; - /** - * @private - * 终点值。 - */ - this.to = 0; - /** - * @private - * 动画启动时刻 - */ - this.startTime = 0; - /** - * @private - * 动画播放结束时的回调函数 - */ - this.endFunction = null; - this.updateFunction = updateFunction; - this.thisObject = thisObject; - } - var d = __define,c=Animation,p=c.prototype; - /** - * @private - * 开始正向播放动画,无论何时调用都重新从零时刻开始,若设置了延迟会首先进行等待。 - */ - p.play = function () { - this.stop(); - this.start(); - }; - /** - * @private - * 开始播放动画 - */ - p.start = function () { - this.isPlaying = false; - this.currentValue = 0; - this.startTime = egret.getTimer(); - this.doInterval(this.startTime); - egret.startTick(this.doInterval, this); - }; - /** - * @private - * 停止播放动画 - */ - p.stop = function () { - this.isPlaying = false; - this.startTime = 0; - egret.stopTick(this.doInterval, this); - }; - /** - * @private - * 计算当前值并返回动画是否结束 - */ - p.doInterval = function (currentTime) { - var runningTime = currentTime - this.startTime; - if (!this.isPlaying) { - this.isPlaying = true; - } - var duration = this.duration; - var fraction = duration == 0 ? 1 : Math.min(runningTime, duration) / duration; - if (this.easerFunction) { - fraction = this.easerFunction(fraction); - } - this.currentValue = this.from + (this.to - this.from) * fraction; - if (this.updateFunction) - this.updateFunction.call(this.thisObject, this); - var isEnded = runningTime >= duration; - if (isEnded) { - this.stop(); - } - if (isEnded && this.endFunction) { - this.endFunction.call(this.thisObject, this); - } - return true; - }; - return Animation; - }()); - sys.Animation = Animation; - egret.registerClass(Animation,'eui.sys.Animation'); - })(sys = eui.sys || (eui.sys = {})); + }(eui.Group)); + eui.ViewStack = ViewStack; + egret.registerClass(ViewStack,'eui.ViewStack',["eui.ICollection","egret.IEventDispatcher"]); + eui.registerBindable(ViewStack.prototype, "selectedIndex"); + if (DEBUG) { + egret.$markReadOnly(ViewStack, "length"); + egret.$markReadOnly(ViewStack, "layout"); + } })(eui || (eui = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -15401,48 +15618,93 @@ var eui; (function (eui) { /** * @language en_US - * Default instance of interface IThemeAdapter. + * The VScrollBar (vertical scrollbar) control lets you control + * the portion of data that is displayed when there is too much data + * to fit vertically in a display area. + * + *

        Although you can use the VScrollBar control as a stand-alone control, + * you usually combine it as part of another group of components to + * provide scrolling functionality.

        + * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native + * @includeExample extension/eui/components/VScrollBarExample.ts */ /** * @language zh_CN - * 默认的IThemeAdapter接口实现。 + * VScrollBar(垂直 ScrollBar)控件可以在因数据太多而不能在显示区域中以垂直方向完全显示时控制显示的数据部分。 + *

        虽然 VScrollBar 控件可以单独使用,但通常将它与其他组件一起使用来提供滚动功能。

        + * * @version Egret 2.4 * @version eui 1.0 * @platform Web,Native + * @includeExample extension/eui/components/VScrollBarExample.ts */ - var DefaultThemeAdapter = (function () { - function DefaultThemeAdapter() { + var VScrollBar = (function (_super) { + __extends(VScrollBar, _super); + function VScrollBar() { + _super.apply(this, arguments); } - var d = __define,c=DefaultThemeAdapter,p=c.prototype; + var d = __define,c=VScrollBar,p=c.prototype; /** - * 解析主题 - * @param url 待解析的主题url - * @param compFunc 解析完成回调函数,示例:compFunc(e:egret.Event):void; - * @param errorFunc 解析失败回调函数,示例:errorFunc():void; - * @param thisObject 回调的this引用 + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - p.getTheme = function (url, compFunc, errorFunc, thisObject) { - function onGet(event) { - var loader = (event.target); - compFunc.call(thisObject, loader.response); + p.updateDisplayList = function (unscaledWidth, unscaledHeight) { + _super.prototype.updateDisplayList.call(this, unscaledWidth, unscaledHeight); + var thumb = this.thumb; + var viewport = this.$viewport; + if (!thumb || !viewport) { + return; } - function onError(event) { - errorFunc.call(thisObject); + var bounds = egret.$TempRectangle; + thumb.getPreferredBounds(bounds); + var thumbHeight = bounds.height; + var thumbX = bounds.x; + var vsp = viewport.scrollV; + var contentHeight = viewport.contentHeight; + var height = viewport.height; + if (vsp <= 0) { + var scaleHeight = thumbHeight * (1 - (-vsp) / (height * 0.5)); + scaleHeight = Math.max(5, Math.round(scaleHeight)); + thumb.setLayoutBoundsSize(NaN, scaleHeight); + thumb.setLayoutBoundsPosition(thumbX, 0); + } + else if (vsp >= contentHeight - height) { + scaleHeight = thumbHeight * (1 - (vsp - contentHeight + height) / (height * 0.5)); + scaleHeight = Math.max(5, Math.round(scaleHeight)); + thumb.setLayoutBoundsSize(NaN, scaleHeight); + thumb.setLayoutBoundsPosition(thumbX, unscaledHeight - scaleHeight); + } + else { + var thumbY = (unscaledHeight - thumbHeight) * vsp / (contentHeight - height); + thumb.setLayoutBoundsSize(NaN, NaN); + thumb.setLayoutBoundsPosition(thumbX, thumbY); } - var loader = new egret.HttpRequest(); - loader.addEventListener(egret.Event.COMPLETE, onGet, thisObject); - loader.addEventListener(egret.IOErrorEvent.IO_ERROR, onError, thisObject); - loader.responseType = egret.HttpResponseType.TEXT; - loader.open(url); - loader.send(); }; - return DefaultThemeAdapter; - }()); - eui.DefaultThemeAdapter = DefaultThemeAdapter; - egret.registerClass(DefaultThemeAdapter,'eui.DefaultThemeAdapter',["eui.IThemeAdapter"]); + /** + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + p.onPropertyChanged = function (event) { + switch (event.property) { + case "scrollV": + case "contentHeight": + this.invalidateDisplayList(); + break; + } + }; + return VScrollBar; + }(eui.ScrollBarBase)); + eui.VScrollBar = VScrollBar; + egret.registerClass(VScrollBar,'eui.VScrollBar'); })(eui || (eui = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -15474,317 +15736,109 @@ var eui; ////////////////////////////////////////////////////////////////////////////////////// var eui; (function (eui) { - var sys; - (function (sys) { - /** - * @private - * 需要记录的历史速度的最大次数。 - */ - var MAX_VELOCITY_COUNT = 4; - /** - * @private - * 记录的历史速度的权重列表。 - */ - var VELOCITY_WEIGHTS = [1, 1.33, 1.66, 2]; - /** - * @private - * 当前速度所占的权重。 - */ - var CURRENT_VELOCITY_WEIGHT = 2.33; - /** - * @private - * 最小的改变速度,解决浮点数精度问题。 - */ - var MINIMUM_VELOCITY = 0.02; - /** - * @private - * 当容器自动滚动时要应用的摩擦系数 - */ - var FRICTION = 0.998; - /** - * @private - * 当容器自动滚动时并且滚动位置超出容器范围时要额外应用的摩擦系数 - */ - var EXTRA_FRICTION = 0.95; + /** + * @language en_US + * The VSlider (vertical slider) control lets users select a value + * by moving a slider thumb between the end points of the slider track. + * The current value of the slider is determined by the relative location of the thumb between + * the end points of the slider, corresponding to the slider's minimum and maximum values. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/VSliderExample.ts + */ + /** + * @language zh_CN + * 使用 VSlider(垂直滑块)控件,用户可通过在滑块轨道的端点之间移动滑块来选择值。 + * 滑块的当前值由滑块端点(对应于滑块的最小值和最大值)之间滑块的相对位置确定。 + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + * @includeExample extension/eui/components/VSliderExample.ts + */ + var VSlider = (function (_super) { + __extends(VSlider, _super); /** - * @private - * 摩擦系数的自然对数 + * @language en_US + * Constructor. + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - var FRICTION_LOG = Math.log(FRICTION); /** - * @private + * @language zh_CN + * 构造函数。 * - * @param ratio - * @returns + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - function easeOut(ratio) { - var invRatio = ratio - 1.0; - return invRatio * invRatio * invRatio + 1; + function VSlider() { + _super.call(this); } + var d = __define,c=VSlider,p=c.prototype; /** - * @private - * 一个工具类,用于容器的滚屏拖动操作,计算在一段时间持续滚动后释放,应该继续滚动到的值和缓动时间。 - * 使用此工具类,您需要创建一个 ScrollThrown 实例,并在滚动发生时调用start()方法,然后在触摸移动过程中调用update()更新当前舞台坐标。 - * 内部将会启动一个计时器定时根据当前位置计算出速度值,并缓存下来最后4个值。当停止滚动时,再调用finish()方法, - * 将立即停止记录位移,并将计算出的最终结果存储到 Thrown.scrollTo 和 Thrown.duration 属性上。 + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native */ - var TouchScroll = (function () { - /** - * @private - * 创建一个 TouchScroll 实例 - * @param updateFunction 滚动位置更新回调函数 - */ - function TouchScroll(updateFunction, endFunction, target) { - /** - * @private - * 当前容器滚动外界可调节的系列 - */ - this.$scrollFactor = 1.0; - /** - * @private - */ - this.previousTime = 0; - /** - * @private - */ - this.velocity = 0; - /** - * @private - */ - this.previousVelocity = []; - /** - * @private - */ - this.currentPosition = 0; - /** - * @private - */ - this.previousPosition = 0; - /** - * @private - */ - this.currentScrollPos = 0; - /** - * @private - */ - this.maxScrollPos = 0; - /** - * @private - * 触摸按下时的偏移量 - */ - this.offsetPoint = 0; - this.$bounces = true; - this.started = true; - if (DEBUG && !updateFunction) { - egret.$error(1003, "updateFunction"); - } - this.updateFunction = updateFunction; - this.endFunction = endFunction; - this.target = target; - this.animation = new sys.Animation(this.onScrollingUpdate, this); - this.animation.endFunction = this.finishScrolling; - this.animation.easerFunction = easeOut; + p.pointToValue = function (x, y) { + if (!this.thumb || !this.track) + return 0; + var values = this.$Range; + var range = values[0 /* maximum */] - values[2 /* minimum */]; + var thumbRange = this.getThumbRange(); + return values[2 /* minimum */] + ((thumbRange != 0) ? ((thumbRange - y) / thumbRange) * range : 0); + }; + /** + * @private + * + * @returns + */ + p.getThumbRange = function () { + var bounds = egret.$TempRectangle; + this.track.getLayoutBounds(bounds); + var thumbRange = bounds.height; + this.thumb.getLayoutBounds(bounds); + return thumbRange - bounds.height; + }; + /** + * @inheritDoc + * + * @version Egret 2.4 + * @version eui 1.0 + * @platform Web,Native + */ + p.updateSkinDisplayList = function () { + if (!this.thumb || !this.track) + return; + var values = this.$Range; + var thumbRange = this.getThumbRange(); + var range = values[0 /* maximum */] - values[2 /* minimum */]; + var thumbPosTrackY = (range > 0) ? thumbRange - (((this.pendingValue - values[2 /* minimum */]) / range) * thumbRange) : 0; + var thumbPos = this.track.localToGlobal(0, thumbPosTrackY, egret.$TempPoint); + var thumbPosX = thumbPos.x; + var thumbPosY = thumbPos.y; + var thumbPosParentY = this.thumb.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).y; + var bounds = egret.$TempRectangle; + var thumbHeight = bounds.height; + this.thumb.getLayoutBounds(bounds); + this.thumb.setLayoutBoundsPosition(bounds.x, Math.round(thumbPosParentY)); + if (this.trackHighlight) { + var trackHighlightY = this.trackHighlight.$parent.globalToLocal(thumbPosX, thumbPosY, egret.$TempPoint).y; + this.trackHighlight.y = Math.round(trackHighlightY + thumbHeight); + this.trackHighlight.height = Math.round(thumbRange - trackHighlightY); } - var d = __define,c=TouchScroll,p=c.prototype; - /** - * @private - * 正在播放缓动动画的标志。 - */ - p.isPlaying = function () { - return this.animation.isPlaying; - }; - /** - * @private - * 如果正在执行缓动滚屏,停止缓动。 - */ - p.stop = function () { - this.animation.stop(); - egret.stopTick(this.onTick, this); - this.started = false; - }; - /** - * @private - * true表示已经调用过start方法。 - */ - p.isStarted = function () { - return this.started; - }; - /** - * @private - * 开始记录位移变化。注意:当使用完毕后,必须调用 finish() 方法结束记录,否则该对象将无法被回收。 - * @param touchPoint 起始触摸位置,以像素为单位,通常是stageX或stageY。 - */ - p.start = function (touchPoint) { - this.started = true; - this.velocity = 0; - this.previousVelocity.length = 0; - this.previousTime = egret.getTimer(); - this.previousPosition = this.currentPosition = touchPoint; - this.offsetPoint = touchPoint; - egret.startTick(this.onTick, this); - }; - /** - * @private - * 更新当前移动到的位置 - * @param touchPoint 当前触摸位置,以像素为单位,通常是stageX或stageY。 - */ - p.update = function (touchPoint, maxScrollValue, scrollValue) { - maxScrollValue = Math.max(maxScrollValue, 0); - this.currentPosition = touchPoint; - this.maxScrollPos = maxScrollValue; - var disMove = this.offsetPoint - touchPoint; - var scrollPos = disMove + scrollValue; - this.offsetPoint = touchPoint; - if (scrollPos < 0) { - if (!this.$bounces) { - scrollPos = 0; - } - else { - scrollPos -= disMove * 0.5; - } - } - if (scrollPos > maxScrollValue) { - if (!this.$bounces) { - scrollPos = maxScrollValue; - } - else { - scrollPos -= disMove * 0.5; - } - } - this.currentScrollPos = scrollPos; - this.updateFunction.call(this.target, scrollPos); - }; - /** - * @private - * 停止记录位移变化,并计算出目标值和继续缓动的时间。 - * @param currentScrollPos 容器当前的滚动值。 - * @param maxScrollPos 容器可以滚动的最大值。当目标值不在 0~maxValue之间时,将会应用更大的摩擦力,从而影响缓动时间的长度。 - */ - p.finish = function (currentScrollPos, maxScrollPos) { - egret.stopTick(this.onTick, this); - this.started = false; - var sum = this.velocity * CURRENT_VELOCITY_WEIGHT; - var previousVelocityX = this.previousVelocity; - var length = previousVelocityX.length; - var totalWeight = CURRENT_VELOCITY_WEIGHT; - for (var i = 0; i < length; i++) { - var weight = VELOCITY_WEIGHTS[i]; - sum += previousVelocityX[0] * weight; - totalWeight += weight; - } - var pixelsPerMS = sum / totalWeight; - var absPixelsPerMS = Math.abs(pixelsPerMS); - var duration = 0; - var posTo = 0; - if (absPixelsPerMS > MINIMUM_VELOCITY) { - posTo = currentScrollPos + (pixelsPerMS - MINIMUM_VELOCITY) / FRICTION_LOG * 2 * this.$scrollFactor; - if (posTo < 0 || posTo > maxScrollPos) { - posTo = currentScrollPos; - while (Math.abs(pixelsPerMS) > MINIMUM_VELOCITY) { - posTo -= pixelsPerMS; - if (posTo < 0 || posTo > maxScrollPos) { - pixelsPerMS *= FRICTION * EXTRA_FRICTION; - } - else { - pixelsPerMS *= FRICTION; - } - duration++; - } - } - else { - duration = Math.log(MINIMUM_VELOCITY / absPixelsPerMS) / FRICTION_LOG; - } - } - else { - posTo = currentScrollPos; - } - if (this.target["$getThrowInfo"]) { - var event = this.target["$getThrowInfo"](currentScrollPos, posTo); - posTo = event.toPos; - } - if (duration > 0) { - //如果取消了回弹,保证动画之后不会超出边界 - if (!this.$bounces) { - if (posTo < 0) { - posTo = 0; - } - else if (posTo > maxScrollPos) { - posTo = maxScrollPos; - } - } - this.throwTo(posTo, duration); - } - else { - this.finishScrolling(); - } - }; - /** - * @private - * - * @param timeStamp - * @returns - */ - p.onTick = function (timeStamp) { - var timeOffset = timeStamp - this.previousTime; - if (timeOffset > 10) { - var previousVelocity = this.previousVelocity; - if (previousVelocity.length >= MAX_VELOCITY_COUNT) { - previousVelocity.shift(); - } - this.velocity = (this.currentPosition - this.previousPosition) / timeOffset; - previousVelocity.push(this.velocity); - this.previousTime = timeStamp; - this.previousPosition = this.currentPosition; - } - return true; - }; - /** - * @private - * - * @param animation - */ - p.finishScrolling = function (animation) { - var hsp = this.currentScrollPos; - var maxHsp = this.maxScrollPos; - var hspTo = hsp; - if (hsp < 0) { - hspTo = 0; - } - if (maxHsp && hsp > maxHsp) { - hspTo = maxHsp; - } - this.throwTo(hspTo, 300); - }; - /** - * @private - * 缓动到水平滚动位置 - */ - p.throwTo = function (hspTo, duration) { - if (duration === void 0) { duration = 500; } - var hsp = this.currentScrollPos; - if (hsp == hspTo) { - this.endFunction.call(this.target); - return; - } - var animation = this.animation; - animation.duration = duration; - animation.from = hsp; - animation.to = hspTo; - animation.play(); - }; - /** - * @private - * 更新水平滚动位置 - */ - p.onScrollingUpdate = function (animation) { - this.currentScrollPos = animation.currentValue; - this.updateFunction.call(this.target, animation.currentValue); - }; - return TouchScroll; - }()); - sys.TouchScroll = TouchScroll; - egret.registerClass(TouchScroll,'eui.sys.TouchScroll'); - })(sys = eui.sys || (eui.sys = {})); + }; + return VSlider; + }(eui.SliderBase)); + eui.VSlider = VSlider; + egret.registerClass(VSlider,'eui.VSlider'); })(eui || (eui = {})); ////////////////////////////////////////////////////////////////////////////////////// // @@ -17916,6 +17970,12 @@ var eui; */ function EXSetStateProperty(target, property, templates, chainIndex) { _super.call(this); + if (target) { + target = "this." + target; + } + else { + target = "this"; + } this.target = target; this.property = property; this.templates = templates; @@ -18256,6 +18316,9 @@ var eui; else if (node.nodeType === 1) { var id = node.attributes["id"]; if (id) { + if (id.indexOf(" ") > -1) { + egret.$warn(2022, id); + } if (this.skinParts.indexOf(id) == -1) { this.skinParts.push(id); } @@ -19963,6 +20026,7 @@ var eui; locale_strings[2019] = "EXML parsing error {0}: the container’s child item must be visible nodes: {1}"; locale_strings[2020] = "EXML parsing error {0}: for child nodes in w: Declarations, the includeIn and excludeFrom properties are not allowed to use \n {1}"; locale_strings[2021] = "Compile errors in {0}, the attribute name: {1}, the attribute value: {2}."; + locale_strings[2022] = "EXML parsing error: there can be no Spaces in the id `{0}`"; locale_strings[2101] = "EXML parsing warnning : fail to register the class property : {0},there is already a class with the same name in the global,please try to rename the class name for the exml. \n {1}"; locale_strings[2102] = "EXML parsing warnning {0}: no child node can be found on the property code \n {1}"; locale_strings[2103] = "EXML parsing warnning {0}: the same property '{1}' on the node is assigned multiple times \n {2}"; @@ -20028,6 +20092,7 @@ var eui; locale_strings[2019] = "EXML解析错误 {0}: 容器的子项必须是可视节点:{1}"; locale_strings[2020] = "EXML解析错误 {0}: 在w:Declarations内的子节点,不允许使用includeIn和excludeFrom属性\n{1}"; locale_strings[2021] = "{0} 中存在编译错误,属性名 : {1},属性值 : {2}"; + locale_strings[2022] = "EXML解析错误: id `{0}` 中不可以有空格"; //EXML警告信息 locale_strings[2101] = "EXML解析警告: 在EXML根节点上声明的 class 属性: {0} 注册失败,所对应的类已经存在,请尝试重命名要注册的类名。\n{1}"; locale_strings[2102] = "EXML解析警告 {0}: 在属性节点上找不到任何子节点\n{1}"; @@ -20528,6 +20593,23 @@ var eui; var sys; (function (sys) { var UIComponentClass = "eui.UIComponent"; + /** + * @private + * @param value 要格式化的相对值 + * @param total 在此值方向上的总长度 + */ + function formatRelative(value, total) { + if (!value || typeof value == "number") { + return value; + } + var str = value; + var index = str.indexOf("%"); + if (index == -1) { + return +str; + } + var percent = +str.substring(0, index); + return percent * 0.01 * total; + } /** * @private * 一个工具方法,使用BasicLayout规则测量目标对象。 @@ -20546,12 +20628,12 @@ var eui; continue; } var values = layoutElement.$UIComponent; - var hCenter = values[4 /* horizontalCenter */]; - var vCenter = values[5 /* verticalCenter */]; - var left = values[0 /* left */]; - var right = values[1 /* right */]; - var top = values[2 /* top */]; - var bottom = values[3 /* bottom */]; + var hCenter = +values[4 /* horizontalCenter */]; + var vCenter = +values[5 /* verticalCenter */]; + var left = +values[0 /* left */]; + var right = +values[1 /* right */]; + var top = +values[2 /* top */]; + var bottom = +values[3 /* bottom */]; var extX; var extY; layoutElement.getPreferredBounds(bounds); @@ -20606,12 +20688,12 @@ var eui; continue; } var values = layoutElement.$UIComponent; - var hCenter = values[4 /* horizontalCenter */]; - var vCenter = values[5 /* verticalCenter */]; - var left = values[0 /* left */]; - var right = values[1 /* right */]; - var top = values[2 /* top */]; - var bottom = values[3 /* bottom */]; + var hCenter = formatRelative(values[4 /* horizontalCenter */], unscaledWidth * 0.5); + var vCenter = formatRelative(values[5 /* verticalCenter */], unscaledHeight * 0.5); + var left = formatRelative(values[0 /* left */], unscaledWidth); + var right = formatRelative(values[1 /* right */], unscaledWidth); + var top = formatRelative(values[2 /* top */], unscaledHeight); + var bottom = formatRelative(values[3 /* bottom */], unscaledHeight); var percentWidth = values[6 /* percentWidth */]; var percentHeight = values[7 /* percentHeight */]; var childWidth = NaN; diff --git a/build/eui/eui.min.js b/build/eui/eui.min.js index 81a1cc6a99..b12108dd3f 100644 --- a/build/eui/eui.min.js +++ b/build/eui/eui.min.js @@ -1,6 +1,6 @@ -var eui;!function(t){function e(e){for(var i=e[0],n=i instanceof t.Watcher?i.getValue():i,s=e.length,r=1;s>r;r++){var a=e[r];a instanceof t.Watcher&&(a=a.getValue()),n+=a}return n}var i=function(){function i(){}var n=(__define,i);n.prototype;return i.bindProperty=function(e,i,n,s){var r=t.Watcher.watch(e,i,null,null);if(r){var a=function(t){n[s]=t};r.setHandler(a,null),a(r.getValue())}return r},i.bindHandler=function(e,i,n,s){var r=t.Watcher.watch(e,i,n,s);return r&&n.call(s,r.getValue()),r},i.$bindProperties=function(n,s,r,a,o){if(1==s.length)return i.bindProperty(n,s[0].split("."),a,o);for(var h=function(){a[o]=e(s)},l=r.length,u=0;l>u;u++){var d=r[u],c=s[d].split("."),p=t.Watcher.watch(n,c,null,null);p&&(s[d]=p,p.setHandler(h,null))}return h(),p},i}();t.Binding=i,egret.registerClass(i,"eui.Binding")}(eui||(eui={}));var eui;!function(t){function e(t,i){var n=Object.getOwnPropertyDescriptor(t,i);if(n)return n;var s=Object.getPrototypeOf(t);return s?e(s,i):null}function i(t,e){for(var i=t[n],s=i.length,r=0;s>r;r+=2){var a=i[r],o=i[r+1];a.call(o,e)}}var n="__listeners__",s="__bindables__",r=0,a=function(){function a(t,e,i,n){this.isExecuting=!1,this.property=t,this.handler=e,this.next=n,this.thisObject=i}var o=(__define,a),h=o.prototype;return a.watch=function(t,e,i,n){if(e.length>0){var s=e.shift(),r=a.watch(null,e,i,n),o=new a(s,i,n,r);return o.reset(t),o}return null},a.checkBindable=function(a,o){var h=a[s];if(h&&-1!=h.indexOf(o))return!0;var l=egret.is(a,"egret.IEventDispatcher");l||a[n]||(a[n]=[]);var u=e(a,o);if(u&&u.set&&u.get){var d=u.set;u.set=function(e){this[o]!=e&&(d.call(this,e),l?t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,o):i(this,o))}}else{if(u&&(u.get||u.set))return!1;r++;var c="_"+r+o;a[c]=u?u.value:null,u={enumerable:!0,configurable:!0},u.get=function(){return this[c]},u.set=function(e){this[c]!=e&&(this[c]=e,l?t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,o):i(this,o))}}Object.defineProperty(a,o,u),t.registerBindable(a,o)},h.unwatch=function(){this.reset(null),this.handler=null,this.next&&(this.next.handler=null)},h.getValue=function(){return this.next?this.next.getValue():this.getHostPropertyValue()},h.setHandler=function(t,e){this.handler=t,this.thisObject=e,this.next&&this.next.setHandler(t,e)},h.reset=function(e){var i=this.host;if(i)if(egret.is(i,"egret.IEventDispatcher"))i.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.wrapHandler,this);else{var s=i[n],r=s.indexOf(this);s.splice(r-1,2)}if(this.host=e,e)if(a.checkBindable(e,this.property),egret.is(e,"egret.IEventDispatcher"))e.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.wrapHandler,this,!1,100);else{var s=e[n];s.push(this.onPropertyChange),s.push(this)}this.next&&this.next.reset(this.getHostPropertyValue())},h.getHostPropertyValue=function(){return this.host?this.host[this.property]:null},h.wrapHandler=function(t){this.onPropertyChange(t.property)},h.onPropertyChange=function(t){if(t==this.property&&!this.isExecuting)try{this.isExecuting=!0,this.next&&this.next.reset(this.getHostPropertyValue()),this.handler.call(this.thisObject,this.getValue())}finally{this.isExecuting=!1}},a}();t.Watcher=a,egret.registerClass(a,"eui.Watcher")}(eui||(eui={}));var eui;!function(t){function e(t,e,i,n){var s=t.prototype;s.__meta__=s.__meta__||{},s.__meta__[e]=i,n&&(s.__defaultProperty__=e)}t.registerProperty=e}(eui||(eui={}));var eui;!function(t){function e(t,e){if(t.hasOwnProperty(i))t[i].push(e);else{var n=[e];t[i]&&(n=t[i].concat(n)),t[i]=n}}var i="__bindables__";t.registerBindable=e}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t){e.call(this),t?this._source=t:this._source=[]}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"source",function(){return this._source},function(e){e||(e=[]),this._source=e,this.dispatchCoEvent(t.CollectionEventKind.RESET)}),r.refresh=function(){this.dispatchCoEvent(t.CollectionEventKind.REFRESH)},n(r,"length",function(){return this._source.length}),r.addItem=function(e){this._source.push(e),this.dispatchCoEvent(t.CollectionEventKind.ADD,this._source.length-1,-1,[e])},r.addItemAt=function(e,i){0>i||i>this._source.length,this._source.splice(i,0,e),this.dispatchCoEvent(t.CollectionEventKind.ADD,i,-1,[e])},r.getItemAt=function(t){return this._source[t]},r.getItemIndex=function(t){for(var e=this._source.length,i=0;e>i;i++)if(this._source[i]===t)return i;return-1},r.itemUpdated=function(e){var i=this.getItemIndex(e);-1!=i&&this.dispatchCoEvent(t.CollectionEventKind.UPDATE,i,-1,[e])},r.removeAll=function(){var e=this._source.concat();this._source.length=0,this.dispatchCoEvent(t.CollectionEventKind.REMOVE,0,-1,e)},r.removeItemAt=function(e){if(!(0>e||e>=this._source.length)){var i=this._source.splice(e,1)[0];return this.dispatchCoEvent(t.CollectionEventKind.REMOVE,e,-1,[i]),i}},r.replaceItemAt=function(e,i){if(!(0>i||i>=this._source.length)){var n=this._source.splice(i,1,e)[0];return this.dispatchCoEvent(t.CollectionEventKind.REPLACE,i,-1,[e],[n]),n}},r.replaceAll=function(t){t||(t=[]);for(var e=t.length,i=this._source.length,n=e;i>n;n++)this.removeItemAt(e);for(n=0;e>n;n++)n>=i?this.addItemAt(t[n],n):this.replaceItemAt(t[n],n);this._source=t},r.dispatchCoEvent=function(e,i,n,s,r){t.CollectionEvent.dispatchCollectionEvent(this,t.CollectionEvent.COLLECTION_CHANGE,e,i,n,s,r)},i}(egret.EventDispatcher);t.ArrayCollection=e,egret.registerClass(e,"eui.ArrayCollection",["eui.ICollection","egret.IEventDispatcher"]),t.registerProperty(e,"source","Array",!0)}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e=function(t){function e(){t.call(this),this.targetLevel=Number.POSITIVE_INFINITY,this.invalidatePropertiesFlag=!1,this.invalidateClientPropertiesFlag=!1,this.invalidatePropertiesQueue=new i,this.invalidateSizeFlag=!1,this.invalidateClientSizeFlag=!1,this.invalidateSizeQueue=new i,this.invalidateDisplayListFlag=!1,this.invalidateDisplayListQueue=new i,this.eventDisplay=new egret.Bitmap,this.listenersAttached=!1}__extends(e,t);var n=(__define,e),s=n.prototype;return s.invalidateProperties=function(t){this.invalidatePropertiesFlag||(this.invalidatePropertiesFlag=!0,this.listenersAttached||this.attachListeners()),this.targetLevel<=t.$nestLevel&&(this.invalidateClientPropertiesFlag=!0),this.invalidatePropertiesQueue.insert(t)},s.validateProperties=function(){for(var t=this.invalidatePropertiesQueue,e=t.shift();e;)e.$stage&&e.validateProperties(),e=t.shift();t.isEmpty()&&(this.invalidatePropertiesFlag=!1)},s.invalidateSize=function(t){this.invalidateSizeFlag||(this.invalidateSizeFlag=!0,this.listenersAttached||this.attachListeners()),this.targetLevel<=t.$nestLevel&&(this.invalidateClientSizeFlag=!0),this.invalidateSizeQueue.insert(t)},s.validateSize=function(){for(var t=this.invalidateSizeQueue,e=t.pop();e;)e.$stage&&e.validateSize(),e=t.pop();t.isEmpty()&&(this.invalidateSizeFlag=!1)},s.invalidateDisplayList=function(t){this.invalidateDisplayListFlag||(this.invalidateDisplayListFlag=!0,this.listenersAttached||this.attachListeners()),this.invalidateDisplayListQueue.insert(t)},s.validateDisplayList=function(){for(var t=this.invalidateDisplayListQueue,e=t.shift();e;)e.$stage&&e.validateDisplayList(),e=t.shift();t.isEmpty()&&(this.invalidateDisplayListFlag=!1)},s.attachListeners=function(){this.eventDisplay.addEventListener(egret.Event.ENTER_FRAME,this.doPhasedInstantiationCallBack,this),this.eventDisplay.addEventListener(egret.Event.RENDER,this.doPhasedInstantiationCallBack,this),egret.sys.$invalidateRenderFlag=!0,this.listenersAttached=!0},s.doPhasedInstantiationCallBack=function(t){this.eventDisplay.removeEventListener(egret.Event.ENTER_FRAME,this.doPhasedInstantiationCallBack,this),this.eventDisplay.removeEventListener(egret.Event.RENDER,this.doPhasedInstantiationCallBack,this),this.doPhasedInstantiation()},s.doPhasedInstantiation=function(){this.invalidatePropertiesFlag&&this.validateProperties(),this.invalidateSizeFlag&&this.validateSize(),this.invalidateDisplayListFlag&&this.validateDisplayList(),this.invalidatePropertiesFlag||this.invalidateSizeFlag||this.invalidateDisplayListFlag?this.attachListeners():this.listenersAttached=!1},s.validateClient=function(t){var e,i=!1,n=this.targetLevel;this.targetLevel===Number.POSITIVE_INFINITY&&(this.targetLevel=t.$nestLevel);for(var s=this.invalidatePropertiesQueue,r=this.invalidateSizeQueue,a=this.invalidateDisplayListQueue;!i;){for(i=!0,e=s.removeSmallestChild(t);e;)e.$stage&&e.validateProperties(),e=s.removeSmallestChild(t);for(s.isEmpty()&&(this.invalidatePropertiesFlag=!1),this.invalidateClientPropertiesFlag=!1,e=r.removeLargestChild(t);e;){if(e.$stage&&e.validateSize(),this.invalidateClientPropertiesFlag&&(e=s.removeSmallestChild(t))){s.insert(e),i=!1;break}e=r.removeLargestChild(t)}for(r.isEmpty()&&(this.invalidateSizeFlag=!1),this.invalidateClientPropertiesFlag=!1,this.invalidateClientSizeFlag=!1,e=a.removeSmallestChild(t);e;){if(e.$stage&&e.validateDisplayList(),this.invalidateClientPropertiesFlag&&(e=s.removeSmallestChild(t))){s.insert(e),i=!1;break}if(this.invalidateClientSizeFlag&&(e=r.removeLargestChild(t))){r.insert(e),i=!1;break}e=a.removeSmallestChild(t)}a.isEmpty()&&(this.invalidateDisplayListFlag=!1)}n===Number.POSITIVE_INFINITY&&(this.targetLevel=Number.POSITIVE_INFINITY)},e}(egret.EventDispatcher);t.Validator=e,egret.registerClass(e,"eui.sys.Validator");var i=function(){function t(){this.depthBins={},this.minDepth=0,this.maxDepth=-1}var e=(__define,t),i=e.prototype;return i.insert=function(t){var e=t.$nestLevel;this.maxDepththis.maxDepth&&(this.maxDepth=e));var i=this.depthBins[e];i||(i=this.depthBins[e]=new n),i.insert(t)},i.pop=function(){var t,e=this.minDepth;if(e<=this.maxDepth){for(var i=this.depthBins[this.maxDepth];!i||0===i.length;){if(this.maxDepth--,this.maxDepthe)return null;i=this.depthBins[this.minDepth]}for(t=i.pop();!(i&&0!=i.length||(this.minDepth++,this.minDepth>e));)i=this.depthBins[this.minDepth]}return t},i.removeLargestChild=function(t){for(var e=t.$hashCode,i=t.$nestLevel,n=this.maxDepth,s=i;n>=s;){var r=this.depthBins[n];if(r&&r.length>0){if(n===i){if(r.map[e])return r.remove(t),t}else{if(!egret.is(t,"egret.DisplayObjectContainer"))break;for(var a=r.items,o=r.length,h=0;o>h;h++){var l=a[h];if(t.contains(l))return r.remove(l),l}}n--}else if(n==this.maxDepth&&this.maxDepth--,n--,s>n)break}return null},i.removeSmallestChild=function(t){for(var e=t.$nestLevel,i=e,n=this.maxDepth,s=t.$hashCode;n>=i;){var r=this.depthBins[i];if(r&&r.length>0){if(i===e){if(r.map[s])return r.remove(t),t}else{if(!egret.is(t,"egret.DisplayObjectContainer"))break;for(var a=r.items,o=r.length,h=0;o>h;h++){var l=a[h];if(t.contains(l))return r.remove(l),l}}i++}else if(i==this.minDepth&&this.minDepth++,i++,i>n)break}return null},i.isEmpty=function(){return this.minDepth>this.maxDepth},t}();egret.registerClass(i,"DepthQueue");var n=function(){function t(){this.map={},this.items=[],this.length=0}var e=(__define,t),i=e.prototype;return i.insert=function(t){var e=t.$hashCode;this.map[e]||(this.map[e]=!0,this.length++,this.items.push(t))},i.pop=function(){var t=this.items.pop();return t&&(this.length--,0===this.length?this.map={}:this.map[t.$hashCode]=!1),t},i.remove=function(t){var e=this.items.indexOf(t);e>=0&&(this.items.splice(e,1),this.length--,0===this.length?this.map={}:this.map[t.$hashCode]=!1)},t}();egret.registerClass(n,"DepthBin")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e;!function(e){function i(t){return 1===t.a&&0===t.b&&0===t.c&&1===t.d}function n(t,e){if("function"!=typeof t[e])return!1;var i=t[e].toString(),n=i.indexOf("{"),s=i.lastIndexOf("}");return i=i.substring(n+1,s),""==i.trim()}function s(t,e){for(var i in e)"prototype"!=i&&e.hasOwnProperty(i)&&(t[i]=e[i]);for(var s=t.prototype,r=e.prototype,a=Object.keys(r),o=a.length,h=0;o>h;h++){var l=a[h];if("__meta__"!=l&&(!s.hasOwnProperty(l)||n(s,l))){var u=Object.getOwnPropertyDescriptor(r,l);Object.defineProperty(s,l,u)}}}function r(t,e,i){s(t,h);var n=t.prototype;n.$super=e.prototype,i&&(n.$childAdded=function(t,e){this.invalidateSize(),this.invalidateDisplayList()},n.$childRemoved=function(t,e){this.invalidateSize(),this.invalidateDisplayList()})}var a="eui.UIComponent",o=new e.Validator,h=function(n){function s(){n.call(this),this.initializeUIValues()}__extends(s,n);var r=__define,h=s,l=h.prototype;return l.initializeUIValues=function(){this.$UIComponent={0:0/0,1:0/0,2:0/0,3:0/0,4:0/0,5:0/0,6:0/0,7:0/0,8:0/0,9:0/0,10:0,11:0,12:0,13:1e5,14:0,15:1e5,16:0,17:0,18:0/0,19:0/0,20:0,21:0,22:0,23:0,24:!0,25:!0,26:!0,27:!1,28:!1,29:!1},this.$includeInLayout=!0,this.$touchEnabled=!0},l.createChildren=function(){},l.childrenCreated=function(){},l.commitProperties=function(){var e=this.$UIComponent;(e[22]!=e[10]||e[23]!=e[11])&&(this.dispatchEventWith(egret.Event.RESIZE),e[22]=e[10],e[23]=e[11]),(e[20]!=this.$getX()||e[21]!=this.$getY())&&(t.UIEvent.dispatchUIEvent(this,t.UIEvent.MOVE),e[20]=this.$getX(),e[21]=this.$getY())},l.measure=function(){},l.updateDisplayList=function(t,e){},r(l,"includeInLayout",function(){return this.$includeInLayout},function(t){t=!!t,this.$includeInLayout!==t&&(this.$includeInLayout=!0,this.invalidateParentLayout(),this.$includeInLayout=t)}),l.$onAddToStage=function(e,i){this.$super.$onAddToStage.call(this,e,i),this.checkInvalidateFlag();var n=this.$UIComponent;n[29]||(n[29]=!0,this.createChildren(),this.childrenCreated(),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CREATION_COMPLETE))},l.checkInvalidateFlag=function(t){var e=this.$UIComponent;e[24]&&o.invalidateProperties(this),e[25]&&o.invalidateSize(this),e[26]&&o.invalidateDisplayList(this)},r(l,"left",function(){return this.$UIComponent[0]},function(t){t=+t;var e=this.$UIComponent;e[0]!==t&&(e[0]=t,this.invalidateParentLayout())}),r(l,"right",function(){return this.$UIComponent[1]},function(t){t=+t;var e=this.$UIComponent;e[1]!==t&&(e[1]=t,this.invalidateParentLayout())}),r(l,"top",function(){return this.$UIComponent[2]},function(t){t=+t;var e=this.$UIComponent;e[2]!==t&&(e[2]=t,this.invalidateParentLayout())}),r(l,"bottom",function(){return this.$UIComponent[3]},function(t){t=+t;var e=this.$UIComponent;e[3]!=t&&(e[3]=t,this.invalidateParentLayout())}),r(l,"horizontalCenter",function(){return this.$UIComponent[4]},function(t){t=+t;var e=this.$UIComponent;e[4]!==t&&(e[4]=t,this.invalidateParentLayout())}),r(l,"verticalCenter",function(){return this.$UIComponent[5]},function(t){t=+t;var e=this.$UIComponent;e[5]!==t&&(e[5]=t,this.invalidateParentLayout())}),r(l,"percentWidth",function(){return this.$UIComponent[6]},function(t){t=+t;var e=this.$UIComponent;e[6]!==t&&(e[6]=t,this.invalidateParentLayout())}),r(l,"percentHeight",function(){return this.$UIComponent[7]},function(t){t=+t;var e=this.$UIComponent;e[7]!==t&&(e[7]=t,this.invalidateParentLayout())}),r(l,"explicitWidth",function(){return this.$UIComponent[8]}),r(l,"explicitHeight",function(){return this.$UIComponent[9]}),l.$getWidth=function(){return this.validateSizeNow(),this.$UIComponent[10]},l.$setWidth=function(t){t=+t;var e=this.$UIComponent;return 0>t||e[10]===t&&e[8]===t?!1:(e[8]=t,isNaN(t)&&this.invalidateSize(),this.invalidateProperties(),this.invalidateDisplayList(),this.invalidateParentLayout(),!0)},l.validateSizeNow=function(){this.validateSize(!0),this.updateFinalSize()},l.$getHeight=function(){return this.validateSizeNow(),this.$UIComponent[11]},l.$setHeight=function(t){t=+t;var e=this.$UIComponent;return 0>t||e[11]===t&&e[9]===t?!1:(e[9]=t,isNaN(t)&&this.invalidateSize(),this.invalidateProperties(),this.invalidateDisplayList(),this.invalidateParentLayout(),!0)},l.$setScaleX=function(t){var e=this.$super.$setScaleX.call(this,t);return e&&this.invalidateParentLayout(),e},l.$setScaleY=function(t){var e=this.$super.$setScaleY.call(this,t);return e&&this.invalidateParentLayout(),e},r(l,"minWidth",function(){return this.$UIComponent[12]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[12]===t||(e[12]=t,this.invalidateSize(),this.invalidateParentLayout())}),r(l,"maxWidth",function(){return this.$UIComponent[13]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[13]===t||(e[13]=t,this.invalidateSize(),this.invalidateParentLayout())}),r(l,"minHeight",function(){return this.$UIComponent[14]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[14]===t||(e[14]=t,this.invalidateSize(),this.invalidateParentLayout())}),r(l,"maxHeight",function(){return this.$UIComponent[15]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[15]===t||(e[15]=t,this.invalidateSize(),this.invalidateParentLayout())}),l.setMeasuredSize=function(t,e){var i=this.$UIComponent;i[16]=Math.ceil(+t||0),i[17]=Math.ceil(+e||0)},l.setActualSize=function(t,e){var i=!1,n=this.$UIComponent;n[10]!==t&&(n[10]=t,i=!0),n[11]!==e&&(n[11]=e,i=!0),i&&(this.invalidateDisplayList(),this.dispatchEventWith(egret.Event.RESIZE))},l.$setX=function(t){var e=this.$super.$setX.call(this,t);return e&&(this.invalidateParentLayout(),this.invalidateProperties()),e},l.$setY=function(t){var e=this.$super.$setY.call(this,t);return e&&(this.invalidateParentLayout(),this.invalidateProperties()),e},l.invalidateProperties=function(){var t=this.$UIComponent;t[24]||(t[24]=!0,this.$stage&&o.invalidateProperties(this))},l.validateProperties=function(){var t=this.$UIComponent;t[24]&&(this.commitProperties(),t[24]=!1)},l.invalidateSize=function(){var t=this.$UIComponent;t[25]||(t[25]=!0,this.$stage&&o.invalidateSize(this))},l.validateSize=function(t){if(t){var e=this.$children;if(e)for(var i=e.length,n=0;i>n;n++){var s=e[n];egret.is(s,a)&&s.validateSize(!0)}}var r=this.$UIComponent;if(r[25]){var o=this.measureSizes();o&&(this.invalidateDisplayList(),this.invalidateParentLayout()),r[25]=!1}},l.measureSizes=function(){var t=!1,e=this.$UIComponent;if(!e[25])return t;(isNaN(e[8])||isNaN(e[9]))&&(this.measure(),e[16]e[13]&&(e[16]=e[13]),e[17]e[15]&&(e[17]=e[15]));var i=this.getPreferredUWidth(),n=this.getPreferredUHeight();return(i!==e[18]||n!==e[19])&&(e[18]=i,e[19]=n,t=!0),t},l.invalidateDisplayList=function(){var t=this.$UIComponent;t[26]||(t[26]=!0,this.$stage&&o.invalidateDisplayList(this))},l.validateDisplayList=function(){var t=this.$UIComponent;t[26]&&(this.updateFinalSize(),this.updateDisplayList(t[10],t[11]),t[26]=!1)},l.updateFinalSize=function(){var t=0,e=0,i=this.$UIComponent;t=i[27]?i[10]:isNaN(i[8])?i[16]:i[8],e=i[28]?i[11]:isNaN(i[9])?i[17]:i[9],this.setActualSize(t,e)},l.validateNow=function(){this.$stage&&o.validateClient(this)},l.invalidateParentLayout=function(){var t=this.$parent;t&&this.$includeInLayout&&egret.is(t,a)&&(t.invalidateSize(),t.invalidateDisplayList())},l.setLayoutBoundsSize=function(t,n){if(n=+n,t=+t,!(0>n||0>t)){var s,r,a=this.$UIComponent,o=a[13],h=a[15],l=Math.min(a[12],o),u=Math.min(a[14],h);isNaN(t)?(a[27]=!1,s=this.getPreferredUWidth()):(a[27]=!0,s=Math.max(l,Math.min(o,t))),isNaN(n)?(a[28]=!1,r=this.getPreferredUHeight()):(a[28]=!0,r=Math.max(u,Math.min(h,n)));var d=this.$getMatrix();if(i(d))return void this.setActualSize(s,r);var c=e.MatrixUtil.fitBounds(t,n,d,a[8],a[9],this.getPreferredUWidth(),this.getPreferredUHeight(),l,u,o,h);c||(c=egret.Point.create(l,u)),this.setActualSize(c.x,c.y),egret.Point.release(c)}},l.setLayoutBoundsPosition=function(e,n){var s=this.$getMatrix();if(!i(s)){var r=egret.$TempRectangle;this.getLayoutBounds(r),e+=this.$getX()-r.x,n+=this.$getY()-r.y}var a=this.$super.$setX.call(this,e);(this.$super.$setY.call(this,n)||a)&&t.UIEvent.dispatchUIEvent(this,t.UIEvent.MOVE)},l.getLayoutBounds=function(t){var e,i=this.$UIComponent;e=i[27]?i[10]:isNaN(i[8])?i[16]:i[8];var n;n=i[28]?i[11]:isNaN(i[9])?i[17]:i[9],this.applyMatrix(t,e,n)},l.getPreferredUWidth=function(){var t=this.$UIComponent;return isNaN(t[8])?t[16]:t[8]},l.getPreferredUHeight=function(){var t=this.$UIComponent;return isNaN(t[9])?t[17]:t[9]},l.getPreferredBounds=function(t){var e=this.getPreferredUWidth(),i=this.getPreferredUHeight();this.applyMatrix(t,e,i)},l.applyMatrix=function(t,e,n){var t=t.setTo(0,0,e,n),s=this.$getMatrix();i(s)?(t.x+=s.tx,t.y+=s.ty):s.$transformBounds(t)},s}(egret.DisplayObject);e.UIComponentImpl=h,egret.registerClass(h,"eui.sys.UIComponentImpl",["eui.UIComponent"]),e.mixin=s,e.implementUIComponent=r}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(t){i.call(this),this.$createChildrenCalled=!1,this.$fontChanged=!1,this._widthConstraint=0/0,this.initializeUIValues(),this.text=t}__extends(n,i);var s=(__define,n),r=s.prototype;return r.$invalidateContentBounds=function(){i.prototype.$invalidateContentBounds.call(this),this.invalidateSize()},r.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),s=e.prototype.$setWidth.call(this,t);return n&&s},r.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),s=e.prototype.$setHeight.call(this,t);return n&&s},r.$setText=function(e){var n=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),n},r.$setFont=function(t){this.$BitmapText;return this.$font==t?!1:(this.$font=t,this.$createChildrenCalled?this.$parseFont():this.$fontChanged=!0,this.$BitmapText[6]=!0,!0)},r.$parseFont=function(){if(this.$fontChanged=!1,this.$font&&"string"==typeof this.$font){var e=this.$stage.getImplementation("eui.IAssetAdapter");e||(e=new t.DefaultAssetAdapter),e.getAsset(this.$font,this.$onFontChanged,this)}else this.$setFontData(this.$font)},r.$onFontChanged=function(t,e){e===this.$font&&this.$setFontData(t)},r.$setFontData=function(t){return t==this.$BitmapText[5]?!1:(this.$BitmapText[5]=t,this.$invalidateContentBounds(),!0)},r.createChildren=function(){this.$fontChanged&&this.$parseFont(),this.$createChildrenCalled=!0},r.childrenCreated=function(){},r.commitProperties=function(){},r.measure=function(){var t=this.$UIComponent,e=this.$BitmapText,n=e[0],s=0/0;isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(s=t[13]):s=t[8]:(s=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,s),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,n)},r.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&(this._widthConstraint=t,this.invalidateSize())}},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},n}(egret.BitmapText);t.BitmapLabel=i,egret.registerClass(i,"eui.BitmapLabel",["eui.UIComponent","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.BitmapText),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.initializeUIValues(),this.$Component={0:null,1:null,2:"",3:!0,4:!1,5:!1,6:!0,7:!0,8:null},this.$touchEnabled=!0}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"hostComponentKey",function(){return this.$Component[0]},function(t){this.$Component[0]=t}),n(r,"skinName",function(){return this.$Component[1]},function(t){var e=this.$Component;if(e[5]=!0,e[1]!=t){if(t)e[1]=t;else if(this.$stage){var i=this.$stage.getImplementation("eui.Theme");if(i){var n=i.getSkinName(this);n&&(e[1]=n)}}this.$parseSkinName()}}),r.$parseSkinName=function(){var t,e=this.skinName;if(e)if(e.prototype)t=new e;else if("string"==typeof e){var i,n=e.trim();if("<"==n.charAt(0))i=EXML.parse(n);else if(i=egret.getDefinitionByName(e),!i&&-1!=n.toLowerCase().indexOf(".exml"))return void EXML.load(e,this.onExmlLoaded,this,!0);i&&(t=new i)}else t=e;this.setSkin(t)},r.onExmlLoaded=function(t,e){if(this.skinName==e){var i=new t;this.setSkin(i)}},n(r,"skin",function(){return this.$Component[8]}),r.setSkin=function(e){!e||e instanceof t.Skin||(e=null);var i=this.$Component,n=i[8];if(n){for(var s=n.skinParts,r=s.length,a=0;r>a;a++){var o=s[a];this[o]&&this.setSkinPart(o,null)}var h=n.$elementsContent;if(h){r=h.length;for(var a=0;r>a;a++){var l=h[a];l.$parent==this&&this.removeChild(l)}}n.hostComponent=null}if(i[8]=e,e){for(var s=e.skinParts,r=s.length,a=0;r>a;a++){var o=s[a],u=e[o];u&&this.setSkinPart(o,u)}if(h=e.$elementsContent)for(a=h.length-1;a>=0;a--)this.addChildAt(h[a],0);e.hostComponent=this}this.invalidateSize(),this.invalidateDisplayList(),this.dispatchEventWith(egret.Event.COMPLETE)},r.setSkinPart=function(t,e){var i=this[t];i&&this.partRemoved(t,i),this[t]=e,e&&this.partAdded(t,e)},r.partAdded=function(t,e){},r.partRemoved=function(t,e){},r.$setTouchChildren=function(t){t=!!t;var i=this.$Component;return i[6]=t,i[3]?(i[6]=t,e.prototype.$setTouchChildren.call(this,t)):!0},r.$setTouchEnabled=function(t){t=!!t;var i=this.$Component;return i[7]=t,i[3]?e.prototype.$setTouchEnabled.call(this,t):!0},n(r,"enabled",function(){return this.$Component[3]},function(t){t=!!t,this.$setEnabled(t)}),r.$setEnabled=function(t){var e=this.$Component;return t===e[3]?!1:(e[3]=t,t?(this.$touchEnabled=e[7],this.$touchChildren=e[6]):(this.$touchEnabled=!1,this.$touchChildren=!1),this.invalidateState(),!0)},n(r,"currentState",function(){var t=this.$Component;return t[2]?t[2]:this.getCurrentState()},function(t){var e=this.$Component;t!=e[2]&&(e[2]=t,this.invalidateState())}),r.invalidateState=function(){var t=this.$Component;t[4]||(t[4]=!0,this.invalidateProperties())},r.getCurrentState=function(){return""},r.createChildren=function(){var t=this.$Component;if(!t[1]){var e=this.$stage.getImplementation("eui.Theme");if(e){var i=e.getSkinName(this);i&&(t[1]=i,this.$parseSkinName())}}},r.childrenCreated=function(){},r.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this);var e=this.$Component;e[4]&&(e[4]=!1,e[8]&&(e[8].currentState=this.currentState))},r.measure=function(){t.sys.measure(this);var e=this.$Component[8];if(e){var i=this.$UIComponent;isNaN(e.width)?(i[16]e.maxWidth&&(i[16]=e.maxWidth)):i[16]=e.width,isNaN(e.height)?(i[17]e.maxHeight&&(i[17]=e.maxHeight)):i[17]=e.height}},r.updateDisplayList=function(e,i){t.sys.updateDisplayList(this,e,i)},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,e){},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},i}(egret.DisplayObjectContainer);t.Component=e,egret.registerClass(e,"eui.Component",["eui.UIComponent"]),t.registerProperty(e,"skinName","Class"),t.sys.implementUIComponent(e,egret.DisplayObjectContainer,!0)}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this),this.labelDisplay=null,this._label="",this.iconDisplay=null,this._icon=null,this.touchCaptured=!1,this.touchChildren=!1,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this)}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"label",function(){return this._label},function(t){this._label=t,this.labelDisplay&&(this.labelDisplay.text=t)}),i(s,"icon",function(){return this._icon},function(t){this._icon=t,this.iconDisplay&&(this.iconDisplay.source=t)}),s.onTouchCancle=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!1,this.invalidateState()},s.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!0,this.invalidateState(),t.updateAfterEvent()},s.onStageTouchEnd=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.contains(t.target)&&this.buttonReleased(),this.touchCaptured=!1,this.invalidateState()},s.getCurrentState=function(){return this.enabled?this.touchCaptured?"down":"up":"disabled"},s.partAdded=function(t,e){e===this.labelDisplay?this.labelDisplay.text=this._label:e==this.iconDisplay&&(this.iconDisplay.source=this._icon)},s.buttonReleased=function(){},e}(t.Component);t.Button=e,egret.registerClass(e,"eui.Button")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.apply(this,arguments),this.$selected=!1,this.$autoSelected=!0}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"selected",function(){return this.$selected},function(t){this.$setSelected(t)}),r.$setSelected=function(e){return e=!!e,e===this.$selected?!1:(this.$selected=e,this.invalidateState(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selected"),!0)},r.getCurrentState=function(){var t=e.prototype.getCurrentState.call(this);if(this.$selected){var i=t+"AndSelected",n=this.skin;return n&&n.hasState(i)?i:"disabled"==t?"disabled":"down"}return t},r.buttonReleased=function(){this.$autoSelected&&(this.selected=!this.$selected,this.dispatchEventWith(egret.Event.CHANGE))},i}(t.Button);t.ToggleButton=e,egret.registerClass(e,"eui.ToggleButton"),t.registerBindable(e.prototype,"selected")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e);i.prototype;return e}(t.ToggleButton);t.CheckBox=e,egret.registerClass(e,"eui.CheckBox")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t,i){void 0===i&&(i=[]),e.call(this),this.name=t,this.overrides=i}__extends(i,e);var n=(__define,i),s=n.prototype;return s.initialize=function(e,i){for(var n=this.overrides,s=n.length,r=0;s>r;r++){var a=n[r];if(a instanceof t.AddItems){var o=e[a.target];o&&o instanceof t.Image&&!o.$parent&&(i.addChild(o),i.removeChild(o))}}},i}(egret.HashObject);t.State=e,egret.registerClass(e,"eui.State")}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e=function(){function t(){}var e=__define,i=t,n=i.prototype;return e(n,"states",function(){return this.$stateValues.states},function(t){t||(t=[]);var e=this.$stateValues;e.states=t;for(var i={},n=t.length,s=0;n>s;s++){var r=t[s];i[r.name]=r}e.statesMap=i,e.parent&&this.commitCurrentState()}),e(n,"currentState",function(){return this.$stateValues.currentState},function(t){var e=this.$stateValues;e.explicitState=t,e.currentState=t,this.commitCurrentState()}),n.commitCurrentState=function(){var t=this.$stateValues;if(t.parent){var e=t.statesMap[t.currentState];if(!e){if(!(t.states.length>0))return;t.currentState=t.states[0].name}if(t.oldState!=t.currentState){var i=t.parent,n=t.statesMap[t.oldState];if(n)for(var s=n.overrides,r=s.length,a=0;r>a;a++)s[a].remove(this,i);if(t.oldState=t.currentState,n=t.statesMap[t.currentState])for(s=n.overrides,r=s.length,a=0;r>a;a++)s[a].apply(this,i)}}},n.hasState=function(t){return!!this.$stateValues.statesMap[t]},n.initializeStates=function(t){this.$stateValues.intialized=!0;for(var e=this.states,i=e.length,n=0;i>n;n++)e[n].initialize(this,t) -},t}();t.StateClient=e,egret.registerClass(e,"eui.sys.StateClient");var i=function(){function t(){this.intialized=!1,this.statesMap={},this.states=[],this.oldState=null,this.explicitState=null,this.currentState=null,this.parent=null,this.stateIsDirty=!1}var e=(__define,t);e.prototype;return t}();t.StateValues=i,egret.registerClass(i,"eui.sys.StateValues")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$layout=null,this.$stateValues=new t.sys.StateValues,this.initializeUIValues(),this.$Group={0:0,1:0,2:0,3:0,4:!1,5:!1},this.$stateValues.parent=this}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"elementsContent",void 0,function(t){if(t)for(var e=t.length,i=0;e>i;i++)this.addChild(t[i])}),n(r,"layout",function(){return this.$layout},function(t){this.$setLayout(t)}),r.$setLayout=function(t){return this.$layout==t?!1:(this.$layout&&(this.$layout.target=null),this.$layout=t,t&&(t.target=this),this.invalidateSize(),this.invalidateDisplayList(),!0)},n(r,"contentWidth",function(){return this.$Group[0]}),n(r,"contentHeight",function(){return this.$Group[1]}),r.setContentSize=function(e,i){e=Math.ceil(+e||0),i=Math.ceil(+i||0);var n=this.$Group,s=n[0]!==e,r=n[1]!==i;(s||r)&&(n[0]=e,n[1]=i,s&&t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"contentWidth"),r&&t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"contentHeight"))},n(r,"scrollEnabled",function(){return this.$Group[4]},function(t){t=!!t;var e=this.$Group;t!==e[4]&&(e[4]=t,this.updateScrollRect())}),n(r,"scrollH",function(){return this.$Group[2]},function(e){e=+e||0;var i=this.$Group;e!==i[2]&&(i[2]=e,this.updateScrollRect()&&this.$layout&&this.$layout.scrollPositionChanged(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"scrollH"))}),n(r,"scrollV",function(){return this.$Group[3]},function(e){e=+e||0;var i=this.$Group;e!=i[3]&&(i[3]=e,this.updateScrollRect()&&this.$layout&&this.$layout.scrollPositionChanged(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"scrollV"))}),r.updateScrollRect=function(){var t=this.$Group,e=t[4];if(e){var i=this.$UIComponent;this.scrollRect=egret.$TempRectangle.setTo(t[2],t[3],i[10],i[11])}else this.$scrollRect&&(this.scrollRect=null);return e},n(r,"numElements",function(){return this.$children.length}),r.getElementAt=function(t){return this.$children[t]},r.getVirtualElementAt=function(t){return this.getElementAt(t)},r.setVirtualElementIndicesInView=function(t,e){},n(r,"touchThrough",function(){return this.$Group[5]},function(t){this.$Group[5]=!!t}),r.$hitTest=function(t,i){var n=e.prototype.$hitTest.call(this,t,i);if(n||this.$Group[5])return n;if(!this.$visible||!this.touchEnabled)return null;var s=this.globalToLocal(t,i,egret.$TempPoint),r=this.$UIComponent,a=egret.$TempRectangle.setTo(0,0,r[10],r[11]),o=this.$scrollRect;return o&&(a.x=o.x,a.y=o.y),a.contains(s.x,s.y)?this:null},r.invalidateState=function(){var t=this.$stateValues;t.stateIsDirty||(t.stateIsDirty=!0,this.invalidateProperties())},r.getCurrentState=function(){return""},r.createChildren=function(){this.$layout||this.$setLayout(new t.BasicLayout),this.initializeStates(this.$stage)},r.childrenCreated=function(){},r.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this);var e=this.$stateValues;e.stateIsDirty&&(e.stateIsDirty=!1,e.explicitState||(e.currentState=this.getCurrentState(),this.commitCurrentState()))},r.measure=function(){return this.$layout?void this.$layout.measure():void this.setMeasuredSize(0,0)},r.updateDisplayList=function(t,e){this.$layout&&this.$layout.updateDisplayList(t,e),this.updateScrollRect()},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,e){},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},i}(egret.DisplayObjectContainer);t.Group=e,egret.registerClass(e,"eui.Group",["eui.IViewport","eui.UIComponent"]),t.sys.implementUIComponent(e,egret.DisplayObjectContainer,!0),t.sys.mixin(e,t.sys.StateClient),t.registerProperty(e,"elementsContent","Array",!0),t.registerProperty(e,"states","State[]")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$dataProviderChanged=!1,this.$dataProvider=null,this.$indexToRenderer=[],this.$DataGroup={0:!0,1:!1,2:{},3:{},4:!1,5:!1,6:null,7:null,8:!1,9:null,10:!1,11:!1,12:null,13:null,14:!1}}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"useVirtualLayout",function(){return this.$layout?this.$layout.$useVirtualLayout:this.$DataGroup[0]},function(t){t=!!t;var e=this.$DataGroup;t!==e[0]&&(e[0]=t,this.$layout&&(this.$layout.useVirtualLayout=t))}),r.$setLayout=function(t){if(t==this.$layout)return!1;this.$layout&&(this.$layout.setTypicalSize(0,0),this.$layout.removeEventListener("useVirtualLayoutChanged",this.onUseVirtualLayoutChanged,this)),this.$layout&&t&&this.$layout.$useVirtualLayout!=t.$useVirtualLayout&&this.onUseVirtualLayoutChanged();var i=e.prototype.$setLayout.call(this,t);if(t){var n=this.$DataGroup[9];n&&t.setTypicalSize(n.width,n.height),t.useVirtualLayout=this.$DataGroup[0],t.addEventListener("useVirtualLayoutChanged",this.onUseVirtualLayoutChanged,this)}return i},r.onUseVirtualLayoutChanged=function(t){var e=this.$DataGroup;e[1]=!0,e[10]=!0,this.removeDataProviderListener(),this.invalidateProperties()},r.setVirtualElementIndicesInView=function(t,e){if(this.$layout&&this.$layout.$useVirtualLayout)for(var i=this.$indexToRenderer,n=Object.keys(i),s=n.length,r=0;s>r;r++){var a=+n[r];(t>a||a>e)&&this.freeRendererByIndex(a)}},r.getElementAt=function(t){return this.$indexToRenderer[t]},r.getVirtualElementAt=function(t){if(t=0|+t,0>t||t>=this.$dataProvider.length)return null;var e=this.$indexToRenderer[t];if(!e){var i=this.$dataProvider.getItemAt(t);e=this.createVirtualRenderer(i),this.$indexToRenderer[t]=e,this.updateRenderer(e,t,i);var n=this.$DataGroup;n[4]&&(e.validateNow(),n[4]=!1,this.rendererAdded(e,t,i))}return e},r.freeRendererByIndex=function(t){var e=this.$indexToRenderer[t];e&&(delete this.$indexToRenderer[t],this.doFreeRenderer(e))},r.doFreeRenderer=function(t){var e=this.$DataGroup,i=e[2][t.$hashCode],n=i.$hashCode;e[3][n]||(e[3][n]=[]),e[3][n].push(t),t.visible=!1},r.invalidateSize=function(){this.$DataGroup[4]||e.prototype.invalidateSize.call(this)},r.createVirtualRenderer=function(t){var e,i=this.itemToRendererClass(t),n=i.$hashCode,s=this.$DataGroup,r=s[3];return r[n]&&r[n].length>0?(e=r[n].pop(),e.visible=!0,this.invalidateDisplayList(),e):(s[4]=!0,this.createOneRenderer(i))},r.createOneRenderer=function(t){var e=new t,i=this.$DataGroup;return i[2][e.$hashCode]=t,egret.is(e,"eui.IItemRenderer")?(i[13]&&this.setItemRenderSkinName(e,i[13]),this.addChild(e),e):null},r.setItemRenderSkinName=function(e,i){if(e&&e instanceof t.Component){var n=e;n.$Component[5]||(n.skinName=i,n.$Component[5]=!1)}},n(r,"dataProvider",function(){return this.$dataProvider},function(t){this.$setDataProvider(t)}),r.$setDataProvider=function(t){return this.$dataProvider==t?!1:(this.removeDataProviderListener(),this.$dataProvider=t,this.$dataProviderChanged=!0,this.$DataGroup[10]=!0,this.invalidateProperties(),this.invalidateSize(),this.invalidateDisplayList(),!0)},r.removeDataProviderListener=function(){this.$dataProvider&&this.$dataProvider.removeEventListener(t.CollectionEvent.COLLECTION_CHANGE,this.onCollectionChange,this)},r.onCollectionChange=function(e){switch(e.kind){case t.CollectionEventKind.ADD:this.itemAddedHandler(e.items,e.location);break;case t.CollectionEventKind.REMOVE:this.itemRemovedHandler(e.items,e.location);break;case t.CollectionEventKind.UPDATE:case t.CollectionEventKind.REPLACE:this.itemUpdatedHandler(e.items[0],e.location);break;case t.CollectionEventKind.RESET:case t.CollectionEventKind.REFRESH:if(this.$layout&&this.$layout.$useVirtualLayout)for(var i=this.$indexToRenderer,n=Object.keys(i),s=n.length,r=s-1;r>=0;r--){var a=+n[r];this.freeRendererByIndex(a)}this.$dataProviderChanged=!0,this.invalidateProperties()}this.invalidateSize(),this.invalidateDisplayList()},r.itemAddedHandler=function(t,e){for(var i=t.length,n=0;i>n;n++)this.itemAdded(t[n],e+n);this.resetRenderersIndices()},r.itemRemovedHandler=function(t,e){for(var i=t.length,n=i-1;n>=0;n--)this.itemRemoved(t[n],e+n);this.resetRenderersIndices()},r.itemAdded=function(t,e){if(this.$layout&&this.$layout.elementAdded(e),this.$layout&&this.$layout.$useVirtualLayout)return void this.$indexToRenderer.splice(e,0,null);var i=this.createVirtualRenderer(t);if(this.$indexToRenderer.splice(e,0,i),i){this.updateRenderer(i,e,t);var n=this.$DataGroup;n[4]&&(n[4]=!1,this.rendererAdded(i,e,t))}},r.itemRemoved=function(t,e){this.$layout&&this.$layout.elementRemoved(e);var i=this.$indexToRenderer[e];this.$indexToRenderer.length>e&&this.$indexToRenderer.splice(e,1),i&&(this.$layout&&this.$layout.$useVirtualLayout?this.doFreeRenderer(i):(this.rendererRemoved(i,e,t),this.removeChild(i)))},r.resetRenderersIndices=function(){var t=this.$indexToRenderer;if(0!=t.length)if(this.$layout&&this.$layout.$useVirtualLayout)for(var e=Object.keys(t),i=e.length,n=0;i>n;n++){var s=+e[n];this.resetRendererItemIndex(s)}else{var r=t.length;for(s=0;r>s;s++)this.resetRendererItemIndex(s)}},r.itemUpdatedHandler=function(t,e){if(!this.$DataGroup[11]){var i=this.$indexToRenderer[e];i&&this.updateRenderer(i,e,t)}},r.resetRendererItemIndex=function(t){var e=this.$indexToRenderer[t];e&&(e.itemIndex=t)},n(r,"itemRenderer",function(){return this.$DataGroup[6]},function(t){var e=this.$DataGroup;e[6]!=t&&(e[6]=t,e[5]=!0,e[8]=!0,e[10]=!0,this.removeDataProviderListener(),this.invalidateProperties())}),n(r,"itemRendererSkinName",function(){return this.$DataGroup[13]},function(t){var e=this.$DataGroup;e[13]!=t&&(e[13]=t,this.$UIComponent[29]&&(e[14]=!0,this.invalidateProperties()))}),n(r,"itemRendererFunction",function(){return this.$DataGroup[7]},function(t){var e=this.$DataGroup;e[7]!=t&&(e[7]=t,e[5]=!0,e[8]=!0,this.removeDataProviderListener(),this.invalidateProperties())}),r.itemToRendererClass=function(e){var i,n=this.$DataGroup;return n[7]&&(i=n[7](e)),i||(i=n[6]),i||(i=t.ItemRenderer),i.$hashCode||(i.$hashCode=egret.$hashCount++),i},r.createChildren=function(){if(!this.$layout){var i=new t.VerticalLayout;i.gap=0,i.horizontalAlign=t.JustifyAlign.CONTENT_JUSTIFY,this.$setLayout(i)}e.prototype.createChildren.call(this)},r.commitProperties=function(){var i=this.$DataGroup;if((i[5]||this.$dataProviderChanged||i[1])&&(this.removeAllRenderers(),this.$layout&&this.$layout.clearVirtualLayoutCache(),this.setTypicalLayoutRect(null),i[1]=!1,i[5]=!1,this.$dataProvider&&this.$dataProvider.addEventListener(t.CollectionEvent.COLLECTION_CHANGE,this.onCollectionChange,this),this.$layout&&this.$layout.$useVirtualLayout?(this.invalidateSize(),this.invalidateDisplayList()):this.createRenderers(),this.$dataProviderChanged&&(this.$dataProviderChanged=!1,this.scrollV=this.scrollH=0)),e.prototype.commitProperties.call(this),i[8]&&(i[8]=!1,this.$dataProvider&&this.$dataProvider.length>0&&(i[12]=this.$dataProvider.getItemAt(0),this.measureRendererSize())),i[14]){i[14]=!1;for(var n=i[13],s=this.$indexToRenderer,r=Object.keys(s),a=r.length,o=0;a>o;o++){var h=r[o];this.setItemRenderSkinName(s[h],n)}for(var l=i[3],r=Object.keys(l),a=r.length,o=0;a>o;o++)for(var u=r[o],d=l[u],a=d.length,o=0;a>o;o++)this.setItemRenderSkinName(d[o],n)}},r.measure=function(){this.$layout&&this.$layout.$useVirtualLayout&&this.ensureTypicalLayoutElement(),e.prototype.measure.call(this)},r.updateDisplayList=function(t,i){var n=this.$layout&&this.$layout.$useVirtualLayout;n&&this.ensureTypicalLayoutElement(),e.prototype.updateDisplayList.call(this,t,i);var s=this.$DataGroup;if(n){var r=s[9];if(r){var a=this.$indexToRenderer[0];if(a){var o=egret.$TempRectangle;a.getPreferredBounds(o),(o.width!=r.width||o.height!=r.height)&&(s[9]=null)}}}},r.ensureTypicalLayoutElement=function(){this.$DataGroup[9]||this.$dataProvider&&this.$dataProvider.length>0&&(this.$DataGroup[12]=this.$dataProvider.getItemAt(0),this.measureRendererSize())},r.measureRendererSize=function(){var t=this.$DataGroup;if(!t[12])return void this.setTypicalLayoutRect(null);var e=this.createVirtualRenderer(t[12]);if(!e)return void this.setTypicalLayoutRect(null);this.updateRenderer(e,0,t[12]),e.validateNow();var i=egret.$TempRectangle;e.getPreferredBounds(i);var n=new egret.Rectangle(0,0,i.width,i.height);this.$layout&&this.$layout.$useVirtualLayout?(t[4]&&this.rendererAdded(e,0,t[12]),this.doFreeRenderer(e)):this.removeChild(e),this.setTypicalLayoutRect(n),t[4]=!1},r.setTypicalLayoutRect=function(t){this.$DataGroup[9]=t,this.$layout&&(t?this.$layout.setTypicalSize(t.width,t.height):this.$layout.setTypicalSize(0,0))},r.removeAllRenderers=function(){for(var t=this.$indexToRenderer,e=Object.keys(t),i=e.length,n=0;i>n;n++){var s=e[n],r=t[s];r&&(this.rendererRemoved(r,r.itemIndex,r.data),this.removeChild(r))}this.$indexToRenderer=[];var a=this.$DataGroup;if(a[10]){for(var o=a[3],e=Object.keys(o),i=e.length,n=0;i>n;n++)for(var h=e[n],l=o[h],i=l.length,n=0;i>n;n++)r=l[n],this.rendererRemoved(r,r.itemIndex,r.data),this.removeChild(r);a[3]={},a[2]={},a[10]=!1}},r.createRenderers=function(){if(this.$dataProvider)for(var t=0,e=this.$dataProvider.length,i=0;e>i;i++){var n=this.$dataProvider.getItemAt(i),s=this.itemToRendererClass(n),r=this.createOneRenderer(s);r&&(this.$indexToRenderer[t]=r,this.updateRenderer(r,t,n),this.rendererAdded(r,t,n),t++)}},r.updateRenderer=function(t,e,i){var n=this.$DataGroup;return n[11]=!0,t.itemIndex=e,t.data=i,n[11]=!1,t},n(r,"numElements",function(){return this.$dataProvider?this.$dataProvider.length:0}),r.rendererAdded=function(t,e,i){},r.rendererRemoved=function(t,e,i){},i}(t.Group);t.DataGroup=e,egret.registerClass(e,"eui.DataGroup"),t.registerProperty(e,"itemRenderer","Class"),t.registerProperty(e,"itemRendererSkinName","Class"),t.registerProperty(e,"dataProvider","eui.ICollection",!0)}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(){i.call(this),this._widthConstraint=0/0,this.$isShowPrompt=!1,this.$promptColor=6710886,this.$isFocusIn=!1,this.initializeUIValues(),this.type=egret.TextFieldType.INPUT,this.$EditableText={0:null,1:16777215,2:!1}}__extends(n,i);var s=__define,r=n,a=r.prototype;return a.$invalidateContentBounds=function(){i.prototype.$invalidateContentBounds.call(this),this.invalidateSize()},a.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),s=e.prototype.$setWidth.call(this,t);return n&&s},a.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),s=e.prototype.$setHeight.call(this,t);return n&&s},a.$getText=function(){var t=i.prototype.$getText.call(this);return t==this.$EditableText[0]&&(t=""),t},a.$setText=function(e){var n=this.$EditableText[0];(n!=e||null==n)&&(this.$isShowPrompt=!1,this.textColor=this.$EditableText[1]),this.$isFocusIn||(""==e||null==e)&&(e=n,this.$isShowPrompt=!0,i.prototype.$setTextColor.call(this,this.$promptColor));var s=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),s},a.$onAddToStage=function(e,i){t.sys.UIComponentImpl.prototype.$onAddToStage.call(this,e,i),this.addEventListener(egret.FocusEvent.FOCUS_IN,this.onfocusIn,this),this.addEventListener(egret.FocusEvent.FOCUS_OUT,this.onfocusOut,this)},a.$onRemoveFromStage=function(){t.sys.UIComponentImpl.prototype.$onRemoveFromStage.call(this),this.removeEventListener(egret.FocusEvent.FOCUS_IN,this.onfocusIn,this),this.removeEventListener(egret.FocusEvent.FOCUS_OUT,this.onfocusOut,this)},s(a,"prompt",function(){return this.$EditableText[0]},function(t){var e=this.$EditableText,i=e[0];if(i!=t){e[0]=t;var n=this.text;n&&n!=i||this.showPromptText()}}),s(a,"promptColor",function(){return this.$promptColor},function(t){if(t=0|+t,this.$promptColor!=t){this.$promptColor=t;var e=this.text;e&&e!=this.$EditableText[0]||this.showPromptText()}}),a.onfocusOut=function(){this.$isFocusIn=!1,this.text||this.showPromptText()},a.onfocusIn=function(){this.$isFocusIn=!0,this.$isShowPrompt=!1,this.displayAsPassword=this.$EditableText[2];var t=this.$EditableText,e=this.text;e&&e!=t[0]||(this.textColor=t[1],this.text="")},a.showPromptText=function(){var t=this.$EditableText;this.$isShowPrompt=!0,i.prototype.$setTextColor.call(this,this.$promptColor),i.prototype.$setDisplayAsPassword.call(this,!1),this.text=t[0]},a.$setTextColor=function(t){return t=0|+t,this.$EditableText[1]=t,this.$isShowPrompt||i.prototype.$setTextColor.call(this,t),!0},a.$setDisplayAsPassword=function(t){return this.$EditableText[2]=t,this.$isShowPrompt||i.prototype.$setDisplayAsPassword.call(this,t),!0},a.createChildren=function(){this.onfocusOut()},a.childrenCreated=function(){},a.commitProperties=function(){},a.measure=function(){var t=this.$UIComponent,e=this.$TextField,n=e[3],s=0/0;isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(s=t[13]):s=t[8]:(s=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,s),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,n)},a.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},a.invalidateParentLayout=function(){},a.setMeasuredSize=function(t,e){},a.invalidateProperties=function(){},a.validateProperties=function(){},a.invalidateSize=function(){},a.validateSize=function(t){},a.invalidateDisplayList=function(){},a.validateDisplayList=function(){},a.validateNow=function(){},a.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&(this._widthConstraint=t,this.invalidateSize())}},a.setLayoutBoundsPosition=function(t,e){},a.getLayoutBounds=function(t){},a.getPreferredBounds=function(t){},n}(egret.TextField);t.EditableText=i,egret.registerClass(i,"eui.EditableText",["eui.UIComponent","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.TextField),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.thumb=null,this.$viewport=null,this.autoVisibility=!0}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"viewport",function(){return this.$viewport},function(e){if(e!=this.$viewport){var i=this.$viewport;i&&(i.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onPropertyChanged,this),i.removeEventListener(egret.Event.RESIZE,this.onViewportResize,this)),this.$viewport=e,e&&(e.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onPropertyChanged,this),e.addEventListener(egret.Event.RESIZE,this.onViewportResize,this)),this.invalidateDisplayList()}}),r.onViewportResize=function(t){this.invalidateDisplayList()},r.onPropertyChanged=function(t){},i}(t.Component);t.ScrollBarBase=e,egret.registerClass(e,"eui.ScrollBarBase")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.updateDisplayList=function(e,i){t.prototype.updateDisplayList.call(this,e,i);var n=this.thumb,s=this.$viewport;if(n&&s){var r=egret.$TempRectangle;n.getPreferredBounds(r);var a=r.width,o=r.y,h=s.scrollH,l=s.contentWidth,u=s.width;if(0>=h){var d=a*(1- -h/(.5*u));d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(d,0/0),n.setLayoutBoundsPosition(0,o)}else if(h>=l-u)d=a*(1-(h-l+u)/(.5*u)),d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(d,0/0),n.setLayoutBoundsPosition(e-d,o);else{var c=(e-a)*h/(l-u);n.setLayoutBoundsSize(0/0,0/0),n.setLayoutBoundsPosition(c,o)}}},n.onPropertyChanged=function(t){switch(t.property){case"scrollH":case"contentWidth":this.invalidateDisplayList()}},e}(t.ScrollBarBase);t.HScrollBar=e,egret.registerClass(e,"eui.HScrollBar")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$Range={0:100,1:!1,2:0,3:!1,4:0,5:0,6:!1,7:1,8:!1,9:!1}}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"maximum",function(){return this.$Range[0]},function(t){t=+t||0;var e=this.$Range;t!==e[0]&&(e[0]=t,e[1]=!0,this.invalidateProperties(),this.invalidateDisplayList())}),n(r,"minimum",function(){return this.$Range[2]},function(t){t=+t||0;var e=this.$Range;t!==e[2]&&(e[2]=t,e[3]=!0,this.invalidateProperties(),this.invalidateDisplayList())}),n(r,"value",function(){var t=this.$Range;return t[6]?t[5]:t[4]},function(t){t=+t||0,this.$setValue(t)}),r.$setValue=function(t){if(t===this.value)return!1;var e=this.$Range;return e[5]=t,e[6]=!0,this.invalidateProperties(),!0},n(r,"snapInterval",function(){return this.$Range[7]},function(t){var e=this.$Range;e[9]=!0,t=+t||0,t!==e[7]&&(isNaN(t)?(e[7]=1,e[9]=!1):e[7]=t,e[8]=!0,this.invalidateProperties())}),r.commitProperties=function(){e.prototype.commitProperties.call(this);var t=this.$Range;if(t[2]>t[0]&&(t[1]?t[0]=t[2]:t[2]=t[0]),t[6]||t[1]||t[3]||t[8]){var i=t[6]?t[5]:t[4];t[6]=!1,t[1]=!1,t[3]=!1,t[8]=!1,this.setValue(this.nearestValidValue(i,t[7]))}},r.nearestValidSize=function(t){var e=this.snapInterval;if(0==e)return t;var i=Math.round(t/e)*e;return Math.abs(i)=(o-a)/2?o:a;return h/s+i[2]},r.setValue=function(e){var i=this.$Range;i[4]!==e&&(i[0]>i[2]?i[4]=Math.min(i[0],Math.max(i[2],e)):i[4]=e,i[6]=!1,this.invalidateDisplayList(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"value"))},r.updateDisplayList=function(t,i){e.prototype.updateDisplayList.call(this,t,i),this.updateSkinDisplayList()},r.updateSkinDisplayList=function(){},i}(t.Component);t.Range=e,egret.registerClass(e,"eui.Range"),t.registerBindable(e.prototype,"value")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.trackHighlight=null,this.thumb=null,this.track=null,this.$SliderBase={0:0,1:0,2:0,3:0,4:null,5:null,6:300,7:0,8:0,9:!0},this.maximum=10,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this)}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"slideDuration",function(){return this.$SliderBase[6]},function(t){this.$SliderBase[6]=+t||0}),r.pointToValue=function(t,e){return this.minimum},n(r,"liveDragging",function(){return this.$SliderBase[9]},function(t){this.$SliderBase[9]=!!t}),n(r,"pendingValue",function(){return this.$SliderBase[7]},function(t){t=+t||0;var e=this.$SliderBase;t!==e[7]&&(e[7]=t,this.invalidateDisplayList())}),r.setValue=function(t){this.$SliderBase[7]=t,e.prototype.setValue.call(this,t)},r.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i==this.thumb?(this.thumb.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onThumbTouchBegin,this),this.thumb.addEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i==this.track?(this.track.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTrackTouchBegin,this),this.track.addEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i===this.trackHighlight&&(this.trackHighlight.touchEnabled=!1,egret.is(this.trackHighlight,"egret.DisplayObjectContainer")&&(this.trackHighlight.touchChildren=!1))},r.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i==this.thumb?(this.thumb.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onThumbTouchBegin,this),this.thumb.removeEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i==this.track&&(this.track.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTrackTouchBegin,this),this.track.removeEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this))},r.onTrackOrThumbResize=function(t){this.updateSkinDisplayList()},r.onThumbTouchBegin=function(e){var i=this.$SliderBase;i[5]&&i[5].isPlaying&&this.stopAnimation();var n=this.$stage;n.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onStageTouchMove,this),n.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this);var s=this.thumb.globalToLocal(e.stageX,e.stageY,egret.$TempPoint);i[0]=s.x,i[1]=s.y,t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_START)},r.onStageTouchMove=function(t){var e=this.$SliderBase;e[2]=t.$stageX,e[3]=t.$stageY;var i=this.track;if(i){var n=i.globalToLocal(e[2],e[3],egret.$TempPoint),s=this.pointToValue(n.x-e[0],n.y-e[1]);s=this.nearestValidValue(s,this.snapInterval),this.updateWhenTouchMove(s),t.updateAfterEvent()}},r.updateWhenTouchMove=function(t){t!=this.$SliderBase[7]&&(this.liveDragging?(this.setValue(t),this.dispatchEventWith(egret.Event.CHANGE)):this.pendingValue=t)},r.onStageTouchEnd=function(e){var i=e.$currentTarget;i.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onStageTouchMove,this),i.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END);var n=this.$SliderBase;this.liveDragging||this.value==n[7]||(this.setValue(n[7]),this.dispatchEventWith(egret.Event.CHANGE))},r.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.stageTouchEndHandler,this),this.$SliderBase[4]=t.$target},r.stageTouchEndHandler=function(t){var e=t.$target,i=this.$SliderBase;t.$currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END,this.stageTouchEndHandler,this),i[4]!=e&&this.contains(e)&&egret.TouchEvent.dispatchTouchEvent(this,egret.TouchEvent.TOUCH_TAP,!0,!0,t.$stageX,t.$stageY,t.touchPointID),i[4]=null},r.$animationUpdateHandler=function(t){this.pendingValue=t.currentValue},r.animationEndHandler=function(e){this.setValue(this.$SliderBase[8]),this.dispatchEventWith(egret.Event.CHANGE),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},r.stopAnimation=function(){this.$SliderBase[5].stop(),this.setValue(this.nearestValidValue(this.pendingValue,this.snapInterval)),this.dispatchEventWith(egret.Event.CHANGE),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},r.onTrackTouchBegin=function(e){var i=this.thumb?this.thumb.width:0,n=this.thumb?this.thumb.height:0,s=e.$stageX-i/2,r=e.$stageY-n/2,a=this.track.globalToLocal(s,r,egret.$TempPoint),o=this.$Range,h=this.pointToValue(a.x,a.y);h=this.nearestValidValue(h,o[7]);var l=this.$SliderBase;if(h!=l[7])if(0!=l[6]){l[5]||(l[5]=new t.sys.Animation(this.$animationUpdateHandler,this),l[5].endFunction=this.animationEndHandler);var u=l[5];u.isPlaying&&this.stopAnimation(),l[8]=h,u.duration=l[6]*(Math.abs(l[7]-l[8])/(o[0]-o[2])),u.from=l[7],u.to=l[8],t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_START),u.play()}else this.setValue(h),this.dispatchEventWith(egret.Event.CHANGE)},i}(t.Range);t.SliderBase=e,egret.registerClass(e,"eui.SliderBase")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.pointToValue=function(t,e){if(!this.thumb||!this.track)return 0;var i=this.$Range,n=i[0]-i[2],s=this.getThumbRange();return i[2]+(0!=s?t/s*n:0)},n.getThumbRange=function(){var t=egret.$TempRectangle;this.track.getLayoutBounds(t);var e=t.width;return this.thumb.getLayoutBounds(t),e-t.width},n.updateSkinDisplayList=function(){if(this.thumb&&this.track){var t=this.$Range,e=this.getThumbRange(),i=t[0]-t[2],n=i>0?(this.pendingValue-t[2])/i*e:0,s=this.track.localToGlobal(n,0,egret.$TempPoint),r=s.x,a=s.y,o=this.thumb.$parent.globalToLocal(r,a,egret.$TempPoint).x,h=egret.$TempRectangle;if(this.thumb.getLayoutBounds(h),this.thumb.setLayoutBoundsPosition(Math.round(o),h.y),this.trackHighlight&&this.trackHighlight.$parent){var l=this.trackHighlight.$parent.globalToLocal(r,a,egret.$TempPoint).x-n;this.trackHighlight.x=Math.round(l),this.trackHighlight.width=Math.round(n)}}},e}(t.SliderBase);t.HSlider=e,egret.registerClass(e,"eui.HSlider")}(eui||(eui={}));var eui;!function(t){var e=[],i={},n={},s=function(){function t(){}var s=(__define,t),r=s.prototype;return r.getAsset=function(t,s,r){var a=i[t];if(a)return void a.push([s,r]);var o=e.pop();o||(o=new egret.ImageLoader),i[t]=[[s,r]],n[o.$hashCode]=t,o.addEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),o.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this),o.load(t)},r.onLoadFinish=function(t){var s=t.currentTarget;s.removeEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),s.removeEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this);var r;t.$type==egret.Event.COMPLETE&&(r=new egret.Texture,r._setBitmapData(s.data),s.data=null),e.push(s);var a=n[s.$hashCode];delete n[s.$hashCode];var o=i[a];delete i[a];for(var h=o.length,l=0;h>l;l++){var u=o[l];u[0].call(u[1],r,a)}},t}();t.DefaultAssetAdapter=s,egret.registerClass(s,"eui.DefaultAssetAdapter",["eui.IAssetAdapter"])}(eui||(eui={}));var eui;!function(t){var e=new t.DefaultAssetAdapter,i=function(i){function n(t){i.call(this),this.sourceChanged=!1,this._source=null,this.initializeUIValues(),t&&(this.source=t)}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"scale9Grid",function(){return this.$scale9Grid},function(t){this.$scale9Grid=t,this.$invalidateContentBounds(),this.invalidateDisplayList()}),s(a,"fillMode",function(){return this.$fillMode},function(t){t!=this.$fillMode&&(this.$fillMode=t,this.invalidateDisplayList())}),a.$setFillMode=function(t){var e=i.prototype.$setFillMode.call(this,t);return this.invalidateDisplayList(),e},s(a,"source",function(){return this._source},function(t){t!=this._source&&(this._source=t,this.$stage?this.parseSource():(this.sourceChanged=!0,this.invalidateProperties()))}),a.$setBitmapData=function(t){if(t==this.$Bitmap[0])return!1;var e=i.prototype.$setBitmapData.call(this,t);return this.sourceChanged=!1,this.invalidateSize(),this.invalidateDisplayList(),e},a.parseSource=function(){this.sourceChanged=!1;var t=this._source;if(t&&"string"==typeof t){var i=this.$stage.getImplementation("eui.IAssetAdapter");i||(i=e),i.getAsset(this._source,this.contentChanged,this)}else this.$setBitmapData(t)},a.contentChanged=function(t,e){e===this._source&&egret.is(t,"egret.Texture")&&(this.$setBitmapData(t),t&&this.dispatchEventWith(egret.Event.COMPLETE))},a.$measureContentBounds=function(t){var e=(this.$Bitmap,this.$Bitmap[0]);if(e){var i=this.$UIComponent,n=i[10],s=i[11];if(isNaN(n)||isNaN(s))return void t.setEmpty();"clip"==this.$fillMode&&(n>e.$getTextureWidth()&&(n=e.$getTextureWidth()),s>e.$getTextureHeight()&&(s=e.$getTextureHeight())),t.setTo(0,0,n,s)}else t.setEmpty()},a.$render=function(){var t=this.$Bitmap[0];if(t){var e=this.$UIComponent,i=e[10],n=e[11];if(0!==i&&0!==n){var s=this.$Bitmap;egret.sys.BitmapNode.$updateTextureData(this.$renderNode,s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],i,n,s[13],s[14],this.scale9Grid,this.$fillMode,s[10])}}},a.createChildren=function(){this.sourceChanged&&this.parseSource()},a.childrenCreated=function(){},a.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this),this.sourceChanged&&this.parseSource()},a.measure=function(){var t=this.$Bitmap[0];t?this.setMeasuredSize(t.$getTextureWidth(),t.$getTextureHeight()):this.setMeasuredSize(0,0)},a.updateDisplayList=function(t,e){this.$invalidateContentBounds()},a.invalidateParentLayout=function(){},a.setMeasuredSize=function(t,e){},a.invalidateProperties=function(){},a.validateProperties=function(){},a.invalidateSize=function(){},a.validateSize=function(t){},a.invalidateDisplayList=function(){},a.validateDisplayList=function(){},a.validateNow=function(){},a.setLayoutBoundsSize=function(t,e){},a.setLayoutBoundsPosition=function(t,e){},a.getLayoutBounds=function(t){},a.getPreferredBounds=function(t){},n -}(egret.Bitmap);t.Image=i,egret.registerClass(i,"eui.Image",["eui.UIComponent"]),t.sys.implementUIComponent(i,egret.Bitmap),t.registerProperty(i,"scale9Grid","egret.Rectangle")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this._data=null,this._selected=!1,this.itemIndex=-1,this.touchCaptured=!1,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this)}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"data",function(){return this._data},function(e){this._data=e,t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"data"),this.dataChanged()}),r.dataChanged=function(){},n(r,"selected",function(){return this._selected},function(t){this._selected!=t&&(this._selected=t,this.invalidateState())}),r.onTouchCancle=function(t){this.touchCaptured=!1;var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.invalidateState()},r.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!0,this.invalidateState(),t.updateAfterEvent()},r.onStageTouchEnd=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!1,this.invalidateState()},r.getCurrentState=function(){var t="up";if(this.touchCaptured&&(t="down"),this._selected){var e=t+"AndSelected",i=this.skin;return i&&i.hasState(e)?e:"disabled"==t?"disabled":"down"}return t},i}(t.Component);t.ItemRenderer=e,egret.registerClass(e,"eui.ItemRenderer",["eui.IItemRenderer","eui.UIComponent"]),t.registerBindable(e.prototype,"data")}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(t){i.call(this),this._widthConstraint=0/0,this.availableWidth=0/0,this.initializeUIValues(),this.text=t}__extends(n,i);var s=(__define,n),r=s.prototype;return r.$invalidateContentBounds=function(){i.prototype.$invalidateContentBounds.call(this),this.invalidateSize()},r.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),s=e.prototype.$setWidth.call(this,t);return n&&s},r.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),s=e.prototype.$setHeight.call(this,t);return n&&s},r.$setText=function(e){var n=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),n},r.createChildren=function(){},r.childrenCreated=function(){},r.commitProperties=function(){},r.measure=function(){var t=this.$UIComponent,e=this.$TextField,n=e[3];isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(this.availableWidth=t[13]):this.availableWidth=t[8]:(this.availableWidth=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,this.availableWidth),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,n)},r.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),this._widthConstraint=t,!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&this.invalidateSize()}},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},n}(egret.TextField);t.Label=i,egret.registerClass(i,"eui.Label",["eui.UIComponent","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.TextField),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$ListBase={0:!1,1:!1,2:-2,3:-1,4:!1,5:void 0,6:!1,7:null,8:!1}}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"requireSelection",function(){return this.$ListBase[0]},function(t){t=!!t;var e=this.$ListBase;t!==e[0]&&(e[0]=t,t&&(e[1]=!0,this.invalidateProperties()))}),n(r,"selectedIndex",function(){return this.$getSelectedIndex()},function(t){t=0|+t,this.setSelectedIndex(t,!1)}),r.$getSelectedIndex=function(){var t=this.$ListBase;return t[2]!=i.NO_PROPOSED_SELECTION?t[2]:t[3]},r.setSelectedIndex=function(t,e){if(t!=this.selectedIndex){var i=this.$ListBase;e&&(i[4]=i[4]||e),i[2]=t,this.invalidateProperties()}},n(r,"selectedItem",function(){var t=this.$ListBase;if(void 0!==t[5])return t[5];var e=this.$getSelectedIndex();if(e!=i.NO_SELECTION&&null!=this.$dataProvider)return this.$dataProvider.length>e?this.$dataProvider.getItemAt(e):void 0},function(t){this.setSelectedItem(t,!1)}),r.setSelectedItem=function(t,e){if(void 0===e&&(e=!1),this.selectedItem!==t){var i=this.$ListBase;e&&(i[4]=i[4]||e),i[5]=t,this.invalidateProperties()}},r.commitProperties=function(){var n=this.$dataProviderChanged;e.prototype.commitProperties.call(this);var s=this.$ListBase,r=this.$getSelectedIndex(),a=this.$dataProvider;n&&(r>=0&&a&&r0&&(s[2]=0)),void 0!==s[5]&&(a?s[2]=a.getItemIndex(s[5]):s[2]=i.NO_SELECTION,s[5]=void 0);var o=!1;s[2]!=i.NO_PROPOSED_SELECTION&&(o=this.commitSelection()),s[6]&&(s[6]=!1,o||t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"))},r.updateRenderer=function(t,i,n){return this.itemSelected(i,this.$isItemIndexSelected(i)),e.prototype.updateRenderer.call(this,t,i,n)},r.itemSelected=function(t,e){var i=this.$indexToRenderer[t];i&&(i.selected=e)},r.$isItemIndexSelected=function(t){return t==this.selectedIndex},r.commitSelection=function(e){void 0===e&&(e=!0);var n=this.$dataProvider,s=this.$ListBase,r=n?n.length-1:-1,a=s[3],o=s[2];if(or&&(o=r),s[0]&&o==i.NO_SELECTION&&n&&n.length>0)return s[2]=i.NO_PROPOSED_SELECTION,s[4]=!1,!1;if(s[4]){var h=this.dispatchEventWith(egret.Event.CHANGING,!1,!0);if(!h)return this.itemSelected(s[2],!1),s[2]=i.NO_PROPOSED_SELECTION,s[4]=!1,!1}return s[3]=o,s[2]=i.NO_PROPOSED_SELECTION,a!=i.NO_SELECTION&&this.itemSelected(a,!1),s[3]!=i.NO_SELECTION&&this.itemSelected(s[3],!0),e&&(s[4]&&(this.dispatchEventWith(egret.Event.CHANGE),s[4]=!1),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedItem")),!0},r.adjustSelection=function(t,e){void 0===e&&(e=!1);var n=this.$ListBase;n[2]!=i.NO_PROPOSED_SELECTION?n[2]=t:n[3]=t,n[6]=!0,this.invalidateProperties()},r.itemAdded=function(t,n){e.prototype.itemAdded.call(this,t,n);var s=this.$getSelectedIndex();s==i.NO_SELECTION?this.$ListBase[0]&&this.adjustSelection(n,!0):s>=n&&this.adjustSelection(s+1,!0)},r.itemRemoved=function(t,n){if(e.prototype.itemRemoved.call(this,t,n),this.selectedIndex!=i.NO_SELECTION){var s=this.$getSelectedIndex();n==s?this.requireSelection&&this.$dataProvider&&this.$dataProvider.length>0?0==n?(this.$ListBase[2]=0,this.invalidateProperties()):this.setSelectedIndex(0,!1):this.adjustSelection(-1,!1):s>n&&this.adjustSelection(s-1,!1)}},r.onCollectionChange=function(n){e.prototype.onCollectionChange.call(this,n),n.kind==t.CollectionEventKind.RESET?0==this.$dataProvider.length&&this.setSelectedIndex(i.NO_SELECTION,!1):n.kind==t.CollectionEventKind.REFRESH&&this.dataProviderRefreshed()},r.dataProviderRefreshed=function(){this.setSelectedIndex(i.NO_SELECTION,!1)},r.rendererAdded=function(t,e,i){t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onRendererTouchBegin,this),t.addEventListener(egret.TouchEvent.TOUCH_END,this.onRendererTouchEnd,this),t.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onRendererTouchCancle,this)},r.rendererRemoved=function(t,e,i){t.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onRendererTouchBegin,this),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onRendererTouchEnd,this),t.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onRendererTouchCancle,this)},r.onRendererTouchBegin=function(t){var e=this.$ListBase;t.$isDefaultPrevented||(e[8]=!1,e[7]=t.$currentTarget,this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this))},r.onRendererTouchCancle=function(t){var e=this.$ListBase;e[7]=null,e[8]=!0,this.$stage&&this.$stage.removeEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this)},r.onRendererTouchEnd=function(e){var i=this.$ListBase,n=e.$currentTarget,s=i[7];n==s&&(i[8]||(this.setSelectedIndex(n.itemIndex,!0),t.ItemTapEvent.dispatchItemTapEvent(this,t.ItemTapEvent.ITEM_TAP,n)),i[8]=!1)},r.stage_touchEndHandler=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this),this.$ListBase[7]=null},i.NO_SELECTION=-1,i.NO_PROPOSED_SELECTION=-2,i}(t.DataGroup);t.ListBase=e,egret.registerClass(e,"eui.ListBase"),t.registerBindable(e.prototype,"selectedIndex"),t.registerBindable(e.prototype,"selectedItem")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=this;e.apply(this,arguments),this.allowMultipleSelection=!1,this._selectedIndices=[],this.isValidIndex=function(e,i,n){return t.$dataProvider&&e>=0&&e0?this._proposedSelectedIndices[0]:-1:this.$getSelectedIndex()},function(t){this.setSelectedIndex(t)}),n(r,"selectedItems",function(){var t=[],e=this.selectedIndices;if(e)for(var i=e.length,n=0;i>n;n++)t[n]=this.$dataProvider.getItemAt(e[n]);return t},function(t){var e=[];if(t)for(var i=t.length,n=0;i>n;n++){var s=this.$dataProvider.getItemIndex(t[n]);if(-1!=s&&e.splice(0,0,s),-1==s){e=[];break}}this.setSelectedIndices(e,!1)}),r.setSelectedIndices=function(t,e){var i=this.$ListBase;e&&(i[4]=i[4]||e),t?this._proposedSelectedIndices=t:this._proposedSelectedIndices=[],this.invalidateProperties()},r.commitProperties=function(){e.prototype.commitProperties.call(this),this._proposedSelectedIndices&&this.commitSelection()},r.commitSelection=function(i){void 0===i&&(i=!0);var n=this.$ListBase,s=n[3];if(this._proposedSelectedIndices){if(this._proposedSelectedIndices=this._proposedSelectedIndices.filter(this.isValidIndex),!this.allowMultipleSelection&&this._proposedSelectedIndices.length>0){var r=[];r.push(this._proposedSelectedIndices[0]),this._proposedSelectedIndices=r}this._proposedSelectedIndices.length>0?n[2]=this._proposedSelectedIndices[0]:n[2]=-1}var a=e.prototype.commitSelection.call(this,!1);if(!a)return this._proposedSelectedIndices=null,!1;var o=this.$getSelectedIndex();return o>t.ListBase.NO_SELECTION&&(this._proposedSelectedIndices?-1==this._proposedSelectedIndices.indexOf(o)&&this._proposedSelectedIndices.push(o):this._proposedSelectedIndices=[o]),this._proposedSelectedIndices&&(-1!=this._proposedSelectedIndices.indexOf(s)&&this.itemSelected(s,!0),this.commitMultipleSelection()),i&&a&&(n[4]&&(this.dispatchEventWith(egret.Event.CHANGE),n[4]=!1),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedItem")),a},r.commitMultipleSelection=function(){var t,e,i=[],n=[],s=this._selectedIndices,r=this._proposedSelectedIndices;if(s.length>0&&r.length>0){for(e=r.length,t=0;e>t;t++)-1==s.indexOf(r[t])&&n.push(r[t]);for(e=s.length,t=0;e>t;t++)-1==r.indexOf(s[t])&&i.push(s[t])}else s.length>0?i=s:r.length>0&&(n=r);if(this._selectedIndices=r,i.length>0)for(e=i.length,t=0;e>t;t++)this.itemSelected(i[t],!1);if(n.length>0)for(e=n.length,t=0;e>t;t++)this.itemSelected(n[t],!0);this._proposedSelectedIndices=null},r.$isItemIndexSelected=function(t){return this.allowMultipleSelection?-1!=this._selectedIndices.indexOf(t):e.prototype.$isItemIndexSelected.call(this,t)},r.dataProviderRefreshed=function(){this.allowMultipleSelection||e.prototype.dataProviderRefreshed.call(this)},r.calculateSelectedIndices=function(t){var e=[],i=this._selectedIndices,n=i.length;if(n>0){if(1==n&&i[0]==t)return this.$ListBase[0]?(e.splice(0,0,i[0]),e):e;for(var s=!1,r=0;n>r;r++)i[r]==t?s=!0:i[r]!=t&&e.splice(0,0,i[r]);return s||e.splice(0,0,t),e}return e.splice(0,0,t),e},r.onRendererTouchEnd=function(i){if(this.allowMultipleSelection){var n=i.currentTarget,s=this.$ListBase[7];if(n!=s)return;this.setSelectedIndices(this.calculateSelectedIndices(n.itemIndex),!0),t.ItemTapEvent.dispatchItemTapEvent(this,t.ItemTapEvent.ITEM_TAP,n)}else e.prototype.onRendererTouchEnd.call(this,i)},i}(t.ListBase);t.List=e,egret.registerClass(e,"eui.List")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.closeButton=null,this.moveArea=null,this.titleDisplay=null,this._title="",this.offsetPointX=0,this.offsetPointY=0,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onWindowTouchBegin,this,!1,100)}__extends(i,e);var n=__define,s=i,r=s.prototype;return r.onWindowTouchBegin=function(t){this.$parent.addChild(this)},n(r,"elementsContent",void 0,function(t){if(t)for(var e=t.length,i=0;e>i;i++)this.addChild(t[i])}),n(r,"title",function(){return this._title},function(t){this._title=t,this.titleDisplay&&(this.titleDisplay.text=this.title)}),r.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i==this.titleDisplay?this.titleDisplay.text=this._title:i==this.moveArea?this.moveArea.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this):i==this.closeButton&&this.closeButton.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onCloseButtonClick,this)},r.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i==this.moveArea?this.moveArea.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this):i==this.closeButton&&this.closeButton.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onCloseButtonClick,this)},r.onCloseButtonClick=function(e){t.UIEvent.dispatchUIEvent(this,t.UIEvent.CLOSING,!0,!0)&&this.close()},r.close=function(){this.$parent&&this.$parent.removeChild(this)},r.onTouchBegin=function(t){this.$includeInLayout=!1,this.offsetPointX=this.x-t.$stageX,this.offsetPointY=this.y-t.$stageY,this.$stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this)},r.onTouchMove=function(t){this.x=t.$stageX+this.offsetPointX,this.y=t.$stageY+this.offsetPointY},r.onTouchEnd=function(t){this.$stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.$stage.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this)},i}(t.Component);t.Panel=e,egret.registerClass(e,"eui.Panel"),t.registerProperty(e,"elementsContent","Array",!0)}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.thumb=null,this.labelDisplay=null,this._labelFunction=null,this._slideDuration=500,this._direction=t.Direction.LTR,this.slideToValue=0,this.animationValue=0,this.thumbInitX=0,this.thumbInitY=0,this.animation=new t.sys.Animation(this.animationUpdateHandler,this)}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"labelFunction",function(){return this._labelFunction},function(t){this._labelFunction!=t&&(this._labelFunction=t,this.invalidateDisplayList())}),r.valueToLabel=function(t,e){return null!=this.labelFunction?this._labelFunction(t,e):t+" / "+e},n(r,"slideDuration",function(){return this._slideDuration},function(t){t=0|+t,this._slideDuration!==t&&(this._slideDuration=t,this.animation.isPlaying&&(this.animation.stop(),this.setValue(this.slideToValue)))}),n(r,"direction",function(){return this._direction},function(t){this._direction!=t&&(this.thumb&&(this.thumb.x=this.thumbInitX),this.thumb&&(this.thumb.y=this.thumbInitY),this._direction=t,this.invalidateDisplayList())}),r.$setValue=function(t){if(this.value===t)return!1;var i=this.$Range,n=e.prototype.$setValue.call(this,t);if(this._slideDuration>0&&this.$stage){this.validateProperties();var s=this.animation;if(s.isPlaying&&(this.animationValue=this.slideToValue,this.invalidateDisplayList(),s.stop()),this.slideToValue=this.nearestValidValue(t,i[7]),this.slideToValue===this.animationValue)return n;var r=this._slideDuration*(Math.abs(this.animationValue-this.slideToValue)/(i[0]-i[2]));s.duration=r===1/0?0:r,s.from=this.animationValue,s.to=this.slideToValue,s.play()}else this.animationValue=this.value;return n},r.animationUpdateHandler=function(t){var e=this.$Range,i=this.nearestValidValue(t.currentValue,e[7]);this.animationValue=Math.min(e[0],Math.max(e[2],i)),this.invalidateDisplayList()},r.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i===this.thumb&&(this.thumb.x&&(this.thumbInitX=this.thumb.x),this.thumb.y&&(this.thumbInitY=this.thumb.y),this.thumb.addEventListener(egret.Event.RESIZE,this.onThumbResize,this))},r.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i===this.thumb&&this.thumb.removeEventListener(egret.Event.RESIZE,this.onThumbResize,this)},r.onThumbResize=function(t){this.updateSkinDisplayList()},r.updateSkinDisplayList=function(){var e=this.animation.isPlaying?this.animationValue:this.value,i=this.maximum,n=this.thumb;if(n){var s=n.width,r=n.height,a=Math.round(e/i*s);(0>a||a===1/0)&&(a=0);var o=Math.round(e/i*r);(0>o||o===1/0)&&(o=0);var h=n.$scrollRect;h||(h=egret.$TempRectangle),h.setTo(0,0,s,r);var l=n.x-h.x,u=n.y-h.y;switch(this._direction){case t.Direction.LTR:h.width=a,n.x=l;break;case t.Direction.RTL:h.width=a,h.x=s-a,n.x=h.x;break;case t.Direction.TTB:h.height=o,n.y=u;break;case t.Direction.BTT:h.height=o,h.y=r-o,n.y=h.y}n.scrollRect=h}this.labelDisplay&&(this.labelDisplay.text=this.valueToLabel(e,i))},i}(t.Range);t.ProgressBar=e,egret.registerClass(e,"eui.ProgressBar")}(eui||(eui={}));var eui;!function(t){var e={},i=function(i){function n(){i.call(this),this.$indexNumber=0,this.$radioButtonGroup=null,this._group=null,this.groupChanged=!1,this._groupName="radioGroup",this._value=null,this.groupName="radioGroup"}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"enabled",function(){return this.$Component[3]?!this.$radioButtonGroup||this.$radioButtonGroup.$enabled:!1},function(t){this.$setEnabled(t)}),s(a,"group",function(){if(!this._group&&this._groupName){var i=e[this._groupName];i||(i=new t.RadioButtonGroup,i.$name=this._groupName,e[this._groupName]=i),this._group=i}return this._group},function(t){this._group!=t&&(this.$radioButtonGroup&&this.$radioButtonGroup.$removeInstance(this,!1),this._group=t,this._groupName=t?this.group.$name:"radioGroup",this.groupChanged=!0,this.invalidateProperties(),this.invalidateDisplayList())}),s(a,"groupName",function(){return this._groupName},function(t){t&&""!=t&&(this._groupName=t,this.$radioButtonGroup&&this.$radioButtonGroup.$removeInstance(this,!1),this._group=null,this.groupChanged=!0,this.invalidateProperties(),this.invalidateDisplayList())}),a.$setSelected=function(t){var e=i.prototype.$setSelected.call(this,t);return this.invalidateDisplayList(),e},s(a,"value",function(){return this._value},function(e){this._value!=e&&(this._value=e,this.$selected&&this.group&&t.PropertyEvent.dispatchPropertyEvent(this.group,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue"))}),a.commitProperties=function(){this.groupChanged&&(this.addToGroup(),this.groupChanged=!1),i.prototype.commitProperties.call(this)},a.updateDisplayList=function(t,e){i.prototype.updateDisplayList.call(this,t,e),this.group&&(this.$selected?this._group.$setSelection(this,!1):this.group.selection==this&&this._group.$setSelection(null,!1))},a.buttonReleased=function(){this.enabled&&!this.selected&&(this.$radioButtonGroup||this.addToGroup(),i.prototype.buttonReleased.call(this),this.group.$setSelection(this,!0))},a.addToGroup=function(){var t=this.group;return t&&t.$addInstance(this),t},n}(t.ToggleButton);t.RadioButton=i,egret.registerClass(i,"eui.RadioButton")}(eui||(eui={}));var eui;!function(t){function e(t,i){var n=t.parent,s=i.parent;if(!n||!s)return 0;var r=t.$nestLevel,a=i.$nestLevel,o=0,h=0;return n==s&&(o=n.getChildIndex(t),h=s.getChildIndex(i)),r>a||o>h?1:a>r||h>o?-1:t==i?0:e(n,s)}var i=0,n=function(n){function s(){n.call(this),this.$name=null,this.radioButtons=[],this.$enabled=!0,this._selectedValue=null,this._selection=null,this.$name="_radioButtonGroup"+i++}__extends(s,n);var r=__define,a=s,o=a.prototype;return o.getRadioButtonAt=function(t){return this.radioButtons[t]},r(o,"enabled",function(){return this.$enabled},function(t){if(t=!!t,this.$enabled!==t){this.$enabled=t;for(var e=this.radioButtons,i=e.length,n=0;i>n;n++)e[n].invalidateState()}}),r(o,"numRadioButtons",function(){return this.radioButtons.length}),r(o,"selectedValue",function(){return this.selection?null!=this.selection.value?this.selection.value:this.selection.label:null},function(e){if(this._selectedValue=e,null==e)return void this.$setSelection(null,!1);for(var i=this.numRadioButtons,n=0;i>n;n++){var s=this.radioButtons[n];if(s.value==e||s.label==e){this.changeSelection(n,!1),this._selectedValue=null,t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue");break}}}),r(o,"selection",function(){return this._selection},function(t){this._selection!=t&&this.$setSelection(t,!1)}),o.$addInstance=function(t){t.addEventListener(egret.Event.REMOVED,this.removedHandler,this);var i=this.radioButtons;i.push(t),i.sort(e);for(var n=i.length,s=0;n>s;s++)i[s].$indexNumber=s;this._selectedValue&&(this.selectedValue=this._selectedValue),1==t.selected&&(this.selection=t),t.$radioButtonGroup=this,t.invalidateState()},o.$removeInstance=function(t,e){if(t)for(var i=!1,n=this.radioButtons,s=n.length,r=0;s>r;r++){var a=n[r];i?a.$indexNumber=a.$indexNumber-1:a==t&&(e&&t.addEventListener(egret.Event.ADDED,this.addedHandler,this),t==this._selection&&(this._selection=null),t.$radioButtonGroup=null,t.invalidateState(),this.radioButtons.splice(r,1),i=!0,r--,s--)}},o.$setSelection=function(e,i){if(this._selection==e)return!1;if(e){for(var n=this.numRadioButtons,s=0;n>s;s++)if(e==this.getRadioButtonAt(s)){this.changeSelection(s,i);break}}else this._selection&&(this._selection.selected=!1,this._selection=null,i&&this.dispatchEventWith(egret.Event.CHANGE));return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue"),!0},o.changeSelection=function(t,e){var i=this.getRadioButtonAt(t);i&&i!=this._selection&&(this._selection&&(this._selection.selected=!1),this._selection=i,this._selection.selected=!0,e&&this.dispatchEventWith(egret.Event.CHANGE))},o.addedHandler=function(t){var e=t.target;e&&(e.removeEventListener(egret.Event.ADDED,this.addedHandler,this),this.$addInstance(e))},o.removedHandler=function(t){var e=t.target;e&&(e.removeEventListener(egret.Event.REMOVED,this.removedHandler,this),this.$removeInstance(e,!0))},s}(egret.EventDispatcher);t.RadioButtonGroup=n,egret.registerClass(n,"eui.RadioButtonGroup"),t.registerBindable(n.prototype,"selectedValue")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n){t.call(this),this.$fillColor=0,this.$fillAlpha=1,this.$strokeColor=4473924,this.$strokeAlpha=1,this.$strokeWeight=0,this.$ellipseWidth=0,this.$ellipseHeight=0,this.touchChildren=!1,this.$graphics=new egret.Graphics,this.$graphics.$setTarget(this),this.width=e,this.height=i,this.fillColor=n}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"graphics",function(){return this.$graphics}),s.$measureContentBounds=function(t){this.$graphics&&t.setTo(0,0,this.width,this.height)},i(s,"fillColor",function(){return this.$fillColor},function(t){void 0!=t&&this.$fillColor!=t&&(this.$fillColor=t,this.invalidateDisplayList())}),i(s,"fillAlpha",function(){return this.$fillAlpha},function(t){this.$fillAlpha!=t&&(this.$fillAlpha=t,this.invalidateDisplayList())}),i(s,"strokeColor",function(){return this.$strokeColor},function(t){this.$strokeColor!=t&&(this.$strokeColor=t,this.invalidateDisplayList())}),i(s,"strokeAlpha",function(){return this.$strokeAlpha},function(t){this.$strokeAlpha!=t&&(this.$strokeAlpha=t,this.invalidateDisplayList())}),i(s,"strokeWeight",function(){return this.$strokeWeight},function(t){this.$strokeWeight!=t&&(this.$strokeWeight=t,this.invalidateDisplayList())}),i(s,"ellipseWidth",function(){return this.$ellipseWidth},function(t){this.$ellipseWidth!=t&&(this.$ellipseWidth=t,this.invalidateDisplayList())}),i(s,"ellipseHeight",function(){return this.$ellipseHeight},function(t){this.$ellipseHeight!=t&&(this.$ellipseHeight=t,this.invalidateDisplayList())}),s.updateDisplayList=function(t,e){var i=this.graphics;i.clear(),this.$strokeWeight>0&&(i.beginFill(this.$fillColor,0),i.lineStyle(this.$strokeWeight,this.$strokeColor,this.$strokeAlpha,!0,"normal","square","miter"),0==this.$ellipseWidth?i.drawRect(this.$strokeWeight/2,this.$strokeWeight/2,t-this.$strokeWeight,e-this.$strokeWeight):i.drawRoundRect(this.$strokeWeight/2,this.$strokeWeight/2,t-this.$strokeWeight,e-this.$strokeWeight,this.$ellipseWidth,0),i.endFill()),i.beginFill(this.$fillColor,this.$fillAlpha),i.lineStyle(this.$strokeWeight,this.$strokeColor,0,!0,"normal","square","miter"),0==this.$ellipseWidth?i.drawRect(this.$strokeWeight,this.$strokeWeight,t-2*this.$strokeWeight,e-2*this.$strokeWeight):i.drawRoundRect(this.$strokeWeight,this.$strokeWeight,t-2*this.$strokeWeight,e-2*this.$strokeWeight,this.$ellipseWidth,0),i.endFill(),this.$invalidateContentBounds()},e}(t.Component);t.Rect=e,egret.registerClass(e,"eui.Rect")}(eui||(eui={}));var eui;!function(t){var e,i=function(i){function n(){i.call(this),this.$bounces=!0,this.horizontalScrollBar=null,this.verticalScrollBar=null;var e=new t.sys.TouchScroll(this.horizontalUpdateHandler,this.horizontalEndHandler,this),n=new t.sys.TouchScroll(this.verticalUpdateHandler,this.verticalEndHanlder,this);this.$Scroller={0:"auto",1:"auto",2:null,3:0,4:0,5:!1,6:!1,7:!1,8:e,9:n,10:null,11:!1,12:!1}}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"bounces",function(){return this.$bounces},function(t){this.$bounces=!!t;var e=this.$Scroller[8];e&&(e.$bounces=this.$bounces);var i=this.$Scroller[9];i&&(i.$bounces=this.$bounces)}),s(a,"throwSpeed",function(){return this.$Scroller[8].$scrollFactor},function(t){t=+t,0>t&&(t=0),this.$Scroller[8].$scrollFactor=t,this.$Scroller[9].$scrollFactor=t}),a.$getThrowInfo=function(i,n){return e?(e.currentPos=i,e.toPos=n):e=new t.ScrollerThrowEvent(t.ScrollerThrowEvent.THROW,!1,!1,i,n),e},s(a,"scrollPolicyV",function(){return this.$Scroller[0]},function(t){var e=this.$Scroller;e[0]!=t&&(e[0]=t,this.checkScrollPolicy())}),s(a,"scrollPolicyH",function(){return this.$Scroller[1]},function(t){var e=this.$Scroller;e[1]!=t&&(e[1]=t,this.checkScrollPolicy())}),a.stopAnimation=function(){var e=this.$Scroller,i=e[9],n=e[8];i.animation.isPlaying?t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END):n.animation.isPlaying&&t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END),i.stop(),n.stop();var s=this.verticalScrollBar,r=this.horizontalScrollBar;s&&s.autoVisibility&&(s.visible=!1),r&&r.autoVisibility&&(r.visible=!1)},s(a,"viewport",function(){return this.$Scroller[10]},function(t){var e=this.$Scroller;t!=e[10]&&(this.uninstallViewport(),e[10]=t,e[11]=!1,this.installViewport())}),a.installViewport=function(){var t=this.viewport;t&&(this.addChildAt(t,0),t.scrollEnabled=!0,t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBeginCapture,this,!0),t.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEndCapture,this,!0),t.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouchTapCapture,this,!0),t.addEventListener(egret.Event.REMOVED,this.onViewPortRemove,this)),this.horizontalScrollBar&&(this.horizontalScrollBar.viewport=t),this.verticalScrollBar&&(this.verticalScrollBar.viewport=t)},a.uninstallViewport=function(){this.horizontalScrollBar&&(this.horizontalScrollBar.viewport=null),this.verticalScrollBar&&(this.verticalScrollBar.viewport=null);var t=this.viewport;t&&(t.scrollEnabled=!1,t.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBeginCapture,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEndCapture,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouchTapCapture,this,!0),t.removeEventListener(egret.Event.REMOVED,this.onViewPortRemove,this),0==this.$Scroller[11]&&this.removeChild(t))},a.onViewPortRemove=function(t){t.target==this.viewport&&(this.$Scroller[11]=!0,this.viewport=null)},a.setSkin=function(t){i.prototype.setSkin.call(this,t);var e=this.viewport;e&&this.addChildAt(e,0)},a.onTouchBeginCapture=function(t){this.$Scroller[12]=!1;var e=this.checkScrollPolicy();e&&this.onTouchBegin(t)},a.onTouchEndCapture=function(t){this.$Scroller[12]&&(t.stopPropagation(),this.onTouchEnd(t))},a.onTouchTapCapture=function(t){this.$Scroller[12]&&t.stopPropagation()},a.checkScrollPolicy=function(){var t=this.$Scroller,e=t[10];if(!e)return!1;var i,n=e.$UIComponent;switch(t[1]){case"auto":i=e.contentWidth>n[10]||0!==e.scrollH?!0:!1;break;case"on":i=!0;break;case"off":i=!1}t[6]=i;var s;switch(t[0]){case"auto":s=e.contentHeight>n[11]||0!==e.scrollV?!0:!1;break;case"on":s=!0;break;case"off":s=!1}return t[7]=s,i||s},a.onTouchBegin=function(t){if(!t.isDefaultPrevented()&&this.checkScrollPolicy()){this.downTarget=t.target;var e=this.$Scroller;this.stopAnimation(),e[3]=t.$stageX,e[4]=t.$stageY,e[6]&&e[8].start(t.$stageX),e[7]&&e[9].start(t.$stageY);var i=this.$stage;this.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),i.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this,!0),this.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancel,this),this.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveListeners,this)}},a.onTouchMove=function(e){if(!e.isDefaultPrevented()){var i=this.$Scroller;if(!i[5]){if(Math.abs(i[3]-e.$stageX)h;h++)if(s[h]===e){o=h;break}s.splice(0,o+1),a-=o+1,this.$dispatchPropagationEvent(i,s,a),egret.Event.release(i)}},a.onTouchEnd=function(t){var e=this.$Scroller;e[5]=!1,this.onRemoveListeners();var i=e[10],n=i.$UIComponent;e[8].isStarted()&&e[8].finish(i.scrollH,i.contentWidth-n[10]),e[9].isStarted()&&e[9].finish(i.scrollV,i.contentHeight-n[11])},a.onRemoveListeners=function(){var t=this.$stage;this.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancel,!0),this.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveListeners,this) -},a.horizontalUpdateHandler=function(t){this.dispatchEventWith(egret.Event.CHANGE),this.$Scroller[10].scrollH=t},a.verticalUpdateHandler=function(t){this.dispatchEventWith(egret.Event.CHANGE),this.$Scroller[10].scrollV=t},a.horizontalEndHandler=function(){this.$Scroller[9].isPlaying()||this.onChangeEnd()},a.verticalEndHanlder=function(){this.$Scroller[8].isPlaying()||this.onChangeEnd()},a.onChangeEnd=function(){var e=this.$Scroller,i=this.horizontalScrollBar,n=this.verticalScrollBar;(i&&i.visible||n&&n.visible)&&(e[2]||(e[2]=new egret.Timer(200,1),e[2].addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.onAutoHideTimer,this)),e[2].reset(),e[2].start()),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},a.onAutoHideTimer=function(t){var e=this.horizontalScrollBar,i=this.verticalScrollBar;e&&e.autoVisibility&&(e.visible=!1),i&&i.autoVisibility&&(i.visible=!1)},a.updateDisplayList=function(t,e){i.prototype.updateDisplayList.call(this,t,e);var n=this.viewport;n&&(n.setLayoutBoundsSize(t,e),n.setLayoutBoundsPosition(0,0))},a.partAdded=function(t,e){i.prototype.partAdded.call(this,t,e),e==this.horizontalScrollBar?(this.horizontalScrollBar.touchChildren=!1,this.horizontalScrollBar.touchEnabled=!1,this.horizontalScrollBar.viewport=this.viewport,this.horizontalScrollBar.autoVisibility&&(this.horizontalScrollBar.visible=!1)):e==this.verticalScrollBar&&(this.verticalScrollBar.touchChildren=!1,this.verticalScrollBar.touchEnabled=!1,this.verticalScrollBar.viewport=this.viewport,this.verticalScrollBar.autoVisibility&&(this.verticalScrollBar.visible=!1))},n.scrollThreshold=5,n}(t.Component);t.Scroller=i,egret.registerClass(i,"eui.Scroller"),t.registerProperty(i,"viewport","eui.IViewport",!0)}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.apply(this,arguments),this.maxWidth=1e5,this.minWidth=0,this.maxHeight=1e5,this.minHeight=0,this.width=0/0,this.height=0/0,this.$elementsContent=[],this._hostComponent=null,this.$stateValues=new t.sys.StateValues}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"elementsContent",void 0,function(t){this.$elementsContent=t}),n(r,"hostComponent",function(){return this._hostComponent},function(e){if(this._hostComponent!=e){this._hostComponent&&this._hostComponent.removeEventListener(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this),this._hostComponent=e;var i=this.$stateValues;i.parent=e,e&&(this.commitCurrentState(),this.$stateValues.intialized||(e.$stage?this.initializeStates(e.$stage):e.once(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this))),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"hostComponent")}}),r.onAddedToStage=function(t){this.initializeStates(this._hostComponent.$stage)},i}(egret.EventDispatcher);t.Skin=e,egret.registerClass(e,"eui.Skin"),t.sys.mixin(e,t.sys.StateClient),t.registerProperty(e,"elementsContent","Array",!0),t.registerProperty(e,"states","State[]"),t.registerBindable(e.prototype,"hostComponent")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.indexBeingUpdated=!1,this.requireSelection=!0,this.useVirtualLayout=!1}__extends(i,e);var n=(__define,i),s=n.prototype;return s.createChildren=function(){if(!this.$layout){var i=new t.HorizontalLayout;i.gap=0,i.horizontalAlign=t.JustifyAlign.JUSTIFY,i.verticalAlign=t.JustifyAlign.CONTENT_JUSTIFY,this.$setLayout(i)}e.prototype.createChildren.call(this)},s.$setDataProvider=function(i){var n=this.$dataProvider;return n&&n instanceof t.ViewStack&&(n.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onViewStackIndexChange,this),this.removeEventListener(egret.Event.CHANGE,this.onIndexChanged,this)),i&&i instanceof t.ViewStack&&(i.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onViewStackIndexChange,this),this.addEventListener(egret.Event.CHANGE,this.onIndexChanged,this)),e.prototype.$setDataProvider.call(this,i)},s.onIndexChanged=function(t){this.indexBeingUpdated=!0,this.$dataProvider.selectedIndex=this.selectedIndex,this.indexBeingUpdated=!1},s.onViewStackIndexChange=function(t){"selectedIndex"!=t.property||this.indexBeingUpdated||this.setSelectedIndex(this.$dataProvider.selectedIndex,!1)},i}(t.ListBase);t.TabBar=e,egret.registerClass(e,"eui.TabBar")}(eui||(eui={}));var eui;!function(t){var e=egret.FocusEvent,i=function(i){function n(){i.call(this),this.isFocus=!1,this.$TextInput={0:null,1:null,2:null,3:null,4:null,5:null,6:"",7:null,8:egret.TextFieldInputType.TEXT}}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"prompt",function(){return this.promptDisplay?this.promptDisplay.text:this.$TextInput[0]},function(t){this.$TextInput[0]=t,this.promptDisplay&&(this.promptDisplay.text=t),this.invalidateProperties(),this.invalidateState()}),s(a,"displayAsPassword",function(){if(this.textDisplay)return this.textDisplay.displayAsPassword;var t=this.$TextInput[1];return t?t:!1},function(t){this.$TextInput[1]=t,this.textDisplay&&(this.textDisplay.displayAsPassword=t),this.invalidateProperties()}),s(a,"inputType",function(){return console.log("get inputType"),this.textDisplay?this.textDisplay.inputType:this.$TextInput[8]},function(t){console.log("set inputType"),this.$TextInput[8]=t,this.textDisplay&&(this.textDisplay.inputType=t),this.invalidateProperties()}),s(a,"textColor",function(){return this.textDisplay?this.textDisplay.textColor:this.$TextInput[2]},function(t){this.$TextInput[2]=t,this.textDisplay&&(this.textDisplay.textColor=t),this.invalidateProperties()}),s(a,"maxChars",function(){if(this.textDisplay)return this.textDisplay.maxChars;var t=this.$TextInput[3];return t?t:0},function(t){this.$TextInput[3]=t,this.textDisplay&&(this.textDisplay.maxChars=t),this.invalidateProperties()}),s(a,"maxWidth",function(){if(this.textDisplay)return this.textDisplay.maxWidth;var t=this.$TextInput[4];return t?t:1e5},function(t){this.$TextInput[4]=t,this.textDisplay&&(this.textDisplay.maxWidth=t),this.invalidateProperties()}),s(a,"maxHeight",function(){this.textDisplay;var t=this.$TextInput[5];return t?t:1e5},function(t){this.$TextInput[5]=t,this.textDisplay&&(this.textDisplay.maxHeight=t),this.invalidateProperties()}),s(a,"text",function(){return this.textDisplay?this.textDisplay.text:this.$TextInput[6]},function(t){this.$TextInput[6]=t,this.textDisplay&&(this.textDisplay.text=t),this.invalidateProperties(),this.invalidateState()}),s(a,"restrict",function(){return this.textDisplay?this.textDisplay.restrict:this.$TextInput[7]},function(t){this.$TextInput[7]=t,this.textDisplay&&(this.textDisplay.restrict=t),this.invalidateProperties()}),a.focusInHandler=function(t){this.isFocus=!0,this.invalidateState()},a.focusOutHandler=function(t){this.isFocus=!1,this.invalidateState()},a.getCurrentState=function(){var t=this.skin;return!this.prompt||this.isFocus||this.text?this.enabled?"normal":"disabled":this.enabled&&t.hasState("normalWithPrompt")?"normalWithPrompt":!this.enabled&&t.hasState("disabledWithPrompt")?"disabledWithPrompt":void 0},a.partAdded=function(n,s){i.prototype.partAdded.call(this,n,s);var r=this.$TextInput;s==this.textDisplay?(this.textDisplayAdded(),this.textDisplay instanceof t.EditableText&&(this.textDisplay.addEventListener(e.FOCUS_IN,this.focusInHandler,this),this.textDisplay.addEventListener(e.FOCUS_OUT,this.focusOutHandler,this))):s==this.promptDisplay&&r[0]&&(this.promptDisplay.text=r[0])},a.partRemoved=function(n,s){i.prototype.partRemoved.call(this,n,s),s==this.textDisplay?(this.textDisplayRemoved(),this.textDisplay instanceof t.EditableText&&(this.textDisplay.removeEventListener(e.FOCUS_IN,this.focusInHandler,this),this.textDisplay.removeEventListener(e.FOCUS_OUT,this.focusOutHandler,this))):s==this.promptDisplay&&(this.$TextInput[0]=this.promptDisplay.text)},a.textDisplayAdded=function(){var t=this.$TextInput;t[1]&&(this.textDisplay.displayAsPassword=t[1]),t[2]&&(this.textDisplay.textColor=t[2]),t[3]&&(this.textDisplay.maxChars=t[3]),t[4]&&(this.textDisplay.maxWidth=t[4]),t[5]&&(this.textDisplay.maxHeight=t[5]),t[6]&&(this.textDisplay.text=t[6]),t[7]&&(this.textDisplay.restrict=t[7]),t[8]&&(this.textDisplay.inputType=t[8])},a.textDisplayRemoved=function(){var t=this.$TextInput;t[1]=this.textDisplay.displayAsPassword,t[2]=this.textDisplay.textColor,t[3]=this.textDisplay.maxChars,t[4]=this.textDisplay.maxWidth,t[5]=this.textDisplay.maxHeight,t[6]=this.textDisplay.text,t[7]=this.textDisplay.restrict,t[8]=this.textDisplay.inputType},n}(t.Component);t.TextInput=i,egret.registerClass(i,"eui.TextInput")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e);i.prototype;return e}(t.ToggleButton);t.ToggleSwitch=e,egret.registerClass(e,"eui.ToggleSwitch")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this),this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this),this.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveFromStage,this)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.onAddToStage=function(t){this.$stage.addEventListener(egret.Event.RESIZE,this.onResize,this),this.onResize()},n.onRemoveFromStage=function(t){this.$stage.removeEventListener(egret.Event.RESIZE,this.onResize,this)},n.onResize=function(t){var e=this.$stage;this.$setWidth(e.$stageWidth),this.$setHeight(e.$stageHeight)},e}(t.Group);t.UILayer=e,egret.registerClass(e,"eui.UILayer")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.updateDisplayList=function(e,i){t.prototype.updateDisplayList.call(this,e,i);var n=this.thumb,s=this.$viewport;if(n&&s){var r=egret.$TempRectangle;n.getPreferredBounds(r);var a=r.height,o=r.x,h=s.scrollV,l=s.contentHeight,u=s.height;if(0>=h){var d=a*(1- -h/(.5*u));d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(0/0,d),n.setLayoutBoundsPosition(o,0)}else if(h>=l-u)d=a*(1-(h-l+u)/(.5*u)),d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(0/0,d),n.setLayoutBoundsPosition(o,i-d);else{var c=(i-a)*h/(l-u);n.setLayoutBoundsSize(0/0,0/0),n.setLayoutBoundsPosition(o,c)}}},n.onPropertyChanged=function(t){switch(t.property){case"scrollV":case"contentHeight":this.invalidateDisplayList()}},e}(t.ScrollBarBase);t.VScrollBar=e,egret.registerClass(e,"eui.VScrollBar")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.pointToValue=function(t,e){if(!this.thumb||!this.track)return 0;var i=this.$Range,n=i[0]-i[2],s=this.getThumbRange();return i[2]+(0!=s?(s-e)/s*n:0)},n.getThumbRange=function(){var t=egret.$TempRectangle;this.track.getLayoutBounds(t);var e=t.height;return this.thumb.getLayoutBounds(t),e-t.height},n.updateSkinDisplayList=function(){if(this.thumb&&this.track){var t=this.$Range,e=this.getThumbRange(),i=t[0]-t[2],n=i>0?e-(this.pendingValue-t[2])/i*e:0,s=this.track.localToGlobal(0,n,egret.$TempPoint),r=s.x,a=s.y,o=this.thumb.$parent.globalToLocal(r,a,egret.$TempPoint).y,h=egret.$TempRectangle,l=h.height;if(this.thumb.getLayoutBounds(h),this.thumb.setLayoutBoundsPosition(h.x,Math.round(o)),this.trackHighlight){var u=this.trackHighlight.$parent.globalToLocal(r,a,egret.$TempPoint).y;this.trackHighlight.y=Math.round(u+l),this.trackHighlight.height=Math.round(e-u)}}},e}(t.SliderBase);t.VSlider=e,egret.registerClass(e,"eui.VSlider")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this._selectedChild=null,this.proposedSelectedIndex=t.ListBase.NO_PROPOSED_SELECTION,this._selectedIndex=-1}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"layout",function(){return this.$layout}),n(r,"selectedChild",function(){var t=this.selectedIndex;return t>=0&&t=0&&e0?0==n?(this.proposedSelectedIndex=0,this.invalidateProperties()):this.setSelectedIndex(0):this.setSelectedIndex(-1):s>n&&this.setSelectedIndex(s-1),t.CollectionEvent.dispatchCollectionEvent(this,t.CollectionEvent.COLLECTION_CHANGE,t.CollectionEventKind.REMOVE,n,-1,[i.name])},r.commitProperties=function(){e.prototype.commitProperties.call(this),this.proposedSelectedIndex!=t.ListBase.NO_PROPOSED_SELECTION&&(this.commitSelection(this.proposedSelectedIndex),this.proposedSelectedIndex=t.ListBase.NO_PROPOSED_SELECTION)},r.commitSelection=function(t){t>=0&&tn;n++)if(e[n].name==t)return n;return-1},i}(t.Group);t.ViewStack=e,egret.registerClass(e,"eui.ViewStack",["eui.ICollection","egret.IEventDispatcher"]),t.registerBindable(e.prototype,"selectedIndex")}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){return-.5*(Math.cos(Math.PI*t)-1)}var i=function(){function t(t,i){this.easerFunction=e,this.isPlaying=!1,this.duration=500,this.currentValue=0,this.from=0,this.to=0,this.startTime=0,this.endFunction=null,this.updateFunction=t,this.thisObject=i}var i=(__define,t),n=i.prototype;return n.play=function(){this.stop(),this.start()},n.start=function(){this.isPlaying=!1,this.currentValue=0,this.startTime=egret.getTimer(),this.doInterval(this.startTime),egret.startTick(this.doInterval,this)},n.stop=function(){this.isPlaying=!1,this.startTime=0,egret.stopTick(this.doInterval,this)},n.doInterval=function(t){var e=t-this.startTime;this.isPlaying||(this.isPlaying=!0);var i=this.duration,n=0==i?1:Math.min(e,i)/i;this.easerFunction&&(n=this.easerFunction(n)),this.currentValue=this.from+(this.to-this.from)*n,this.updateFunction&&this.updateFunction.call(this.thisObject,this);var s=e>=i;return s&&this.stop(),s&&this.endFunction&&this.endFunction.call(this.thisObject,this),!0},t}();t.Animation=i,egret.registerClass(i,"eui.sys.Animation")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t),i=e.prototype;return i.getTheme=function(t,e,i,n){function s(t){var i=t.target;e.call(n,i.response)}function r(t){i.call(n)}var a=new egret.HttpRequest;a.addEventListener(egret.Event.COMPLETE,s,n),a.addEventListener(egret.IOErrorEvent.IO_ERROR,r,n),a.responseType=egret.HttpResponseType.TEXT,a.open(t),a.send()},t}();t.DefaultThemeAdapter=e,egret.registerClass(e,"eui.DefaultThemeAdapter",["eui.IThemeAdapter"])}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){var e=t-1;return e*e*e+1}var i=4,n=[1,1.33,1.66,2],s=2.33,r=.02,a=.998,o=.95,h=Math.log(a),l=function(){function l(i,n,s){this.$scrollFactor=1,this.previousTime=0,this.velocity=0,this.previousVelocity=[],this.currentPosition=0,this.previousPosition=0,this.currentScrollPos=0,this.maxScrollPos=0,this.offsetPoint=0,this.$bounces=!0,this.started=!0,this.updateFunction=i,this.endFunction=n,this.target=s,this.animation=new t.Animation(this.onScrollingUpdate,this),this.animation.endFunction=this.finishScrolling,this.animation.easerFunction=e}var u=(__define,l),d=u.prototype;return d.isPlaying=function(){return this.animation.isPlaying},d.stop=function(){this.animation.stop(),egret.stopTick(this.onTick,this),this.started=!1},d.isStarted=function(){return this.started},d.start=function(t){this.started=!0,this.velocity=0,this.previousVelocity.length=0,this.previousTime=egret.getTimer(),this.previousPosition=this.currentPosition=t,this.offsetPoint=t,egret.startTick(this.onTick,this)},d.update=function(t,e,i){e=Math.max(e,0),this.currentPosition=t,this.maxScrollPos=e;var n=this.offsetPoint-t,s=n+i;this.offsetPoint=t,0>s&&(this.$bounces?s-=.5*n:s=0),s>e&&(this.$bounces?s-=.5*n:s=e),this.currentScrollPos=s,this.updateFunction.call(this.target,s)},d.finish=function(t,e){egret.stopTick(this.onTick,this),this.started=!1;for(var i=this.velocity*s,l=this.previousVelocity,u=l.length,d=s,c=0;u>c;c++){var p=n[c];i+=l[0]*p,d+=p}var v=i/d,f=Math.abs(v),g=0,m=0;if(f>r)if(m=t+(v-r)/h*2*this.$scrollFactor,0>m||m>e)for(m=t;Math.abs(v)>r;)m-=v,v*=0>m||m>e?a*o:a,g++;else g=Math.log(r/f)/h;else m=t;if(this.target.$getThrowInfo){var y=this.target.$getThrowInfo(t,m);m=y.toPos}g>0?(this.$bounces||(0>m?m=0:m>e&&(m=e)),this.throwTo(m,g)):this.finishScrolling()},d.onTick=function(t){var e=t-this.previousTime;if(e>10){var n=this.previousVelocity;n.length>=i&&n.shift(),this.velocity=(this.currentPosition-this.previousPosition)/e,n.push(this.velocity),this.previousTime=t,this.previousPosition=this.currentPosition}return!0},d.finishScrolling=function(t){var e=this.currentScrollPos,i=this.maxScrollPos,n=e;0>e&&(n=0),i&&e>i&&(n=i),this.throwTo(n,300)},d.throwTo=function(t,e){void 0===e&&(e=500);var i=this.currentScrollPos;if(i==t)return void this.endFunction.call(this.target);var n=this.animation;n.duration=e,n.from=i,n.to=t,n.play()},d.onScrollingUpdate=function(t){this.currentScrollPos=t.currentValue,this.updateFunction.call(this.target,t.currentValue)},l}();t.TouchScroll=l,egret.registerClass(l,"eui.sys.TouchScroll")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.LTR="ltr",t.RTL="rtl",t.TTB="ttb",t.BTT="btt",t}();t.Direction=e,egret.registerClass(e,"eui.Direction")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.AUTO="auto",t.OFF="off",t.ON="on",t}();t.ScrollPolicy=e,egret.registerClass(e,"eui.ScrollPolicy")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t,i){e.call(this),this.delayList=[],this.skinMap={},this.initialized=!t,i&&(this.$stage=i,EXML.$stage=i,i.registerImplementation("eui.Theme",this)),this.$configURL=t,this.load(t)}__extends(i,e);var n=(__define,i),s=n.prototype;return s.load=function(e){var i=this.$stage?this.$stage.getImplementation("eui.IThemeAdapter"):null;i||(i=new t.DefaultThemeAdapter),i.getTheme(e,this.onConfigLoaded,this.onConfigLoaded,this)},s.onConfigLoaded=function(t){if(t)var e,e=JSON.parse(t);if(e&&e.skins)for(var i=this.skinMap,n=e.skins,s=Object.keys(n),r=s.length,a=0;r>a;a++){var o=s[a];i[o]||this.mapSkin(o,n[o])}e.exmls&&0!=e.exmls.length?e.exmls[0].gjs?(e.exmls.forEach(function(t){return EXML.$parseURLContentAsJs(t.path,t.gjs,t.className)}),this.onLoaded()):e.exmls[0].content?(e.exmls.forEach(function(t){return EXML.$parseURLContent(t.path,t.content)}),this.onLoaded()):EXML.$loadAll(e.exmls,this.onLoaded,this,!0):this.onLoaded()},s.onLoaded=function(t,e){this.initialized=!0,this.handleDelayList(),this.dispatchEventWith(egret.Event.COMPLETE)},s.handleDelayList=function(){for(var t=this.delayList,e=t.length,i=0;e>i;i++){var n=t[i];if(!n.$Component[5]){var s=this.getSkinName(n);s&&(n.$Component[1]=s,n.$parseSkinName())}}t.length=0},s.getSkinName=function(t){if(!this.initialized)return-1==this.delayList.indexOf(t)&&this.delayList.push(t),"";var e=this.skinMap,i=e[t.hostComponentKey];return i||(i=this.findSkinName(t)),i},s.findSkinName=function(t){if(!t)return"";var e=t.__class__;if(void 0===e)return"";var i=this.skinMap[e];return i||"eui.Component"==e?i:this.findSkinName(Object.getPrototypeOf(t))},s.mapSkin=function(t,e){this.skinMap[t]=e},i}(egret.EventDispatcher);t.Theme=e,egret.registerClass(e,"eui.Theme")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,s,r,a,o,h){t.call(this,e,i,n),this.$initTo(s,r,a,o,h)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.$initTo=function(t,e,i,n,s){this.kind=t,this.location=0|+e,this.oldLocation=0|+i,this.items=n||[],this.oldItems=s||[]},n.clean=function(){t.prototype.clean.call(this),this.items=this.oldItems=null},e.dispatchCollectionEvent=function(t,i,n,s,r,a,o){if(!t.hasEventListener(i))return!0;var h=egret.Event.create(e,i);h.$initTo(n,s,r,a,o);var l=t.dispatchEvent(h);return egret.Event.release(h),l},e.COLLECTION_CHANGE="collectionChange",e}(egret.Event);t.CollectionEvent=e,egret.registerClass(e,"eui.CollectionEvent")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.ADD="add",t.REFRESH="refresh",t.REMOVE="remove",t.REPLACE="replace",t.RESET="reset",t.UPDATE="update",t}();t.CollectionEventKind=e,egret.registerClass(e,"eui.CollectionEventKind")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments),this.item=null,this.itemRenderer=null,this.itemIndex=-1}__extends(e,t);var i=(__define,e),n=i.prototype;return n.clean=function(){t.prototype.clean.call(this),this.item=this.itemRenderer=null},e.dispatchItemTapEvent=function(t,i,n){if(!t.hasEventListener(i))return!0;var s=egret.Event.create(e,i);s.item=n.data,s.itemIndex=n.itemIndex,s.itemRenderer=n;var r=t.dispatchEvent(s);return egret.Event.release(s),r},e.ITEM_TAP="itemTap",e}(egret.Event);t.ItemTapEvent=e,egret.registerClass(e,"eui.ItemTapEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,s){t.call(this,e,i,n),this.property=s}__extends(e,t);var i=(__define,e);i.prototype;return e.dispatchPropertyEvent=function(t,i,n){if(!t.hasEventListener(i))return!0;var s=egret.Event.create(e,i);s.property=n;var r=t.dispatchEvent(s);return egret.Event.release(s),r},e.PROPERTY_CHANGE="propertyChange",e}(egret.Event);t.PropertyEvent=e,egret.registerClass(e,"eui.PropertyEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,s,r){t.call(this,e,i,n),s=+s,r=+r,this.currentPos=s,this.toPos=r}__extends(e,t);var i=(__define,e);i.prototype;return e.THROW="throw",e}(egret.Event);t.ScrollerThrowEvent=e,egret.registerClass(e,"eui.ScrollerThrowEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n){t.call(this,e,i,n)}__extends(e,t);var i=(__define,e);i.prototype;return e.dispatchUIEvent=function(t,i,n,s){if(!t.hasEventListener(i))return!0;var r=egret.Event.create(e,i,n,s),a=t.dispatchEvent(r);return egret.Event.release(r),a},e.CREATION_COMPLETE="creationComplete",e.CHANGE_END="changeEnd",e.CHANGE_START="changeStart",e.CLOSING="closing",e.MOVE="move",e}(egret.Event);t.UIEvent=e,egret.registerClass(e,"eui.UIEvent")}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e="eui.State",i="eui.AddItems",n="eui.SetProperty",s="eui.SetStateProperty",r="eui.Binding.$bindProperties",a=function(){function t(){this.indent=0}var e=(__define,t),i=e.prototype;return i.toCode=function(){return""},i.getIndent=function(t){void 0===t&&(t=this.indent);for(var e="",i=0;t>i;i++)e+=" ";return e},t}();t.CodeBase=a,egret.registerClass(a,"eui.sys.CodeBase");var o=function(t){function e(){t.apply(this,arguments),this.className="",this.superClass="",this.innerClassBlock=[],this.variableBlock=[],this.functionBlock=[]}__extends(e,t);var i=(__define,e),n=i.prototype;return n.addInnerClass=function(t){-1==this.innerClassBlock.indexOf(t)&&this.innerClassBlock.push(t)},n.addVariable=function(t){-1==this.variableBlock.indexOf(t)&&this.variableBlock.push(t)},n.getVariableByName=function(t){for(var e=this.variableBlock,i=e.length,n=0;i>n;n++){var s=e[n];if(s.name==t)return s}return null},n.addFunction=function(t){-1==this.functionBlock.indexOf(t)&&this.functionBlock.push(t)},n.getFuncByName=function(t){for(var e=this.functionBlock,i=e.length,n=0;i>n;n++){var s=e[n];if(s.name==t)return s}return null},n.toCode=function(){var t=this.indent,e=this.getIndent(t),i=this.getIndent(t+1),n=this.getIndent(t+2),s=e+"(function (";s+=this.superClass?"_super) {\n"+i+"__extends("+this.className+", _super);\n":") {\n";for(var r=this.innerClassBlock,a=r.length,o=0;a>o;o++){var h=r[o];h.indent=t+1,s+=i+"var "+h.className+" = "+h.toCode()+"\n\n"}s+=i+"function "+this.className+"() {\n",this.superClass&&(s+=n+"_super.call(this);\n");var l=this.variableBlock;for(a=l.length,o=0;a>o;o++){var u=l[o];u.defaultValue&&(s+=n+u.toCode()+"\n")}if(this.constructCode){var d=this.constructCode.toCode().split("\n");for(a=d.length,o=0;a>o;o++){var c=d[o];s+=n+c+"\n"}}s+=i+"}\n",s+=i+"var _proto = "+this.className+".prototype;\n\n";var p=this.functionBlock;for(a=p.length,o=0;a>o;o++){var v=p[o];v.indent=t+1,s+=v.toCode()+"\n"}return s+=i+"return "+this.className+";\n"+e,s+=this.superClass?"})("+this.superClass+");":"})();"},e}(a);t.EXClass=o,egret.registerClass(o,"eui.sys.EXClass");var h=function(t){function e(){t.apply(this,arguments),this.lines=[]}__extends(e,t);var i=(__define,e),n=i.prototype;return n.addVar=function(t,e){var i=e?" = "+e:"";this.addCodeLine("var "+t+i+";")},n.addAssignment=function(t,e,i){var n=i?"."+i:"";this.addCodeLine(t+n+" = "+e+";")},n.addReturn=function(t){this.addCodeLine("return "+t+";")},n.addEmptyLine=function(){this.addCodeLine("")},n.startIf=function(t){this.addCodeLine("if("+t+")"),this.startBlock()},n.startElse=function(){this.addCodeLine("else"),this.startBlock()},n.startElseIf=function(t){this.addCodeLine("else if("+t+")"),this.startBlock()},n.startBlock=function(){this.addCodeLine("{"),this.indent++},n.endBlock=function(){this.indent--,this.addCodeLine("}")},n.doFunction=function(t,e){var i=e.join(",");this.addCodeLine(t+"("+i+")")},n.addCodeLine=function(t){this.lines.push(this.getIndent()+t)},n.addCodeLineAt=function(t,e){this.lines.splice(e,0,this.getIndent()+t)},n.containsCodeLine=function(t){return-1!=this.lines.indexOf(t)},n.concat=function(t){this.lines=this.lines.concat(t.lines)},n.toCode=function(){return this.lines.join("\n")},e}(a);t.EXCodeBlock=h,egret.registerClass(h,"eui.sys.EXCodeBlock");var l=function(t){function e(){t.apply(this,arguments),this.codeBlock=null,this.isGet=!1,this.name=""}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){var t,e=this.getIndent(),i=this.getIndent(this.indent+1),n=e;if(this.isGet?(t=this.getIndent(this.indent+2),n+='Object.defineProperty(_proto, "skinParts", {\n',n+=i+"get: function () {\n"):(t=i,n+="_proto."+this.name+" = function () {\n"),this.codeBlock)for(var s=this.codeBlock.toCode().split("\n"),r=s.length,a=0;r>a;a++){var o=s[a];n+=t+o+"\n"}return n+=this.isGet?i+"},\n"+i+"enumerable: true,\n"+i+"configurable: true\n"+e+"});":e+"};"},e}(a);t.EXFunction=l,egret.registerClass(l,"eui.sys.EXFunction");var u=function(t){function e(e,i){t.call(this),this.indent=2,this.name=e,this.defaultValue=i}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){return this.defaultValue?"this."+this.name+" = "+this.defaultValue+";":""},e}(a);t.EXVariable=u,egret.registerClass(u,"eui.sys.EXVariable");var d=function(t){function i(e,i){t.call(this),this.name="",this.stateGroups=[],this.addItems=[],this.setProperty=[],this.name=e,i&&(this.stateGroups=i)}__extends(i,t);var n=(__define,i),s=n.prototype;return s.addOverride=function(t){t instanceof c?this.addItems.push(t):this.setProperty.push(t)},s.toCode=function(){for(var t=this.getIndent(1),i="new "+e+' ("'+this.name+'",\n'+t+"[\n",n=0,s=!0,r=this.addItems.concat(this.setProperty);nl;l++){var u=o[l];o[l]=t+t+u}i+=o.join("\n"),n++}return i+="\n"+t+"])"},i}(a);t.EXState=d,egret.registerClass(d,"eui.sys.EXState");var c=function(t){function e(e,i,n,s){t.call(this),this.target=e,this.property=i,this.position=n,this.relativeTo=s}__extends(e,t);var n=(__define,e),s=n.prototype;return s.toCode=function(){var t="new "+i+'("'+this.target+'","'+this.property+'",'+this.position+',"'+this.relativeTo+'")';return t},e}(a);t.EXAddItems=c,egret.registerClass(c,"eui.sys.EXAddItems");var p=function(t){function e(e,i,n){t.call(this),this.target=e,this.name=i,this.value=n}__extends(e,t);var i=(__define,e),s=i.prototype;return s.toCode=function(){return"new "+n+'("'+this.target+'","'+this.name+'",'+this.value+")"},e}(a);t.EXSetProperty=p,egret.registerClass(p,"eui.sys.EXSetProperty");var v=function(t){function e(e,i,n,s){t.call(this),this.target=e,this.property=i,this.templates=n,this.chainIndex=s}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){var t=this.templates.join(","),e=this.chainIndex.join(",");return"new "+s+"(this, ["+t+"],["+e+"],"+this.target+',"'+this.property+'")'},e}(a);t.EXSetStateProperty=v,egret.registerClass(v,"eui.sys.EXSetStateProperty");var f=function(t){function e(e,i,n,s){t.call(this),this.target=e,this.property=i,this.templates=n,this.chainIndex=s}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){var t=this.templates.join(","),e=this.chainIndex.join(",");return r+"(this, ["+t+"],["+e+"],"+this.target+',"'+this.property+'")'},e}(a);t.EXBinding=f,egret.registerClass(f,"eui.sys.EXBinding")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(eui){var sys;!function(sys){function getRepeatedIds(t){var e=[];return this.repeatedIdMap={},this.getIds(t,e),e}function getIds(t,e){if(t.namespace!=sys.NS_W&&t.attributes.id){var i=t.attributes.id;this.repeatedIdMap[i]?e.push(toXMLString(t)):this.repeatedIdMap[i]=!0}var n=t.children;if(n)for(var s=n.length,r=0;s>r;r++){var a=n[r];this.isInnerClass(a)||this.getIds(a,e)}}function toXMLString(t){if(!t)return"";for(var e=" at <"+t.name,i=t.attributes,n=Object.keys(i),s=n.length,r=0;s>r;r++){var a=n[r],o=i[a];("id"!=a||"__"!=o.substring(0,2))&&(e+=" "+a+'="'+o+'"')}return e+=0==t.children.length?"/>":">"}function checkDeclarations(t,e){if(t){var i=t.children;if(i)for(var n=i.length,s=0;n>s;s++){var r=i[s];1==r.nodeType&&(r.attributes.includeIn&&e.push(toXMLString(r)),r.attributes.excludeFrom&&e.push(toXMLString(r)),checkDeclarations(r,e))}}}function getPropertyStr(t){var e=toXMLString(t.parent),i=toXMLString(t).substring(5);return e+"\n "+i}var exmlParserPool=[],parsedClasses={},innerClassCount=1,HOST_COMPONENT="hostComponent",SKIN_CLASS="eui.Skin",DECLARATIONS="Declarations",RECTANGLE="egret.Rectangle",TYPE_CLASS="Class",TYPE_ARRAY="Array",TYPE_STATE="State[]",SKIN_NAME="skinName",ELEMENTS_CONTENT="elementsContent",basicTypes=[TYPE_ARRAY,"boolean","string","number"],wingKeys=["id","locked","includeIn","excludeFrom"],htmlEntities=[["<","<"],[">",">"],["&","&"],['"',"""],["'","'"]],jsKeyWords=["null","NaN","undefined","true","false"],EXMLParser=function(){function EXMLParser(){this.delayAssignmentDic={}}var d=__define,c=EXMLParser,p=c.prototype;return p.$parseCode=function(codeText,classStr){var className=classStr?classStr:"$exmlClass"+innerClassCount++,clazz=eval(codeText),hasClass=!0;if(hasClass&&clazz){egret.registerClass(clazz,className);for(var paths=className.split("."),length=paths.length,definition=__global,i=0;length-1>i;i++){var path=paths[i];definition=definition[path]||(definition[path]={})}definition[paths[length-1]]||(definition[paths[length-1]]=clazz)}return clazz},p.parse=function(text){var xmlData,xmlData=egret.XML.parse(text),hasClass=!1,className="";xmlData.attributes["class"]?(className=xmlData.attributes["class"],delete xmlData.attributes["class"],hasClass=!!className):className="$exmlClass"+innerClassCount++; -var exClass=this.parseClass(xmlData,className),code=exClass.toCode(),clazz,clazz=eval(code);if(hasClass&&clazz){egret.registerClass(clazz,className);for(var paths=className.split("."),length=paths.length,definition=__global,i=0;length-1>i;i++){var path=paths[i];definition=definition[path]||(definition[path]={})}definition[paths[length-1]]||(definition[paths[length-1]]=clazz)}return clazz},p.parseClass=function(t,e){sys.exmlConfig||(sys.exmlConfig=new sys.EXMLConfig),this.currentXML=t,this.currentClassName=e,this.delayAssignmentDic={},this.idDic={},this.stateCode=[],this.stateNames=[],this.skinParts=[],this.bindings=[],this.declarations=null,this.currentClass=new sys.EXClass,this.stateIds=[];var i=e.lastIndexOf(".");-1!=i?this.currentClass.className=e.substring(i+1):this.currentClass.className=e,this.startCompile();var n=this.currentClass;return this.currentClass=null,n},p.startCompile=function(){var t=this.getClassNameOfNode(this.currentXML);this.isSkinClass=t==SKIN_CLASS,this.currentClass.superClass=t,this.getStateNames();var e=this.currentXML.children;if(e)for(var i=e.length,n=0;i>n;n++){var s=e[n];if(1===s.nodeType&&s.namespace==sys.NS_W&&s.localName==DECLARATIONS){this.declarations=s;break}}this.currentXML.namespace&&(this.addIds(this.currentXML.children),this.createConstructFunc())},p.addIds=function(t){if(t)for(var e=t.length,i=0;e>i;i++){var n=t[i];if(1==n.nodeType&&n.namespace&&!this.isInnerClass(n))if(this.addIds(n.children),n.namespace!=sys.NS_W&&n.localName){if(this.isProperty(n)){var s=n.localName,r=s.indexOf("."),a=n.children;if(-1==r||!a||0==a.length)continue;var o=a[0];this.stateIds.push(o.attributes.id)}else if(1===n.nodeType){var h=n.attributes.id;h?(-1==this.skinParts.indexOf(h)&&this.skinParts.push(h),this.createVarForNode(n),this.isStateNode(n)&&this.stateIds.push(h)):(this.createIdForNode(n),this.isStateNode(n)&&this.stateIds.push(n.attributes.id))}}else;}},p.isInnerClass=function(t){if(t.hasOwnProperty("isInnerClass"))return t.isInnerClass;var e="Skin"==t.localName&&t.namespace==sys.NS_S;if(!e)if(this.isProperty(t))e=!1;else{var i=t.parent;if(this.isProperty(i)){var n=i.localName,s=n.indexOf(".");if(-1!=s){n.substring(s+1);n=n.substring(0,s)}i=i.parent}else n=sys.exmlConfig.getDefaultPropById(i.localName,i.namespace);var r=sys.exmlConfig.getClassNameById(i.localName,i.namespace);e=sys.exmlConfig.getPropertyType(n,r)==TYPE_CLASS}return t.isInnerClass=e,e},p.containsState=function(t){var e=t.attributes;if(e.includeIn||e.excludeFrom)return!0;for(var i=Object.keys(e),n=i.length,s=0;n>s;s++){var r=i[s];if(-1!=r.indexOf("."))return!0}return!1},p.createIdForNode=function(t){var e=this.getNodeId(t);this.idDic[e]?this.idDic[e]++:this.idDic[e]=1,e+=this.idDic[e],t.attributes.id=e},p.getNodeId=function(t){return t.attributes.id?t.attributes.id:"_"+t.localName},p.createVarForNode=function(t){var e=this.getClassNameOfNode(t);""!=e&&(this.currentClass.getVariableByName(t.attributes.id)||this.currentClass.addVariable(new sys.EXVariable(t.attributes.id)))},p.createFuncForNode=function(t){var e=t.localName,i=this.isBasicTypeData(e);if(i)return this.createBasicTypeForNode(t);var n=this.getClassNameOfNode(t),s=new sys.EXFunction,r="_i",a=t.attributes.id;s.name=a+r,this.currentClass.addFunction(s);var o=new sys.EXCodeBlock;s.codeBlock=o;var h="t";"Object"==e?o.addVar(h,"{}"):o.addVar(h,"new "+n+"()");var l=!!this.currentClass.getVariableByName(a);l&&o.addAssignment("this."+a,h),this.addAttributesToCodeBlock(o,h,t),this.initlizeChildNode(t,o,h);var u=this.delayAssignmentDic[a];if(u)for(var d=u.length,c=0;d>c;c++){var p=u[c];o.concat(p)}return o.addReturn(h),"this."+s.name+"()"},p.isBasicTypeData=function(t){return-1!=basicTypes.indexOf(t)},p.createBasicTypeForNode=function(t){var e=t.localName,i="",n=this.currentClass.getVariableByName(t.attributes.id),s=t.children,r="";if(s&&s.length>0){var a=s[0];3==a.nodeType&&(r=a.text.trim())}switch(e){case TYPE_ARRAY:var o=[];if(s)for(var h=s.length,l=0;h>l;l++){var u=s[l];1==u.nodeType&&o.push(this.createFuncForNode(u))}i="["+o.join(",")+"]";break;case"boolean":i="false"!=r&&r?"true":"false";break;case"number":i=r,-1!=i.indexOf("%")&&(i=i.substring(0,i.length-1));break;case"string":i=this.formatString(r)}return n&&(n.defaultValue=i),i},p.addAttributesToCodeBlock=function(t,e,i){var n,s,r=i.attributes,a=Object.keys(r);a.sort();for(var o=a.length,h=0;o>h;h++)if(n=a[h],this.isNormalKey(n)&&(s=r[n],n=this.formatKey(n,s),s=this.formatValue(n,s,i))){if(this.currentClass.getVariableByName(s)){var l="this.",u=r.id,d=l+u+" = t;";this.currentClass.getVariableByName(u)||this.createVarForNode(i),t.containsCodeLine(d)||t.addCodeLineAt(d,1);var c=new sys.EXCodeBlock;"this"==e?c.addAssignment(e,l+s,n):(c.startIf(l+u),c.addAssignment(l+u,l+s,n),c.endBlock()),this.delayAssignmentDic[s]||(this.delayAssignmentDic[s]=[]),this.delayAssignmentDic[s].push(c),s=l+s}t.addAssignment(e,s,n)}},p.initlizeChildNode=function(t,e,i){var n=t.children;if(n&&0!=n.length){for(var s=sys.exmlConfig.getClassNameById(t.localName,t.namespace),r=[],a=n.length,o=[],h=0;a>h;h++){var l=n[h];if(1==l.nodeType&&l.namespace!=sys.NS_W)if(this.isInnerClass(l)){if("Skin"==l.localName){var u=this.parseInnerClass(l),d=sys.exmlConfig.getPropertyType(SKIN_NAME,s);d?e.addAssignment(i,u,SKIN_NAME):egret.$error(2005,this.currentClassName,SKIN_NAME,getPropertyStr(l))}}else{var c=l.localName;if(this.isProperty(l)){if(!this.isNormalKey(c))continue;var d=sys.exmlConfig.getPropertyType(l.localName,s);if(!d)continue;if(!l.children||0==l.children.length)continue;var p;this.addChildrenToProp(l.children,d,c,e,i,p,o,t)}else r.push(l)}}if(0!=r.length){var p,v=sys.exmlConfig.getDefaultPropById(t.localName,t.namespace),f=sys.exmlConfig.getPropertyType(v,s);v&&f&&this.addChildrenToProp(r,f,v,e,i,p,o,t)}}},p.parseInnerClass=function(t){var e=exmlParserPool.pop();e||(e=new EXMLParser);var i=this.currentClass.className+"$"+t.localName+innerClassCount++,n=e.parseClass(t,i);return this.currentClass.addInnerClass(n),exmlParserPool.push(e),i},p.addChildrenToProp=function(t,e,i,n,s,r,a,o){var h="",l=t.length;if(l>1){if(e!=TYPE_ARRAY)return;for(var u=[],d=0;l>d;d++){var c=t[d];if(1==c.nodeType){h=this.createFuncForNode(c);var p=this.getClassNameOfNode(c);this.isStateNode(c)||u.push(h)}}h="["+u.join(",")+"]"}else{var v=t[0];if(e==TYPE_ARRAY)if(v.localName==TYPE_ARRAY){if(u=[],v.children)for(var f=v.children.length,g=0;f>g;g++)c=v.children[g],1==c.nodeType&&(h=this.createFuncForNode(c),p=this.getClassNameOfNode(c),this.isStateNode(c)||u.push(h));h="["+u.join(",")+"]"}else{h=this.createFuncForNode(v);var p=this.getClassNameOfNode(v);h=this.isStateNode(v)?"[]":"["+h+"]"}else if(1==v.nodeType)if(e==TYPE_CLASS){if(l>1)return;h=this.parseInnerClass(t[0])}else{this.getClassNameOfNode(v);h=this.createFuncForNode(v)}else h=this.formatValue(i,v.text,o)}""!=h&&(-1==h.indexOf("()")&&(i=this.formatKey(i,h)),-1==a.indexOf(i)&&a.push(i),n.addAssignment(s,h,i))},p.isProperty=function(t){if(t.hasOwnProperty("isProperty"))return t.isProperty;var e,i=t.localName;if(i&&1===t.nodeType&&t.parent&&!this.isBasicTypeData(i)){var n=t.parent,s=i.indexOf(".");-1!=s&&(i=i.substr(0,s));var r=sys.exmlConfig.getClassNameById(n.localName,n.namespace);e=!!sys.exmlConfig.getPropertyType(i,r)}else e=!1;return t.isProperty=e,e},p.isNormalKey=function(t){return t&&-1==t.indexOf(".")&&-1==wingKeys.indexOf(t)?!0:!1},p.formatKey=function(t,e){return-1!=e.indexOf("%")&&("height"==t?t="percentHeight":"width"==t&&(t="percentWidth")),t},p.formatValue=function(t,e,i){e||(e="");var n=e;e=e.trim();var s=this.getClassNameOfNode(i),r=sys.exmlConfig.getPropertyType(t,s),a=this.formatBinding(t,e,i);if(a){this.checkIdForState(i);var o="this";i!==this.currentXML&&(o+="."+i.attributes.id),this.bindings.push(new sys.EXBinding(o,t,a.templates,a.chainIndex)),e=""}else if(r==RECTANGLE){e="new "+RECTANGLE+"("+e+")"}else{switch(r){case TYPE_CLASS:t==SKIN_NAME&&(e=this.formatString(n));break;case"number":0==e.indexOf("#")?e="0x"+e.substring(1):-1!=e.indexOf("%")&&(e=parseFloat(e.substr(0,e.length-1)).toString());break;case"boolean":e="false"!=e&&e?"true":"false";break;case"string":case"any":e=this.formatString(n)}}return e},p.formatString=function(t){return t=this.unescapeHTMLEntity(t),t=t.split("\n").join("\\n"),t=t.split("\r").join("\\n"),t=t.split('"').join('\\"'),t='"'+t+'"'},p.formatBinding=function(t,e,i){if(!e)return null;if(e=e.trim(),"{"!=e.charAt(0)||"}"!=e.charAt(e.length-1))return null;e=e.substring(1,e.length-1).trim();for(var n=e.split("+"),s=[],r=n.length,a=0;r>a;a++){var o=n[a].trim();if(o){var h=o.charAt(0);if(!("'"==h||'"'==h||h>="0"&&"9">=h||-1==o.indexOf(".")&&-1!=jsKeyWords.indexOf(o))){0==o.indexOf("this.")&&(o=o.substring(5));var l=o.split(".")[0];l!=HOST_COMPONENT&&-1==this.skinParts.indexOf(l)&&(o=HOST_COMPONENT+"."+o),n[a]='"'+o+'"',s.push(a)}}else n.splice(a,1),a--,r--}return{templates:n,chainIndex:s}},p.unescapeHTMLEntity=function(t){if(!t)return"";for(var e=htmlEntities.length,i=0;e>i;i++){var n=htmlEntities[i],s=n[0],r=n[1];t=t.split(r).join(s)}return t},p.createConstructFunc=function(){var t=new sys.EXCodeBlock;t.addEmptyLine();var e="this";if(this.addAttributesToCodeBlock(t,e,this.currentXML),this.declarations){var i=this.declarations.children;if(i&&i.length>0)for(var n=i.length,s=0;n>s;s++){var r=i[s];if(1==r.nodeType){var a=this.createFuncForNode(r);a&&t.addCodeLine(a+";")}}}this.initlizeChildNode(this.currentXML,t,e);var o,h=this.stateIds;if(h.length>0){n=h.length;for(var s=0;n>s;s++)o=h[s],t.addCodeLine("this."+o+"_i();");t.addEmptyLine()}var l=this.skinParts,u="[]";if(n=l.length,n>0){for(s=0;n>s;s++)l[s]='"'+l[s]+'"';u="["+l.join(",")+"]"}var d=new sys.EXFunction;d.name="skinParts",d.isGet=!0;var c=new sys.EXCodeBlock;c.addReturn(u),d.codeBlock=c,this.currentClass.addFunction(d),this.currentXML.attributes.id="",this.createStates(this.currentXML);for(var p,v=this.currentXML,f=(this.getClassNameOfNode(v),v.attributes),g=Object.keys(f),m=g.length,y=0;m>y;y++){var C=g[y],$=f[C],E=C.indexOf(".");if(-1!=E){var _=C.substring(0,E);_=this.formatKey(_,$);var T=this.formatValue(_,$,v);if(!T)continue;var I=C.substr(E+1);p=this.getStateByName(I,v);var x=p.length;if(x>0)for(s=0;x>s;s++){var S=p[s];S.addOverride(new sys.EXSetProperty("",_,T))}}}var L=this.stateCode;if(n=L.length,n>0){var P=" ";t.addCodeLine("this.states = [");var N=!0;for(s=0;n>s;s++){S=L[s],N?N=!1:t.addCodeLine(P+",");for(var A=S.toCode().split("\n"),R=0;R0)for(t.addEmptyLine(),s=0;n>s;s++){var b=D[s];t.addCodeLine(b.toCode())}this.currentClass.constructCode=t},p.isStateNode=function(t){var e=t.attributes;return e.hasOwnProperty("includeIn")||e.hasOwnProperty("excludeFrom")},p.getStateNames=function(){var t=this.currentXML,e=sys.exmlConfig.getClassNameById(t.localName,t.namespace),i=sys.exmlConfig.getPropertyType("states",e);if(i==TYPE_STATE){var n=t.attributes.states;n&&delete t.attributes.states;var s,r=this.stateNames,a=t.children;if(a)for(var o=a.length,h=0;o>h;h++){var l=a[h];if(1==l.nodeType&&"states"==l.localName){l.namespace=sys.NS_W,s=l.children;break}}if(s||n)if(n){var u=n.split(",");o=u.length;for(var h=0;o>h;h++){var d=u[h].trim();d&&(-1==r.indexOf(d)&&r.push(d),this.stateCode.push(new sys.EXState(d)))}}else for(o=s.length,h=0;o>h;h++){var c=s[h];if(1==c.nodeType){var p=[],v=c.attributes;if(v.stateGroups)for(var f=v.stateGroups.split(","),g=f.length,m=0;g>m;m++){var y=f[m].trim();y&&(-1==r.indexOf(y)&&r.push(y),p.push(y))}d=v.name,-1==r.indexOf(d)&&r.push(d),this.stateCode.push(new sys.EXState(d,p))}}}},p.createStates=function(t){var e=t.children;if(e)for(var i=e.length,n=0;i>n;n++){var s=e[n];if(1==s.nodeType&&!this.isInnerClass(s)&&(this.createStates(s),s.namespace!=sys.NS_W&&s.localName))if(this.isProperty(s)){var r=s.localName,a=r.indexOf("."),o=s.children;if(-1==a||!o||0==o.length)continue;var h=r.substring(a+1);r=r.substring(0,a);var l,u=this.getClassNameOfNode(t),d=(sys.exmlConfig.getPropertyType(r,u),o[0]);1==d.nodeType?(this.createFuncForNode(d),this.checkIdForState(d),l="this."+d.attributes.id):l=this.formatValue(r,d.text,t),g=this.getStateByName(h,s);var c=g.length;if(c>0)for(var p=0;c>p;p++)m=g[p],m.addOverride(new sys.EXSetProperty(t.attributes.id,r,l))}else if(this.containsState(s)){var v=s.attributes,f=v.id;this.getClassNameOfNode(s);this.checkIdForState(s);var h,g,m;if(this.isStateNode(s)){var y="",C=s.parent;C.localName==TYPE_ARRAY&&(C=C.parent),C&&C.parent&&this.isProperty(C)&&(C=C.parent),C&&C!=this.currentXML&&(y=C.attributes.id,this.checkIdForState(C));var $=this.findNearNodeId(s),E=[];if(v.includeIn)E=v.includeIn.split(",");else{for(var _=v.excludeFrom.split(","),T=_.length,p=0;T>p;p++){var I=_[p];this.getStateByName(I,s)}for(T=this.stateCode.length,p=0;T>p;p++)m=this.stateCode[p],-1==_.indexOf(m.name)&&E.push(m.name)}for(var x=E.length,S=0;x>S;S++)if(h=E[S],g=this.getStateByName(h,s),g.length>0)for(var c=g.length,p=0;c>p;p++)m=g[p],m.addOverride(new sys.EXAddItems(f,y,$.position,$.relativeTo))}for(var L=Object.keys(v),P=L.length,N=0;P>N;N++){I=L[N];var l=v[I],a=I.indexOf(".");if(-1!=a){var A=I.substring(0,a);A=this.formatKey(A,l);var R=this.formatBinding(A,l,s);if(!R){var l=this.formatValue(A,l,s);if(!l)continue}h=I.substr(a+1),g=this.getStateByName(h,s);var c=g.length;if(c>0)for(var p=0;c>p;p++)m=g[p],R?m.addOverride(new sys.EXSetStateProperty(f,A,R.templates,R.chainIndex)):m.addOverride(new sys.EXSetProperty(f,A,l))}}}}},p.checkIdForState=function(t){if(t&&!this.currentClass.getVariableByName(t.attributes.id)){this.createVarForNode(t);var e=t.attributes.id,i=e+"_i",n=this.currentClass.getFuncByName(i);if(n){var s="this."+e+" = t;",r=n.codeBlock;r&&(r.containsCodeLine(s)||r.addCodeLineAt(s,1))}}},p.getStateByName=function(t,e){for(var i=[],n=this.stateCode,s=n.length,r=0;s>r;r++){var a=n[r];if(a.name==t)-1==i.indexOf(a)&&i.push(a);else if(a.stateGroups.length>0){for(var o=!1,h=a.stateGroups.length,l=0;h>l;l++){var u=a.stateGroups[l];if(u==t){o=!0;break}}o&&-1==i.indexOf(a)&&i.push(a)}}return i},p.findNearNodeId=function(t){for(var e,i,n,s=t.parent,r="",a=-1,o=!1,h=s.children,l=h.length,u=0;l>u;u++){var d=h[u];this.isProperty(d)||(d==t?(o=!0,a=u):!o||n||this.isStateNode(d)||(n=d),o||this.isStateNode(d)||(i=d))}return 0==a?(e=0,{position:e,relativeTo:r}):a==l-1?(e=1,{position:e,relativeTo:r}):n&&(e=2,r=n.attributes.id)?(this.checkIdForState(n),{position:e,relativeTo:r}):{position:1,relativeTo:r}},p.getClassNameOfNode=function(t){var e=sys.exmlConfig.getClassNameById(t.localName,t.namespace);return e},EXMLParser}();sys.EXMLParser=EXMLParser,egret.registerClass(EXMLParser,"eui.sys.EXMLParser")}(sys=eui.sys||(eui.sys={}))}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){return"[object Array]"===Object.prototype.toString.call(t)}function i(t){var e=egret.getDefinitionByName(t);return e?e.prototype:null}function n(t){if(!t)return null;var e,e=new t;return e}t.NS_S="http://ns.egret.com/eui",t.NS_W="http://ns.egret.com/wing";var s=["Point","Matrix","Rectangle"],r=["Array","boolean","string","number"],a="eui.",o=0,h={},l=function(){function l(){}var u=(__define,l),d=u.prototype;return d.$describe=function(t){function i(){}if(!t)return null;var s=Object.getPrototypeOf(t);if(!s)return null;var a;if(s.hasOwnProperty("__hashCode__")&&(a=h[s.__hashCode__]))return a;var l=Object.getPrototypeOf(s);if(!l)return null;var u=n(l.constructor),d=this.$describe(u);d?(i.prototype=d,a=new i):a={};for(var c=Object.keys(s).concat(Object.keys(t)),p=c.length,v=t.__meta__,f=0;p>f;f++){var g=c[f];if("constructor"!=g&&"_"!=g.charAt(0)&&"$"!=g.charAt(0)){var m;if(v&&v[g])m=v[g];else if(e(t[g]))m="Array";else{if(m=typeof t[g],"function"==m)continue;-1==r.indexOf(m)&&(m="any")}a[g]=m}}return Object.getPrototypeOf(l)&&(s.__hashCode__=o++,h[s.__hashCode__]=a),a},d.getClassNameById=function(e,n){if(n==t.NS_S){if("Object"==e)return e;if(-1!=s.indexOf(e))return"egret."+e}var o="";return-1!=r.indexOf(e)?e:(n==t.NS_W||(o=n&&n!=t.NS_S?n.substring(0,n.length-1)+e:a+e),i(o)||(o=""),o)},d.getDefaultPropById=function(t,e){var n,s=this.getClassNameById(t,e),r=i(s);return r&&(n=r.__defaultProperty__),n?n:""},d.getPropertyType=function(t,e){if("Object"==e)return"any";var s="",r=i(e);if(r){if(!r.hasOwnProperty("__hashCode__")){var a=egret.getDefinitionByName(e),o=n(a);if(!o)return s;this.$describe(o)}var l=h[r.__hashCode__];l&&(s=l[t])}return s},l}();t.EXMLConfig=l,egret.registerClass(l,"eui.sys.EXMLConfig")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var EXML;!function(t){function e(t){return h.parse(t)}function i(t,e,i,n){if(void 0===n&&(n=!1),n&&t in u)return void(e&&e.call(i,u[t],t));var s=l[t];return s?void s.push([e,i]):(l[t]=[[e,i]],void o(t,a))}function n(t,e,i,n){if(void 0===n&&(n=!1),!t||0==t.length)return void(e&&e.call(i,[],t));var r=[];t.forEach(function(a){if(n&&a in u)return r[a]="",void r.push(a);var h=function(n,a){r[n]=a,r.push(n),r.length==t.length&&s(t,r,e,i)};o(a,h)})}function s(t,e,i,n){var s=[];t.forEach(function(t,i){if(t in u&&!e[t])return void(s[i]=u[t]);var n=e[t],r=a(t,n);s[i]=r}),i&&i.call(n,s,t)}function r(t,e,i){if(e)var n=h.$parseCode(e,i);if(t){u[t]=n;var s=l[t];delete l[t];for(var r=s?s.length:0,a=0;r>a;a++){var o=s[a];o[0]&&o[1]&&o[0].call(o[1],n,t)}}return n}function a(t,i){if(i)var n=e(i);if(t){u[t]=n;var s=l[t];delete l[t];for(var r=s?s.length:0,a=0;r>a;a++){var o=s[a];o[0]&&o[1]&&o[0].call(o[1],n,t)}}return n}function o(e,i){var n=e;-1==e.indexOf("://")&&(n=d+e);var s=function(t){t||(t=""),i(e,t)},r=t.$stage?t.$stage.getImplementation("eui.IThemeAdapter"):null;r||(r=new eui.DefaultThemeAdapter),r.getTheme(n,s,s,this)}var h=new eui.sys.EXMLParser,l={},u={},d="";Object.defineProperty(t,"prefixURL",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0}),t.parse=e,t.load=i,t.$loadAll=n,t.$parseURLContentAsJs=r,t.$parseURLContent=a}(EXML||(EXML={}));var eui;!function(t){egret.$locale_strings=egret.$locale_strings||{},egret.$locale_strings.en_US=egret.$locale_strings.en_US||{};var e=egret.$locale_strings.en_US;e[2001]="EXML parsing error {0}: EXML file can't be found ",e[2002]="EXML parsing error : invalid XML file:\n{0}",e[2003]="EXML parsing error {0}: the class definitions corresponding to nodes can't be found \n {1}",e[2004]="EXML parsing error {0}: nodes cannot contain id property with the same name \n {1}",e[2005]="EXML parsing error {0}: property with the name of '{1}' does not exist on the node, or the property does not have a default value: \n {2}",e[2006]="EXML parsing error {0}: undefined view state name: '{1}' \n {2}",e[2007]="EXML parsing error {0}: only UIComponent objects within the container can use the includeIn and excludeFrom properties\n {1}",e[2008]="EXML parsing error {0}: fail to assign values of '{1}' class to property: '{2}' \n {3}",e[2009]="EXML parsing error {0}: only one ID can be referenced in the node property value '{}' label; and complex expression is not allowed to use \n {1}",e[2010]="EXML parsing error {0}: ID referenced by property: '{1}': '{2}' does not exist \n {3}",e[2011]="EXML parsing error {0}: fail to assign more than one child nodes to the same property: '{1}' \n {2}",e[2012]="EXML parsing error {0}: no default property exists on the node; and you must explicitly declare the property name that the child node is assigned to \n {1}",e[2013]="EXML parsing error {0}: view state grammar is not allowed to use on property nodes of Array class \n {1} ",e[2014]="EXML parsing error {0}: assigning the skin class itself to the node property is not allowed \n {1}",e[2015]="EXML parsing error {0}: class definition referenced by node: {1} does not exist \n {2}",e[2016]="EXML parsing error {0}: format error of 'scale9Grid' property value on the node: {1}",e[2017]="EXML parsing error {0}: namespace prefix missing on the node: {1}",e[2018]="EXML parsing error {0}: format error of 'skinName' property value on the node: {1}",e[2019]="EXML parsing error {0}: the container’s child item must be visible nodes: {1}",e[2020]="EXML parsing error {0}: for child nodes in w: Declarations, the includeIn and excludeFrom properties are not allowed to use \n {1}",e[2021]="Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.",e[2101]="EXML parsing warnning : fail to register the class property : {0},there is already a class with the same name in the global,please try to rename the class name for the exml. \n {1}",e[2102]="EXML parsing warnning {0}: no child node can be found on the property code \n {1}",e[2103]="EXML parsing warnning {0}: the same property '{1}' on the node is assigned multiple times \n {2}",e[2104]="EXML parsing warnning, Instantiate class {0} error,the parameters of its constructor method must be empty.",e[2201]="BasicLayout doesn't support virtualization.",e[2202]="parse skinName error,the parsing result of skinName must be a instance of eui.Skin.",e[2203]="Could not find the skin class '{0}'。",e[2301]="parse source failed,could not find asset from URL:{0} ."}(eui||(eui={}));var eui;!function(t){egret.$locale_strings=egret.$locale_strings||{},egret.$locale_strings.zh_CN=egret.$locale_strings.zh_CN||{};var e=egret.$locale_strings.zh_CN;e[2001]="EXML解析错误 {0}: 找不到EXML文件",e[2002]="EXML解析错误: 不是有效的XML文件:\n{0}",e[2003]="EXML解析错误 {0}: 无法找到节点所对应的类定义\n{1}",e[2004]="EXML解析错误 {0}: 节点不能含有同名的id属性\n{1}",e[2005]="EXML解析错误 {0}: 节点上不存在名为'{1}'的属性,或者该属性没有初始值:\n{2}",e[2006]="EXML解析错误 {0}: 未定义的视图状态名称:'{1}'\n{2}",e[2007]="EXML解析错误 {0}: 只有处于容器内的 UIComponent 对象可以使用includeIn和excludeFrom属性\n{1}",e[2008]="EXML解析错误 {0}: 无法将'{1}'类型的值赋给属性:'{2}'\n{3}",e[2009]="EXML解析错误 {0}: 在节点属性值的‘{}’标签内只能引用一个ID,不允许使用复杂表达式\n{1}",e[2010]="EXML解析错误 {0}: 属性:'{1}'所引用的ID: '{2}'不存在\n{3}",e[2011]="EXML解析错误 {0}: 无法将多个子节点赋值给同一个属性:'{1}'\n{2}",e[2012]="EXML解析错误 {0}: 节点上不存在默认属性,必须显式声明子节点要赋值到的属性名\n{1}",e[2013]="EXML解析错误 {0}: 类型为Array的属性节点上不允许使用视图状态语法\n{1}",e[2014]="EXML解析错误 {0}: 不允许将皮肤类自身赋值给节点属性\n{1}",e[2015]="EXML解析错误 {0}: 节点引用的类定义:{1}不存在\n{2}",e[2016]="EXML解析错误 {0}: 节点上'scale9Grid'属性值的格式错误:{1}",e[2017]="EXML解析错误 {0}: 节点上缺少命名空间前缀:{1}",e[2018]="EXML解析错误 {0}: 节点上'skinName'属性值的格式错误:{1}",e[2019]="EXML解析错误 {0}: 容器的子项必须是可视节点:{1}",e[2020]="EXML解析错误 {0}: 在w:Declarations内的子节点,不允许使用includeIn和excludeFrom属性\n{1}",e[2021]="{0} 中存在编译错误,属性名 : {1},属性值 : {2}",e[2101]="EXML解析警告: 在EXML根节点上声明的 class 属性: {0} 注册失败,所对应的类已经存在,请尝试重命名要注册的类名。\n{1}",e[2102]="EXML解析警告 {0}: 在属性节点上找不到任何子节点\n{1}",e[2103]="EXML解析警告 {0}: 节点上的同一个属性'{1}'被多次赋值\n{2}",e[2104]="EXML解析警告,无法直接实例化自定义组件:{0} ,在EXML中使用的自定义组件必须要能直接被实例化,否则可能导致后续EXML解析报错。",e[2201]="BasicLayout 不支持虚拟化。",e[2202]="皮肤解析出错,属性 skinName 的值必须要能够解析为一个 eui.Skin 的实例。",e[2203]="找不到指定的皮肤类 '{0}'。",e[2301]="素材解析失败,找不到URL:{0} 所对应的资源。"}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this),this.$target=null,this.$useVirtualLayout=!1,this.$typicalWidth=71,this.$typicalHeight=22}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"target",function(){return this.$target},function(t){this.$target!==t&&(this.$target=t,this.clearVirtualLayoutCache())}),i(s,"useVirtualLayout",function(){return this.$useVirtualLayout},function(t){t=!!t,this.$useVirtualLayout!=t&&(this.$useVirtualLayout=t,this.dispatchEventWith("useVirtualLayoutChanged"),this.$useVirtualLayout&&!t&&this.clearVirtualLayoutCache(),this.target&&this.target.invalidateDisplayList())}),s.setTypicalSize=function(t,e){t=+t||71,e=+e||22,(t!==this.$typicalWidth||e!==this.$typicalHeight)&&(this.$typicalWidth=t,this.$typicalHeight=e,this.$target&&this.$target.invalidateSize())},s.scrollPositionChanged=function(){},s.clearVirtualLayoutCache=function(){},s.elementAdded=function(t){},s.elementRemoved=function(t){},s.getElementIndicesInView=function(){return null},s.measure=function(){},s.updateDisplayList=function(t,e){},e}(egret.EventDispatcher);t.LayoutBase=e,egret.registerClass(e,"eui.LayoutBase")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this)}__extends(i,e);var n=(__define,i),s=n.prototype;return s.measure=function(){e.prototype.measure.call(this),t.sys.measure(this.$target)},s.updateDisplayList=function(i,n){e.prototype.updateDisplayList.call(this,i,n);var s=this.$target,r=t.sys.updateDisplayList(s,i,n);s.setContentSize(Math.ceil(r.x),Math.ceil(r.y))},i}(t.LayoutBase);t.BasicLayout=e,egret.registerClass(e,"eui.BasicLayout")}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){if(t){for(var e=0,i=0,s=egret.$TempRectangle,r=t.numChildren,a=0;r>a;a++){var o=t.getChildAt(a);if(egret.is(o,n)&&o.$includeInLayout){var h,l,u=o.$UIComponent,d=u[4],c=u[5],p=u[0],v=u[1],f=u[2],g=u[3];o.getPreferredBounds(s),isNaN(p)||isNaN(v)?isNaN(d)?isNaN(p)&&isNaN(v)?h=s.x:(h=isNaN(p)?0:p,h+=isNaN(v)?0:v):h=2*Math.abs(d):h=p+v,isNaN(f)||isNaN(g)?isNaN(c)?isNaN(f)&&isNaN(g)?l=s.y:(l=isNaN(f)?0:f,l+=isNaN(g)?0:g):l=2*Math.abs(c):l=f+g;var m=s.width,y=s.height;e=Math.ceil(Math.max(e,h+m)),i=Math.ceil(Math.max(i,l+y))}}t.setMeasuredSize(e,i)}}function i(t,e,i){if(t){for(var s=t.numChildren,r=0,a=0,o=egret.$TempRectangle,h=0;s>h;h++){var l=t.getChildAt(h);if(egret.is(l,n)&&l.$includeInLayout){var u=l.$UIComponent,d=u[4],c=u[5],p=u[0],v=u[1],f=u[2],g=u[3],m=u[6],y=u[7],C=0/0,$=0/0;isNaN(p)||isNaN(v)?isNaN(m)||(C=Math.round(e*Math.min(.01*m,1))):C=e-v-p,isNaN(f)||isNaN(g)?isNaN(y)||($=Math.round(i*Math.min(.01*y,1))):$=i-g-f,l.setLayoutBoundsSize(C,$),l.getLayoutBounds(o);var E=o.width,_=o.height,T=0/0,I=0/0;T=isNaN(d)?isNaN(p)?isNaN(v)?o.x:e-E-v:p:Math.round((e-E)/2+d),I=isNaN(c)?isNaN(f)?isNaN(g)?o.y:i-_-g:f:Math.round((i-_)/2+c),l.setLayoutBoundsPosition(T,I),r=Math.max(r,T+E),a=Math.max(a,I+_)}}return egret.$TempPoint.setTo(r,a)}}var n="eui.UIComponent";t.measure=e,t.updateDisplayList=i}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.LEFT="left",t.JUSTIFY_USING_GAP="justifyUsingGap",t.JUSTIFY_USING_WIDTH="justifyUsingWidth",t}();t.ColumnAlign=e,egret.registerClass(e,"eui.ColumnAlign")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments),this.$horizontalAlign="left",this.$verticalAlign="top",this.$gap=6,this.$paddingLeft=0,this.$paddingRight=0,this.$paddingTop=0,this.$paddingBottom=0,this.elementSizeTable=[],this.startIndex=-1,this.endIndex=-1,this.indexInViewCalculated=!1,this.maxElementSize=0}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"horizontalAlign",function(){return this.$horizontalAlign},function(t){this.$horizontalAlign!=t&&(this.$horizontalAlign=t,this.$target&&this.$target.invalidateDisplayList())}),i(s,"verticalAlign",function(){return this.$verticalAlign},function(t){this.$verticalAlign!=t&&(this.$verticalAlign=t,this.$target&&this.$target.invalidateDisplayList())}),i(s,"gap",function(){return this.$gap},function(t){t=+t||0,this.$gap!==t&&(this.$gap=t,this.invalidateTargetLayout())}),i(s,"paddingLeft",function(){return this.$paddingLeft},function(t){t=+t||0,this.$paddingLeft!==t&&(this.$paddingLeft=t,this.invalidateTargetLayout())}),i(s,"paddingRight",function(){return this.$paddingRight},function(t){t=+t||0,this.$paddingRight!==t&&(this.$paddingRight=t,this.invalidateTargetLayout())}),i(s,"paddingTop",function(){return this.$paddingTop},function(t){t=+t||0,this.$paddingTop!==t&&(this.$paddingTop=t,this.invalidateTargetLayout())}),i(s,"paddingBottom",function(){return this.$paddingBottom},function(t){t=+t||0,this.$paddingBottom!==t&&(this.$paddingBottom=t,this.invalidateTargetLayout())}),s.invalidateTargetLayout=function(){var t=this.$target;t&&(t.invalidateSize(),t.invalidateDisplayList())},s.measure=function(){this.$target&&(this.$useVirtualLayout?this.measureVirtual():this.measureReal())},s.measureReal=function(){},s.measureVirtual=function(){},s.updateDisplayList=function(t,e){var i=this.$target;if(i)return 0==i.numElements?void i.setContentSize(Math.ceil(this.$paddingLeft+this.$paddingRight),Math.ceil(this.$paddingTop+this.$paddingBottom)):void(this.$useVirtualLayout?this.updateDisplayListVirtual(t,e):this.updateDisplayListReal(t,e))},s.getStartPosition=function(t){return 0},s.getElementSize=function(t){return 0},s.getElementTotalSize=function(){return 0},s.elementRemoved=function(e){this.$useVirtualLayout&&(t.prototype.elementRemoved.call(this,e),this.elementSizeTable.splice(e,1))},s.clearVirtualLayoutCache=function(){this.$useVirtualLayout&&(this.elementSizeTable=[],this.maxElementSize=0)},s.findIndexAt=function(t,e,i){var n=.5*(e+i)|0,s=this.getStartPosition(n),r=this.getElementSize(n);return t>=s&&tt?this.findIndexAt(t,e,Math.max(e,n-1)):this.findIndexAt(t,Math.min(n+1,i),i)},s.scrollPositionChanged=function(){if(t.prototype.scrollPositionChanged.call(this),this.$useVirtualLayout){var e=this.getIndexInView();e&&(this.indexInViewCalculated=!0,this.target.invalidateDisplayList())}},s.getIndexInView=function(){return!1},s.updateDisplayListVirtual=function(t,e){},s.updateDisplayListReal=function(t,e){},s.flexChildrenProportionally=function(t,e,i,n){var s,r=n.length;do{s=!0;var a=e-t*i/100;a>0?e-=a:a=0;for(var o=e/i,h=0;r>h;h++){var l=n[h],u=l.percent*o;if(u=d?a-=d:(e-=d-a,a=0),s=!1;break}if(u>l.max){var c=l.max;l.size=c,n[h]=n[--r],n[r]=l,i-=l.percent,a>=c?a-=c:(e-=c-a,a=0),s=!1;break}l.size=u}}while(!s)},e}(t.LayoutBase);t.LinearLayoutBase=e,egret.registerClass(e,"eui.LinearLayoutBase")}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e=function(){function t(){this.layoutElement=null,this.size=0,this.percent=0/0,this.min=0/0,this.max=0/0}var e=(__define,t);e.prototype;return t}();t.ChildInfo=e,egret.registerClass(e,"eui.sys.ChildInfo")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e="eui.UIComponent",i=function(i){function n(){i.apply(this,arguments)}__extends(n,i);var s=(__define,n),r=s.prototype;return r.measureReal=function(){for(var t=this.$target,i=t.numElements,n=i,s=0,r=0,a=egret.$TempRectangle,o=0;i>o;o++){var h=t.getElementAt(o);egret.is(h,e)&&h.$includeInLayout?(h.getPreferredBounds(a),s+=a.width,r=Math.max(r,a.height)):n--}s+=(n-1)*this.$gap;var l=this.$paddingLeft+this.$paddingRight,u=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(s+l,r+u)},r.measureVirtual=function(){for(var t=this.$target,i=this.$typicalWidth,n=this.getElementTotalSize(),s=Math.max(this.maxElementSize,this.$typicalHeight),r=egret.$TempRectangle,a=this.endIndex,o=this.elementSizeTable,h=this.startIndex;a>h;h++){var l=t.getElementAt(h);egret.is(l,e)&&l.$includeInLayout&&(l.getPreferredBounds(r),n+=r.width,n-=isNaN(o[h])?i:o[h],s=Math.max(s,r.height))}var u=this.$paddingLeft+this.$paddingRight,d=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(n+u,s+d)},r.updateDisplayListReal=function(i,n){var s=this.$target,r=this.$paddingLeft,a=this.$paddingRight,o=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=Math.max(0,i-r-a),d=Math.max(0,n-o-h),c=this.$horizontalAlign==t.JustifyAlign.JUSTIFY,p=this.$verticalAlign==t.JustifyAlign.JUSTIFY||this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0;p||(this.$verticalAlign==egret.VerticalAlign.MIDDLE?v=.5:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(v=1));var f,g,m,y=s.numElements,C=y,$=r,E=o,_=0,T=0,I=[],x=u,S=this.maxElementSize,L=egret.$TempRectangle;for(f=0;y>f;f++){var g=s.getElementAt(f);if(egret.is(g,e)&&g.$includeInLayout)if(g.getPreferredBounds(L),S=Math.max(S,L.height),c)_+=L.width;else{var P=g.$UIComponent;isNaN(P[6])?x-=L.width:(T+=P[6],m=new t.sys.ChildInfo,m.layoutElement=g,m.percent=P[6],m.min=P[12],m.max=P[13],I.push(m))}else C--}x-=l*(C-1),x=x>0?x:0;var N,A=u-_-l*(C-1),R=C,B={};if(c){if(0>A){for(N=x/C,f=0;y>f;f++)g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(L),L.width<=N&&(x-=L.width,R--));x=x>0?x:0}}else if(T>0){this.flexChildrenProportionally(u,x,T,I);var D=0,b=I.length;for(f=0;b>f;f++){m=I[f];var M=Math.round(m.size+D);D+=m.size-M,B[m.layoutElement.$hashCode]=M,x-=M}x=x>0?x:0}this.$horizontalAlign==egret.HorizontalAlign.CENTER?$=r+.5*x:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&($=r+x); -var O=r,w=o,V=0,z=0,H=Math.ceil(d);this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY&&(H=Math.ceil(Math.max(d,S))),D=0;var U,k;for(f=0;y>f;f++){var G=0;if(g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout){if(g.getPreferredBounds(L),U=0/0,c?(k=0/0,A>0?k=x*L.width/_:0>A&&L.width>N&&(k=x/R),isNaN(k)||(U=Math.round(k+D),D+=k-U)):U=B[g.$hashCode],p)E=o,g.setLayoutBoundsSize(U,H),g.getLayoutBounds(L);else{var F=0/0,P=g.$UIComponent;if(!isNaN(g.percentHeight)){var W=Math.min(100,P[7]);F=Math.round(d*W*.01)}g.setLayoutBoundsSize(U,F),g.getLayoutBounds(L),G=(d-L.height)*v,G=G>0?G:0,E=o+G}g.setLayoutBoundsPosition(Math.round($),Math.round(E)),V=Math.ceil(L.width),z=Math.ceil(L.height),O=Math.max(O,$+V),w=Math.max(w,E+z),$+=V+l}}this.maxElementSize=S,s.setContentSize(O+a,w+h)},r.updateDisplayListVirtual=function(i,n){var s=this.$target;this.indexInViewCalculated?this.indexInViewCalculated=!1:this.getIndexInView();var r,a=this.$paddingRight,o=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=s.numElements;if(-1==this.startIndex||-1==this.endIndex)return r=this.getStartPosition(u)-l+a,void s.setContentSize(r,s.contentHeight);var d=this.endIndex;s.setVirtualElementIndicesInView(this.startIndex,d);var c=this.$verticalAlign==t.JustifyAlign.JUSTIFY||this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,p=this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0;c||(this.$verticalAlign==egret.VerticalAlign.MIDDLE?v=.5:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(v=1));var f,g=egret.$TempRectangle,m=Math.max(0,n-o-h),y=Math.ceil(m),C=this.$typicalHeight,$=this.$typicalWidth,E=this.maxElementSize,_=Math.max(C,this.maxElementSize);if(p){for(var T=this.startIndex;d>=T;T++)f=s.getVirtualElementAt(T),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),E=Math.max(E,g.height));y=Math.ceil(Math.max(m,E))}for(var I,x=0,S=0,L=0,P=!1,N=this.elementSizeTable,A=this.startIndex;d>=A;A++){var R=0;f=s.getVirtualElementAt(A),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),p||(E=Math.max(E,g.height)),c?(S=o,f.setLayoutBoundsSize(0/0,y),f.getLayoutBounds(g)):(f.getLayoutBounds(g),R=(m-g.height)*v,R=R>0?R:0,S=o+R),L=Math.max(L,g.height),P||(I=isNaN(N[A])?$:N[A],I!=g.width&&(P=!0)),N[A]=g.width,x=this.getStartPosition(A),f.setLayoutBoundsPosition(Math.round(x),Math.round(S)))}L+=o+h,r=this.getStartPosition(u)-l+a,this.maxElementSize=E,s.setContentSize(r,L),(P||_a;a++){var o=r[a];isNaN(o)&&(o=i),n+=o+s}return n},r.getElementSize=function(t){if(this.$useVirtualLayout){var e=this.elementSizeTable[t];return isNaN(e)&&(e=this.$typicalWidth),e}return this.$target?this.$target.getElementAt(t).width:0},r.getElementTotalSize=function(){for(var t=this.$typicalWidth,e=this.$gap,i=0,n=this.$target.numElements,s=this.elementSizeTable,r=0;n>r;r++){var a=s[r];isNaN(a)&&(a=t),i+=a+e}return i-=e},r.elementAdded=function(t){this.useVirtualLayout&&(i.prototype.elementAdded.call(this,t),this.elementSizeTable.splice(t,0,this.$typicalWidth))},r.getIndexInView=function(){var t=this.$target;if(!t||0==t.numElements)return this.startIndex=this.endIndex=-1,!1;var e=t.$UIComponent;if(e[10]<=0||e[11]<=0)return this.startIndex=this.endIndex=-1,!1;var i=t.numElements,n=this.getStartPosition(i-1)+this.elementSizeTable[i-1]+this.$paddingRight,s=t.scrollH;if(s>n-this.$paddingRight)return this.startIndex=-1,this.endIndex=-1,!1;var r=t.scrollH+e[10];if(r0?this._requestedColumnCount:this._columnCount,l=this._requestedRowCount>0?this._requestedRowCount:this._rowCount,u=isNaN(this._horizontalGap)?0:this._horizontalGap,d=isNaN(this._verticalGap)?0:this._verticalGap;h>0&&(r=h*(this._columnWidth+u)-u),l>0&&(a=l*(this._rowHeight+d)-d);var c=this._paddingLeft+this._paddingRight,p=this._paddingTop+this._paddingBottom;t.setMeasuredSize(r+c,a+p),this._columnCount=e,this._rowCount=i,this._columnWidth=n,this._rowHeight=s}},a.calculateRowAndColumn=function(i,n){var s=this.$target,r=isNaN(this._horizontalGap)?0:this._horizontalGap,a=isNaN(this._verticalGap)?0:this._verticalGap;this._rowCount=this._columnCount=-1;for(var o=s.numElements,h=o,l=0;h>l;l++){var u=s.getElementAt(l);!u||egret.is(u,e)&&u.$includeInLayout||o--}if(0==o)return void(this._rowCount=this._columnCount=0);(isNaN(this.explicitColumnWidth)||isNaN(this.explicitRowHeight))&&this.updateMaxElementSize(),isNaN(this.explicitColumnWidth)?this._columnWidth=this.maxElementWidth:this._columnWidth=this.explicitColumnWidth,isNaN(this.explicitRowHeight)?this._rowHeight=this.maxElementHeight:this._rowHeight=this.explicitRowHeight;var d=this._columnWidth+r;0>=d&&(d=1);var c=this._rowHeight+a;0>=c&&(c=1);var p=this._orientation==t.TileOrientation.COLUMNS,v=!isNaN(i),f=!isNaN(n),g=this._paddingLeft,m=this._paddingRight,y=this._paddingTop,C=this._paddingBottom;if(this._requestedColumnCount>0||this._requestedRowCount>0)this._requestedRowCount>0&&(this._rowCount=Math.min(this._requestedRowCount,o)),this._requestedColumnCount>0&&(this._columnCount=Math.min(this._requestedColumnCount,o));else if(v||f)if(!v||f&&p){var $=Math.max(0,n-y-C);this._rowCount=Math.floor(($+a)/c),this._rowCount=Math.max(1,Math.min(this._rowCount,o))}else{var E=Math.max(0,i-g-m);this._columnCount=Math.floor((E+r)/d),this._columnCount=Math.max(1,Math.min(this._columnCount,o))}else{var _=Math.sqrt(o*d*c);p?this._rowCount=Math.max(1,Math.round(_/c)):this._columnCount=Math.max(1,Math.round(_/d))}-1==this._rowCount&&(this._rowCount=Math.max(1,Math.ceil(o/this._columnCount))),-1==this._columnCount&&(this._columnCount=Math.max(1,Math.ceil(o/this._rowCount))),this._requestedColumnCount>0&&this._requestedRowCount>0&&(this._orientation==t.TileOrientation.ROWS?this._rowCount=Math.max(1,Math.ceil(o/this._requestedColumnCount)):this._columnCount=Math.max(1,Math.ceil(o/this._requestedRowCount)))},a.updateMaxElementSize=function(){this.$target&&(this.$useVirtualLayout?(this.maxElementWidth=Math.max(this.maxElementWidth,this.$typicalWidth),this.maxElementHeight=Math.max(this.maxElementHeight,this.$typicalHeight),this.doUpdateMaxElementSize(this.startIndex,this.endIndex)):this.doUpdateMaxElementSize(0,this.$target.numElements-1))},a.doUpdateMaxElementSize=function(t,i){var n=this.maxElementWidth,s=this.maxElementHeight,r=egret.$TempRectangle,a=this.$target;if(-1!=t&&-1!=i)for(var o=t;i>=o;o++){var h=a.getVirtualElementAt(o);egret.is(h,e)&&h.$includeInLayout&&(h.getPreferredBounds(r),n=Math.max(n,r.width),s=Math.max(s,r.height))}this.maxElementWidth=n,this.maxElementHeight=s},a.clearVirtualLayoutCache=function(){i.prototype.clearVirtualLayoutCache.call(this),this.maxElementWidth=0,this.maxElementHeight=0},a.scrollPositionChanged=function(){if(this.$useVirtualLayout){var t=this.getIndexInView();t&&(this.indexInViewCalculated=!0,this.$target.invalidateDisplayList())}},a.getIndexInView=function(){if(!this.$target||0==this.$target.numElements)return this.startIndex=this.endIndex=-1,!1;var e=this.$target,i=e.numElements;if(!this.$useVirtualLayout)return this.startIndex=0,this.endIndex=i-1,!1;var n=e.$UIComponent;if(0==n[10]||0==n[11])return this.startIndex=this.endIndex=-1,!1;var s=this.startIndex,r=this.endIndex,a=this._paddingLeft,o=this._paddingTop,h=isNaN(this._horizontalGap)?0:this._horizontalGap,l=isNaN(this._verticalGap)?0:this._verticalGap;if(this._orientation==t.TileOrientation.COLUMNS){var u=this._columnWidth+h;if(0>=u)return this.startIndex=0,this.endIndex=i-1,!1;var d=e.scrollH,c=d+n[10],p=Math.floor((d-a)/u);0>p&&(p=0);var v=Math.ceil((c-a)/u);0>v&&(v=0),this.startIndex=Math.min(i-1,Math.max(0,p*this._rowCount)),this.endIndex=Math.min(i-1,Math.max(0,v*this._rowCount-1))}else{var f=this._rowHeight+l;if(0>=f)return this.startIndex=0,this.endIndex=i-1,!1;var g=e.scrollV,m=g+n[11],y=Math.floor((g-o)/f);0>y&&(y=0);var C=Math.ceil((m-o)/f);0>C&&(C=0),this.startIndex=Math.min(i-1,Math.max(0,y*this._columnCount)),this.endIndex=Math.min(i-1,Math.max(0,C*this._columnCount-1))}return this.startIndex!=s||this.endIndex!=r},a.updateDisplayList=function(n,s){if(i.prototype.updateDisplayList.call(this,n,s),this.$target){var r=this.$target,a=this._paddingLeft,o=this._paddingRight,h=this._paddingTop,l=this._paddingBottom;if(this.indexInViewCalculated)this.indexInViewCalculated=!1;else{if(this.calculateRowAndColumn(n,s),0==this._rowCount||0==this._columnCount)return void r.setContentSize(a+o,h+l);this.adjustForJustify(n,s),this.getIndexInView()}if(this.$useVirtualLayout&&(this.calculateRowAndColumn(n,s),this.adjustForJustify(n,s)),-1==this.startIndex||-1==this.endIndex)return void r.setContentSize(0,0);var u=this.endIndex;r.setVirtualElementIndicesInView(this.startIndex,u);for(var d,c,p,v,f,g=this._orientation==t.TileOrientation.COLUMNS,m=this.startIndex,y=isNaN(this._horizontalGap)?0:this._horizontalGap,C=isNaN(this._verticalGap)?0:this._verticalGap,$=this._rowCount,E=this._columnCount,_=this._columnWidth,T=this._rowHeight,I=this.startIndex;u>=I;I++)d=this.$useVirtualLayout?this.target.getVirtualElementAt(I):this.target.getElementAt(I),egret.is(d,e)&&d.$includeInLayout&&(g?(v=Math.ceil((m+1)/$)-1,f=Math.ceil((m+1)%$)-1,-1==f&&(f=$-1)):(v=Math.ceil((m+1)%E)-1,-1==v&&(v=E-1),f=Math.ceil((m+1)/E)-1),c=v*(_+y)+a,p=f*(T+C)+h,this.sizeAndPositionElement(d,c,p,_,T),m++);var x=a+o,S=h+l,L=(_+y)*E-y,P=(T+C)*$-C;r.setContentSize(L+x,P+S)}},a.sizeAndPositionElement=function(e,i,n,s,r){var a=0/0,o=0/0,h=e.$UIComponent;this._horizontalAlign==t.JustifyAlign.JUSTIFY?a=s:isNaN(h[6])||(a=s*h[6]*.01),this._verticalAlign==t.JustifyAlign.JUSTIFY?o=r:isNaN(h[7])||(o=r*h[7]*.01),e.setLayoutBoundsSize(Math.round(a),Math.round(o));var l=i,u=egret.$TempRectangle;switch(e.getLayoutBounds(u),this._horizontalAlign){case egret.HorizontalAlign.RIGHT:l+=s-u.width;break;case egret.HorizontalAlign.CENTER:l=i+(s-u.width)/2}var d=n;switch(this._verticalAlign){case egret.VerticalAlign.BOTTOM:d+=r-u.height;break;case egret.VerticalAlign.MIDDLE:d+=(r-u.height)/2}e.setLayoutBoundsPosition(Math.round(l),Math.round(d))},a.adjustForJustify=function(e,i){var n=this._paddingLeft,s=this._paddingRight,r=this._paddingTop,a=this._paddingBottom,o=Math.max(0,e-n-s),h=Math.max(0,i-r-a);isNaN(this.explicitVerticalGap)||(this._verticalGap=this.explicitVerticalGap),isNaN(this.explicitHorizontalGap)||(this._horizontalGap=this.explicitHorizontalGap),this._verticalGap=isNaN(this._verticalGap)?0:this._verticalGap,this._horizontalGap=isNaN(this._horizontalGap)?0:this._horizontalGap;var l,u=h-this._rowHeight*this._rowCount,d=o-this._columnWidth*this._columnCount;u>0&&(this._rowAlign==t.RowAlign.JUSTIFY_USING_GAP?(l=Math.max(1,this._rowCount-1),this._verticalGap=u/l):this._rowAlign==t.RowAlign.JUSTIFY_USING_HEIGHT&&this._rowCount>0&&(this._rowHeight+=(u-(this._rowCount-1)*this._verticalGap)/this._rowCount)),d>0&&(this._columnAlign==t.ColumnAlign.JUSTIFY_USING_GAP?(l=Math.max(1,this._columnCount-1),this._horizontalGap=d/l):this._columnAlign==t.ColumnAlign.JUSTIFY_USING_WIDTH&&this._columnCount>0&&(this._columnWidth+=(d-(this._columnCount-1)*this._horizontalGap)/this._columnCount))},n}(t.LayoutBase);t.TileLayout=i,egret.registerClass(i,"eui.TileLayout")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.ROWS="rows",t.COLUMNS="columns",t}();t.TileOrientation=e,egret.registerClass(e,"eui.TileOrientation")}(eui||(eui={}));var eui;!function(t){var e="eui.UIComponent",i=function(i){function n(){i.apply(this,arguments)}__extends(n,i);var s=(__define,n),r=s.prototype;return r.measureReal=function(){for(var t=this.$target,i=t.numElements,n=i,s=0,r=0,a=egret.$TempRectangle,o=0;i>o;o++){var h=t.getElementAt(o);egret.is(h,e)&&h.$includeInLayout?(h.getPreferredBounds(a),r+=a.height,s=Math.max(s,a.width)):n--}r+=(n-1)*this.$gap;var l=this.$paddingLeft+this.$paddingRight,u=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(s+l,r+u)},r.measureVirtual=function(){for(var t=this.$target,i=this.$typicalHeight,n=this.getElementTotalSize(),s=Math.max(this.maxElementSize,this.$typicalWidth),r=egret.$TempRectangle,a=this.endIndex,o=this.elementSizeTable,h=this.startIndex;a>h;h++){var l=t.getElementAt(h);egret.is(l,e)&&l.$includeInLayout&&(l.getPreferredBounds(r),n+=r.height,n-=isNaN(o[h])?i:o[h],s=Math.max(s,r.width))}var u=this.$paddingLeft+this.$paddingRight,d=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(s+u,n+d)},r.updateDisplayListReal=function(i,n){var s=this.$target,r=this.$paddingLeft,a=this.$paddingRight,o=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=Math.max(0,i-r-a),d=Math.max(0,n-o-h),c=this.$verticalAlign==t.JustifyAlign.JUSTIFY,p=this.$horizontalAlign==t.JustifyAlign.JUSTIFY||this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0;p||(this.$horizontalAlign==egret.HorizontalAlign.CENTER?v=.5:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&(v=1));var f,g,m,y=s.numElements,C=y,$=r,E=o,_=0,T=0,I=[],x=d,S=this.maxElementSize,L=egret.$TempRectangle;for(f=0;y>f;f++){var g=s.getElementAt(f);if(egret.is(g,e)&&g.$includeInLayout)if(g.getPreferredBounds(L),S=Math.max(S,L.width),c)_+=L.height;else{var P=g.$UIComponent;isNaN(P[7])?x-=L.height:(T+=P[7],m=new t.sys.ChildInfo,m.layoutElement=g,m.percent=P[7],m.min=P[14],m.max=P[15],I.push(m))}else C--}x-=l*(C-1),x=x>0?x:0;var N,A=d-_-l*(C-1),R=C,B={};if(c){if(0>A){for(N=x/C,f=0;y>f;f++)g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(L),L.height<=N&&(x-=L.height,R--));x=x>0?x:0}}else if(T>0){this.flexChildrenProportionally(d,x,T,I);var D=0,b=I.length;for(f=0;b>f;f++){m=I[f];var M=Math.round(m.size+D);D+=m.size-M,B[m.layoutElement.$hashCode]=M,x-=M}x=x>0?x:0}this.$verticalAlign==egret.VerticalAlign.MIDDLE?E=o+.5*x:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(E=o+x);var O=r,w=o,V=0,z=0,H=Math.ceil(u);this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY&&(H=Math.ceil(Math.max(u,S))),D=0;var U,k;for(f=0;y>f;f++){var G=0;if(g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout){if(g.getPreferredBounds(L),U=0/0,c?(k=0/0,A>0?k=x*L.height/_:0>A&&L.height>N&&(k=x/R),isNaN(k)||(U=Math.round(k+D),D+=k-U)):U=B[g.$hashCode],p)$=r,g.setLayoutBoundsSize(H,U),g.getLayoutBounds(L);else{var F=0/0,P=g.$UIComponent;if(!isNaN(P[6])){var W=Math.min(100,P[6]);F=Math.round(u*W*.01)}g.setLayoutBoundsSize(F,U),g.getLayoutBounds(L),G=(u-L.width)*v,G=G>0?G:0,$=r+G}g.setLayoutBoundsPosition(Math.round($),Math.round(E)),V=Math.ceil(L.width),z=Math.ceil(L.height),O=Math.max(O,$+V),w=Math.max(w,E+z),E+=z+l}}this.maxElementSize=S,s.setContentSize(O+a,w+h)},r.updateDisplayListVirtual=function(i,n){var s=this.$target;this.indexInViewCalculated?this.indexInViewCalculated=!1:this.getIndexInView();var r,a=this.$paddingBottom,o=this.$paddingLeft,h=this.$paddingRight,l=this.$gap,u=s.numElements;if(-1==this.startIndex||-1==this.endIndex)return r=this.getStartPosition(u)-l+a,void s.setContentSize(s.contentWidth,r);var d=this.endIndex;s.setVirtualElementIndicesInView(this.startIndex,d);var c=this.$horizontalAlign==t.JustifyAlign.JUSTIFY||this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,p=this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0;c||(this.$horizontalAlign==egret.HorizontalAlign.CENTER?v=.5:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&(v=1));var f,g=egret.$TempRectangle,m=Math.max(0,i-o-h),y=Math.ceil(m),C=this.$typicalHeight,$=this.$typicalWidth,E=this.maxElementSize,_=Math.max($,this.maxElementSize);if(p){for(var T=this.startIndex;d>=T;T++)f=s.getVirtualElementAt(T),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),E=Math.max(E,g.width));y=Math.ceil(Math.max(m,E))}for(var I,x=0,S=0,L=0,P=!1,N=this.elementSizeTable,A=this.startIndex;d>=A;A++){var R=0;f=s.getVirtualElementAt(A),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),p||(E=Math.max(E,g.width)),c?(x=o,f.setLayoutBoundsSize(y,0/0),f.getLayoutBounds(g)):(f.getLayoutBounds(g),R=(m-g.width)*v,R=R>0?R:0,x=o+R),L=Math.max(L,g.width),P||(I=isNaN(N[A])?C:N[A],I!=g.height&&(P=!0)),N[A]=g.height,S=this.getStartPosition(A),f.setLayoutBoundsPosition(Math.round(x),Math.round(S)))}L+=o+h,r=this.getStartPosition(u)-l+a,this.maxElementSize=E,s.setContentSize(L,r),(P||_a;a++){var o=r[a];isNaN(o)&&(o=i),n+=o+s}return n},r.getElementSize=function(t){if(this.$useVirtualLayout){var e=this.elementSizeTable[t];return isNaN(e)&&(e=this.$typicalHeight),e}return this.$target?this.$target.getElementAt(t).height:0},r.getElementTotalSize=function(){for(var t=this.$typicalHeight,e=this.$gap,i=0,n=this.$target.numElements,s=this.elementSizeTable,r=0;n>r;r++){var a=s[r];isNaN(a)&&(a=t),i+=a+e}return i-=e},r.elementAdded=function(t){this.$useVirtualLayout&&(i.prototype.elementAdded.call(this,t),this.elementSizeTable.splice(t,0,this.$typicalHeight))},r.getIndexInView=function(){var t=this.$target;if(!t||0==t.numElements)return this.startIndex=this.endIndex=-1,!1;var e=t.$UIComponent;if(0==e[10]||0==e[11])return this.startIndex=this.endIndex=-1,!1;var i=t.numElements,n=this.getStartPosition(i-1)+this.elementSizeTable[i-1]+this.$paddingBottom,s=t.scrollV;if(s>n-this.$paddingBottom)return this.startIndex=-1,this.endIndex=-1,!1;var r=t.scrollV+e[11];if(r-1&&s.splice(r,1)}},t}();t.AddItems=e,egret.registerClass(e,"eui.AddItems",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e=function(){function t(t,e,i){this.target=t,this.name=e,this.value=i}var e=(__define,t),i=e.prototype;return i.apply=function(t,e){var i=this.target?t[this.target]:t;i&&(this.oldValue=i[this.name],this.setPropertyValue(i,this.name,this.value,this.oldValue))},i.remove=function(t,e){var i=this.target?t[this.target]:t;i&&(this.setPropertyValue(i,this.name,this.oldValue,this.oldValue),this.oldValue=null)},i.setPropertyValue=function(t,e,i,n){void 0===i||null===i?t[e]=i:"number"==typeof n?t[e]=+i:"boolean"==typeof n?t[e]=this.toBoolean(i):t[e]=i},i.toBoolean=function(t){return"string"==typeof t?"true"==t.toLowerCase():0!=t},t}();t.SetProperty=e,egret.registerClass(e,"eui.SetProperty",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e=function(){function e(t,e,i,n,s){this.host=t,this.templates=e,this.chainIndex=i,this.target=n,this.prop=s}var i=(__define,e),n=i.prototype;return n.apply=function(e,i){if(this.target){var n=this.target[this.prop];this.oldValue&&this.setPropertyValue(this.target,this.prop,this.oldValue,this.oldValue),n&&(this.oldValue=n),t.Binding.$bindProperties(this.host,this.templates.concat(),this.chainIndex.concat(),this.target,this.prop)}},n.remove=function(t,e){if(this.target){var i=this.oldValue;this.target[this.prop]&&(this.oldValue=this.target[this.prop]),i&&this.setPropertyValue(this.target,this.prop,i,i)}},n.setPropertyValue=function(t,e,i,n){void 0===i||null===i?t[e]=i:"number"==typeof n?t[e]=+i:"boolean"==typeof n?t[e]=this.toBoolean(i):t[e]=i},n.toBoolean=function(t){return"string"==typeof t?"true"==t.toLowerCase():0!=t},e}();t.SetStateProperty=e,egret.registerClass(e,"eui.SetStateProperty",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t,e,i,n,r,a,o,h,l,u){var d;if(!isNaN(i)&&isNaN(n)){if(d=s(t,e,i,a,i,h,i,u))return d}else if(isNaN(i)&&!isNaN(n)&&(d=s(t,e,r,n,o,n,l,n)))return d;return d=s(t,e,r,a,o,h,l,u)}function i(t,e,i,s,r,a,o,h,l,u){var d;if(!isNaN(i)&&isNaN(s)){if(d=n(t,e,i,a,i,h,i,u))return d}else if(isNaN(i)&&!isNaN(s)&&(d=n(t,e,r,s,o,s,l,s)))return d;return d=n(t,e,r,a,o,h,l,u)}function n(t,e,i,n,s,a,h,l){var u=e.b,d=e.d;if(u>-1e-9&&1e-9>u&&(u=0),d>-1e-9&&1e-9>d&&(d=0),0==u&&0==d)return null;if(0==u&&0==d)return null;if(0==u)return egret.Point.create(i,t/Math.abs(d));if(0==d)return egret.Point.create(t/Math.abs(u),n);var c,p,v,f=u*d>=0?d:-d;if(0!=f&&i>0){var g=1/f;i=Math.max(s,Math.min(h,i)),p=i,v=(t-u*p)*g,v>=a&&l>=v&&u*p+f*v>=0&&(c=egret.Point.create(p,v)),v=(-t-u*p)*g,v>=a&&l>=v&&0>u*p+f*v&&(!c||o(c.x,c.y,e).width>o(p,v,e).width)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(0!=u&&n>0){var m=1/u;n=Math.max(a,Math.min(l,n)),v=n,p=(t-f*v)*m,p>=s&&h>=p&&u*p+f*v>=0&&(!c||o(c.x,c.y,e).width>o(p,v,e).width)&&(c=egret.Point.create(p,v)),p=(-t-f*v)*m,p>=s&&h>=p&&0>u*p+f*v&&(!c||o(c.x,c.y,e).width>o(p,v,e).width)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(c)return c;var y=e.a,C=e.c,$=y*C>=0?C:-C;return r(u,f,t,s,a,h,l,y,$)}function s(t,e,i,n,s,a,h,l){var u=e.a,d=e.c;if(u>-1e-9&&1e-9>u&&(u=0),d>-1e-9&&1e-9>d&&(d=0),0==u&&0==d)return null;if(0==u)return egret.Point.create(i,t/Math.abs(d));if(0==d)return egret.Point.create(t/Math.abs(u),n);var c,p,v,f=u*d>=0?d:-d;if(0!=f&&i>0){var g=1/f;i=Math.max(s,Math.min(h,i)),p=i,v=(t-u*p)*g,v>=a&&l>=v&&u*p+f*v>=0&&(c=egret.Point.create(p,v)),v=(-t-u*p)*g,v>=a&&l>=v&&0>u*p+f*v&&(!c||o(c.x,c.y,e).height>o(p,v,e).height)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(0!=u&&n>0){var m=1/u;n=Math.max(a,Math.min(l,n)),v=n,p=(t-f*v)*m,p>=s&&h>=p&&u*p+f*v>=0&&(!c||o(c.x,c.y,e).height>o(p,v,e).height)&&(egret.Point.release(c),c=egret.Point.create(p,v)),p=(-t-f*v)*m,p>=s&&h>=p&&0>u*p+f*v&&(!c||o(c.x,c.y,e).height>o(p,v,e).height)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(c)return c;var y=e.b,C=e.d,$=y*C>=0?C:-C;return r(u,f,t,s,a,h,l,y,$)}function r(t,e,i,n,s,r,a,o,h){if(0==t||0==e)return null;var l,u,d=(i-n*t)/e,c=(i-r*t)/e,p=Math.max(s,Math.min(d,c)),v=Math.min(a,Math.max(d,c)),f=o*e-t*h;return v>=p?(u=Math.abs(f)<1e-9?i/(t+e):o*i/f,u=Math.max(p,Math.min(u,v)),l=(i-e*u)/t,egret.Point.create(l,u)):(d=-(n*t+i)/e,c=-(r*t+i)/e,p=Math.max(s,Math.min(d,c)),v=Math.min(a,Math.max(d,c)),v>=p?(u=Math.abs(f)<1e-9?-i/(t+e):-o*i/f,u=Math.max(p,Math.min(u,v)),l=(-i-e*u)/t,egret.Point.create(l,u)):null)}function a(t,e,i,n,s,a,o){var l=i.a,u=i.b,d=i.c,c=i.d;if(l>-1e-9&&1e-9>l&&(l=0),u>-1e-9&&1e-9>u&&(u=0),d>-1e-9&&1e-9>d&&(d=0),c>-1e-9&&1e-9>c&&(c=0),0==u&&0==d)return 0==l||0==c?null:egret.Point.create(t/Math.abs(l),e/Math.abs(c));if(0==l&&0==c)return 0==u||0==d?null:egret.Point.create(e/Math.abs(u),t/Math.abs(d));var p=l*d>=0?d:-d,v=u*c>=0?c:-c,f=l*v-u*p;if(Math.abs(f)<1e-9)return 0==p||0==l||l==-p?null:Math.abs(l*e-u*t)>1e-9?null:r(l,p,t,n,n,a,o,u,v);var g=1/f;t*=g,e*=g;var m;return m=h(l,p,u,v,t,e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x>=0&&u*m.x+v*m.y>=0?m:(m=h(l,p,u,v,t,-e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x>=0&&u*m.x+v*m.y<0?m:(m=h(l,p,u,v,-t,e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x<0&&u*m.x+v*m.y>=0?m:(m=h(l,p,u,v,-t,-e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x<0&&u*m.x+v*m.y<0?m:(egret.Point.release(m),null))))}function o(t,e,i){var n=egret.$TempRectangle.setTo(0,0,t,e);return i.$transformBounds(n),n}function h(t,e,i,n,s,r){return egret.Point.create(n*s-e*r,t*r-i*s)}var l=.1,u=.1,d=function(){function t(){}var n=(__define,t);n.prototype;return t.fitBounds=function(t,n,s,r,h,d,c,p,v,f,g){if(isNaN(t)&&isNaN(n))return egret.Point.create(d,c);var m,y=u>p?0:p-u,C=u>v?0:v-u,$=f+u,E=g+u;if(isNaN(t)||isNaN(n))return isNaN(t)?i(n,s,r,h,d,c,y,C,$,E):e(t,s,r,h,d,c,y,C,$,E);if(m=a(t,n,s,y,C,$,E),!m){var _;if(_=e(t,s,r,h,d,c,y,C,$,E)){var T=o(_.x,_.y,s).height;T-l>n&&(egret.Point.release(_),_=null)}var I;if(I=i(n,s,r,h,d,c,y,C,$,E)){var x=o(I.x,I.y,s).width;x-l>t&&(egret.Point.release(I),I=null)}m=_&&I?_.x*_.y>I.x*I.y?_:I:_?_:I,egret.Point.release(_),egret.Point.release(I)}return m},t}();t.MatrixUtil=d,egret.registerClass(d,"eui.sys.MatrixUtil")}(e=t.sys||(t.sys={}))}(eui||(eui={})); \ No newline at end of file +var eui;!function(t){function e(e){for(var i=e[0],n=i instanceof t.Watcher?i.getValue():i,s=e.length,r=1;s>r;r++){var a=e[r];a instanceof t.Watcher&&(a=a.getValue()),n+=a}return n}var i=function(){function i(){}var n=(__define,i);n.prototype;return i.bindProperty=function(e,i,n,s){var r=t.Watcher.watch(e,i,null,null);if(r){var a=function(t){n[s]=t};r.setHandler(a,null),a(r.getValue())}return r},i.bindHandler=function(e,i,n,s){var r=t.Watcher.watch(e,i,n,s);return r&&n.call(s,r.getValue()),r},i.$bindProperties=function(n,s,r,a,o){if(1==s.length)return i.bindProperty(n,s[0].split("."),a,o);for(var h=function(){a[o]=e(s)},l=r.length,u=0;l>u;u++){var d=r[u],c=s[d].split("."),p=t.Watcher.watch(n,c,null,null);p&&(s[d]=p,p.setHandler(h,null))}return h(),p},i}();t.Binding=i,egret.registerClass(i,"eui.Binding")}(eui||(eui={}));var eui;!function(t){function e(t,i){var n=Object.getOwnPropertyDescriptor(t,i);if(n)return n;var s=Object.getPrototypeOf(t);return s?e(s,i):null}function i(t,e){for(var i=t[n],s=i.length,r=0;s>r;r+=2){var a=i[r],o=i[r+1];a.call(o,e)}}var n="__listeners__",s="__bindables__",r=0,a=function(){function a(t,e,i,n){this.isExecuting=!1,this.property=t,this.handler=e,this.next=n,this.thisObject=i}var o=(__define,a),h=o.prototype;return a.watch=function(t,e,i,n){if(e.length>0){var s=e.shift(),r=a.watch(null,e,i,n),o=new a(s,i,n,r);return o.reset(t),o}return null},a.checkBindable=function(a,o){var h=a[s];if(h&&-1!=h.indexOf(o))return!0;var l=egret.is(a,"egret.IEventDispatcher");l||a[n]||(a[n]=[]);var u=e(a,o);if(u&&u.set&&u.get){var d=u.set;u.set=function(e){this[o]!=e&&(d.call(this,e),l?t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,o):i(this,o))}}else{if(u&&(u.get||u.set))return!1;r++;var c="_"+r+o;a[c]=u?u.value:null,u={enumerable:!0,configurable:!0},u.get=function(){return this[c]},u.set=function(e){this[c]!=e&&(this[c]=e,l?t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,o):i(this,o))}}Object.defineProperty(a,o,u),t.registerBindable(a,o)},h.unwatch=function(){this.reset(null),this.handler=null,this.next&&(this.next.handler=null)},h.getValue=function(){return this.next?this.next.getValue():this.getHostPropertyValue()},h.setHandler=function(t,e){this.handler=t,this.thisObject=e,this.next&&this.next.setHandler(t,e)},h.reset=function(e){var i=this.host;if(i)if(egret.is(i,"egret.IEventDispatcher"))i.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.wrapHandler,this);else{var s=i[n],r=s.indexOf(this);s.splice(r-1,2)}if(this.host=e,e)if(a.checkBindable(e,this.property),egret.is(e,"egret.IEventDispatcher"))e.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.wrapHandler,this,!1,100);else{var s=e[n];s.push(this.onPropertyChange),s.push(this)}this.next&&this.next.reset(this.getHostPropertyValue())},h.getHostPropertyValue=function(){return this.host?this.host[this.property]:null},h.wrapHandler=function(t){this.onPropertyChange(t.property)},h.onPropertyChange=function(t){if(t==this.property&&!this.isExecuting)try{this.isExecuting=!0,this.next&&this.next.reset(this.getHostPropertyValue()),this.handler.call(this.thisObject,this.getValue())}finally{this.isExecuting=!1}},a}();t.Watcher=a,egret.registerClass(a,"eui.Watcher")}(eui||(eui={}));var eui;!function(t){function e(t,e,i,n){var s=t.prototype;s.__meta__=s.__meta__||{},s.__meta__[e]=i,n&&(s.__defaultProperty__=e)}t.registerProperty=e}(eui||(eui={}));var eui;!function(t){function e(t,e){if(t.hasOwnProperty(i))t[i].push(e);else{var n=[e];t[i]&&(n=t[i].concat(n)),t[i]=n}}var i="__bindables__";t.registerBindable=e}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t){e.call(this),t?this._source=t:this._source=[]}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"source",function(){return this._source},function(e){e||(e=[]),this._source=e,this.dispatchCoEvent(t.CollectionEventKind.RESET)}),r.refresh=function(){this.dispatchCoEvent(t.CollectionEventKind.REFRESH)},n(r,"length",function(){return this._source.length}),r.addItem=function(e){this._source.push(e),this.dispatchCoEvent(t.CollectionEventKind.ADD,this._source.length-1,-1,[e])},r.addItemAt=function(e,i){0>i||i>this._source.length,this._source.splice(i,0,e),this.dispatchCoEvent(t.CollectionEventKind.ADD,i,-1,[e])},r.getItemAt=function(t){return this._source[t]},r.getItemIndex=function(t){for(var e=this._source.length,i=0;e>i;i++)if(this._source[i]===t)return i;return-1},r.itemUpdated=function(e){var i=this.getItemIndex(e);-1!=i&&this.dispatchCoEvent(t.CollectionEventKind.UPDATE,i,-1,[e])},r.removeAll=function(){var e=this._source.concat();this._source.length=0,this.dispatchCoEvent(t.CollectionEventKind.REMOVE,0,-1,e)},r.removeItemAt=function(e){if(!(0>e||e>=this._source.length)){var i=this._source.splice(e,1)[0];return this.dispatchCoEvent(t.CollectionEventKind.REMOVE,e,-1,[i]),i}},r.replaceItemAt=function(e,i){if(!(0>i||i>=this._source.length)){var n=this._source.splice(i,1,e)[0];return this.dispatchCoEvent(t.CollectionEventKind.REPLACE,i,-1,[e],[n]),n}},r.replaceAll=function(t){t||(t=[]);for(var e=t.length,i=this._source.length,n=e;i>n;n++)this.removeItemAt(e);for(n=0;e>n;n++)n>=i?this.addItemAt(t[n],n):this.replaceItemAt(t[n],n);this._source=t},r.dispatchCoEvent=function(e,i,n,s,r){t.CollectionEvent.dispatchCollectionEvent(this,t.CollectionEvent.COLLECTION_CHANGE,e,i,n,s,r)},i}(egret.EventDispatcher);t.ArrayCollection=e,egret.registerClass(e,"eui.ArrayCollection",["eui.ICollection","egret.IEventDispatcher"]),t.registerProperty(e,"source","Array",!0)}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e=function(t){function e(){t.call(this),this.targetLevel=Number.POSITIVE_INFINITY,this.invalidatePropertiesFlag=!1,this.invalidateClientPropertiesFlag=!1,this.invalidatePropertiesQueue=new i,this.invalidateSizeFlag=!1,this.invalidateClientSizeFlag=!1,this.invalidateSizeQueue=new i,this.invalidateDisplayListFlag=!1,this.invalidateDisplayListQueue=new i,this.eventDisplay=new egret.Bitmap,this.listenersAttached=!1}__extends(e,t);var n=(__define,e),s=n.prototype;return s.invalidateProperties=function(t){this.invalidatePropertiesFlag||(this.invalidatePropertiesFlag=!0,this.listenersAttached||this.attachListeners()),this.targetLevel<=t.$nestLevel&&(this.invalidateClientPropertiesFlag=!0),this.invalidatePropertiesQueue.insert(t)},s.validateProperties=function(){for(var t=this.invalidatePropertiesQueue,e=t.shift();e;)e.$stage&&e.validateProperties(),e=t.shift();t.isEmpty()&&(this.invalidatePropertiesFlag=!1)},s.invalidateSize=function(t){this.invalidateSizeFlag||(this.invalidateSizeFlag=!0,this.listenersAttached||this.attachListeners()),this.targetLevel<=t.$nestLevel&&(this.invalidateClientSizeFlag=!0),this.invalidateSizeQueue.insert(t)},s.validateSize=function(){for(var t=this.invalidateSizeQueue,e=t.pop();e;)e.$stage&&e.validateSize(),e=t.pop();t.isEmpty()&&(this.invalidateSizeFlag=!1)},s.invalidateDisplayList=function(t){this.invalidateDisplayListFlag||(this.invalidateDisplayListFlag=!0,this.listenersAttached||this.attachListeners()),this.invalidateDisplayListQueue.insert(t)},s.validateDisplayList=function(){for(var t=this.invalidateDisplayListQueue,e=t.shift();e;)e.$stage&&e.validateDisplayList(),e=t.shift();t.isEmpty()&&(this.invalidateDisplayListFlag=!1)},s.attachListeners=function(){this.eventDisplay.addEventListener(egret.Event.ENTER_FRAME,this.doPhasedInstantiationCallBack,this),this.eventDisplay.addEventListener(egret.Event.RENDER,this.doPhasedInstantiationCallBack,this),egret.sys.$invalidateRenderFlag=!0,this.listenersAttached=!0},s.doPhasedInstantiationCallBack=function(t){this.eventDisplay.removeEventListener(egret.Event.ENTER_FRAME,this.doPhasedInstantiationCallBack,this),this.eventDisplay.removeEventListener(egret.Event.RENDER,this.doPhasedInstantiationCallBack,this),this.doPhasedInstantiation()},s.doPhasedInstantiation=function(){this.invalidatePropertiesFlag&&this.validateProperties(),this.invalidateSizeFlag&&this.validateSize(),this.invalidateDisplayListFlag&&this.validateDisplayList(),this.invalidatePropertiesFlag||this.invalidateSizeFlag||this.invalidateDisplayListFlag?this.attachListeners():this.listenersAttached=!1},s.validateClient=function(t){var e,i=!1,n=this.targetLevel;this.targetLevel===Number.POSITIVE_INFINITY&&(this.targetLevel=t.$nestLevel);for(var s=this.invalidatePropertiesQueue,r=this.invalidateSizeQueue,a=this.invalidateDisplayListQueue;!i;){for(i=!0,e=s.removeSmallestChild(t);e;)e.$stage&&e.validateProperties(),e=s.removeSmallestChild(t);for(s.isEmpty()&&(this.invalidatePropertiesFlag=!1),this.invalidateClientPropertiesFlag=!1,e=r.removeLargestChild(t);e;){if(e.$stage&&e.validateSize(),this.invalidateClientPropertiesFlag&&(e=s.removeSmallestChild(t))){s.insert(e),i=!1;break}e=r.removeLargestChild(t)}for(r.isEmpty()&&(this.invalidateSizeFlag=!1),this.invalidateClientPropertiesFlag=!1,this.invalidateClientSizeFlag=!1,e=a.removeSmallestChild(t);e;){if(e.$stage&&e.validateDisplayList(),this.invalidateClientPropertiesFlag&&(e=s.removeSmallestChild(t))){s.insert(e),i=!1;break}if(this.invalidateClientSizeFlag&&(e=r.removeLargestChild(t))){r.insert(e),i=!1;break}e=a.removeSmallestChild(t)}a.isEmpty()&&(this.invalidateDisplayListFlag=!1)}n===Number.POSITIVE_INFINITY&&(this.targetLevel=Number.POSITIVE_INFINITY)},e}(egret.EventDispatcher);t.Validator=e,egret.registerClass(e,"eui.sys.Validator");var i=function(){function t(){this.depthBins={},this.minDepth=0,this.maxDepth=-1}var e=(__define,t),i=e.prototype;return i.insert=function(t){var e=t.$nestLevel;this.maxDepththis.maxDepth&&(this.maxDepth=e));var i=this.depthBins[e];i||(i=this.depthBins[e]=new n),i.insert(t)},i.pop=function(){var t,e=this.minDepth;if(e<=this.maxDepth){for(var i=this.depthBins[this.maxDepth];!i||0===i.length;){if(this.maxDepth--,this.maxDepthe)return null;i=this.depthBins[this.minDepth]}for(t=i.pop();!(i&&0!=i.length||(this.minDepth++,this.minDepth>e));)i=this.depthBins[this.minDepth]}return t},i.removeLargestChild=function(t){for(var e=t.$hashCode,i=t.$nestLevel,n=this.maxDepth,s=i;n>=s;){var r=this.depthBins[n];if(r&&r.length>0){if(n===i){if(r.map[e])return r.remove(t),t}else{if(!egret.is(t,"egret.DisplayObjectContainer"))break;for(var a=r.items,o=r.length,h=0;o>h;h++){var l=a[h];if(t.contains(l))return r.remove(l),l}}n--}else if(n==this.maxDepth&&this.maxDepth--,n--,s>n)break}return null},i.removeSmallestChild=function(t){for(var e=t.$nestLevel,i=e,n=this.maxDepth,s=t.$hashCode;n>=i;){var r=this.depthBins[i];if(r&&r.length>0){if(i===e){if(r.map[s])return r.remove(t),t}else{if(!egret.is(t,"egret.DisplayObjectContainer"))break;for(var a=r.items,o=r.length,h=0;o>h;h++){var l=a[h];if(t.contains(l))return r.remove(l),l}}i++}else if(i==this.minDepth&&this.minDepth++,i++,i>n)break}return null},i.isEmpty=function(){return this.minDepth>this.maxDepth},t}();egret.registerClass(i,"DepthQueue");var n=function(){function t(){this.map={},this.items=[],this.length=0}var e=(__define,t),i=e.prototype;return i.insert=function(t){var e=t.$hashCode;this.map[e]||(this.map[e]=!0,this.length++,this.items.push(t))},i.pop=function(){var t=this.items.pop();return t&&(this.length--,0===this.length?this.map={}:this.map[t.$hashCode]=!1),t},i.remove=function(t){var e=this.items.indexOf(t);e>=0&&(this.items.splice(e,1),this.length--,0===this.length?this.map={}:this.map[t.$hashCode]=!1)},t}();egret.registerClass(n,"DepthBin")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e;!function(e){function i(t){return 1===t.a&&0===t.b&&0===t.c&&1===t.d}function n(t,e){if("function"!=typeof t[e])return!1;var i=t[e].toString(),n=i.indexOf("{"),s=i.lastIndexOf("}");return i=i.substring(n+1,s),""==i.trim()}function s(t,e){for(var i in e)"prototype"!=i&&e.hasOwnProperty(i)&&(t[i]=e[i]);for(var s=t.prototype,r=e.prototype,a=Object.keys(r),o=a.length,h=0;o>h;h++){var l=a[h];if("__meta__"!=l&&(!s.hasOwnProperty(l)||n(s,l))){var u=Object.getOwnPropertyDescriptor(r,l);Object.defineProperty(s,l,u)}}}function r(e,i,n){s(e,h);var r=e.prototype;r.$super=i.prototype,t.registerProperty(e,"left","any"),t.registerProperty(e,"right","any"),t.registerProperty(e,"top","any"),t.registerProperty(e,"bottom","any"),t.registerProperty(e,"horizontalCenter","any"),t.registerProperty(e,"verticalCenter","any"),n&&(r.$childAdded=function(t,e){this.invalidateSize(),this.invalidateDisplayList()},r.$childRemoved=function(t,e){this.invalidateSize(),this.invalidateDisplayList()})}var a="eui.UIComponent",o=new e.Validator,h=function(n){function s(){n.call(this),this.initializeUIValues()}__extends(s,n);var r=__define,h=s,l=h.prototype;return l.initializeUIValues=function(){this.$UIComponent={0:0/0,1:0/0,2:0/0,3:0/0,4:0/0,5:0/0,6:0/0,7:0/0,8:0/0,9:0/0,10:0,11:0,12:0,13:1e5,14:0,15:1e5,16:0,17:0,18:0/0,19:0/0,20:0,21:0,22:0,23:0,24:!0,25:!0,26:!0,27:!1,28:!1,29:!1},this.$includeInLayout=!0,this.$touchEnabled=!0},l.createChildren=function(){},l.childrenCreated=function(){},l.commitProperties=function(){var e=this.$UIComponent;(e[22]!=e[10]||e[23]!=e[11])&&(this.dispatchEventWith(egret.Event.RESIZE),e[22]=e[10],e[23]=e[11]),(e[20]!=this.$getX()||e[21]!=this.$getY())&&(t.UIEvent.dispatchUIEvent(this,t.UIEvent.MOVE),e[20]=this.$getX(),e[21]=this.$getY())},l.measure=function(){},l.updateDisplayList=function(t,e){},r(l,"includeInLayout",function(){return this.$includeInLayout},function(t){t=!!t,this.$includeInLayout!==t&&(this.$includeInLayout=!0,this.invalidateParentLayout(),this.$includeInLayout=t)}),l.$onAddToStage=function(e,i){this.$super.$onAddToStage.call(this,e,i),this.checkInvalidateFlag();var n=this.$UIComponent;n[29]||(n[29]=!0,this.createChildren(),this.childrenCreated(),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CREATION_COMPLETE))},l.checkInvalidateFlag=function(t){var e=this.$UIComponent;e[24]&&o.invalidateProperties(this),e[25]&&o.invalidateSize(this),e[26]&&o.invalidateDisplayList(this)},r(l,"left",function(){return this.$UIComponent[0]},function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[0]!==t&&(e[0]=t,this.invalidateParentLayout())}),r(l,"right",function(){return this.$UIComponent[1]},function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[1]!==t&&(e[1]=t,this.invalidateParentLayout())}),r(l,"top",function(){return this.$UIComponent[2]},function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[2]!==t&&(e[2]=t,this.invalidateParentLayout())}),r(l,"bottom",function(){return this.$UIComponent[3]},function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[3]!=t&&(e[3]=t,this.invalidateParentLayout())}),r(l,"horizontalCenter",function(){return this.$UIComponent[4]},function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[4]!==t&&(e[4]=t,this.invalidateParentLayout())}),r(l,"verticalCenter",function(){return this.$UIComponent[5]},function(t){t=t&&"number"!=typeof t?t.toString().trim():+t;var e=this.$UIComponent;e[5]!==t&&(e[5]=t,this.invalidateParentLayout())}),r(l,"percentWidth",function(){return this.$UIComponent[6]},function(t){t=+t;var e=this.$UIComponent;e[6]!==t&&(e[6]=t,this.invalidateParentLayout())}),r(l,"percentHeight",function(){return this.$UIComponent[7]},function(t){t=+t;var e=this.$UIComponent;e[7]!==t&&(e[7]=t,this.invalidateParentLayout())}),r(l,"explicitWidth",function(){return this.$UIComponent[8]}),r(l,"explicitHeight",function(){return this.$UIComponent[9]}),l.$getWidth=function(){return this.validateSizeNow(),this.$UIComponent[10]},l.$setWidth=function(t){t=+t;var e=this.$UIComponent;return 0>t||e[10]===t&&e[8]===t?!1:(e[8]=t,isNaN(t)&&this.invalidateSize(),this.invalidateProperties(),this.invalidateDisplayList(),this.invalidateParentLayout(),!0)},l.validateSizeNow=function(){this.validateSize(!0),this.updateFinalSize()},l.$getHeight=function(){return this.validateSizeNow(),this.$UIComponent[11]},l.$setHeight=function(t){t=+t;var e=this.$UIComponent;return 0>t||e[11]===t&&e[9]===t?!1:(e[9]=t,isNaN(t)&&this.invalidateSize(),this.invalidateProperties(),this.invalidateDisplayList(),this.invalidateParentLayout(),!0)},r(l,"minWidth",function(){return this.$UIComponent[12]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[12]===t||(e[12]=t,this.invalidateSize(),this.invalidateParentLayout())}),r(l,"maxWidth",function(){return this.$UIComponent[13]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[13]===t||(e[13]=t,this.invalidateSize(),this.invalidateParentLayout())}),r(l,"minHeight",function(){return this.$UIComponent[14]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[14]===t||(e[14]=t,this.invalidateSize(),this.invalidateParentLayout())}),r(l,"maxHeight",function(){return this.$UIComponent[15]},function(t){t=+t||0;var e=this.$UIComponent;0>t||e[15]===t||(e[15]=t,this.invalidateSize(),this.invalidateParentLayout())}),l.setMeasuredSize=function(t,e){var i=this.$UIComponent;i[16]=Math.ceil(+t||0),i[17]=Math.ceil(+e||0)},l.setActualSize=function(t,e){var i=!1,n=this.$UIComponent;n[10]!==t&&(n[10]=t,i=!0),n[11]!==e&&(n[11]=e,i=!0),i&&(this.invalidateDisplayList(),this.dispatchEventWith(egret.Event.RESIZE))},l.$invalidateMatrix=function(){this.$super.$invalidateMatrix.call(this),this.invalidateParentLayout()},l.$setMatrix=function(t,e){return void 0===e&&(e=!0),this.$super.$setMatrix.call(this,t,e),this.invalidateParentLayout(),!0},l.$setAnchorOffsetX=function(t){return this.$super.$setAnchorOffsetX.call(this,t),this.invalidateParentLayout(),!0},l.$setAnchorOffsetY=function(t){return this.$super.$setAnchorOffsetY.call(this,t),this.invalidateParentLayout(),!0},l.$setX=function(t){var e=this.$super.$setX.call(this,t);return e&&this.invalidateProperties(),e},l.$setY=function(t){var e=this.$super.$setY.call(this,t);return e&&this.invalidateProperties(),e},l.invalidateProperties=function(){var t=this.$UIComponent;t[24]||(t[24]=!0,this.$stage&&o.invalidateProperties(this))},l.validateProperties=function(){var t=this.$UIComponent;t[24]&&(this.commitProperties(),t[24]=!1)},l.invalidateSize=function(){var t=this.$UIComponent;t[25]||(t[25]=!0,this.$stage&&o.invalidateSize(this))},l.validateSize=function(t){if(t){var e=this.$children;if(e)for(var i=e.length,n=0;i>n;n++){var s=e[n];egret.is(s,a)&&s.validateSize(!0)}}var r=this.$UIComponent;if(r[25]){var o=this.measureSizes();o&&(this.invalidateDisplayList(),this.invalidateParentLayout()),r[25]=!1}},l.measureSizes=function(){var t=!1,e=this.$UIComponent;if(!e[25])return t;(isNaN(e[8])||isNaN(e[9]))&&(this.measure(),e[16]e[13]&&(e[16]=e[13]),e[17]e[15]&&(e[17]=e[15]));var i=this.getPreferredUWidth(),n=this.getPreferredUHeight();return(i!==e[18]||n!==e[19])&&(e[18]=i,e[19]=n,t=!0),t},l.invalidateDisplayList=function(){var t=this.$UIComponent;t[26]||(t[26]=!0,this.$stage&&o.invalidateDisplayList(this))},l.validateDisplayList=function(){var t=this.$UIComponent;t[26]&&(this.updateFinalSize(),this.updateDisplayList(t[10],t[11]),t[26]=!1)},l.updateFinalSize=function(){var t=0,e=0,i=this.$UIComponent;t=i[27]?i[10]:isNaN(i[8])?i[16]:i[8],e=i[28]?i[11]:isNaN(i[9])?i[17]:i[9],this.setActualSize(t,e)},l.validateNow=function(){this.$stage&&o.validateClient(this)},l.invalidateParentLayout=function(){var t=this.$parent;t&&this.$includeInLayout&&egret.is(t,a)&&(t.invalidateSize(),t.invalidateDisplayList())},l.setLayoutBoundsSize=function(t,n){if(n=+n,t=+t,!(0>n||0>t)){var s,r,a=this.$UIComponent,o=a[13],h=a[15],l=Math.min(a[12],o),u=Math.min(a[14],h);isNaN(t)?(a[27]=!1,s=this.getPreferredUWidth()):(a[27]=!0,s=Math.max(l,Math.min(o,t))),isNaN(n)?(a[28]=!1,r=this.getPreferredUHeight()):(a[28]=!0,r=Math.max(u,Math.min(h,n)));var d=this.getAnchorMatrix();if(i(d))return void this.setActualSize(s,r);var c=e.MatrixUtil.fitBounds(t,n,d,a[8],a[9],this.getPreferredUWidth(),this.getPreferredUHeight(),l,u,o,h);c||(c=egret.Point.create(l,u)),this.setActualSize(c.x,c.y),egret.Point.release(c)}},l.setLayoutBoundsPosition=function(e,n){var s=this.$getMatrix();if(!i(s)||0!=this.anchorOffsetX||0!=this.anchorOffsetY){var r=egret.$TempRectangle;this.getLayoutBounds(r),e+=this.$getX()-r.x,n+=this.$getY()-r.y}var a=this.$super.$setX.call(this,e);(this.$super.$setY.call(this,n)||a)&&t.UIEvent.dispatchUIEvent(this,t.UIEvent.MOVE)},l.getLayoutBounds=function(t){var e,i=this.$UIComponent;e=i[27]?i[10]:isNaN(i[8])?i[16]:i[8];var n;n=i[28]?i[11]:isNaN(i[9])?i[17]:i[9],this.applyMatrix(t,e,n)},l.getPreferredUWidth=function(){var t=this.$UIComponent;return isNaN(t[8])?t[16]:t[8]},l.getPreferredUHeight=function(){var t=this.$UIComponent;return isNaN(t[9])?t[17]:t[9]},l.getPreferredBounds=function(t){var e=this.getPreferredUWidth(),i=this.getPreferredUHeight();this.applyMatrix(t,e,i)},l.applyMatrix=function(t,e,n){var t=t.setTo(0,0,e,n),s=this.getAnchorMatrix();i(s)?(t.x+=s.tx,t.y+=s.ty):s.$transformBounds(t)},l.getAnchorMatrix=function(){var t=this.$getMatrix(),e=this.anchorOffsetX,i=this.anchorOffsetY;if(0!=e||0!=i){var n=egret.$TempMatrix;return t.$preMultiplyInto(n.setTo(1,0,0,1,-e,-i),n),n}return t},s}(egret.DisplayObject);e.UIComponentImpl=h,egret.registerClass(h,"eui.sys.UIComponentImpl",["eui.UIComponent"]),e.mixin=s,e.implementUIComponent=r}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(t){i.call(this),this.$createChildrenCalled=!1,this.$fontChanged=!1,this._widthConstraint=0/0,this.initializeUIValues(),this.text=t}__extends(n,i);var s=(__define,n),r=s.prototype;return r.$invalidateContentBounds=function(){i.prototype.$invalidateContentBounds.call(this),this.invalidateSize()},r.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),s=e.prototype.$setWidth.call(this,t);return n&&s},r.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),s=e.prototype.$setHeight.call(this,t);return n&&s},r.$setText=function(e){var n=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),n},r.$setFont=function(t){this.$BitmapText;return this.$font==t?!1:(this.$font=t,this.$createChildrenCalled?this.$parseFont():this.$fontChanged=!0,this.$BitmapText[6]=!0,!0)},r.$parseFont=function(){if(this.$fontChanged=!1,this.$font&&"string"==typeof this.$font){var e=this.$stage.getImplementation("eui.IAssetAdapter");e||(e=new t.DefaultAssetAdapter),e.getAsset(this.$font,this.$onFontChanged,this)}else this.$setFontData(this.$font)},r.$onFontChanged=function(t,e){e===this.$font&&this.$setFontData(t)},r.$setFontData=function(t){return t==this.$BitmapText[5]?!1:(this.$BitmapText[5]=t,this.$invalidateContentBounds(),!0)},r.createChildren=function(){this.$fontChanged&&this.$parseFont(),this.$createChildrenCalled=!0},r.childrenCreated=function(){},r.commitProperties=function(){},r.measure=function(){var t=this.$UIComponent,e=this.$BitmapText,n=e[0],s=0/0;isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(s=t[13]):s=t[8]:(s=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,s),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,n)},r.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&(this._widthConstraint=t,this.invalidateSize())}},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},n}(egret.BitmapText);t.BitmapLabel=i,egret.registerClass(i,"eui.BitmapLabel",["eui.UIComponent","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.BitmapText),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.initializeUIValues(),this.$Component={0:null,1:null,2:"",3:!0,4:!1,5:!1,6:!0,7:!0,8:null},this.$touchEnabled=!0}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"hostComponentKey",function(){return this.$Component[0]},function(t){this.$Component[0]=t}),n(r,"skinName",function(){return this.$Component[1]},function(t){var e=this.$Component;if(e[5]=!0,e[1]!=t){if(t)e[1]=t;else if(this.$stage){var i=this.$stage.getImplementation("eui.Theme");if(i){var n=i.getSkinName(this);n&&(e[1]=n)}}this.$parseSkinName()}}),r.$parseSkinName=function(){var t,e=this.skinName;if(e)if(e.prototype)t=new e;else if("string"==typeof e){var i,n=e.trim();if("<"==n.charAt(0))i=EXML.parse(n);else if(i=egret.getDefinitionByName(e),!i&&-1!=n.toLowerCase().indexOf(".exml"))return void EXML.load(e,this.onExmlLoaded,this,!0);i&&(t=new i)}else t=e;this.setSkin(t)},r.onExmlLoaded=function(t,e){if(this.skinName==e){var i=new t;this.setSkin(i)}},n(r,"skin",function(){return this.$Component[8]}),r.setSkin=function(e){!e||e instanceof t.Skin||(e=null);var i=this.$Component,n=i[8];if(n){for(var s=n.skinParts,r=s.length,a=0;r>a;a++){var o=s[a];this[o]&&this.setSkinPart(o,null)}var h=n.$elementsContent;if(h){r=h.length;for(var a=0;r>a;a++){var l=h[a];l.$parent==this&&this.removeChild(l)}}n.hostComponent=null}if(i[8]=e,e){for(var s=e.skinParts,r=s.length,a=0;r>a;a++){var o=s[a],u=e[o];u&&this.setSkinPart(o,u)}if(h=e.$elementsContent)for(a=h.length-1;a>=0;a--)this.addChildAt(h[a],0);e.hostComponent=this}this.invalidateSize(),this.invalidateDisplayList(),this.dispatchEventWith(egret.Event.COMPLETE)},r.setSkinPart=function(t,e){var i=this[t];i&&this.partRemoved(t,i),this[t]=e,e&&this.partAdded(t,e)},r.partAdded=function(t,e){},r.partRemoved=function(t,e){},r.$setTouchChildren=function(t){t=!!t;var i=this.$Component;return i[6]=t,i[3]?(i[6]=t,e.prototype.$setTouchChildren.call(this,t)):!0},r.$setTouchEnabled=function(t){t=!!t;var i=this.$Component;return i[7]=t,i[3]?e.prototype.$setTouchEnabled.call(this,t):!0},n(r,"enabled",function(){return this.$Component[3]},function(t){t=!!t,this.$setEnabled(t)}),r.$setEnabled=function(t){var e=this.$Component;return t===e[3]?!1:(e[3]=t,t?(this.$touchEnabled=e[7],this.$touchChildren=e[6]):(this.$touchEnabled=!1,this.$touchChildren=!1),this.invalidateState(),!0)},n(r,"currentState",function(){var t=this.$Component;return t[2]?t[2]:this.getCurrentState()},function(t){var e=this.$Component;t!=e[2]&&(e[2]=t,this.invalidateState())}),r.invalidateState=function(){var t=this.$Component;t[4]||(t[4]=!0,this.invalidateProperties())},r.getCurrentState=function(){return""},r.createChildren=function(){var t=this.$Component;if(!t[1]){var e=this.$stage.getImplementation("eui.Theme");if(e){var i=e.getSkinName(this);i&&(t[1]=i,this.$parseSkinName())}}},r.childrenCreated=function(){},r.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this);var e=this.$Component;e[4]&&(e[4]=!1,e[8]&&(e[8].currentState=this.currentState))},r.measure=function(){t.sys.measure(this);var e=this.$Component[8];if(e){var i=this.$UIComponent;isNaN(e.width)?(i[16]e.maxWidth&&(i[16]=e.maxWidth)):i[16]=e.width,isNaN(e.height)?(i[17]e.maxHeight&&(i[17]=e.maxHeight)):i[17]=e.height}},r.updateDisplayList=function(e,i){t.sys.updateDisplayList(this,e,i)},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,e){},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},i}(egret.DisplayObjectContainer);t.Component=e,egret.registerClass(e,"eui.Component",["eui.UIComponent"]),t.registerProperty(e,"skinName","Class"),t.sys.implementUIComponent(e,egret.DisplayObjectContainer,!0)}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this),this.labelDisplay=null,this._label="",this.iconDisplay=null,this._icon=null,this.touchCaptured=!1,this.touchChildren=!1,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this)}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"label",function(){return this._label},function(t){this._label=t,this.labelDisplay&&(this.labelDisplay.text=t)}),i(s,"icon",function(){return this._icon},function(t){this._icon=t,this.iconDisplay&&(this.iconDisplay.source=t)}),s.onTouchCancle=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!1,this.invalidateState()},s.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!0,this.invalidateState(),t.updateAfterEvent()},s.onStageTouchEnd=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.contains(t.target)&&this.buttonReleased(),this.touchCaptured=!1,this.invalidateState()},s.getCurrentState=function(){return this.enabled?this.touchCaptured?"down":"up":"disabled"},s.partAdded=function(t,e){e===this.labelDisplay?this.labelDisplay.text=this._label:e==this.iconDisplay&&(this.iconDisplay.source=this._icon)},s.buttonReleased=function(){},e}(t.Component);t.Button=e,egret.registerClass(e,"eui.Button")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.apply(this,arguments),this.$selected=!1,this.$autoSelected=!0}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"selected",function(){return this.$selected},function(t){this.$setSelected(t)}),r.$setSelected=function(e){return e=!!e,e===this.$selected?!1:(this.$selected=e,this.invalidateState(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selected"),!0)},r.getCurrentState=function(){var t=e.prototype.getCurrentState.call(this);if(this.$selected){var i=t+"AndSelected",n=this.skin;return n&&n.hasState(i)?i:"disabled"==t?"disabled":"down"}return t},r.buttonReleased=function(){this.$autoSelected&&(this.selected=!this.$selected,this.dispatchEventWith(egret.Event.CHANGE))},i}(t.Button);t.ToggleButton=e,egret.registerClass(e,"eui.ToggleButton"),t.registerBindable(e.prototype,"selected")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e);i.prototype;return e}(t.ToggleButton);t.CheckBox=e,egret.registerClass(e,"eui.CheckBox")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t,i){void 0===i&&(i=[]),e.call(this),this.name=t,this.overrides=i}__extends(i,e);var n=(__define,i),s=n.prototype;return s.initialize=function(e,i){for(var n=this.overrides,s=n.length,r=0;s>r;r++){var a=n[r];if(a instanceof t.AddItems){var o=e[a.target];o&&o instanceof t.Image&&!o.$parent&&(i.addChild(o),i.removeChild(o))}}},i}(egret.HashObject);t.State=e,egret.registerClass(e,"eui.State")}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e=function(){function t(){}var e=__define,i=t,n=i.prototype;return e(n,"states",function(){return this.$stateValues.states},function(t){t||(t=[]); +var e=this.$stateValues;e.states=t;for(var i={},n=t.length,s=0;n>s;s++){var r=t[s];i[r.name]=r}e.statesMap=i,e.parent&&this.commitCurrentState()}),e(n,"currentState",function(){return this.$stateValues.currentState},function(t){var e=this.$stateValues;e.explicitState=t,e.currentState=t,this.commitCurrentState()}),n.commitCurrentState=function(){var t=this.$stateValues;if(t.parent){var e=t.statesMap[t.currentState];if(!e){if(!(t.states.length>0))return;t.currentState=t.states[0].name}if(t.oldState!=t.currentState){var i=t.parent,n=t.statesMap[t.oldState];if(n)for(var s=n.overrides,r=s.length,a=0;r>a;a++)s[a].remove(this,i);if(t.oldState=t.currentState,n=t.statesMap[t.currentState])for(s=n.overrides,r=s.length,a=0;r>a;a++)s[a].apply(this,i)}}},n.hasState=function(t){return!!this.$stateValues.statesMap[t]},n.initializeStates=function(t){this.$stateValues.intialized=!0;for(var e=this.states,i=e.length,n=0;i>n;n++)e[n].initialize(this,t)},t}();t.StateClient=e,egret.registerClass(e,"eui.sys.StateClient");var i=function(){function t(){this.intialized=!1,this.statesMap={},this.states=[],this.oldState=null,this.explicitState=null,this.currentState=null,this.parent=null,this.stateIsDirty=!1}var e=(__define,t);e.prototype;return t}();t.StateValues=i,egret.registerClass(i,"eui.sys.StateValues")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$layout=null,this.$stateValues=new t.sys.StateValues,this.initializeUIValues(),this.$Group={0:0,1:0,2:0,3:0,4:!1,5:!1},this.$stateValues.parent=this}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"elementsContent",void 0,function(t){if(t)for(var e=t.length,i=0;e>i;i++)this.addChild(t[i])}),n(r,"layout",function(){return this.$layout},function(t){this.$setLayout(t)}),r.$setLayout=function(t){return this.$layout==t?!1:(this.$layout&&(this.$layout.target=null),this.$layout=t,t&&(t.target=this),this.invalidateSize(),this.invalidateDisplayList(),!0)},n(r,"contentWidth",function(){return this.$Group[0]}),n(r,"contentHeight",function(){return this.$Group[1]}),r.setContentSize=function(e,i){e=Math.ceil(+e||0),i=Math.ceil(+i||0);var n=this.$Group,s=n[0]!==e,r=n[1]!==i;(s||r)&&(n[0]=e,n[1]=i,s&&t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"contentWidth"),r&&t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"contentHeight"))},n(r,"scrollEnabled",function(){return this.$Group[4]},function(t){t=!!t;var e=this.$Group;t!==e[4]&&(e[4]=t,this.updateScrollRect())}),n(r,"scrollH",function(){return this.$Group[2]},function(e){e=+e||0;var i=this.$Group;e!==i[2]&&(i[2]=e,this.updateScrollRect()&&this.$layout&&this.$layout.scrollPositionChanged(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"scrollH"))}),n(r,"scrollV",function(){return this.$Group[3]},function(e){e=+e||0;var i=this.$Group;e!=i[3]&&(i[3]=e,this.updateScrollRect()&&this.$layout&&this.$layout.scrollPositionChanged(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"scrollV"))}),r.updateScrollRect=function(){var t=this.$Group,e=t[4];if(e){var i=this.$UIComponent;this.scrollRect=egret.$TempRectangle.setTo(t[2],t[3],i[10],i[11])}else this.$scrollRect&&(this.scrollRect=null);return e},n(r,"numElements",function(){return this.$children.length}),r.getElementAt=function(t){return this.$children[t]},r.getVirtualElementAt=function(t){return this.getElementAt(t)},r.setVirtualElementIndicesInView=function(t,e){},n(r,"touchThrough",function(){return this.$Group[5]},function(t){this.$Group[5]=!!t}),r.$hitTest=function(t,i){var n=e.prototype.$hitTest.call(this,t,i);if(n||this.$Group[5])return n;if(!this.$visible||!this.touchEnabled)return null;var s=this.globalToLocal(t,i,egret.$TempPoint),r=this.$UIComponent,a=egret.$TempRectangle.setTo(0,0,r[10],r[11]),o=this.$scrollRect;return o&&(a.x=o.x,a.y=o.y),a.contains(s.x,s.y)?this:null},r.invalidateState=function(){var t=this.$stateValues;t.stateIsDirty||(t.stateIsDirty=!0,this.invalidateProperties())},r.getCurrentState=function(){return""},r.createChildren=function(){this.$layout||this.$setLayout(new t.BasicLayout),this.initializeStates(this.$stage)},r.childrenCreated=function(){},r.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this);var e=this.$stateValues;e.stateIsDirty&&(e.stateIsDirty=!1,e.explicitState||(e.currentState=this.getCurrentState(),this.commitCurrentState()))},r.measure=function(){return this.$layout?void this.$layout.measure():void this.setMeasuredSize(0,0)},r.updateDisplayList=function(t,e){this.$layout&&this.$layout.updateDisplayList(t,e),this.updateScrollRect()},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,e){},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},i}(egret.DisplayObjectContainer);t.Group=e,egret.registerClass(e,"eui.Group",["eui.IViewport","eui.UIComponent"]),t.sys.implementUIComponent(e,egret.DisplayObjectContainer,!0),t.sys.mixin(e,t.sys.StateClient),t.registerProperty(e,"elementsContent","Array",!0),t.registerProperty(e,"states","State[]")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$dataProviderChanged=!1,this.$dataProvider=null,this.$indexToRenderer=[],this.$DataGroup={0:!0,1:!1,2:{},3:{},4:!1,5:!1,6:null,7:null,8:!1,9:null,10:!1,11:!1,12:null,13:null,14:!1}}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"useVirtualLayout",function(){return this.$layout?this.$layout.$useVirtualLayout:this.$DataGroup[0]},function(t){t=!!t;var e=this.$DataGroup;t!==e[0]&&(e[0]=t,this.$layout&&(this.$layout.useVirtualLayout=t))}),r.$setLayout=function(t){if(t==this.$layout)return!1;this.$layout&&(this.$layout.setTypicalSize(0,0),this.$layout.removeEventListener("useVirtualLayoutChanged",this.onUseVirtualLayoutChanged,this)),this.$layout&&t&&this.$layout.$useVirtualLayout!=t.$useVirtualLayout&&this.onUseVirtualLayoutChanged();var i=e.prototype.$setLayout.call(this,t);if(t){var n=this.$DataGroup[9];n&&t.setTypicalSize(n.width,n.height),t.useVirtualLayout=this.$DataGroup[0],t.addEventListener("useVirtualLayoutChanged",this.onUseVirtualLayoutChanged,this)}return i},r.onUseVirtualLayoutChanged=function(t){var e=this.$DataGroup;e[1]=!0,e[10]=!0,this.removeDataProviderListener(),this.invalidateProperties()},r.setVirtualElementIndicesInView=function(t,e){if(this.$layout&&this.$layout.$useVirtualLayout)for(var i=this.$indexToRenderer,n=Object.keys(i),s=n.length,r=0;s>r;r++){var a=+n[r];(t>a||a>e)&&this.freeRendererByIndex(a)}},r.getElementAt=function(t){return this.$indexToRenderer[t]},r.getVirtualElementAt=function(t){if(t=0|+t,0>t||t>=this.$dataProvider.length)return null;var e=this.$indexToRenderer[t];if(!e){var i=this.$dataProvider.getItemAt(t);e=this.createVirtualRenderer(i),this.$indexToRenderer[t]=e,this.updateRenderer(e,t,i);var n=this.$DataGroup;n[4]&&(e.validateNow(),n[4]=!1,this.rendererAdded(e,t,i))}return e},r.freeRendererByIndex=function(t){var e=this.$indexToRenderer[t];e&&(delete this.$indexToRenderer[t],this.doFreeRenderer(e))},r.doFreeRenderer=function(t){var e=this.$DataGroup,i=e[2][t.$hashCode],n=i.$hashCode;e[3][n]||(e[3][n]=[]),e[3][n].push(t),t.visible=!1},r.invalidateSize=function(){this.$DataGroup[4]||e.prototype.invalidateSize.call(this)},r.createVirtualRenderer=function(t){var e,i=this.itemToRendererClass(t),n=i.$hashCode,s=this.$DataGroup,r=s[3];return r[n]&&r[n].length>0?(e=r[n].pop(),e.visible=!0,this.invalidateDisplayList(),e):(s[4]=!0,this.createOneRenderer(i))},r.createOneRenderer=function(t){var e=new t,i=this.$DataGroup;return i[2][e.$hashCode]=t,egret.is(e,"eui.IItemRenderer")?(i[13]&&this.setItemRenderSkinName(e,i[13]),this.addChild(e),e):null},r.setItemRenderSkinName=function(e,i){if(e&&e instanceof t.Component){var n=e;n.$Component[5]||(n.skinName=i,n.$Component[5]=!1)}},n(r,"dataProvider",function(){return this.$dataProvider},function(t){this.$setDataProvider(t)}),r.$setDataProvider=function(t){return this.$dataProvider==t?!1:(this.removeDataProviderListener(),this.$dataProvider=t,this.$dataProviderChanged=!0,this.$DataGroup[10]=!0,this.invalidateProperties(),this.invalidateSize(),this.invalidateDisplayList(),!0)},r.removeDataProviderListener=function(){this.$dataProvider&&this.$dataProvider.removeEventListener(t.CollectionEvent.COLLECTION_CHANGE,this.onCollectionChange,this)},r.onCollectionChange=function(e){switch(e.kind){case t.CollectionEventKind.ADD:this.itemAddedHandler(e.items,e.location);break;case t.CollectionEventKind.REMOVE:this.itemRemovedHandler(e.items,e.location);break;case t.CollectionEventKind.UPDATE:case t.CollectionEventKind.REPLACE:this.itemUpdatedHandler(e.items[0],e.location);break;case t.CollectionEventKind.RESET:case t.CollectionEventKind.REFRESH:if(this.$layout&&this.$layout.$useVirtualLayout)for(var i=this.$indexToRenderer,n=Object.keys(i),s=n.length,r=s-1;r>=0;r--){var a=+n[r];this.freeRendererByIndex(a)}this.$dataProviderChanged=!0,this.invalidateProperties()}this.invalidateSize(),this.invalidateDisplayList()},r.itemAddedHandler=function(t,e){for(var i=t.length,n=0;i>n;n++)this.itemAdded(t[n],e+n);this.resetRenderersIndices()},r.itemRemovedHandler=function(t,e){for(var i=t.length,n=i-1;n>=0;n--)this.itemRemoved(t[n],e+n);this.resetRenderersIndices()},r.itemAdded=function(t,e){if(this.$layout&&this.$layout.elementAdded(e),this.$layout&&this.$layout.$useVirtualLayout)return void this.$indexToRenderer.splice(e,0,null);var i=this.createVirtualRenderer(t);if(this.$indexToRenderer.splice(e,0,i),i){this.updateRenderer(i,e,t);var n=this.$DataGroup;n[4]&&(n[4]=!1,this.rendererAdded(i,e,t))}},r.itemRemoved=function(t,e){this.$layout&&this.$layout.elementRemoved(e);var i=this.$indexToRenderer[e];this.$indexToRenderer.length>e&&this.$indexToRenderer.splice(e,1),i&&(this.$layout&&this.$layout.$useVirtualLayout?this.doFreeRenderer(i):(this.rendererRemoved(i,e,t),this.removeChild(i)))},r.resetRenderersIndices=function(){var t=this.$indexToRenderer;if(0!=t.length)if(this.$layout&&this.$layout.$useVirtualLayout)for(var e=Object.keys(t),i=e.length,n=0;i>n;n++){var s=+e[n];this.resetRendererItemIndex(s)}else{var r=t.length;for(s=0;r>s;s++)this.resetRendererItemIndex(s)}},r.itemUpdatedHandler=function(t,e){if(!this.$DataGroup[11]){var i=this.$indexToRenderer[e];i&&this.updateRenderer(i,e,t)}},r.resetRendererItemIndex=function(t){var e=this.$indexToRenderer[t];e&&(e.itemIndex=t)},n(r,"itemRenderer",function(){return this.$DataGroup[6]},function(t){var e=this.$DataGroup;e[6]!=t&&(e[6]=t,e[5]=!0,e[8]=!0,e[10]=!0,this.removeDataProviderListener(),this.invalidateProperties())}),n(r,"itemRendererSkinName",function(){return this.$DataGroup[13]},function(t){var e=this.$DataGroup;e[13]!=t&&(e[13]=t,this.$UIComponent[29]&&(e[14]=!0,this.invalidateProperties()))}),n(r,"itemRendererFunction",function(){return this.$DataGroup[7]},function(t){var e=this.$DataGroup;e[7]!=t&&(e[7]=t,e[5]=!0,e[8]=!0,this.removeDataProviderListener(),this.invalidateProperties())}),r.itemToRendererClass=function(e){var i,n=this.$DataGroup;return n[7]&&(i=n[7](e)),i||(i=n[6]),i||(i=t.ItemRenderer),i.$hashCode||(i.$hashCode=egret.$hashCount++),i},r.createChildren=function(){if(!this.$layout){var i=new t.VerticalLayout;i.gap=0,i.horizontalAlign=t.JustifyAlign.CONTENT_JUSTIFY,this.$setLayout(i)}e.prototype.createChildren.call(this)},r.commitProperties=function(){var i=this.$DataGroup;if((i[5]||this.$dataProviderChanged||i[1])&&(this.removeAllRenderers(),this.$layout&&this.$layout.clearVirtualLayoutCache(),this.setTypicalLayoutRect(null),i[1]=!1,i[5]=!1,this.$dataProvider&&this.$dataProvider.addEventListener(t.CollectionEvent.COLLECTION_CHANGE,this.onCollectionChange,this),this.$layout&&this.$layout.$useVirtualLayout?(this.invalidateSize(),this.invalidateDisplayList()):this.createRenderers(),this.$dataProviderChanged&&(this.$dataProviderChanged=!1,this.scrollV=this.scrollH=0)),e.prototype.commitProperties.call(this),i[8]&&(i[8]=!1,this.$dataProvider&&this.$dataProvider.length>0&&(i[12]=this.$dataProvider.getItemAt(0),this.measureRendererSize())),i[14]){i[14]=!1;for(var n=i[13],s=this.$indexToRenderer,r=Object.keys(s),a=r.length,o=0;a>o;o++){var h=r[o];this.setItemRenderSkinName(s[h],n)}for(var l=i[3],r=Object.keys(l),a=r.length,o=0;a>o;o++)for(var u=r[o],d=l[u],a=d.length,o=0;a>o;o++)this.setItemRenderSkinName(d[o],n)}},r.measure=function(){this.$layout&&this.$layout.$useVirtualLayout&&this.ensureTypicalLayoutElement(),e.prototype.measure.call(this)},r.updateDisplayList=function(t,i){var n=this.$layout&&this.$layout.$useVirtualLayout;n&&this.ensureTypicalLayoutElement(),e.prototype.updateDisplayList.call(this,t,i);var s=this.$DataGroup;if(n){var r=s[9];if(r){var a=this.$indexToRenderer[0];if(a){var o=egret.$TempRectangle;a.getPreferredBounds(o),(o.width!=r.width||o.height!=r.height)&&(s[9]=null)}}}},r.ensureTypicalLayoutElement=function(){this.$DataGroup[9]||this.$dataProvider&&this.$dataProvider.length>0&&(this.$DataGroup[12]=this.$dataProvider.getItemAt(0),this.measureRendererSize())},r.measureRendererSize=function(){var t=this.$DataGroup;if(!t[12])return void this.setTypicalLayoutRect(null);var e=this.createVirtualRenderer(t[12]);if(!e)return void this.setTypicalLayoutRect(null);this.updateRenderer(e,0,t[12]),e.validateNow();var i=egret.$TempRectangle;e.getPreferredBounds(i);var n=new egret.Rectangle(0,0,i.width,i.height);this.$layout&&this.$layout.$useVirtualLayout?(t[4]&&this.rendererAdded(e,0,t[12]),this.doFreeRenderer(e)):this.removeChild(e),this.setTypicalLayoutRect(n),t[4]=!1},r.setTypicalLayoutRect=function(t){this.$DataGroup[9]=t,this.$layout&&(t?this.$layout.setTypicalSize(t.width,t.height):this.$layout.setTypicalSize(0,0))},r.removeAllRenderers=function(){for(var t=this.$indexToRenderer,e=Object.keys(t),i=e.length,n=0;i>n;n++){var s=e[n],r=t[s];r&&(this.rendererRemoved(r,r.itemIndex,r.data),this.removeChild(r))}this.$indexToRenderer=[];var a=this.$DataGroup;if(a[10]){for(var o=a[3],e=Object.keys(o),i=e.length,n=0;i>n;n++)for(var h=e[n],l=o[h],i=l.length,n=0;i>n;n++)r=l[n],this.rendererRemoved(r,r.itemIndex,r.data),this.removeChild(r);a[3]={},a[2]={},a[10]=!1}},r.createRenderers=function(){if(this.$dataProvider)for(var t=0,e=this.$dataProvider.length,i=0;e>i;i++){var n=this.$dataProvider.getItemAt(i),s=this.itemToRendererClass(n),r=this.createOneRenderer(s);r&&(this.$indexToRenderer[t]=r,this.updateRenderer(r,t,n),this.rendererAdded(r,t,n),t++)}},r.updateRenderer=function(t,e,i){var n=this.$DataGroup;return n[11]=!0,t.itemIndex=e,t.data=i,n[11]=!1,t},n(r,"numElements",function(){return this.$dataProvider?this.$dataProvider.length:0}),r.rendererAdded=function(t,e,i){},r.rendererRemoved=function(t,e,i){},i}(t.Group);t.DataGroup=e,egret.registerClass(e,"eui.DataGroup"),t.registerProperty(e,"itemRenderer","Class"),t.registerProperty(e,"itemRendererSkinName","Class"),t.registerProperty(e,"dataProvider","eui.ICollection",!0)}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(){i.call(this),this._widthConstraint=0/0,this.$isShowPrompt=!1,this.$promptColor=6710886,this.$isFocusIn=!1,this.initializeUIValues(),this.type=egret.TextFieldType.INPUT,this.$EditableText={0:null,1:16777215,2:!1}}__extends(n,i);var s=__define,r=n,a=r.prototype;return a.$invalidateContentBounds=function(){i.prototype.$invalidateContentBounds.call(this),this.invalidateSize()},a.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),s=e.prototype.$setWidth.call(this,t);return n&&s},a.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),s=e.prototype.$setHeight.call(this,t);return n&&s},a.$getText=function(){var t=i.prototype.$getText.call(this);return t==this.$EditableText[0]&&(t=""),t},a.$setText=function(e){var n=this.$EditableText[0];(n!=e||null==n)&&(this.$isShowPrompt=!1,this.textColor=this.$EditableText[1]),this.$isFocusIn||(""==e||null==e)&&(e=n,this.$isShowPrompt=!0,i.prototype.$setTextColor.call(this,this.$promptColor));var s=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),s},a.$onAddToStage=function(e,i){t.sys.UIComponentImpl.prototype.$onAddToStage.call(this,e,i),this.addEventListener(egret.FocusEvent.FOCUS_IN,this.onfocusIn,this),this.addEventListener(egret.FocusEvent.FOCUS_OUT,this.onfocusOut,this)},a.$onRemoveFromStage=function(){t.sys.UIComponentImpl.prototype.$onRemoveFromStage.call(this),this.removeEventListener(egret.FocusEvent.FOCUS_IN,this.onfocusIn,this),this.removeEventListener(egret.FocusEvent.FOCUS_OUT,this.onfocusOut,this)},s(a,"prompt",function(){return this.$EditableText[0]},function(t){var e=this.$EditableText,i=e[0];if(i!=t){e[0]=t;var n=this.text;n&&n!=i||this.showPromptText()}}),s(a,"promptColor",function(){return this.$promptColor},function(t){if(t=0|+t,this.$promptColor!=t){this.$promptColor=t;var e=this.text;e&&e!=this.$EditableText[0]||this.showPromptText()}}),a.onfocusOut=function(){this.$isFocusIn=!1,this.text||this.showPromptText()},a.onfocusIn=function(){this.$isFocusIn=!0,this.$isShowPrompt=!1,this.displayAsPassword=this.$EditableText[2];var t=this.$EditableText,e=this.text;e&&e!=t[0]||(this.textColor=t[1],this.text="")},a.showPromptText=function(){var t=this.$EditableText;this.$isShowPrompt=!0,i.prototype.$setTextColor.call(this,this.$promptColor),i.prototype.$setDisplayAsPassword.call(this,!1),this.text=t[0]},a.$setTextColor=function(t){return t=0|+t,this.$EditableText[1]=t,this.$isShowPrompt||i.prototype.$setTextColor.call(this,t),!0},a.$setDisplayAsPassword=function(t){return this.$EditableText[2]=t,this.$isShowPrompt||i.prototype.$setDisplayAsPassword.call(this,t),!0},a.createChildren=function(){this.onfocusOut()},a.childrenCreated=function(){},a.commitProperties=function(){},a.measure=function(){var t=this.$UIComponent,e=this.$TextField,n=e[3],s=0/0;isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(s=t[13]):s=t[8]:(s=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,s),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,n)},a.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},a.invalidateParentLayout=function(){},a.setMeasuredSize=function(t,e){},a.invalidateProperties=function(){},a.validateProperties=function(){},a.invalidateSize=function(){},a.validateSize=function(t){},a.invalidateDisplayList=function(){},a.validateDisplayList=function(){},a.validateNow=function(){},a.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&(this._widthConstraint=t,this.invalidateSize())}},a.setLayoutBoundsPosition=function(t,e){},a.getLayoutBounds=function(t){},a.getPreferredBounds=function(t){},n}(egret.TextField);t.EditableText=i,egret.registerClass(i,"eui.EditableText",["eui.UIComponent","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.TextField),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.thumb=null,this.$viewport=null,this.autoVisibility=!0}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"viewport",function(){return this.$viewport},function(e){if(e!=this.$viewport){var i=this.$viewport;i&&(i.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onPropertyChanged,this),i.removeEventListener(egret.Event.RESIZE,this.onViewportResize,this)),this.$viewport=e,e&&(e.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onPropertyChanged,this),e.addEventListener(egret.Event.RESIZE,this.onViewportResize,this)),this.invalidateDisplayList()}}),r.onViewportResize=function(t){this.invalidateDisplayList()},r.onPropertyChanged=function(t){},i}(t.Component);t.ScrollBarBase=e,egret.registerClass(e,"eui.ScrollBarBase")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.updateDisplayList=function(e,i){t.prototype.updateDisplayList.call(this,e,i);var n=this.thumb,s=this.$viewport;if(n&&s){var r=egret.$TempRectangle;n.getPreferredBounds(r);var a=r.width,o=r.y,h=s.scrollH,l=s.contentWidth,u=s.width;if(0>=h){var d=a*(1- -h/(.5*u));d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(d,0/0),n.setLayoutBoundsPosition(0,o)}else if(h>=l-u)d=a*(1-(h-l+u)/(.5*u)),d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(d,0/0),n.setLayoutBoundsPosition(e-d,o);else{var c=(e-a)*h/(l-u);n.setLayoutBoundsSize(0/0,0/0),n.setLayoutBoundsPosition(c,o)}}},n.onPropertyChanged=function(t){switch(t.property){case"scrollH":case"contentWidth":this.invalidateDisplayList()}},e}(t.ScrollBarBase);t.HScrollBar=e,egret.registerClass(e,"eui.HScrollBar")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$Range={0:100,1:!1,2:0,3:!1,4:0,5:0,6:!1,7:1,8:!1,9:!1}}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"maximum",function(){return this.$Range[0]},function(t){t=+t||0;var e=this.$Range;t!==e[0]&&(e[0]=t,e[1]=!0,this.invalidateProperties(),this.invalidateDisplayList())}),n(r,"minimum",function(){return this.$Range[2]},function(t){t=+t||0;var e=this.$Range;t!==e[2]&&(e[2]=t,e[3]=!0,this.invalidateProperties(),this.invalidateDisplayList())}),n(r,"value",function(){var t=this.$Range;return t[6]?t[5]:t[4]},function(t){t=+t||0,this.$setValue(t)}),r.$setValue=function(t){if(t===this.value)return!1;var e=this.$Range;return e[5]=t,e[6]=!0,this.invalidateProperties(),!0},n(r,"snapInterval",function(){return this.$Range[7]},function(t){var e=this.$Range;e[9]=!0,t=+t||0,t!==e[7]&&(isNaN(t)?(e[7]=1,e[9]=!1):e[7]=t,e[8]=!0,this.invalidateProperties())}),r.commitProperties=function(){e.prototype.commitProperties.call(this);var t=this.$Range;if(t[2]>t[0]&&(t[1]?t[0]=t[2]:t[2]=t[0]),t[6]||t[1]||t[3]||t[8]){var i=t[6]?t[5]:t[4];t[6]=!1,t[1]=!1,t[3]=!1,t[8]=!1,this.setValue(this.nearestValidValue(i,t[7]))}},r.nearestValidSize=function(t){var e=this.snapInterval;if(0==e)return t;var i=Math.round(t/e)*e;return Math.abs(i)=(o-a)/2?o:a;return h/s+i[2]},r.setValue=function(e){var i=this.$Range;i[4]!==e&&(i[0]>i[2]?i[4]=Math.min(i[0],Math.max(i[2],e)):i[4]=e,i[6]=!1,this.invalidateDisplayList(),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"value"))},r.updateDisplayList=function(t,i){e.prototype.updateDisplayList.call(this,t,i),this.updateSkinDisplayList()},r.updateSkinDisplayList=function(){},i}(t.Component);t.Range=e,egret.registerClass(e,"eui.Range"),t.registerBindable(e.prototype,"value")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.trackHighlight=null,this.thumb=null,this.track=null,this.$SliderBase={0:0,1:0,2:0,3:0,4:null,5:null,6:300,7:0,8:0,9:!0},this.maximum=10,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this)}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"slideDuration",function(){return this.$SliderBase[6]},function(t){this.$SliderBase[6]=+t||0}),r.pointToValue=function(t,e){return this.minimum},n(r,"liveDragging",function(){return this.$SliderBase[9]},function(t){this.$SliderBase[9]=!!t}),n(r,"pendingValue",function(){return this.$SliderBase[7]},function(t){t=+t||0;var e=this.$SliderBase;t!==e[7]&&(e[7]=t,this.invalidateDisplayList())}),r.setValue=function(t){this.$SliderBase[7]=t,e.prototype.setValue.call(this,t)},r.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i==this.thumb?(this.thumb.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onThumbTouchBegin,this),this.thumb.addEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i==this.track?(this.track.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTrackTouchBegin,this),this.track.addEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i===this.trackHighlight&&(this.trackHighlight.touchEnabled=!1,egret.is(this.trackHighlight,"egret.DisplayObjectContainer")&&(this.trackHighlight.touchChildren=!1))},r.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i==this.thumb?(this.thumb.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onThumbTouchBegin,this),this.thumb.removeEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this)):i==this.track&&(this.track.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTrackTouchBegin,this),this.track.removeEventListener(egret.Event.RESIZE,this.onTrackOrThumbResize,this))},r.onTrackOrThumbResize=function(t){this.updateSkinDisplayList()},r.onThumbTouchBegin=function(e){var i=this.$SliderBase;i[5]&&i[5].isPlaying&&this.stopAnimation();var n=this.$stage;n.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onStageTouchMove,this),n.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this);var s=this.thumb.globalToLocal(e.stageX,e.stageY,egret.$TempPoint);i[0]=s.x,i[1]=s.y,t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_START)},r.onStageTouchMove=function(t){var e=this.$SliderBase;e[2]=t.$stageX,e[3]=t.$stageY;var i=this.track;if(i){var n=i.globalToLocal(e[2],e[3],egret.$TempPoint),s=this.pointToValue(n.x-e[0],n.y-e[1]);s=this.nearestValidValue(s,this.snapInterval),this.updateWhenTouchMove(s),t.updateAfterEvent()}},r.updateWhenTouchMove=function(t){t!=this.$SliderBase[7]&&(this.liveDragging?(this.setValue(t),this.dispatchEventWith(egret.Event.CHANGE)):this.pendingValue=t)},r.onStageTouchEnd=function(e){var i=e.$currentTarget;i.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onStageTouchMove,this),i.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END);var n=this.$SliderBase;this.liveDragging||this.value==n[7]||(this.setValue(n[7]),this.dispatchEventWith(egret.Event.CHANGE))},r.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.stageTouchEndHandler,this),this.$SliderBase[4]=t.$target},r.stageTouchEndHandler=function(t){var e=t.$target,i=this.$SliderBase;t.$currentTarget.removeEventListener(egret.TouchEvent.TOUCH_END,this.stageTouchEndHandler,this),i[4]!=e&&this.contains(e)&&egret.TouchEvent.dispatchTouchEvent(this,egret.TouchEvent.TOUCH_TAP,!0,!0,t.$stageX,t.$stageY,t.touchPointID),i[4]=null},r.$animationUpdateHandler=function(t){this.pendingValue=t.currentValue},r.animationEndHandler=function(e){this.setValue(this.$SliderBase[8]),this.dispatchEventWith(egret.Event.CHANGE),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},r.stopAnimation=function(){this.$SliderBase[5].stop(),this.setValue(this.nearestValidValue(this.pendingValue,this.snapInterval)),this.dispatchEventWith(egret.Event.CHANGE),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},r.onTrackTouchBegin=function(e){var i=this.thumb?this.thumb.width:0,n=this.thumb?this.thumb.height:0,s=e.$stageX-i/2,r=e.$stageY-n/2,a=this.track.globalToLocal(s,r,egret.$TempPoint),o=this.$Range,h=this.pointToValue(a.x,a.y);h=this.nearestValidValue(h,o[7]);var l=this.$SliderBase;if(h!=l[7])if(0!=l[6]){l[5]||(l[5]=new t.sys.Animation(this.$animationUpdateHandler,this),l[5].endFunction=this.animationEndHandler);var u=l[5];u.isPlaying&&this.stopAnimation(),l[8]=h,u.duration=l[6]*(Math.abs(l[7]-l[8])/(o[0]-o[2])),u.from=l[7],u.to=l[8],t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_START),u.play()}else this.setValue(h),this.dispatchEventWith(egret.Event.CHANGE)},i}(t.Range);t.SliderBase=e,egret.registerClass(e,"eui.SliderBase")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.pointToValue=function(t,e){if(!this.thumb||!this.track)return 0;var i=this.$Range,n=i[0]-i[2],s=this.getThumbRange();return i[2]+(0!=s?t/s*n:0)},n.getThumbRange=function(){var t=egret.$TempRectangle;this.track.getLayoutBounds(t);var e=t.width;return this.thumb.getLayoutBounds(t),e-t.width},n.updateSkinDisplayList=function(){if(this.thumb&&this.track){var t=this.$Range,e=this.getThumbRange(),i=t[0]-t[2],n=i>0?(this.pendingValue-t[2])/i*e:0,s=this.track.localToGlobal(n,0,egret.$TempPoint),r=s.x,a=s.y,o=this.thumb.$parent.globalToLocal(r,a,egret.$TempPoint).x,h=egret.$TempRectangle;if(this.thumb.getLayoutBounds(h),this.thumb.setLayoutBoundsPosition(Math.round(o),h.y),this.trackHighlight&&this.trackHighlight.$parent){var l=this.trackHighlight.$parent.globalToLocal(r,a,egret.$TempPoint).x-n;this.trackHighlight.x=Math.round(l),this.trackHighlight.width=Math.round(n)}}},e}(t.SliderBase);t.HSlider=e,egret.registerClass(e,"eui.HSlider")}(eui||(eui={}));var eui;!function(t){var e=[],i={},n={},s=function(){function t(){}var s=(__define,t),r=s.prototype;return r.getAsset=function(t,s,r){var a=i[t];if(a)return void a.push([s,r]);var o=e.pop();o||(o=new egret.ImageLoader),i[t]=[[s,r]],n[o.$hashCode]=t,o.addEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),o.addEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this),o.load(t)},r.onLoadFinish=function(t){var s=t.currentTarget;s.removeEventListener(egret.Event.COMPLETE,this.onLoadFinish,this),s.removeEventListener(egret.IOErrorEvent.IO_ERROR,this.onLoadFinish,this);var r;t.$type==egret.Event.COMPLETE&&(r=new egret.Texture,r._setBitmapData(s.data),s.data=null),e.push(s);var a=n[s.$hashCode];delete n[s.$hashCode];var o=i[a];delete i[a];for(var h=o.length,l=0;h>l;l++){var u=o[l];u[0].call(u[1],r,a)}},t}();t.DefaultAssetAdapter=s,egret.registerClass(s,"eui.DefaultAssetAdapter",["eui.IAssetAdapter"])}(eui||(eui={}));var eui;!function(t){var e=new t.DefaultAssetAdapter,i=function(i){function n(t){i.call(this),this.sourceChanged=!1,this._source=null,this.initializeUIValues(),t&&(this.source=t)}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"scale9Grid",function(){return this.$scale9Grid},function(t){this.$scale9Grid=t,this.$invalidateContentBounds(),this.invalidateDisplayList()}),s(a,"fillMode",function(){return this.$fillMode},function(t){t!=this.$fillMode&&(this.$fillMode=t,this.invalidateDisplayList())}),a.$setFillMode=function(t){var e=i.prototype.$setFillMode.call(this,t);return this.invalidateDisplayList(),e},s(a,"source",function(){return this._source},function(t){t!=this._source&&(this._source=t,this.$stage?this.parseSource():(this.sourceChanged=!0,this.invalidateProperties()))}),a.$setBitmapData=function(t){if(t==this.$Bitmap[0])return!1;var e=i.prototype.$setBitmapData.call(this,t);return this.sourceChanged=!1,this.invalidateSize(),this.invalidateDisplayList(),e},a.parseSource=function(){this.sourceChanged=!1;var t=this._source;if(t&&"string"==typeof t){var i=this.$stage.getImplementation("eui.IAssetAdapter");i||(i=e),i.getAsset(this._source,this.contentChanged,this)}else this.$setBitmapData(t)},a.contentChanged=function(t,e){e===this._source&&egret.is(t,"egret.Texture")&&(this.$setBitmapData(t),t&&this.dispatchEventWith(egret.Event.COMPLETE))},a.$measureContentBounds=function(t){var e=(this.$Bitmap,this.$Bitmap[0]);if(e){var i=this.$UIComponent,n=i[10],s=i[11];if(isNaN(n)||isNaN(s))return void t.setEmpty();"clip"==this.$fillMode&&(n>e.$getTextureWidth()&&(n=e.$getTextureWidth()),s>e.$getTextureHeight()&&(s=e.$getTextureHeight())),t.setTo(0,0,n,s)}else t.setEmpty()},a.$render=function(){var t=this.$Bitmap[0];if(t){var e=this.$UIComponent,i=e[10],n=e[11];if(0!==i&&0!==n){var s=this.$Bitmap;egret.sys.BitmapNode.$updateTextureData(this.$renderNode,s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],i,n,s[13],s[14],this.scale9Grid,this.$fillMode,s[10]) +}}},a.createChildren=function(){this.sourceChanged&&this.parseSource()},a.childrenCreated=function(){},a.commitProperties=function(){t.sys.UIComponentImpl.prototype.commitProperties.call(this),this.sourceChanged&&this.parseSource()},a.measure=function(){var t=this.$Bitmap[0];t?this.setMeasuredSize(t.$getTextureWidth(),t.$getTextureHeight()):this.setMeasuredSize(0,0)},a.updateDisplayList=function(t,e){this.$invalidateContentBounds()},a.invalidateParentLayout=function(){},a.setMeasuredSize=function(t,e){},a.invalidateProperties=function(){},a.validateProperties=function(){},a.invalidateSize=function(){},a.validateSize=function(t){},a.invalidateDisplayList=function(){},a.validateDisplayList=function(){},a.validateNow=function(){},a.setLayoutBoundsSize=function(t,e){},a.setLayoutBoundsPosition=function(t,e){},a.getLayoutBounds=function(t){},a.getPreferredBounds=function(t){},n}(egret.Bitmap);t.Image=i,egret.registerClass(i,"eui.Image",["eui.UIComponent"]),t.sys.implementUIComponent(i,egret.Bitmap),t.registerProperty(i,"scale9Grid","egret.Rectangle")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this._data=null,this._selected=!1,this.itemIndex=-1,this.touchCaptured=!1,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this)}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"data",function(){return this._data},function(e){this._data=e,t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"data"),this.dataChanged()}),r.dataChanged=function(){},n(r,"selected",function(){return this._selected},function(t){this._selected!=t&&(this._selected=t,this.invalidateState())}),r.onTouchCancle=function(t){this.touchCaptured=!1;var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.invalidateState()},r.onTouchBegin=function(t){this.$stage.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!0,this.invalidateState(),t.updateAfterEvent()},r.onStageTouchEnd=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancle,this),e.removeEventListener(egret.TouchEvent.TOUCH_END,this.onStageTouchEnd,this),this.touchCaptured=!1,this.invalidateState()},r.getCurrentState=function(){var t="up";if(this.touchCaptured&&(t="down"),this._selected){var e=t+"AndSelected",i=this.skin;return i&&i.hasState(e)?e:"disabled"==t?"disabled":"down"}return t},i}(t.Component);t.ItemRenderer=e,egret.registerClass(e,"eui.ItemRenderer",["eui.IItemRenderer","eui.UIComponent"]),t.registerBindable(e.prototype,"data")}(eui||(eui={}));var eui;!function(t){var e=t.sys.UIComponentImpl,i=function(i){function n(t){i.call(this),this._widthConstraint=0/0,this.availableWidth=0/0,this.initializeUIValues(),this.text=t}__extends(n,i);var s=(__define,n),r=s.prototype;return r.$invalidateContentBounds=function(){i.prototype.$invalidateContentBounds.call(this),this.invalidateSize()},r.$setWidth=function(t){var n=i.prototype.$setWidth.call(this,t),s=e.prototype.$setWidth.call(this,t);return n&&s},r.$setHeight=function(t){var n=i.prototype.$setHeight.call(this,t),s=e.prototype.$setHeight.call(this,t);return n&&s},r.$setText=function(e){var n=i.prototype.$setText.call(this,e);return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"text"),n},r.createChildren=function(){},r.childrenCreated=function(){},r.commitProperties=function(){},r.measure=function(){var t=this.$UIComponent,e=this.$TextField,n=e[3];isNaN(this._widthConstraint)?isNaN(t[8])?1e5!=t[13]&&(this.availableWidth=t[13]):this.availableWidth=t[8]:(this.availableWidth=this._widthConstraint,this._widthConstraint=0/0),i.prototype.$setWidth.call(this,this.availableWidth),this.setMeasuredSize(this.textWidth,this.textHeight),i.prototype.$setWidth.call(this,n)},r.updateDisplayList=function(t,e){i.prototype.$setWidth.call(this,t),i.prototype.$setHeight.call(this,e)},r.invalidateParentLayout=function(){},r.setMeasuredSize=function(t,e){},r.invalidateProperties=function(){},r.validateProperties=function(){},r.invalidateSize=function(){},r.validateSize=function(t){},r.invalidateDisplayList=function(){},r.validateDisplayList=function(){},r.validateNow=function(){},r.setLayoutBoundsSize=function(t,i){if(e.prototype.setLayoutBoundsSize.call(this,t,i),this._widthConstraint=t,!isNaN(t)&&t!==this._widthConstraint&&0!=t){var n=this.$UIComponent;isNaN(n[9])&&t!=n[16]&&this.invalidateSize()}},r.setLayoutBoundsPosition=function(t,e){},r.getLayoutBounds=function(t){},r.getPreferredBounds=function(t){},n}(egret.TextField);t.Label=i,egret.registerClass(i,"eui.Label",["eui.UIComponent","eui.IDisplayText"]),t.sys.implementUIComponent(i,egret.TextField),t.registerBindable(i.prototype,"text")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.$ListBase={0:!1,1:!1,2:-2,3:-1,4:!1,5:void 0,6:!1,7:null,8:!1}}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"requireSelection",function(){return this.$ListBase[0]},function(t){t=!!t;var e=this.$ListBase;t!==e[0]&&(e[0]=t,t&&(e[1]=!0,this.invalidateProperties()))}),n(r,"selectedIndex",function(){return this.$getSelectedIndex()},function(t){t=0|+t,this.setSelectedIndex(t,!1)}),r.$getSelectedIndex=function(){var t=this.$ListBase;return t[2]!=i.NO_PROPOSED_SELECTION?t[2]:t[3]},r.setSelectedIndex=function(t,e){if(t!=this.selectedIndex){var i=this.$ListBase;e&&(i[4]=i[4]||e),i[2]=t,this.invalidateProperties()}},n(r,"selectedItem",function(){var t=this.$ListBase;if(void 0!==t[5])return t[5];var e=this.$getSelectedIndex();if(e!=i.NO_SELECTION&&null!=this.$dataProvider)return this.$dataProvider.length>e?this.$dataProvider.getItemAt(e):void 0},function(t){this.setSelectedItem(t,!1)}),r.setSelectedItem=function(t,e){if(void 0===e&&(e=!1),this.selectedItem!==t){var i=this.$ListBase;e&&(i[4]=i[4]||e),i[5]=t,this.invalidateProperties()}},r.commitProperties=function(){var n=this.$dataProviderChanged;e.prototype.commitProperties.call(this);var s=this.$ListBase,r=this.$getSelectedIndex(),a=this.$dataProvider;n&&(r>=0&&a&&r0&&(s[2]=0)),void 0!==s[5]&&(a?s[2]=a.getItemIndex(s[5]):s[2]=i.NO_SELECTION,s[5]=void 0);var o=!1;s[2]!=i.NO_PROPOSED_SELECTION&&(o=this.commitSelection()),s[6]&&(s[6]=!1,o||t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"))},r.updateRenderer=function(t,i,n){return this.itemSelected(i,this.$isItemIndexSelected(i)),e.prototype.updateRenderer.call(this,t,i,n)},r.itemSelected=function(t,e){var i=this.$indexToRenderer[t];i&&(i.selected=e)},r.$isItemIndexSelected=function(t){return t==this.selectedIndex},r.commitSelection=function(e){void 0===e&&(e=!0);var n=this.$dataProvider,s=this.$ListBase,r=n?n.length-1:-1,a=s[3],o=s[2];if(or&&(o=r),s[0]&&o==i.NO_SELECTION&&n&&n.length>0)return s[2]=i.NO_PROPOSED_SELECTION,s[4]=!1,!1;if(s[4]){var h=this.dispatchEventWith(egret.Event.CHANGING,!1,!0);if(!h)return this.itemSelected(s[2],!1),s[2]=i.NO_PROPOSED_SELECTION,s[4]=!1,!1}return s[3]=o,s[2]=i.NO_PROPOSED_SELECTION,a!=i.NO_SELECTION&&this.itemSelected(a,!1),s[3]!=i.NO_SELECTION&&this.itemSelected(s[3],!0),e&&(s[4]&&(this.dispatchEventWith(egret.Event.CHANGE),s[4]=!1),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedItem")),!0},r.adjustSelection=function(t,e){void 0===e&&(e=!1);var n=this.$ListBase;n[2]!=i.NO_PROPOSED_SELECTION?n[2]=t:n[3]=t,n[6]=!0,this.invalidateProperties()},r.itemAdded=function(t,n){e.prototype.itemAdded.call(this,t,n);var s=this.$getSelectedIndex();s==i.NO_SELECTION?this.$ListBase[0]&&this.adjustSelection(n,!0):s>=n&&this.adjustSelection(s+1,!0)},r.itemRemoved=function(t,n){if(e.prototype.itemRemoved.call(this,t,n),this.selectedIndex!=i.NO_SELECTION){var s=this.$getSelectedIndex();n==s?this.requireSelection&&this.$dataProvider&&this.$dataProvider.length>0?0==n?(this.$ListBase[2]=0,this.invalidateProperties()):this.setSelectedIndex(0,!1):this.adjustSelection(-1,!1):s>n&&this.adjustSelection(s-1,!1)}},r.onCollectionChange=function(n){e.prototype.onCollectionChange.call(this,n),n.kind==t.CollectionEventKind.RESET?0==this.$dataProvider.length&&this.setSelectedIndex(i.NO_SELECTION,!1):n.kind==t.CollectionEventKind.REFRESH&&this.dataProviderRefreshed()},r.dataProviderRefreshed=function(){this.setSelectedIndex(i.NO_SELECTION,!1)},r.rendererAdded=function(t,e,i){t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onRendererTouchBegin,this),t.addEventListener(egret.TouchEvent.TOUCH_END,this.onRendererTouchEnd,this),t.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onRendererTouchCancle,this)},r.rendererRemoved=function(t,e,i){t.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onRendererTouchBegin,this),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onRendererTouchEnd,this),t.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onRendererTouchCancle,this)},r.onRendererTouchBegin=function(t){var e=this.$ListBase;t.$isDefaultPrevented||(e[8]=!1,e[7]=t.$currentTarget,this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this))},r.onRendererTouchCancle=function(t){var e=this.$ListBase;e[7]=null,e[8]=!0,this.$stage&&this.$stage.removeEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this)},r.onRendererTouchEnd=function(e){var i=this.$ListBase,n=e.$currentTarget,s=i[7];n==s&&(i[8]||(this.setSelectedIndex(n.itemIndex,!0),t.ItemTapEvent.dispatchItemTapEvent(this,t.ItemTapEvent.ITEM_TAP,n)),i[8]=!1)},r.stage_touchEndHandler=function(t){var e=t.$currentTarget;e.removeEventListener(egret.TouchEvent.TOUCH_END,this.stage_touchEndHandler,this),this.$ListBase[7]=null},i.NO_SELECTION=-1,i.NO_PROPOSED_SELECTION=-2,i}(t.DataGroup);t.ListBase=e,egret.registerClass(e,"eui.ListBase"),t.registerBindable(e.prototype,"selectedIndex"),t.registerBindable(e.prototype,"selectedItem")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){var t=this;e.apply(this,arguments),this.allowMultipleSelection=!1,this._selectedIndices=[],this.isValidIndex=function(e,i,n){return t.$dataProvider&&e>=0&&e0?this._proposedSelectedIndices[0]:-1:this.$getSelectedIndex()},function(t){this.setSelectedIndex(t)}),n(r,"selectedItems",function(){var t=[],e=this.selectedIndices;if(e)for(var i=e.length,n=0;i>n;n++)t[n]=this.$dataProvider.getItemAt(e[n]);return t},function(t){var e=[];if(t)for(var i=t.length,n=0;i>n;n++){var s=this.$dataProvider.getItemIndex(t[n]);if(-1!=s&&e.splice(0,0,s),-1==s){e=[];break}}this.setSelectedIndices(e,!1)}),r.setSelectedIndices=function(t,e){var i=this.$ListBase;e&&(i[4]=i[4]||e),t?this._proposedSelectedIndices=t:this._proposedSelectedIndices=[],this.invalidateProperties()},r.commitProperties=function(){e.prototype.commitProperties.call(this),this._proposedSelectedIndices&&this.commitSelection()},r.commitSelection=function(i){void 0===i&&(i=!0);var n=this.$ListBase,s=n[3];if(this._proposedSelectedIndices){if(this._proposedSelectedIndices=this._proposedSelectedIndices.filter(this.isValidIndex),!this.allowMultipleSelection&&this._proposedSelectedIndices.length>0){var r=[];r.push(this._proposedSelectedIndices[0]),this._proposedSelectedIndices=r}this._proposedSelectedIndices.length>0?n[2]=this._proposedSelectedIndices[0]:n[2]=-1}var a=e.prototype.commitSelection.call(this,!1);if(!a)return this._proposedSelectedIndices=null,!1;var o=this.$getSelectedIndex();return o>t.ListBase.NO_SELECTION&&(this._proposedSelectedIndices?-1==this._proposedSelectedIndices.indexOf(o)&&this._proposedSelectedIndices.push(o):this._proposedSelectedIndices=[o]),this._proposedSelectedIndices&&(-1!=this._proposedSelectedIndices.indexOf(s)&&this.itemSelected(s,!0),this.commitMultipleSelection()),i&&a&&(n[4]&&(this.dispatchEventWith(egret.Event.CHANGE),n[4]=!1),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedIndex"),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedItem")),a},r.commitMultipleSelection=function(){var t,e,i=[],n=[],s=this._selectedIndices,r=this._proposedSelectedIndices;if(s.length>0&&r.length>0){for(e=r.length,t=0;e>t;t++)-1==s.indexOf(r[t])&&n.push(r[t]);for(e=s.length,t=0;e>t;t++)-1==r.indexOf(s[t])&&i.push(s[t])}else s.length>0?i=s:r.length>0&&(n=r);if(this._selectedIndices=r,i.length>0)for(e=i.length,t=0;e>t;t++)this.itemSelected(i[t],!1);if(n.length>0)for(e=n.length,t=0;e>t;t++)this.itemSelected(n[t],!0);this._proposedSelectedIndices=null},r.$isItemIndexSelected=function(t){return this.allowMultipleSelection?-1!=this._selectedIndices.indexOf(t):e.prototype.$isItemIndexSelected.call(this,t)},r.dataProviderRefreshed=function(){this.allowMultipleSelection||e.prototype.dataProviderRefreshed.call(this)},r.calculateSelectedIndices=function(t){var e=[],i=this._selectedIndices,n=i.length;if(n>0){if(1==n&&i[0]==t)return this.$ListBase[0]?(e.splice(0,0,i[0]),e):e;for(var s=!1,r=0;n>r;r++)i[r]==t?s=!0:i[r]!=t&&e.splice(0,0,i[r]);return s||e.splice(0,0,t),e}return e.splice(0,0,t),e},r.onRendererTouchEnd=function(i){if(this.allowMultipleSelection){var n=i.currentTarget,s=this.$ListBase[7];if(n!=s)return;this.setSelectedIndices(this.calculateSelectedIndices(n.itemIndex),!0),t.ItemTapEvent.dispatchItemTapEvent(this,t.ItemTapEvent.ITEM_TAP,n)}else e.prototype.onRendererTouchEnd.call(this,i)},i}(t.ListBase);t.List=e,egret.registerClass(e,"eui.List")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.closeButton=null,this.moveArea=null,this.titleDisplay=null,this._title="",this.offsetPointX=0,this.offsetPointY=0,this.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onWindowTouchBegin,this,!1,100)}__extends(i,e);var n=__define,s=i,r=s.prototype;return r.onWindowTouchBegin=function(t){this.$parent.addChild(this)},n(r,"elementsContent",void 0,function(t){if(t)for(var e=t.length,i=0;e>i;i++)this.addChild(t[i])}),n(r,"title",function(){return this._title},function(t){this._title=t,this.titleDisplay&&(this.titleDisplay.text=this.title)}),r.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i==this.titleDisplay?this.titleDisplay.text=this._title:i==this.moveArea?this.moveArea.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this):i==this.closeButton&&this.closeButton.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onCloseButtonClick,this)},r.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i==this.moveArea?this.moveArea.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBegin,this):i==this.closeButton&&this.closeButton.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onCloseButtonClick,this)},r.onCloseButtonClick=function(e){t.UIEvent.dispatchUIEvent(this,t.UIEvent.CLOSING,!0,!0)&&this.close()},r.close=function(){this.$parent&&this.$parent.removeChild(this)},r.onTouchBegin=function(t){this.$includeInLayout=!1,this.offsetPointX=this.x-t.$stageX,this.offsetPointY=this.y-t.$stageY,this.$stage.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.$stage.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this)},r.onTouchMove=function(t){this.x=t.$stageX+this.offsetPointX,this.y=t.$stageY+this.offsetPointY},r.onTouchEnd=function(t){this.$stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.$stage.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this)},i}(t.Component);t.Panel=e,egret.registerClass(e,"eui.Panel"),t.registerProperty(e,"elementsContent","Array",!0)}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.thumb=null,this.labelDisplay=null,this._labelFunction=null,this._slideDuration=500,this._direction=t.Direction.LTR,this.slideToValue=0,this.animationValue=0,this.thumbInitX=0,this.thumbInitY=0,this.animation=new t.sys.Animation(this.animationUpdateHandler,this)}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"labelFunction",function(){return this._labelFunction},function(t){this._labelFunction!=t&&(this._labelFunction=t,this.invalidateDisplayList())}),r.valueToLabel=function(t,e){return null!=this.labelFunction?this._labelFunction(t,e):t+" / "+e},n(r,"slideDuration",function(){return this._slideDuration},function(t){t=0|+t,this._slideDuration!==t&&(this._slideDuration=t,this.animation.isPlaying&&(this.animation.stop(),this.setValue(this.slideToValue)))}),n(r,"direction",function(){return this._direction},function(t){this._direction!=t&&(this.thumb&&(this.thumb.x=this.thumbInitX),this.thumb&&(this.thumb.y=this.thumbInitY),this._direction=t,this.invalidateDisplayList())}),r.$setValue=function(t){if(this.value===t)return!1;var i=this.$Range,n=e.prototype.$setValue.call(this,t);if(this._slideDuration>0&&this.$stage){this.validateProperties();var s=this.animation;if(s.isPlaying&&(this.animationValue=this.slideToValue,this.invalidateDisplayList(),s.stop()),this.slideToValue=this.nearestValidValue(t,i[7]),this.slideToValue===this.animationValue)return n;var r=this._slideDuration*(Math.abs(this.animationValue-this.slideToValue)/(i[0]-i[2]));s.duration=r===1/0?0:r,s.from=this.animationValue,s.to=this.slideToValue,s.play()}else this.animationValue=this.value;return n},r.animationUpdateHandler=function(t){var e=this.$Range,i=this.nearestValidValue(t.currentValue,e[7]);this.animationValue=Math.min(e[0],Math.max(e[2],i)),this.invalidateDisplayList()},r.partAdded=function(t,i){e.prototype.partAdded.call(this,t,i),i===this.thumb&&(this.thumb.x&&(this.thumbInitX=this.thumb.x),this.thumb.y&&(this.thumbInitY=this.thumb.y),this.thumb.addEventListener(egret.Event.RESIZE,this.onThumbResize,this))},r.partRemoved=function(t,i){e.prototype.partRemoved.call(this,t,i),i===this.thumb&&this.thumb.removeEventListener(egret.Event.RESIZE,this.onThumbResize,this)},r.onThumbResize=function(t){this.updateSkinDisplayList()},r.updateSkinDisplayList=function(){var e=this.animation.isPlaying?this.animationValue:this.value,i=this.maximum,n=this.thumb;if(n){var s=n.width,r=n.height,a=Math.round(e/i*s);(0>a||a===1/0)&&(a=0);var o=Math.round(e/i*r);(0>o||o===1/0)&&(o=0);var h=n.$scrollRect;h||(h=egret.$TempRectangle),h.setTo(0,0,s,r);var l=n.x-h.x,u=n.y-h.y;switch(this._direction){case t.Direction.LTR:h.width=a,n.x=l;break;case t.Direction.RTL:h.width=a,h.x=s-a,n.x=h.x;break;case t.Direction.TTB:h.height=o,n.y=u;break;case t.Direction.BTT:h.height=o,h.y=r-o,n.y=h.y}n.scrollRect=h}this.labelDisplay&&(this.labelDisplay.text=this.valueToLabel(e,i))},i}(t.Range);t.ProgressBar=e,egret.registerClass(e,"eui.ProgressBar")}(eui||(eui={}));var eui;!function(t){var e={},i=function(i){function n(){i.call(this),this.$indexNumber=0,this.$radioButtonGroup=null,this._group=null,this.groupChanged=!1,this._groupName="radioGroup",this._value=null,this.groupName="radioGroup"}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"enabled",function(){return this.$Component[3]?!this.$radioButtonGroup||this.$radioButtonGroup.$enabled:!1},function(t){this.$setEnabled(t)}),s(a,"group",function(){if(!this._group&&this._groupName){var i=e[this._groupName];i||(i=new t.RadioButtonGroup,i.$name=this._groupName,e[this._groupName]=i),this._group=i}return this._group},function(t){this._group!=t&&(this.$radioButtonGroup&&this.$radioButtonGroup.$removeInstance(this,!1),this._group=t,this._groupName=t?this.group.$name:"radioGroup",this.groupChanged=!0,this.invalidateProperties(),this.invalidateDisplayList())}),s(a,"groupName",function(){return this._groupName},function(t){t&&""!=t&&(this._groupName=t,this.$radioButtonGroup&&this.$radioButtonGroup.$removeInstance(this,!1),this._group=null,this.groupChanged=!0,this.invalidateProperties(),this.invalidateDisplayList())}),a.$setSelected=function(t){var e=i.prototype.$setSelected.call(this,t);return this.invalidateDisplayList(),e},s(a,"value",function(){return this._value},function(e){this._value!=e&&(this._value=e,this.$selected&&this.group&&t.PropertyEvent.dispatchPropertyEvent(this.group,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue"))}),a.commitProperties=function(){this.groupChanged&&(this.addToGroup(),this.groupChanged=!1),i.prototype.commitProperties.call(this)},a.updateDisplayList=function(t,e){i.prototype.updateDisplayList.call(this,t,e),this.group&&(this.$selected?this._group.$setSelection(this,!1):this.group.selection==this&&this._group.$setSelection(null,!1))},a.buttonReleased=function(){this.enabled&&!this.selected&&(this.$radioButtonGroup||this.addToGroup(),i.prototype.buttonReleased.call(this),this.group.$setSelection(this,!0))},a.addToGroup=function(){var t=this.group;return t&&t.$addInstance(this),t},n}(t.ToggleButton);t.RadioButton=i,egret.registerClass(i,"eui.RadioButton")}(eui||(eui={}));var eui;!function(t){function e(t,i){var n=t.parent,s=i.parent;if(!n||!s)return 0;var r=t.$nestLevel,a=i.$nestLevel,o=0,h=0;return n==s&&(o=n.getChildIndex(t),h=s.getChildIndex(i)),r>a||o>h?1:a>r||h>o?-1:t==i?0:e(n,s)}var i=0,n=function(n){function s(){n.call(this),this.$name=null,this.radioButtons=[],this.$enabled=!0,this._selectedValue=null,this._selection=null,this.$name="_radioButtonGroup"+i++}__extends(s,n);var r=__define,a=s,o=a.prototype;return o.getRadioButtonAt=function(t){return this.radioButtons[t]},r(o,"enabled",function(){return this.$enabled},function(t){if(t=!!t,this.$enabled!==t){this.$enabled=t;for(var e=this.radioButtons,i=e.length,n=0;i>n;n++)e[n].invalidateState()}}),r(o,"numRadioButtons",function(){return this.radioButtons.length}),r(o,"selectedValue",function(){return this.selection?null!=this.selection.value?this.selection.value:this.selection.label:null},function(e){if(this._selectedValue=e,null==e)return void this.$setSelection(null,!1);for(var i=this.numRadioButtons,n=0;i>n;n++){var s=this.radioButtons[n];if(s.value==e||s.label==e){this.changeSelection(n,!1),this._selectedValue=null,t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue");break}}}),r(o,"selection",function(){return this._selection},function(t){this._selection!=t&&this.$setSelection(t,!1)}),o.$addInstance=function(t){t.addEventListener(egret.Event.REMOVED,this.removedHandler,this);var i=this.radioButtons;i.push(t),i.sort(e);for(var n=i.length,s=0;n>s;s++)i[s].$indexNumber=s;this._selectedValue&&(this.selectedValue=this._selectedValue),1==t.selected&&(this.selection=t),t.$radioButtonGroup=this,t.invalidateState()},o.$removeInstance=function(t,e){if(t)for(var i=!1,n=this.radioButtons,s=n.length,r=0;s>r;r++){var a=n[r];i?a.$indexNumber=a.$indexNumber-1:a==t&&(e&&t.addEventListener(egret.Event.ADDED,this.addedHandler,this),t==this._selection&&(this._selection=null),t.$radioButtonGroup=null,t.invalidateState(),this.radioButtons.splice(r,1),i=!0,r--,s--)}},o.$setSelection=function(e,i){if(this._selection==e)return!1;if(e){for(var n=this.numRadioButtons,s=0;n>s;s++)if(e==this.getRadioButtonAt(s)){this.changeSelection(s,i);break}}else this._selection&&(this._selection.selected=!1,this._selection=null,i&&this.dispatchEventWith(egret.Event.CHANGE));return t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"selectedValue"),!0},o.changeSelection=function(t,e){var i=this.getRadioButtonAt(t);i&&i!=this._selection&&(this._selection&&(this._selection.selected=!1),this._selection=i,this._selection.selected=!0,e&&this.dispatchEventWith(egret.Event.CHANGE))},o.addedHandler=function(t){var e=t.target;e&&(e.removeEventListener(egret.Event.ADDED,this.addedHandler,this),this.$addInstance(e))},o.removedHandler=function(t){var e=t.target;e&&(e.removeEventListener(egret.Event.REMOVED,this.removedHandler,this),this.$removeInstance(e,!0))},s}(egret.EventDispatcher);t.RadioButtonGroup=n,egret.registerClass(n,"eui.RadioButtonGroup"),t.registerBindable(n.prototype,"selectedValue")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n){t.call(this),this.$fillColor=0,this.$fillAlpha=1,this.$strokeColor=4473924,this.$strokeAlpha=1,this.$strokeWeight=0,this.$ellipseWidth=0,this.$ellipseHeight=0,this.touchChildren=!1,this.$graphics=new egret.Graphics,this.$graphics.$setTarget(this),this.width=e,this.height=i,this.fillColor=n}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"graphics",function(){return this.$graphics}),s.$measureContentBounds=function(t){this.$graphics&&t.setTo(0,0,this.width,this.height)},i(s,"fillColor",function(){return this.$fillColor},function(t){void 0!=t&&this.$fillColor!=t&&(this.$fillColor=t,this.invalidateDisplayList())}),i(s,"fillAlpha",function(){return this.$fillAlpha},function(t){this.$fillAlpha!=t&&(this.$fillAlpha=t,this.invalidateDisplayList())}),i(s,"strokeColor",function(){return this.$strokeColor},function(t){this.$strokeColor!=t&&(this.$strokeColor=t,this.invalidateDisplayList())}),i(s,"strokeAlpha",function(){return this.$strokeAlpha},function(t){this.$strokeAlpha!=t&&(this.$strokeAlpha=t,this.invalidateDisplayList())}),i(s,"strokeWeight",function(){return this.$strokeWeight},function(t){this.$strokeWeight!=t&&(this.$strokeWeight=t,this.invalidateDisplayList())}),i(s,"ellipseWidth",function(){return this.$ellipseWidth},function(t){this.$ellipseWidth!=t&&(this.$ellipseWidth=t,this.invalidateDisplayList())}),i(s,"ellipseHeight",function(){return this.$ellipseHeight},function(t){this.$ellipseHeight!=t&&(this.$ellipseHeight=t,this.invalidateDisplayList())}),s.updateDisplayList=function(t,e){var i=this.graphics;i.clear(),this.$strokeWeight>0&&(i.beginFill(this.$fillColor,0),i.lineStyle(this.$strokeWeight,this.$strokeColor,this.$strokeAlpha,!0,"normal","square","miter"),0==this.$ellipseWidth&&0==this.$ellipseHeight?i.drawRect(this.$strokeWeight/2,this.$strokeWeight/2,t-this.$strokeWeight,e-this.$strokeWeight):i.drawRoundRect(this.$strokeWeight/2,this.$strokeWeight/2,t-this.$strokeWeight,e-this.$strokeWeight,this.$ellipseWidth,this.$ellipseHeight),i.endFill()),i.beginFill(this.$fillColor,this.$fillAlpha),i.lineStyle(this.$strokeWeight,this.$strokeColor,0,!0,"normal","square","miter"),0==this.$ellipseWidth&&0==this.$ellipseHeight?i.drawRect(this.$strokeWeight,this.$strokeWeight,t-2*this.$strokeWeight,e-2*this.$strokeWeight):i.drawRoundRect(this.$strokeWeight,this.$strokeWeight,t-2*this.$strokeWeight,e-2*this.$strokeWeight,this.$ellipseWidth,this.$ellipseHeight),i.endFill(),this.$invalidateContentBounds()},e}(t.Component);t.Rect=e,egret.registerClass(e,"eui.Rect")}(eui||(eui={}));var eui;!function(t){var e,i=function(i){function n(){i.call(this),this.$bounces=!0,this.horizontalScrollBar=null,this.verticalScrollBar=null;var e=new t.sys.TouchScroll(this.horizontalUpdateHandler,this.horizontalEndHandler,this),n=new t.sys.TouchScroll(this.verticalUpdateHandler,this.verticalEndHanlder,this);this.$Scroller={0:"auto",1:"auto",2:null,3:0,4:0,5:!1,6:!1,7:!1,8:e,9:n,10:null,11:!1,12:!1}}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"bounces",function(){return this.$bounces},function(t){this.$bounces=!!t;var e=this.$Scroller[8];e&&(e.$bounces=this.$bounces);var i=this.$Scroller[9];i&&(i.$bounces=this.$bounces)}),s(a,"throwSpeed",function(){return this.$Scroller[8].$scrollFactor},function(t){t=+t,0>t&&(t=0),this.$Scroller[8].$scrollFactor=t,this.$Scroller[9].$scrollFactor=t}),a.$getThrowInfo=function(i,n){return e?(e.currentPos=i,e.toPos=n):e=new t.ScrollerThrowEvent(t.ScrollerThrowEvent.THROW,!1,!1,i,n),e},s(a,"scrollPolicyV",function(){return this.$Scroller[0]},function(t){var e=this.$Scroller;e[0]!=t&&(e[0]=t,this.checkScrollPolicy())}),s(a,"scrollPolicyH",function(){return this.$Scroller[1]},function(t){var e=this.$Scroller;e[1]!=t&&(e[1]=t,this.checkScrollPolicy())}),a.stopAnimation=function(){var e=this.$Scroller,i=e[9],n=e[8];i.animation.isPlaying?t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END):n.animation.isPlaying&&t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END),i.stop(),n.stop();var s=this.verticalScrollBar,r=this.horizontalScrollBar;s&&s.autoVisibility&&(s.visible=!1),r&&r.autoVisibility&&(r.visible=!1)},s(a,"viewport",function(){return this.$Scroller[10]},function(t){var e=this.$Scroller;t!=e[10]&&(this.uninstallViewport(),e[10]=t,e[11]=!1,this.installViewport())}),a.installViewport=function(){var t=this.viewport;t&&(this.addChildAt(t,0),t.scrollEnabled=!0,t.addEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBeginCapture,this,!0),t.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEndCapture,this,!0),t.addEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouchTapCapture,this,!0),t.addEventListener(egret.Event.REMOVED,this.onViewPortRemove,this)),this.horizontalScrollBar&&(this.horizontalScrollBar.viewport=t),this.verticalScrollBar&&(this.verticalScrollBar.viewport=t)},a.uninstallViewport=function(){this.horizontalScrollBar&&(this.horizontalScrollBar.viewport=null),this.verticalScrollBar&&(this.verticalScrollBar.viewport=null);var t=this.viewport;t&&(t.scrollEnabled=!1,t.removeEventListener(egret.TouchEvent.TOUCH_BEGIN,this.onTouchBeginCapture,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEndCapture,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_TAP,this.onTouchTapCapture,this,!0),t.removeEventListener(egret.Event.REMOVED,this.onViewPortRemove,this),0==this.$Scroller[11]&&this.removeChild(t))},a.onViewPortRemove=function(t){t.target==this.viewport&&(this.$Scroller[11]=!0,this.viewport=null)},a.setSkin=function(t){i.prototype.setSkin.call(this,t);var e=this.viewport;e&&this.addChildAt(e,0)},a.onTouchBeginCapture=function(t){this.$Scroller[12]=!1;var e=this.checkScrollPolicy();e&&this.onTouchBegin(t)},a.onTouchEndCapture=function(t){this.$Scroller[12]&&(t.stopPropagation(),this.onTouchEnd(t))},a.onTouchTapCapture=function(t){this.$Scroller[12]&&t.stopPropagation()},a.checkScrollPolicy=function(){var t=this.$Scroller,e=t[10];if(!e)return!1;var i,n=e.$UIComponent;switch(t[1]){case"auto":i=e.contentWidth>n[10]||0!==e.scrollH?!0:!1;break;case"on":i=!0;break;case"off":i=!1}t[6]=i;var s;switch(t[0]){case"auto":s=e.contentHeight>n[11]||0!==e.scrollV?!0:!1;break;case"on":s=!0;break;case"off":s=!1}return t[7]=s,i||s},a.onTouchBegin=function(t){if(!t.isDefaultPrevented()&&this.checkScrollPolicy()){this.downTarget=t.target;var e=this.$Scroller;this.stopAnimation(),e[3]=t.$stageX,e[4]=t.$stageY,e[6]&&e[8].start(t.$stageX),e[7]&&e[9].start(t.$stageY);var i=this.$stage;this.addEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),i.addEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this,!0),this.addEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancel,this),this.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveListeners,this)}},a.onTouchMove=function(e){if(!e.isDefaultPrevented()){var i=this.$Scroller;if(!i[5]){if(Math.abs(i[3]-e.$stageX)h;h++)if(s[h]===e){o=h;break}s.splice(0,o+1),a-=o+1,this.$dispatchPropagationEvent(i,s,a),egret.Event.release(i)}},a.onTouchEnd=function(t){var e=this.$Scroller;e[5]=!1,this.onRemoveListeners();var i=e[10],n=i.$UIComponent;e[8].isStarted()&&e[8].finish(i.scrollH,i.contentWidth-n[10]),e[9].isStarted()&&e[9].finish(i.scrollV,i.contentHeight-n[11])},a.onRemoveListeners=function(){var t=this.$stage;this.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),t.removeEventListener(egret.TouchEvent.TOUCH_END,this.onTouchEnd,this,!0),t.removeEventListener(egret.TouchEvent.TOUCH_MOVE,this.onTouchMove,this),this.removeEventListener(egret.TouchEvent.TOUCH_CANCEL,this.onTouchCancel,!0),this.removeEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveListeners,this)},a.horizontalUpdateHandler=function(t){this.dispatchEventWith(egret.Event.CHANGE),this.$Scroller[10].scrollH=t},a.verticalUpdateHandler=function(t){this.dispatchEventWith(egret.Event.CHANGE),this.$Scroller[10].scrollV=t},a.horizontalEndHandler=function(){this.$Scroller[9].isPlaying()||this.onChangeEnd()},a.verticalEndHanlder=function(){this.$Scroller[8].isPlaying()||this.onChangeEnd()},a.onChangeEnd=function(){var e=this.$Scroller,i=this.horizontalScrollBar,n=this.verticalScrollBar;(i&&i.visible||n&&n.visible)&&(e[2]||(e[2]=new egret.Timer(200,1),e[2].addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.onAutoHideTimer,this)),e[2].reset(),e[2].start()),t.UIEvent.dispatchUIEvent(this,t.UIEvent.CHANGE_END)},a.onAutoHideTimer=function(t){var e=this.horizontalScrollBar,i=this.verticalScrollBar;e&&e.autoVisibility&&(e.visible=!1),i&&i.autoVisibility&&(i.visible=!1)},a.updateDisplayList=function(t,e){i.prototype.updateDisplayList.call(this,t,e);var n=this.viewport;n&&(n.setLayoutBoundsSize(t,e),n.setLayoutBoundsPosition(0,0))},a.partAdded=function(t,e){i.prototype.partAdded.call(this,t,e),e==this.horizontalScrollBar?(this.horizontalScrollBar.touchChildren=!1,this.horizontalScrollBar.touchEnabled=!1,this.horizontalScrollBar.viewport=this.viewport,this.horizontalScrollBar.autoVisibility&&(this.horizontalScrollBar.visible=!1)):e==this.verticalScrollBar&&(this.verticalScrollBar.touchChildren=!1,this.verticalScrollBar.touchEnabled=!1,this.verticalScrollBar.viewport=this.viewport,this.verticalScrollBar.autoVisibility&&(this.verticalScrollBar.visible=!1))},n.scrollThreshold=5,n}(t.Component);t.Scroller=i,egret.registerClass(i,"eui.Scroller"),t.registerProperty(i,"viewport","eui.IViewport",!0)}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.apply(this,arguments),this.maxWidth=1e5,this.minWidth=0,this.maxHeight=1e5,this.minHeight=0,this.width=0/0,this.height=0/0,this.$elementsContent=[],this._hostComponent=null,this.$stateValues=new t.sys.StateValues}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"elementsContent",void 0,function(t){this.$elementsContent=t}),n(r,"hostComponent",function(){return this._hostComponent},function(e){if(this._hostComponent!=e){this._hostComponent&&this._hostComponent.removeEventListener(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this),this._hostComponent=e;var i=this.$stateValues;i.parent=e,e&&(this.commitCurrentState(),this.$stateValues.intialized||(e.$stage?this.initializeStates(e.$stage):e.once(egret.Event.ADDED_TO_STAGE,this.onAddedToStage,this))),t.PropertyEvent.dispatchPropertyEvent(this,t.PropertyEvent.PROPERTY_CHANGE,"hostComponent")}}),r.onAddedToStage=function(t){this.initializeStates(this._hostComponent.$stage)},i}(egret.EventDispatcher);t.Skin=e,egret.registerClass(e,"eui.Skin"),t.sys.mixin(e,t.sys.StateClient),t.registerProperty(e,"elementsContent","Array",!0),t.registerProperty(e,"states","State[]"),t.registerBindable(e.prototype,"hostComponent")}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){return-.5*(Math.cos(Math.PI*t)-1)}var i=function(){function t(t,i){this.easerFunction=e,this.isPlaying=!1,this.duration=500,this.currentValue=0,this.from=0,this.to=0,this.startTime=0,this.endFunction=null,this.updateFunction=t,this.thisObject=i}var i=(__define,t),n=i.prototype;return n.play=function(){this.stop(),this.start()},n.start=function(){this.isPlaying=!1,this.currentValue=0,this.startTime=egret.getTimer(),this.doInterval(this.startTime),egret.startTick(this.doInterval,this)},n.stop=function(){this.isPlaying=!1,this.startTime=0,egret.stopTick(this.doInterval,this)},n.doInterval=function(t){var e=t-this.startTime;this.isPlaying||(this.isPlaying=!0);var i=this.duration,n=0==i?1:Math.min(e,i)/i;this.easerFunction&&(n=this.easerFunction(n)),this.currentValue=this.from+(this.to-this.from)*n,this.updateFunction&&this.updateFunction.call(this.thisObject,this);var s=e>=i;return s&&this.stop(),s&&this.endFunction&&this.endFunction.call(this.thisObject,this),!0},t}();t.Animation=i,egret.registerClass(i,"eui.sys.Animation")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t),i=e.prototype;return i.getTheme=function(t,e,i,n){function s(t){var i=t.target;e.call(n,i.response)}function r(t){i.call(n)}var a=new egret.HttpRequest;a.addEventListener(egret.Event.COMPLETE,s,n),a.addEventListener(egret.IOErrorEvent.IO_ERROR,r,n),a.responseType=egret.HttpResponseType.TEXT,a.open(t),a.send()},t}();t.DefaultThemeAdapter=e,egret.registerClass(e,"eui.DefaultThemeAdapter",["eui.IThemeAdapter"])}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){var e=t-1;return e*e*e+1}var i=4,n=[1,1.33,1.66,2],s=2.33,r=.02,a=.998,o=.95,h=Math.log(a),l=function(){function l(i,n,s){this.$scrollFactor=1,this.previousTime=0,this.velocity=0,this.previousVelocity=[],this.currentPosition=0,this.previousPosition=0,this.currentScrollPos=0,this.maxScrollPos=0,this.offsetPoint=0,this.$bounces=!0,this.started=!0,this.updateFunction=i,this.endFunction=n,this.target=s,this.animation=new t.Animation(this.onScrollingUpdate,this),this.animation.endFunction=this.finishScrolling,this.animation.easerFunction=e}var u=(__define,l),d=u.prototype;return d.isPlaying=function(){return this.animation.isPlaying},d.stop=function(){this.animation.stop(),egret.stopTick(this.onTick,this),this.started=!1},d.isStarted=function(){return this.started},d.start=function(t){this.started=!0,this.velocity=0,this.previousVelocity.length=0,this.previousTime=egret.getTimer(),this.previousPosition=this.currentPosition=t,this.offsetPoint=t,egret.startTick(this.onTick,this)},d.update=function(t,e,i){e=Math.max(e,0),this.currentPosition=t,this.maxScrollPos=e;var n=this.offsetPoint-t,s=n+i;this.offsetPoint=t,0>s&&(this.$bounces?s-=.5*n:s=0),s>e&&(this.$bounces?s-=.5*n:s=e),this.currentScrollPos=s,this.updateFunction.call(this.target,s)},d.finish=function(t,e){egret.stopTick(this.onTick,this),this.started=!1;for(var i=this.velocity*s,l=this.previousVelocity,u=l.length,d=s,c=0;u>c;c++){var p=n[c];i+=l[0]*p,d+=p}var v=i/d,f=Math.abs(v),g=0,m=0;if(f>r)if(m=t+(v-r)/h*2*this.$scrollFactor,0>m||m>e)for(m=t;Math.abs(v)>r;)m-=v,v*=0>m||m>e?a*o:a,g++;else g=Math.log(r/f)/h;else m=t;if(this.target.$getThrowInfo){var y=this.target.$getThrowInfo(t,m);m=y.toPos}g>0?(this.$bounces||(0>m?m=0:m>e&&(m=e)),this.throwTo(m,g)):this.finishScrolling()},d.onTick=function(t){var e=t-this.previousTime;if(e>10){var n=this.previousVelocity;n.length>=i&&n.shift(),this.velocity=(this.currentPosition-this.previousPosition)/e,n.push(this.velocity),this.previousTime=t,this.previousPosition=this.currentPosition}return!0},d.finishScrolling=function(t){var e=this.currentScrollPos,i=this.maxScrollPos,n=e;0>e&&(n=0),e>i&&(n=i),this.throwTo(n,300)},d.throwTo=function(t,e){void 0===e&&(e=500);var i=this.currentScrollPos;if(i==t)return void this.endFunction.call(this.target);var n=this.animation;n.duration=e,n.from=i,n.to=t,n.play()},d.onScrollingUpdate=function(t){this.currentScrollPos=t.currentValue,this.updateFunction.call(this.target,t.currentValue)},l}();t.TouchScroll=l,egret.registerClass(l,"eui.sys.TouchScroll")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this.indexBeingUpdated=!1,this.requireSelection=!0,this.useVirtualLayout=!1}__extends(i,e);var n=(__define,i),s=n.prototype;return s.createChildren=function(){if(!this.$layout){var i=new t.HorizontalLayout;i.gap=0,i.horizontalAlign=t.JustifyAlign.JUSTIFY,i.verticalAlign=t.JustifyAlign.CONTENT_JUSTIFY,this.$setLayout(i)}e.prototype.createChildren.call(this)},s.$setDataProvider=function(i){var n=this.$dataProvider;return n&&n instanceof t.ViewStack&&(n.removeEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onViewStackIndexChange,this),this.removeEventListener(egret.Event.CHANGE,this.onIndexChanged,this)),i&&i instanceof t.ViewStack&&(i.addEventListener(t.PropertyEvent.PROPERTY_CHANGE,this.onViewStackIndexChange,this),this.addEventListener(egret.Event.CHANGE,this.onIndexChanged,this)),e.prototype.$setDataProvider.call(this,i)},s.onIndexChanged=function(t){this.indexBeingUpdated=!0,this.$dataProvider.selectedIndex=this.selectedIndex,this.indexBeingUpdated=!1},s.onViewStackIndexChange=function(t){"selectedIndex"!=t.property||this.indexBeingUpdated||this.setSelectedIndex(this.$dataProvider.selectedIndex,!1)},i}(t.ListBase);t.TabBar=e,egret.registerClass(e,"eui.TabBar")}(eui||(eui={}));var eui;!function(t){var e=egret.FocusEvent,i=function(i){function n(){i.call(this),this.isFocus=!1,this.$TextInput={0:null,1:null,2:null,3:null,4:null,5:null,6:"",7:null,8:egret.TextFieldInputType.TEXT}}__extends(n,i);var s=__define,r=n,a=r.prototype;return s(a,"prompt",function(){return this.promptDisplay?this.promptDisplay.text:this.$TextInput[0]},function(t){this.$TextInput[0]=t,this.promptDisplay&&(this.promptDisplay.text=t),this.invalidateProperties(),this.invalidateState()}),s(a,"displayAsPassword",function(){if(this.textDisplay)return this.textDisplay.displayAsPassword;var t=this.$TextInput[1];return t?t:!1},function(t){this.$TextInput[1]=t,this.textDisplay&&(this.textDisplay.displayAsPassword=t),this.invalidateProperties()}),s(a,"inputType",function(){return console.log("get inputType"),this.textDisplay?this.textDisplay.inputType:this.$TextInput[8]},function(t){console.log("set inputType"),this.$TextInput[8]=t,this.textDisplay&&(this.textDisplay.inputType=t),this.invalidateProperties()}),s(a,"textColor",function(){return this.textDisplay?this.textDisplay.textColor:this.$TextInput[2]},function(t){this.$TextInput[2]=t,this.textDisplay&&(this.textDisplay.textColor=t),this.invalidateProperties()}),s(a,"maxChars",function(){if(this.textDisplay)return this.textDisplay.maxChars;var t=this.$TextInput[3];return t?t:0},function(t){this.$TextInput[3]=t,this.textDisplay&&(this.textDisplay.maxChars=t),this.invalidateProperties()}),s(a,"maxWidth",function(){if(this.textDisplay)return this.textDisplay.maxWidth;var t=this.$TextInput[4];return t?t:1e5},function(t){this.$TextInput[4]=t,this.textDisplay&&(this.textDisplay.maxWidth=t),this.invalidateProperties()}),s(a,"maxHeight",function(){this.textDisplay;var t=this.$TextInput[5];return t?t:1e5},function(t){this.$TextInput[5]=t,this.textDisplay&&(this.textDisplay.maxHeight=t),this.invalidateProperties()}),s(a,"text",function(){return this.textDisplay?this.textDisplay.text:this.$TextInput[6]},function(t){this.$TextInput[6]=t,this.textDisplay&&(this.textDisplay.text=t),this.invalidateProperties(),this.invalidateState()}),s(a,"restrict",function(){return this.textDisplay?this.textDisplay.restrict:this.$TextInput[7]},function(t){this.$TextInput[7]=t,this.textDisplay&&(this.textDisplay.restrict=t),this.invalidateProperties()}),a.focusInHandler=function(t){this.isFocus=!0,this.invalidateState()},a.focusOutHandler=function(t){this.isFocus=!1,this.invalidateState()},a.getCurrentState=function(){var t=this.skin;return!this.prompt||this.isFocus||this.text?this.enabled?"normal":"disabled":this.enabled&&t.hasState("normalWithPrompt")?"normalWithPrompt":!this.enabled&&t.hasState("disabledWithPrompt")?"disabledWithPrompt":void 0},a.partAdded=function(n,s){i.prototype.partAdded.call(this,n,s);var r=this.$TextInput;s==this.textDisplay?(this.textDisplayAdded(),this.textDisplay instanceof t.EditableText&&(this.textDisplay.addEventListener(e.FOCUS_IN,this.focusInHandler,this),this.textDisplay.addEventListener(e.FOCUS_OUT,this.focusOutHandler,this))):s==this.promptDisplay&&r[0]&&(this.promptDisplay.text=r[0])},a.partRemoved=function(n,s){i.prototype.partRemoved.call(this,n,s),s==this.textDisplay?(this.textDisplayRemoved(),this.textDisplay instanceof t.EditableText&&(this.textDisplay.removeEventListener(e.FOCUS_IN,this.focusInHandler,this),this.textDisplay.removeEventListener(e.FOCUS_OUT,this.focusOutHandler,this))):s==this.promptDisplay&&(this.$TextInput[0]=this.promptDisplay.text)},a.textDisplayAdded=function(){var t=this.$TextInput;t[1]&&(this.textDisplay.displayAsPassword=t[1]),t[2]&&(this.textDisplay.textColor=t[2]),t[3]&&(this.textDisplay.maxChars=t[3]),t[4]&&(this.textDisplay.maxWidth=t[4]),t[5]&&(this.textDisplay.maxHeight=t[5]),t[6]&&(this.textDisplay.text=t[6]),t[7]&&(this.textDisplay.restrict=t[7]),t[8]&&(this.textDisplay.inputType=t[8])},a.textDisplayRemoved=function(){var t=this.$TextInput;t[1]=this.textDisplay.displayAsPassword,t[2]=this.textDisplay.textColor,t[3]=this.textDisplay.maxChars,t[4]=this.textDisplay.maxWidth,t[5]=this.textDisplay.maxHeight,t[6]=this.textDisplay.text,t[7]=this.textDisplay.restrict,t[8]=this.textDisplay.inputType},n}(t.Component);t.TextInput=i,egret.registerClass(i,"eui.TextInput")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e);i.prototype;return e}(t.ToggleButton);t.ToggleSwitch=e,egret.registerClass(e,"eui.ToggleSwitch")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this),this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAddToStage,this),this.addEventListener(egret.Event.REMOVED_FROM_STAGE,this.onRemoveFromStage,this)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.onAddToStage=function(t){this.$stage.addEventListener(egret.Event.RESIZE,this.onResize,this),this.onResize()},n.onRemoveFromStage=function(t){this.$stage.removeEventListener(egret.Event.RESIZE,this.onResize,this)},n.onResize=function(t){var e=this.$stage;this.$setWidth(e.$stageWidth),this.$setHeight(e.$stageHeight)},e}(t.Group);t.UILayer=e,egret.registerClass(e,"eui.UILayer")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this),this._selectedChild=null,this.proposedSelectedIndex=t.ListBase.NO_PROPOSED_SELECTION,this._selectedIndex=-1}__extends(i,e);var n=__define,s=i,r=s.prototype;return n(r,"layout",function(){return this.$layout}),n(r,"selectedChild",function(){var t=this.selectedIndex;return t>=0&&t=0&&e0?0==n?(this.proposedSelectedIndex=0,this.invalidateProperties()):this.setSelectedIndex(0):this.setSelectedIndex(-1):s>n&&this.setSelectedIndex(s-1),t.CollectionEvent.dispatchCollectionEvent(this,t.CollectionEvent.COLLECTION_CHANGE,t.CollectionEventKind.REMOVE,n,-1,[i.name])},r.commitProperties=function(){e.prototype.commitProperties.call(this),this.proposedSelectedIndex!=t.ListBase.NO_PROPOSED_SELECTION&&(this.commitSelection(this.proposedSelectedIndex),this.proposedSelectedIndex=t.ListBase.NO_PROPOSED_SELECTION)},r.commitSelection=function(t){t>=0&&tn;n++)if(e[n].name==t)return n;return-1},i}(t.Group);t.ViewStack=e,egret.registerClass(e,"eui.ViewStack",["eui.ICollection","egret.IEventDispatcher"]),t.registerBindable(e.prototype,"selectedIndex")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.updateDisplayList=function(e,i){t.prototype.updateDisplayList.call(this,e,i);var n=this.thumb,s=this.$viewport;if(n&&s){var r=egret.$TempRectangle;n.getPreferredBounds(r);var a=r.height,o=r.x,h=s.scrollV,l=s.contentHeight,u=s.height;if(0>=h){var d=a*(1- -h/(.5*u));d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(0/0,d),n.setLayoutBoundsPosition(o,0)}else if(h>=l-u)d=a*(1-(h-l+u)/(.5*u)),d=Math.max(5,Math.round(d)),n.setLayoutBoundsSize(0/0,d),n.setLayoutBoundsPosition(o,i-d);else{var c=(i-a)*h/(l-u);n.setLayoutBoundsSize(0/0,0/0),n.setLayoutBoundsPosition(o,c)}}},n.onPropertyChanged=function(t){switch(t.property){case"scrollV":case"contentHeight":this.invalidateDisplayList()}},e}(t.ScrollBarBase);t.VScrollBar=e,egret.registerClass(e,"eui.VScrollBar")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.pointToValue=function(t,e){if(!this.thumb||!this.track)return 0;var i=this.$Range,n=i[0]-i[2],s=this.getThumbRange();return i[2]+(0!=s?(s-e)/s*n:0)},n.getThumbRange=function(){var t=egret.$TempRectangle;this.track.getLayoutBounds(t);var e=t.height;return this.thumb.getLayoutBounds(t),e-t.height},n.updateSkinDisplayList=function(){if(this.thumb&&this.track){var t=this.$Range,e=this.getThumbRange(),i=t[0]-t[2],n=i>0?e-(this.pendingValue-t[2])/i*e:0,s=this.track.localToGlobal(0,n,egret.$TempPoint),r=s.x,a=s.y,o=this.thumb.$parent.globalToLocal(r,a,egret.$TempPoint).y,h=egret.$TempRectangle,l=h.height;if(this.thumb.getLayoutBounds(h),this.thumb.setLayoutBoundsPosition(h.x,Math.round(o)),this.trackHighlight){var u=this.trackHighlight.$parent.globalToLocal(r,a,egret.$TempPoint).y;this.trackHighlight.y=Math.round(u+l),this.trackHighlight.height=Math.round(e-u)}}},e}(t.SliderBase);t.VSlider=e,egret.registerClass(e,"eui.VSlider")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.LTR="ltr",t.RTL="rtl",t.TTB="ttb",t.BTT="btt",t}();t.Direction=e,egret.registerClass(e,"eui.Direction")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.AUTO="auto",t.OFF="off",t.ON="on",t}();t.ScrollPolicy=e,egret.registerClass(e,"eui.ScrollPolicy")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(t,i){e.call(this),this.delayList=[],this.skinMap={},this.initialized=!t,i&&(this.$stage=i,EXML.$stage=i,i.registerImplementation("eui.Theme",this)),this.$configURL=t,this.load(t)}__extends(i,e);var n=(__define,i),s=n.prototype;return s.load=function(e){var i=this.$stage?this.$stage.getImplementation("eui.IThemeAdapter"):null;i||(i=new t.DefaultThemeAdapter),i.getTheme(e,this.onConfigLoaded,this.onConfigLoaded,this)},s.onConfigLoaded=function(t){if(t)var e,e=JSON.parse(t);if(e&&e.skins)for(var i=this.skinMap,n=e.skins,s=Object.keys(n),r=s.length,a=0;r>a;a++){var o=s[a];i[o]||this.mapSkin(o,n[o])}e.exmls&&0!=e.exmls.length?e.exmls[0].gjs?(e.exmls.forEach(function(t){return EXML.$parseURLContentAsJs(t.path,t.gjs,t.className)}),this.onLoaded()):e.exmls[0].content?(e.exmls.forEach(function(t){return EXML.$parseURLContent(t.path,t.content)}),this.onLoaded()):EXML.$loadAll(e.exmls,this.onLoaded,this,!0):this.onLoaded()},s.onLoaded=function(t,e){this.initialized=!0,this.handleDelayList(),this.dispatchEventWith(egret.Event.COMPLETE)},s.handleDelayList=function(){for(var t=this.delayList,e=t.length,i=0;e>i;i++){var n=t[i];if(!n.$Component[5]){var s=this.getSkinName(n);s&&(n.$Component[1]=s,n.$parseSkinName())}}t.length=0},s.getSkinName=function(t){if(!this.initialized)return-1==this.delayList.indexOf(t)&&this.delayList.push(t),"";var e=this.skinMap,i=e[t.hostComponentKey];return i||(i=this.findSkinName(t)),i},s.findSkinName=function(t){if(!t)return"";var e=t.__class__;if(void 0===e)return"";var i=this.skinMap[e];return i||"eui.Component"==e?i:this.findSkinName(Object.getPrototypeOf(t))},s.mapSkin=function(t,e){this.skinMap[t]=e},i}(egret.EventDispatcher);t.Theme=e,egret.registerClass(e,"eui.Theme")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,s,r,a,o,h){t.call(this,e,i,n),this.$initTo(s,r,a,o,h)}__extends(e,t);var i=(__define,e),n=i.prototype;return n.$initTo=function(t,e,i,n,s){this.kind=t,this.location=0|+e,this.oldLocation=0|+i,this.items=n||[],this.oldItems=s||[]},n.clean=function(){t.prototype.clean.call(this),this.items=this.oldItems=null},e.dispatchCollectionEvent=function(t,i,n,s,r,a,o){if(!t.hasEventListener(i))return!0;var h=egret.Event.create(e,i);h.$initTo(n,s,r,a,o);var l=t.dispatchEvent(h);return egret.Event.release(h),l},e.COLLECTION_CHANGE="collectionChange",e}(egret.Event);t.CollectionEvent=e,egret.registerClass(e,"eui.CollectionEvent")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.ADD="add",t.REFRESH="refresh",t.REMOVE="remove",t.REPLACE="replace",t.RESET="reset",t.UPDATE="update",t}();t.CollectionEventKind=e,egret.registerClass(e,"eui.CollectionEventKind")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments),this.item=null,this.itemRenderer=null,this.itemIndex=-1}__extends(e,t);var i=(__define,e),n=i.prototype;return n.clean=function(){t.prototype.clean.call(this),this.item=this.itemRenderer=null},e.dispatchItemTapEvent=function(t,i,n){if(!t.hasEventListener(i))return!0;var s=egret.Event.create(e,i);s.item=n.data,s.itemIndex=n.itemIndex,s.itemRenderer=n;var r=t.dispatchEvent(s);return egret.Event.release(s),r},e.ITEM_TAP="itemTap",e}(egret.Event);t.ItemTapEvent=e,egret.registerClass(e,"eui.ItemTapEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,s){t.call(this,e,i,n),this.property=s}__extends(e,t);var i=(__define,e);i.prototype;return e.dispatchPropertyEvent=function(t,i,n){if(!t.hasEventListener(i))return!0;var s=egret.Event.create(e,i);s.property=n;var r=t.dispatchEvent(s);return egret.Event.release(s),r},e.PROPERTY_CHANGE="propertyChange",e}(egret.Event);t.PropertyEvent=e,egret.registerClass(e,"eui.PropertyEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n,s,r){t.call(this,e,i,n),s=+s,r=+r,this.currentPos=s,this.toPos=r}__extends(e,t);var i=(__define,e);i.prototype;return e.THROW="throw",e}(egret.Event);t.ScrollerThrowEvent=e,egret.registerClass(e,"eui.ScrollerThrowEvent")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(e,i,n){t.call(this,e,i,n)}__extends(e,t);var i=(__define,e);i.prototype;return e.dispatchUIEvent=function(t,i,n,s){if(!t.hasEventListener(i))return!0;var r=egret.Event.create(e,i,n,s),a=t.dispatchEvent(r);return egret.Event.release(r),a},e.CREATION_COMPLETE="creationComplete",e.CHANGE_END="changeEnd",e.CHANGE_START="changeStart",e.CLOSING="closing",e.MOVE="move",e}(egret.Event);t.UIEvent=e,egret.registerClass(e,"eui.UIEvent")}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e="eui.State",i="eui.AddItems",n="eui.SetProperty",s="eui.SetStateProperty",r="eui.Binding.$bindProperties",a=function(){function t(){this.indent=0}var e=(__define,t),i=e.prototype;return i.toCode=function(){return""},i.getIndent=function(t){void 0===t&&(t=this.indent);for(var e="",i=0;t>i;i++)e+=" ";return e},t}();t.CodeBase=a,egret.registerClass(a,"eui.sys.CodeBase");var o=function(t){function e(){t.apply(this,arguments),this.className="",this.superClass="",this.innerClassBlock=[],this.variableBlock=[],this.functionBlock=[]}__extends(e,t);var i=(__define,e),n=i.prototype;return n.addInnerClass=function(t){-1==this.innerClassBlock.indexOf(t)&&this.innerClassBlock.push(t)},n.addVariable=function(t){-1==this.variableBlock.indexOf(t)&&this.variableBlock.push(t)},n.getVariableByName=function(t){for(var e=this.variableBlock,i=e.length,n=0;i>n;n++){var s=e[n];if(s.name==t)return s}return null},n.addFunction=function(t){-1==this.functionBlock.indexOf(t)&&this.functionBlock.push(t)},n.getFuncByName=function(t){for(var e=this.functionBlock,i=e.length,n=0;i>n;n++){var s=e[n];if(s.name==t)return s}return null},n.toCode=function(){var t=this.indent,e=this.getIndent(t),i=this.getIndent(t+1),n=this.getIndent(t+2),s=e+"(function (";s+=this.superClass?"_super) {\n"+i+"__extends("+this.className+", _super);\n":") {\n";for(var r=this.innerClassBlock,a=r.length,o=0;a>o;o++){var h=r[o];h.indent=t+1,s+=i+"var "+h.className+" = "+h.toCode()+"\n\n"}s+=i+"function "+this.className+"() {\n",this.superClass&&(s+=n+"_super.call(this);\n");var l=this.variableBlock;for(a=l.length,o=0;a>o;o++){var u=l[o];u.defaultValue&&(s+=n+u.toCode()+"\n")}if(this.constructCode){var d=this.constructCode.toCode().split("\n");for(a=d.length,o=0;a>o;o++){var c=d[o];s+=n+c+"\n"}}s+=i+"}\n",s+=i+"var _proto = "+this.className+".prototype;\n\n";var p=this.functionBlock;for(a=p.length,o=0;a>o;o++){var v=p[o];v.indent=t+1,s+=v.toCode()+"\n"}return s+=i+"return "+this.className+";\n"+e,s+=this.superClass?"})("+this.superClass+");":"})();"},e}(a);t.EXClass=o,egret.registerClass(o,"eui.sys.EXClass");var h=function(t){function e(){t.apply(this,arguments),this.lines=[]}__extends(e,t);var i=(__define,e),n=i.prototype;return n.addVar=function(t,e){var i=e?" = "+e:"";this.addCodeLine("var "+t+i+";")},n.addAssignment=function(t,e,i){var n=i?"."+i:"";this.addCodeLine(t+n+" = "+e+";")},n.addReturn=function(t){this.addCodeLine("return "+t+";")},n.addEmptyLine=function(){this.addCodeLine("")},n.startIf=function(t){this.addCodeLine("if("+t+")"),this.startBlock()},n.startElse=function(){this.addCodeLine("else"),this.startBlock()},n.startElseIf=function(t){this.addCodeLine("else if("+t+")"),this.startBlock()},n.startBlock=function(){this.addCodeLine("{"),this.indent++},n.endBlock=function(){this.indent--,this.addCodeLine("}")},n.doFunction=function(t,e){var i=e.join(",");this.addCodeLine(t+"("+i+")")},n.addCodeLine=function(t){this.lines.push(this.getIndent()+t)},n.addCodeLineAt=function(t,e){this.lines.splice(e,0,this.getIndent()+t)},n.containsCodeLine=function(t){return-1!=this.lines.indexOf(t)},n.concat=function(t){this.lines=this.lines.concat(t.lines)},n.toCode=function(){return this.lines.join("\n")},e}(a);t.EXCodeBlock=h,egret.registerClass(h,"eui.sys.EXCodeBlock");var l=function(t){function e(){t.apply(this,arguments),this.codeBlock=null,this.isGet=!1,this.name=""}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){var t,e=this.getIndent(),i=this.getIndent(this.indent+1),n=e;if(this.isGet?(t=this.getIndent(this.indent+2),n+='Object.defineProperty(_proto, "skinParts", {\n',n+=i+"get: function () {\n"):(t=i,n+="_proto."+this.name+" = function () {\n"),this.codeBlock)for(var s=this.codeBlock.toCode().split("\n"),r=s.length,a=0;r>a;a++){var o=s[a];n+=t+o+"\n"}return n+=this.isGet?i+"},\n"+i+"enumerable: true,\n"+i+"configurable: true\n"+e+"});":e+"};"},e}(a);t.EXFunction=l,egret.registerClass(l,"eui.sys.EXFunction");var u=function(t){function e(e,i){t.call(this),this.indent=2,this.name=e,this.defaultValue=i}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){return this.defaultValue?"this."+this.name+" = "+this.defaultValue+";":""},e}(a);t.EXVariable=u,egret.registerClass(u,"eui.sys.EXVariable");var d=function(t){function i(e,i){t.call(this),this.name="",this.stateGroups=[],this.addItems=[],this.setProperty=[],this.name=e,i&&(this.stateGroups=i)}__extends(i,t);var n=(__define,i),s=n.prototype;return s.addOverride=function(t){t instanceof c?this.addItems.push(t):this.setProperty.push(t)},s.toCode=function(){for(var t=this.getIndent(1),i="new "+e+' ("'+this.name+'",\n'+t+"[\n",n=0,s=!0,r=this.addItems.concat(this.setProperty);nl;l++){var u=o[l];o[l]=t+t+u}i+=o.join("\n"),n++}return i+="\n"+t+"])"},i}(a);t.EXState=d,egret.registerClass(d,"eui.sys.EXState");var c=function(t){function e(e,i,n,s){t.call(this),this.target=e,this.property=i,this.position=n,this.relativeTo=s}__extends(e,t);var n=(__define,e),s=n.prototype;return s.toCode=function(){var t="new "+i+'("'+this.target+'","'+this.property+'",'+this.position+',"'+this.relativeTo+'")';return t},e}(a);t.EXAddItems=c,egret.registerClass(c,"eui.sys.EXAddItems");var p=function(t){function e(e,i,n){t.call(this),this.target=e,this.name=i,this.value=n}__extends(e,t);var i=(__define,e),s=i.prototype;return s.toCode=function(){return"new "+n+'("'+this.target+'","'+this.name+'",'+this.value+")"},e}(a);t.EXSetProperty=p,egret.registerClass(p,"eui.sys.EXSetProperty");var v=function(t){function e(e,i,n,s){t.call(this),e=e?"this."+e:"this",this.target=e,this.property=i,this.templates=n,this.chainIndex=s}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){var t=this.templates.join(","),e=this.chainIndex.join(",");return"new "+s+"(this, ["+t+"],["+e+"],"+this.target+',"'+this.property+'")'},e}(a);t.EXSetStateProperty=v,egret.registerClass(v,"eui.sys.EXSetStateProperty");var f=function(t){function e(e,i,n,s){t.call(this),this.target=e,this.property=i,this.templates=n,this.chainIndex=s}__extends(e,t);var i=(__define,e),n=i.prototype;return n.toCode=function(){var t=this.templates.join(","),e=this.chainIndex.join(",");return r+"(this, ["+t+"],["+e+"],"+this.target+',"'+this.property+'")'},e}(a);t.EXBinding=f,egret.registerClass(f,"eui.sys.EXBinding")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(eui){var sys;!function(sys){function getRepeatedIds(t){var e=[];return this.repeatedIdMap={},this.getIds(t,e),e}function getIds(t,e){if(t.namespace!=sys.NS_W&&t.attributes.id){var i=t.attributes.id;this.repeatedIdMap[i]?e.push(toXMLString(t)):this.repeatedIdMap[i]=!0}var n=t.children;if(n)for(var s=n.length,r=0;s>r;r++){var a=n[r];this.isInnerClass(a)||this.getIds(a,e)}}function toXMLString(t){if(!t)return"";for(var e=" at <"+t.name,i=t.attributes,n=Object.keys(i),s=n.length,r=0;s>r;r++){var a=n[r],o=i[a];("id"!=a||"__"!=o.substring(0,2))&&(e+=" "+a+'="'+o+'"')}return e+=0==t.children.length?"/>":">"}function checkDeclarations(t,e){if(t){var i=t.children;if(i)for(var n=i.length,s=0;n>s;s++){var r=i[s];1==r.nodeType&&(r.attributes.includeIn&&e.push(toXMLString(r)),r.attributes.excludeFrom&&e.push(toXMLString(r)),checkDeclarations(r,e))}}}function getPropertyStr(t){var e=toXMLString(t.parent),i=toXMLString(t).substring(5);return e+"\n "+i}var exmlParserPool=[],parsedClasses={},innerClassCount=1,HOST_COMPONENT="hostComponent",SKIN_CLASS="eui.Skin",DECLARATIONS="Declarations",RECTANGLE="egret.Rectangle",TYPE_CLASS="Class",TYPE_ARRAY="Array",TYPE_STATE="State[]",SKIN_NAME="skinName",ELEMENTS_CONTENT="elementsContent",basicTypes=[TYPE_ARRAY,"boolean","string","number"],wingKeys=["id","locked","includeIn","excludeFrom"],htmlEntities=[["<","<"],[">",">"],["&","&"],['"',"""],["'","'"]],jsKeyWords=["null","NaN","undefined","true","false"],EXMLParser=function(){function EXMLParser(){this.delayAssignmentDic={} +}var d=__define,c=EXMLParser,p=c.prototype;return p.$parseCode=function(codeText,classStr){var className=classStr?classStr:"$exmlClass"+innerClassCount++,clazz=eval(codeText),hasClass=!0;if(hasClass&&clazz){egret.registerClass(clazz,className);for(var paths=className.split("."),length=paths.length,definition=__global,i=0;length-1>i;i++){var path=paths[i];definition=definition[path]||(definition[path]={})}definition[paths[length-1]]||(definition[paths[length-1]]=clazz)}return clazz},p.parse=function(text){var xmlData,xmlData=egret.XML.parse(text),hasClass=!1,className="";xmlData.attributes["class"]?(className=xmlData.attributes["class"],delete xmlData.attributes["class"],hasClass=!!className):className="$exmlClass"+innerClassCount++;var exClass=this.parseClass(xmlData,className),code=exClass.toCode(),clazz,clazz=eval(code);if(hasClass&&clazz){egret.registerClass(clazz,className);for(var paths=className.split("."),length=paths.length,definition=__global,i=0;length-1>i;i++){var path=paths[i];definition=definition[path]||(definition[path]={})}definition[paths[length-1]]||(definition[paths[length-1]]=clazz)}return clazz},p.parseClass=function(t,e){sys.exmlConfig||(sys.exmlConfig=new sys.EXMLConfig),this.currentXML=t,this.currentClassName=e,this.delayAssignmentDic={},this.idDic={},this.stateCode=[],this.stateNames=[],this.skinParts=[],this.bindings=[],this.declarations=null,this.currentClass=new sys.EXClass,this.stateIds=[];var i=e.lastIndexOf(".");-1!=i?this.currentClass.className=e.substring(i+1):this.currentClass.className=e,this.startCompile();var n=this.currentClass;return this.currentClass=null,n},p.startCompile=function(){var t=this.getClassNameOfNode(this.currentXML);this.isSkinClass=t==SKIN_CLASS,this.currentClass.superClass=t,this.getStateNames();var e=this.currentXML.children;if(e)for(var i=e.length,n=0;i>n;n++){var s=e[n];if(1===s.nodeType&&s.namespace==sys.NS_W&&s.localName==DECLARATIONS){this.declarations=s;break}}this.currentXML.namespace&&(this.addIds(this.currentXML.children),this.createConstructFunc())},p.addIds=function(t){if(t)for(var e=t.length,i=0;e>i;i++){var n=t[i];if(1==n.nodeType&&n.namespace&&!this.isInnerClass(n))if(this.addIds(n.children),n.namespace!=sys.NS_W&&n.localName){if(this.isProperty(n)){var s=n.localName,r=s.indexOf("."),a=n.children;if(-1==r||!a||0==a.length)continue;var o=a[0];this.stateIds.push(o.attributes.id)}else if(1===n.nodeType){var h=n.attributes.id;h?(h.indexOf(" ")>-1&&egret.$warn(2022,h),-1==this.skinParts.indexOf(h)&&this.skinParts.push(h),this.createVarForNode(n),this.isStateNode(n)&&this.stateIds.push(h)):(this.createIdForNode(n),this.isStateNode(n)&&this.stateIds.push(n.attributes.id))}}else;}},p.isInnerClass=function(t){if(t.hasOwnProperty("isInnerClass"))return t.isInnerClass;var e="Skin"==t.localName&&t.namespace==sys.NS_S;if(!e)if(this.isProperty(t))e=!1;else{var i=t.parent;if(this.isProperty(i)){var n=i.localName,s=n.indexOf(".");if(-1!=s){n.substring(s+1);n=n.substring(0,s)}i=i.parent}else n=sys.exmlConfig.getDefaultPropById(i.localName,i.namespace);var r=sys.exmlConfig.getClassNameById(i.localName,i.namespace);e=sys.exmlConfig.getPropertyType(n,r)==TYPE_CLASS}return t.isInnerClass=e,e},p.containsState=function(t){var e=t.attributes;if(e.includeIn||e.excludeFrom)return!0;for(var i=Object.keys(e),n=i.length,s=0;n>s;s++){var r=i[s];if(-1!=r.indexOf("."))return!0}return!1},p.createIdForNode=function(t){var e=this.getNodeId(t);this.idDic[e]?this.idDic[e]++:this.idDic[e]=1,e+=this.idDic[e],t.attributes.id=e},p.getNodeId=function(t){return t.attributes.id?t.attributes.id:"_"+t.localName},p.createVarForNode=function(t){var e=this.getClassNameOfNode(t);""!=e&&(this.currentClass.getVariableByName(t.attributes.id)||this.currentClass.addVariable(new sys.EXVariable(t.attributes.id)))},p.createFuncForNode=function(t){var e=t.localName,i=this.isBasicTypeData(e);if(i)return this.createBasicTypeForNode(t);var n=this.getClassNameOfNode(t),s=new sys.EXFunction,r="_i",a=t.attributes.id;s.name=a+r,this.currentClass.addFunction(s);var o=new sys.EXCodeBlock;s.codeBlock=o;var h="t";"Object"==e?o.addVar(h,"{}"):o.addVar(h,"new "+n+"()");var l=!!this.currentClass.getVariableByName(a);l&&o.addAssignment("this."+a,h),this.addAttributesToCodeBlock(o,h,t),this.initlizeChildNode(t,o,h);var u=this.delayAssignmentDic[a];if(u)for(var d=u.length,c=0;d>c;c++){var p=u[c];o.concat(p)}return o.addReturn(h),"this."+s.name+"()"},p.isBasicTypeData=function(t){return-1!=basicTypes.indexOf(t)},p.createBasicTypeForNode=function(t){var e=t.localName,i="",n=this.currentClass.getVariableByName(t.attributes.id),s=t.children,r="";if(s&&s.length>0){var a=s[0];3==a.nodeType&&(r=a.text.trim())}switch(e){case TYPE_ARRAY:var o=[];if(s)for(var h=s.length,l=0;h>l;l++){var u=s[l];1==u.nodeType&&o.push(this.createFuncForNode(u))}i="["+o.join(",")+"]";break;case"boolean":i="false"!=r&&r?"true":"false";break;case"number":i=r,-1!=i.indexOf("%")&&(i=i.substring(0,i.length-1));break;case"string":i=this.formatString(r)}return n&&(n.defaultValue=i),i},p.addAttributesToCodeBlock=function(t,e,i){var n,s,r=i.attributes,a=Object.keys(r);a.sort();for(var o=a.length,h=0;o>h;h++)if(n=a[h],this.isNormalKey(n)&&(s=r[n],n=this.formatKey(n,s),s=this.formatValue(n,s,i))){if(this.currentClass.getVariableByName(s)){var l="this.",u=r.id,d=l+u+" = t;";this.currentClass.getVariableByName(u)||this.createVarForNode(i),t.containsCodeLine(d)||t.addCodeLineAt(d,1);var c=new sys.EXCodeBlock;"this"==e?c.addAssignment(e,l+s,n):(c.startIf(l+u),c.addAssignment(l+u,l+s,n),c.endBlock()),this.delayAssignmentDic[s]||(this.delayAssignmentDic[s]=[]),this.delayAssignmentDic[s].push(c),s=l+s}t.addAssignment(e,s,n)}},p.initlizeChildNode=function(t,e,i){var n=t.children;if(n&&0!=n.length){for(var s=sys.exmlConfig.getClassNameById(t.localName,t.namespace),r=[],a=n.length,o=[],h=0;a>h;h++){var l=n[h];if(1==l.nodeType&&l.namespace!=sys.NS_W)if(this.isInnerClass(l)){if("Skin"==l.localName){var u=this.parseInnerClass(l),d=sys.exmlConfig.getPropertyType(SKIN_NAME,s);d?e.addAssignment(i,u,SKIN_NAME):egret.$error(2005,this.currentClassName,SKIN_NAME,getPropertyStr(l))}}else{var c=l.localName;if(this.isProperty(l)){if(!this.isNormalKey(c))continue;var d=sys.exmlConfig.getPropertyType(l.localName,s);if(!d)continue;if(!l.children||0==l.children.length)continue;var p;this.addChildrenToProp(l.children,d,c,e,i,p,o,t)}else r.push(l)}}if(0!=r.length){var p,v=sys.exmlConfig.getDefaultPropById(t.localName,t.namespace),f=sys.exmlConfig.getPropertyType(v,s);v&&f&&this.addChildrenToProp(r,f,v,e,i,p,o,t)}}},p.parseInnerClass=function(t){var e=exmlParserPool.pop();e||(e=new EXMLParser);var i=this.currentClass.className+"$"+t.localName+innerClassCount++,n=e.parseClass(t,i);return this.currentClass.addInnerClass(n),exmlParserPool.push(e),i},p.addChildrenToProp=function(t,e,i,n,s,r,a,o){var h="",l=t.length;if(l>1){if(e!=TYPE_ARRAY)return;for(var u=[],d=0;l>d;d++){var c=t[d];if(1==c.nodeType){h=this.createFuncForNode(c);var p=this.getClassNameOfNode(c);this.isStateNode(c)||u.push(h)}}h="["+u.join(",")+"]"}else{var v=t[0];if(e==TYPE_ARRAY)if(v.localName==TYPE_ARRAY){if(u=[],v.children)for(var f=v.children.length,g=0;f>g;g++)c=v.children[g],1==c.nodeType&&(h=this.createFuncForNode(c),p=this.getClassNameOfNode(c),this.isStateNode(c)||u.push(h));h="["+u.join(",")+"]"}else{h=this.createFuncForNode(v);var p=this.getClassNameOfNode(v);h=this.isStateNode(v)?"[]":"["+h+"]"}else if(1==v.nodeType)if(e==TYPE_CLASS){if(l>1)return;h=this.parseInnerClass(t[0])}else{this.getClassNameOfNode(v);h=this.createFuncForNode(v)}else h=this.formatValue(i,v.text,o)}""!=h&&(-1==h.indexOf("()")&&(i=this.formatKey(i,h)),-1==a.indexOf(i)&&a.push(i),n.addAssignment(s,h,i))},p.isProperty=function(t){if(t.hasOwnProperty("isProperty"))return t.isProperty;var e,i=t.localName;if(i&&1===t.nodeType&&t.parent&&!this.isBasicTypeData(i)){var n=t.parent,s=i.indexOf(".");-1!=s&&(i=i.substr(0,s));var r=sys.exmlConfig.getClassNameById(n.localName,n.namespace);e=!!sys.exmlConfig.getPropertyType(i,r)}else e=!1;return t.isProperty=e,e},p.isNormalKey=function(t){return t&&-1==t.indexOf(".")&&-1==wingKeys.indexOf(t)?!0:!1},p.formatKey=function(t,e){return-1!=e.indexOf("%")&&("height"==t?t="percentHeight":"width"==t&&(t="percentWidth")),t},p.formatValue=function(t,e,i){e||(e="");var n=e;e=e.trim();var s=this.getClassNameOfNode(i),r=sys.exmlConfig.getPropertyType(t,s),a=this.formatBinding(t,e,i);if(a){this.checkIdForState(i);var o="this";i!==this.currentXML&&(o+="."+i.attributes.id),this.bindings.push(new sys.EXBinding(o,t,a.templates,a.chainIndex)),e=""}else if(r==RECTANGLE){e="new "+RECTANGLE+"("+e+")"}else{switch(r){case TYPE_CLASS:t==SKIN_NAME&&(e=this.formatString(n));break;case"number":0==e.indexOf("#")?e="0x"+e.substring(1):-1!=e.indexOf("%")&&(e=parseFloat(e.substr(0,e.length-1)).toString());break;case"boolean":e="false"!=e&&e?"true":"false";break;case"string":case"any":e=this.formatString(n)}}return e},p.formatString=function(t){return t=this.unescapeHTMLEntity(t),t=t.split("\n").join("\\n"),t=t.split("\r").join("\\n"),t=t.split('"').join('\\"'),t='"'+t+'"'},p.formatBinding=function(t,e,i){if(!e)return null;if(e=e.trim(),"{"!=e.charAt(0)||"}"!=e.charAt(e.length-1))return null;e=e.substring(1,e.length-1).trim();for(var n=e.split("+"),s=[],r=n.length,a=0;r>a;a++){var o=n[a].trim();if(o){var h=o.charAt(0);if(!("'"==h||'"'==h||h>="0"&&"9">=h||-1==o.indexOf(".")&&-1!=jsKeyWords.indexOf(o))){0==o.indexOf("this.")&&(o=o.substring(5));var l=o.split(".")[0];l!=HOST_COMPONENT&&-1==this.skinParts.indexOf(l)&&(o=HOST_COMPONENT+"."+o),n[a]='"'+o+'"',s.push(a)}}else n.splice(a,1),a--,r--}return{templates:n,chainIndex:s}},p.unescapeHTMLEntity=function(t){if(!t)return"";for(var e=htmlEntities.length,i=0;e>i;i++){var n=htmlEntities[i],s=n[0],r=n[1];t=t.split(r).join(s)}return t},p.createConstructFunc=function(){var t=new sys.EXCodeBlock;t.addEmptyLine();var e="this";if(this.addAttributesToCodeBlock(t,e,this.currentXML),this.declarations){var i=this.declarations.children;if(i&&i.length>0)for(var n=i.length,s=0;n>s;s++){var r=i[s];if(1==r.nodeType){var a=this.createFuncForNode(r);a&&t.addCodeLine(a+";")}}}this.initlizeChildNode(this.currentXML,t,e);var o,h=this.stateIds;if(h.length>0){n=h.length;for(var s=0;n>s;s++)o=h[s],t.addCodeLine("this."+o+"_i();");t.addEmptyLine()}var l=this.skinParts,u="[]";if(n=l.length,n>0){for(s=0;n>s;s++)l[s]='"'+l[s]+'"';u="["+l.join(",")+"]"}var d=new sys.EXFunction;d.name="skinParts",d.isGet=!0;var c=new sys.EXCodeBlock;c.addReturn(u),d.codeBlock=c,this.currentClass.addFunction(d),this.currentXML.attributes.id="",this.createStates(this.currentXML);for(var p,v=this.currentXML,f=(this.getClassNameOfNode(v),v.attributes),g=Object.keys(f),m=g.length,y=0;m>y;y++){var C=g[y],$=f[C],E=C.indexOf(".");if(-1!=E){var _=C.substring(0,E);_=this.formatKey(_,$);var T=this.formatValue(_,$,v);if(!T)continue;var x=C.substr(E+1);p=this.getStateByName(x,v);var I=p.length;if(I>0)for(s=0;I>s;s++){var S=p[s];S.addOverride(new sys.EXSetProperty("",_,T))}}}var L=this.stateCode;if(n=L.length,n>0){var P=" ";t.addCodeLine("this.states = [");var N=!0;for(s=0;n>s;s++){S=L[s],N?N=!1:t.addCodeLine(P+",");for(var A=S.toCode().split("\n"),b=0;b0)for(t.addEmptyLine(),s=0;n>s;s++){var D=B[s];t.addCodeLine(D.toCode())}this.currentClass.constructCode=t},p.isStateNode=function(t){var e=t.attributes;return e.hasOwnProperty("includeIn")||e.hasOwnProperty("excludeFrom")},p.getStateNames=function(){var t=this.currentXML,e=sys.exmlConfig.getClassNameById(t.localName,t.namespace),i=sys.exmlConfig.getPropertyType("states",e);if(i==TYPE_STATE){var n=t.attributes.states;n&&delete t.attributes.states;var s,r=this.stateNames,a=t.children;if(a)for(var o=a.length,h=0;o>h;h++){var l=a[h];if(1==l.nodeType&&"states"==l.localName){l.namespace=sys.NS_W,s=l.children;break}}if(s||n)if(n){var u=n.split(",");o=u.length;for(var h=0;o>h;h++){var d=u[h].trim();d&&(-1==r.indexOf(d)&&r.push(d),this.stateCode.push(new sys.EXState(d)))}}else for(o=s.length,h=0;o>h;h++){var c=s[h];if(1==c.nodeType){var p=[],v=c.attributes;if(v.stateGroups)for(var f=v.stateGroups.split(","),g=f.length,m=0;g>m;m++){var y=f[m].trim();y&&(-1==r.indexOf(y)&&r.push(y),p.push(y))}d=v.name,-1==r.indexOf(d)&&r.push(d),this.stateCode.push(new sys.EXState(d,p))}}}},p.createStates=function(t){var e=t.children;if(e)for(var i=e.length,n=0;i>n;n++){var s=e[n];if(1==s.nodeType&&!this.isInnerClass(s)&&(this.createStates(s),s.namespace!=sys.NS_W&&s.localName))if(this.isProperty(s)){var r=s.localName,a=r.indexOf("."),o=s.children;if(-1==a||!o||0==o.length)continue;var h=r.substring(a+1);r=r.substring(0,a);var l,u=this.getClassNameOfNode(t),d=(sys.exmlConfig.getPropertyType(r,u),o[0]);1==d.nodeType?(this.createFuncForNode(d),this.checkIdForState(d),l="this."+d.attributes.id):l=this.formatValue(r,d.text,t),g=this.getStateByName(h,s);var c=g.length;if(c>0)for(var p=0;c>p;p++)m=g[p],m.addOverride(new sys.EXSetProperty(t.attributes.id,r,l))}else if(this.containsState(s)){var v=s.attributes,f=v.id;this.getClassNameOfNode(s);this.checkIdForState(s);var h,g,m;if(this.isStateNode(s)){var y="",C=s.parent;C.localName==TYPE_ARRAY&&(C=C.parent),C&&C.parent&&this.isProperty(C)&&(C=C.parent),C&&C!=this.currentXML&&(y=C.attributes.id,this.checkIdForState(C));var $=this.findNearNodeId(s),E=[];if(v.includeIn)E=v.includeIn.split(",");else{for(var _=v.excludeFrom.split(","),T=_.length,p=0;T>p;p++){var x=_[p];this.getStateByName(x,s)}for(T=this.stateCode.length,p=0;T>p;p++)m=this.stateCode[p],-1==_.indexOf(m.name)&&E.push(m.name)}for(var I=E.length,S=0;I>S;S++)if(h=E[S],g=this.getStateByName(h,s),g.length>0)for(var c=g.length,p=0;c>p;p++)m=g[p],m.addOverride(new sys.EXAddItems(f,y,$.position,$.relativeTo))}for(var L=Object.keys(v),P=L.length,N=0;P>N;N++){x=L[N];var l=v[x],a=x.indexOf(".");if(-1!=a){var A=x.substring(0,a);A=this.formatKey(A,l);var b=this.formatBinding(A,l,s);if(!b){var l=this.formatValue(A,l,s);if(!l)continue}h=x.substr(a+1),g=this.getStateByName(h,s);var c=g.length;if(c>0)for(var p=0;c>p;p++)m=g[p],b?m.addOverride(new sys.EXSetStateProperty(f,A,b.templates,b.chainIndex)):m.addOverride(new sys.EXSetProperty(f,A,l))}}}}},p.checkIdForState=function(t){if(t&&!this.currentClass.getVariableByName(t.attributes.id)){this.createVarForNode(t);var e=t.attributes.id,i=e+"_i",n=this.currentClass.getFuncByName(i);if(n){var s="this."+e+" = t;",r=n.codeBlock;r&&(r.containsCodeLine(s)||r.addCodeLineAt(s,1))}}},p.getStateByName=function(t,e){for(var i=[],n=this.stateCode,s=n.length,r=0;s>r;r++){var a=n[r];if(a.name==t)-1==i.indexOf(a)&&i.push(a);else if(a.stateGroups.length>0){for(var o=!1,h=a.stateGroups.length,l=0;h>l;l++){var u=a.stateGroups[l];if(u==t){o=!0;break}}o&&-1==i.indexOf(a)&&i.push(a)}}return i},p.findNearNodeId=function(t){for(var e,i,n,s=t.parent,r="",a=-1,o=!1,h=s.children,l=h.length,u=0;l>u;u++){var d=h[u];this.isProperty(d)||(d==t?(o=!0,a=u):!o||n||this.isStateNode(d)||(n=d),o||this.isStateNode(d)||(i=d))}return 0==a?(e=0,{position:e,relativeTo:r}):a==l-1?(e=1,{position:e,relativeTo:r}):n&&(e=2,r=n.attributes.id)?(this.checkIdForState(n),{position:e,relativeTo:r}):{position:1,relativeTo:r}},p.getClassNameOfNode=function(t){var e=sys.exmlConfig.getClassNameById(t.localName,t.namespace);return e},EXMLParser}();sys.EXMLParser=EXMLParser,egret.registerClass(EXMLParser,"eui.sys.EXMLParser")}(sys=eui.sys||(eui.sys={}))}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t){return"[object Array]"===Object.prototype.toString.call(t)}function i(t){var e=egret.getDefinitionByName(t);return e?e.prototype:null}function n(t){if(!t)return null;var e,e=new t;return e}t.NS_S="http://ns.egret.com/eui",t.NS_W="http://ns.egret.com/wing";var s=["Point","Matrix","Rectangle"],r=["Array","boolean","string","number"],a="eui.",o=0,h={},l=function(){function l(){}var u=(__define,l),d=u.prototype;return d.$describe=function(t){function i(){}if(!t)return null;var s=Object.getPrototypeOf(t);if(!s)return null;var a;if(s.hasOwnProperty("__hashCode__")&&(a=h[s.__hashCode__]))return a;var l=Object.getPrototypeOf(s);if(!l)return null;var u=n(l.constructor),d=this.$describe(u);d?(i.prototype=d,a=new i):a={};for(var c=Object.keys(s).concat(Object.keys(t)),p=c.length,v=t.__meta__,f=0;p>f;f++){var g=c[f];if("constructor"!=g&&"_"!=g.charAt(0)&&"$"!=g.charAt(0)){var m;if(v&&v[g])m=v[g];else if(e(t[g]))m="Array";else{if(m=typeof t[g],"function"==m)continue;-1==r.indexOf(m)&&(m="any")}a[g]=m}}return Object.getPrototypeOf(l)&&(s.__hashCode__=o++,h[s.__hashCode__]=a),a},d.getClassNameById=function(e,n){if(n==t.NS_S){if("Object"==e)return e;if(-1!=s.indexOf(e))return"egret."+e}var o="";return-1!=r.indexOf(e)?e:(n==t.NS_W||(o=n&&n!=t.NS_S?n.substring(0,n.length-1)+e:a+e),i(o)||(o=""),o)},d.getDefaultPropById=function(t,e){var n,s=this.getClassNameById(t,e),r=i(s);return r&&(n=r.__defaultProperty__),n?n:""},d.getPropertyType=function(t,e){if("Object"==e)return"any";var s="",r=i(e);if(r){if(!r.hasOwnProperty("__hashCode__")){var a=egret.getDefinitionByName(e),o=n(a);if(!o)return s;this.$describe(o)}var l=h[r.__hashCode__];l&&(s=l[t])}return s},l}();t.EXMLConfig=l,egret.registerClass(l,"eui.sys.EXMLConfig")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var EXML;!function(t){function e(t){return h.parse(t)}function i(t,e,i,n){if(void 0===n&&(n=!1),n&&t in u)return void(e&&e.call(i,u[t],t));var s=l[t];return s?void s.push([e,i]):(l[t]=[[e,i]],void o(t,a))}function n(t,e,i,n){if(void 0===n&&(n=!1),!t||0==t.length)return void(e&&e.call(i,[],t));var r=[];t.forEach(function(a){if(n&&a in u)return r[a]="",void r.push(a);var h=function(n,a){r[n]=a,r.push(n),r.length==t.length&&s(t,r,e,i)};o(a,h)})}function s(t,e,i,n){var s=[];t.forEach(function(t,i){if(t in u&&!e[t])return void(s[i]=u[t]);var n=e[t],r=a(t,n);s[i]=r}),i&&i.call(n,s,t)}function r(t,e,i){if(e)var n=h.$parseCode(e,i);if(t){u[t]=n;var s=l[t];delete l[t];for(var r=s?s.length:0,a=0;r>a;a++){var o=s[a];o[0]&&o[1]&&o[0].call(o[1],n,t)}}return n}function a(t,i){if(i)var n=e(i);if(t){u[t]=n;var s=l[t];delete l[t];for(var r=s?s.length:0,a=0;r>a;a++){var o=s[a];o[0]&&o[1]&&o[0].call(o[1],n,t)}}return n}function o(e,i){var n=e;-1==e.indexOf("://")&&(n=d+e);var s=function(t){t||(t=""),i(e,t)},r=t.$stage?t.$stage.getImplementation("eui.IThemeAdapter"):null;r||(r=new eui.DefaultThemeAdapter),r.getTheme(n,s,s,this)}var h=new eui.sys.EXMLParser,l={},u={},d="";Object.defineProperty(t,"prefixURL",{get:function(){return d},set:function(t){d=t},enumerable:!0,configurable:!0}),t.parse=e,t.load=i,t.$loadAll=n,t.$parseURLContentAsJs=r,t.$parseURLContent=a}(EXML||(EXML={}));var eui;!function(t){egret.$locale_strings=egret.$locale_strings||{},egret.$locale_strings.en_US=egret.$locale_strings.en_US||{};var e=egret.$locale_strings.en_US;e[2001]="EXML parsing error {0}: EXML file can't be found ",e[2002]="EXML parsing error : invalid XML file:\n{0}",e[2003]="EXML parsing error {0}: the class definitions corresponding to nodes can't be found \n {1}",e[2004]="EXML parsing error {0}: nodes cannot contain id property with the same name \n {1}",e[2005]="EXML parsing error {0}: property with the name of '{1}' does not exist on the node, or the property does not have a default value: \n {2}",e[2006]="EXML parsing error {0}: undefined view state name: '{1}' \n {2}",e[2007]="EXML parsing error {0}: only UIComponent objects within the container can use the includeIn and excludeFrom properties\n {1}",e[2008]="EXML parsing error {0}: fail to assign values of '{1}' class to property: '{2}' \n {3}",e[2009]="EXML parsing error {0}: only one ID can be referenced in the node property value '{}' label; and complex expression is not allowed to use \n {1}",e[2010]="EXML parsing error {0}: ID referenced by property: '{1}': '{2}' does not exist \n {3}",e[2011]="EXML parsing error {0}: fail to assign more than one child nodes to the same property: '{1}' \n {2}",e[2012]="EXML parsing error {0}: no default property exists on the node; and you must explicitly declare the property name that the child node is assigned to \n {1}",e[2013]="EXML parsing error {0}: view state grammar is not allowed to use on property nodes of Array class \n {1} ",e[2014]="EXML parsing error {0}: assigning the skin class itself to the node property is not allowed \n {1}",e[2015]="EXML parsing error {0}: class definition referenced by node: {1} does not exist \n {2}",e[2016]="EXML parsing error {0}: format error of 'scale9Grid' property value on the node: {1}",e[2017]="EXML parsing error {0}: namespace prefix missing on the node: {1}",e[2018]="EXML parsing error {0}: format error of 'skinName' property value on the node: {1}",e[2019]="EXML parsing error {0}: the container’s child item must be visible nodes: {1}",e[2020]="EXML parsing error {0}: for child nodes in w: Declarations, the includeIn and excludeFrom properties are not allowed to use \n {1}",e[2021]="Compile errors in {0}, the attribute name: {1}, the attribute value: {2}.",e[2022]="EXML parsing error: there can be no Spaces in the id `{0}`",e[2101]="EXML parsing warnning : fail to register the class property : {0},there is already a class with the same name in the global,please try to rename the class name for the exml. \n {1}",e[2102]="EXML parsing warnning {0}: no child node can be found on the property code \n {1}",e[2103]="EXML parsing warnning {0}: the same property '{1}' on the node is assigned multiple times \n {2}",e[2104]="EXML parsing warnning, Instantiate class {0} error,the parameters of its constructor method must be empty.",e[2201]="BasicLayout doesn't support virtualization.",e[2202]="parse skinName error,the parsing result of skinName must be a instance of eui.Skin.",e[2203]="Could not find the skin class '{0}'。",e[2301]="parse source failed,could not find asset from URL:{0} ."}(eui||(eui={}));var eui;!function(t){egret.$locale_strings=egret.$locale_strings||{},egret.$locale_strings.zh_CN=egret.$locale_strings.zh_CN||{};var e=egret.$locale_strings.zh_CN;e[2001]="EXML解析错误 {0}: 找不到EXML文件",e[2002]="EXML解析错误: 不是有效的XML文件:\n{0}",e[2003]="EXML解析错误 {0}: 无法找到节点所对应的类定义\n{1}",e[2004]="EXML解析错误 {0}: 节点不能含有同名的id属性\n{1}",e[2005]="EXML解析错误 {0}: 节点上不存在名为'{1}'的属性,或者该属性没有初始值:\n{2}",e[2006]="EXML解析错误 {0}: 未定义的视图状态名称:'{1}'\n{2}",e[2007]="EXML解析错误 {0}: 只有处于容器内的 UIComponent 对象可以使用includeIn和excludeFrom属性\n{1}",e[2008]="EXML解析错误 {0}: 无法将'{1}'类型的值赋给属性:'{2}'\n{3}",e[2009]="EXML解析错误 {0}: 在节点属性值的‘{}’标签内只能引用一个ID,不允许使用复杂表达式\n{1}",e[2010]="EXML解析错误 {0}: 属性:'{1}'所引用的ID: '{2}'不存在\n{3}",e[2011]="EXML解析错误 {0}: 无法将多个子节点赋值给同一个属性:'{1}'\n{2}",e[2012]="EXML解析错误 {0}: 节点上不存在默认属性,必须显式声明子节点要赋值到的属性名\n{1}",e[2013]="EXML解析错误 {0}: 类型为Array的属性节点上不允许使用视图状态语法\n{1}",e[2014]="EXML解析错误 {0}: 不允许将皮肤类自身赋值给节点属性\n{1}",e[2015]="EXML解析错误 {0}: 节点引用的类定义:{1}不存在\n{2}",e[2016]="EXML解析错误 {0}: 节点上'scale9Grid'属性值的格式错误:{1}",e[2017]="EXML解析错误 {0}: 节点上缺少命名空间前缀:{1}",e[2018]="EXML解析错误 {0}: 节点上'skinName'属性值的格式错误:{1}",e[2019]="EXML解析错误 {0}: 容器的子项必须是可视节点:{1}",e[2020]="EXML解析错误 {0}: 在w:Declarations内的子节点,不允许使用includeIn和excludeFrom属性\n{1}",e[2021]="{0} 中存在编译错误,属性名 : {1},属性值 : {2}",e[2022]="EXML解析错误: id `{0}` 中不可以有空格",e[2101]="EXML解析警告: 在EXML根节点上声明的 class 属性: {0} 注册失败,所对应的类已经存在,请尝试重命名要注册的类名。\n{1}",e[2102]="EXML解析警告 {0}: 在属性节点上找不到任何子节点\n{1}",e[2103]="EXML解析警告 {0}: 节点上的同一个属性'{1}'被多次赋值\n{2}",e[2104]="EXML解析警告,无法直接实例化自定义组件:{0} ,在EXML中使用的自定义组件必须要能直接被实例化,否则可能导致后续EXML解析报错。",e[2201]="BasicLayout 不支持虚拟化。",e[2202]="皮肤解析出错,属性 skinName 的值必须要能够解析为一个 eui.Skin 的实例。",e[2203]="找不到指定的皮肤类 '{0}'。",e[2301]="素材解析失败,找不到URL:{0} 所对应的资源。"}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.call(this),this.$target=null,this.$useVirtualLayout=!1,this.$typicalWidth=71,this.$typicalHeight=22}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"target",function(){return this.$target},function(t){this.$target!==t&&(this.$target=t,this.clearVirtualLayoutCache())}),i(s,"useVirtualLayout",function(){return this.$useVirtualLayout},function(t){t=!!t,this.$useVirtualLayout!=t&&(this.$useVirtualLayout=t,this.dispatchEventWith("useVirtualLayoutChanged"),this.$useVirtualLayout&&!t&&this.clearVirtualLayoutCache(),this.target&&this.target.invalidateDisplayList())}),s.setTypicalSize=function(t,e){t=+t||71,e=+e||22,(t!==this.$typicalWidth||e!==this.$typicalHeight)&&(this.$typicalWidth=t,this.$typicalHeight=e,this.$target&&this.$target.invalidateSize())},s.scrollPositionChanged=function(){},s.clearVirtualLayoutCache=function(){},s.elementAdded=function(t){},s.elementRemoved=function(t){},s.getElementIndicesInView=function(){return null},s.measure=function(){},s.updateDisplayList=function(t,e){},e}(egret.EventDispatcher);t.LayoutBase=e,egret.registerClass(e,"eui.LayoutBase")}(eui||(eui={}));var eui;!function(t){var e=function(e){function i(){e.call(this)}__extends(i,e);var n=(__define,i),s=n.prototype;return s.measure=function(){e.prototype.measure.call(this),t.sys.measure(this.$target)},s.updateDisplayList=function(i,n){e.prototype.updateDisplayList.call(this,i,n);var s=this.$target,r=t.sys.updateDisplayList(s,i,n);s.setContentSize(Math.ceil(r.x),Math.ceil(r.y))},i}(t.LayoutBase);t.BasicLayout=e,egret.registerClass(e,"eui.BasicLayout")}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t,e){if(!t||"number"==typeof t)return t;var i=t,n=i.indexOf("%");if(-1==n)return+i;var s=+i.substring(0,n);return.01*s*e}function i(t){if(t){for(var e=0,i=0,n=egret.$TempRectangle,r=t.numChildren,a=0;r>a;a++){var o=t.getChildAt(a);if(egret.is(o,s)&&o.$includeInLayout){var h,l,u=o.$UIComponent,d=+u[4],c=+u[5],p=+u[0],v=+u[1],f=+u[2],g=+u[3];o.getPreferredBounds(n),isNaN(p)||isNaN(v)?isNaN(d)?isNaN(p)&&isNaN(v)?h=n.x:(h=isNaN(p)?0:p,h+=isNaN(v)?0:v):h=2*Math.abs(d):h=p+v,isNaN(f)||isNaN(g)?isNaN(c)?isNaN(f)&&isNaN(g)?l=n.y:(l=isNaN(f)?0:f,l+=isNaN(g)?0:g):l=2*Math.abs(c):l=f+g;var m=n.width,y=n.height;e=Math.ceil(Math.max(e,h+m)),i=Math.ceil(Math.max(i,l+y))}}t.setMeasuredSize(e,i)}}function n(t,i,n){if(t){for(var r=t.numChildren,a=0,o=0,h=egret.$TempRectangle,l=0;r>l;l++){var u=t.getChildAt(l);if(egret.is(u,s)&&u.$includeInLayout){var d=u.$UIComponent,c=e(d[4],.5*i),p=e(d[5],.5*n),v=e(d[0],i),f=e(d[1],i),g=e(d[2],n),m=e(d[3],n),y=d[6],C=d[7],$=0/0,E=0/0;isNaN(v)||isNaN(f)?isNaN(y)||($=Math.round(i*Math.min(.01*y,1))):$=i-f-v,isNaN(g)||isNaN(m)?isNaN(C)||(E=Math.round(n*Math.min(.01*C,1))):E=n-m-g,u.setLayoutBoundsSize($,E),u.getLayoutBounds(h);var _=h.width,T=h.height,x=0/0,I=0/0;x=isNaN(c)?isNaN(v)?isNaN(f)?h.x:i-_-f:v:Math.round((i-_)/2+c),I=isNaN(p)?isNaN(g)?isNaN(m)?h.y:n-T-m:g:Math.round((n-T)/2+p),u.setLayoutBoundsPosition(x,I),a=Math.max(a,x+_),o=Math.max(o,I+T)}}return egret.$TempPoint.setTo(a,o)}}var s="eui.UIComponent";t.measure=i,t.updateDisplayList=n}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.LEFT="left",t.JUSTIFY_USING_GAP="justifyUsingGap",t.JUSTIFY_USING_WIDTH="justifyUsingWidth",t}();t.ColumnAlign=e,egret.registerClass(e,"eui.ColumnAlign")}(eui||(eui={}));var eui;!function(t){var e=function(t){function e(){t.apply(this,arguments),this.$horizontalAlign="left",this.$verticalAlign="top",this.$gap=6,this.$paddingLeft=0,this.$paddingRight=0,this.$paddingTop=0,this.$paddingBottom=0,this.elementSizeTable=[],this.startIndex=-1,this.endIndex=-1,this.indexInViewCalculated=!1,this.maxElementSize=0}__extends(e,t);var i=__define,n=e,s=n.prototype;return i(s,"horizontalAlign",function(){return this.$horizontalAlign},function(t){this.$horizontalAlign!=t&&(this.$horizontalAlign=t,this.$target&&this.$target.invalidateDisplayList())}),i(s,"verticalAlign",function(){return this.$verticalAlign},function(t){this.$verticalAlign!=t&&(this.$verticalAlign=t,this.$target&&this.$target.invalidateDisplayList())}),i(s,"gap",function(){return this.$gap},function(t){t=+t||0,this.$gap!==t&&(this.$gap=t,this.invalidateTargetLayout())}),i(s,"paddingLeft",function(){return this.$paddingLeft},function(t){t=+t||0,this.$paddingLeft!==t&&(this.$paddingLeft=t,this.invalidateTargetLayout())}),i(s,"paddingRight",function(){return this.$paddingRight},function(t){t=+t||0,this.$paddingRight!==t&&(this.$paddingRight=t,this.invalidateTargetLayout())}),i(s,"paddingTop",function(){return this.$paddingTop},function(t){t=+t||0,this.$paddingTop!==t&&(this.$paddingTop=t,this.invalidateTargetLayout())}),i(s,"paddingBottom",function(){return this.$paddingBottom},function(t){t=+t||0,this.$paddingBottom!==t&&(this.$paddingBottom=t,this.invalidateTargetLayout())}),s.invalidateTargetLayout=function(){var t=this.$target;t&&(t.invalidateSize(),t.invalidateDisplayList())},s.measure=function(){this.$target&&(this.$useVirtualLayout?this.measureVirtual():this.measureReal())},s.measureReal=function(){},s.measureVirtual=function(){},s.updateDisplayList=function(t,e){var i=this.$target;if(i)return 0==i.numElements?void i.setContentSize(Math.ceil(this.$paddingLeft+this.$paddingRight),Math.ceil(this.$paddingTop+this.$paddingBottom)):void(this.$useVirtualLayout?this.updateDisplayListVirtual(t,e):this.updateDisplayListReal(t,e))},s.getStartPosition=function(t){return 0},s.getElementSize=function(t){return 0},s.getElementTotalSize=function(){return 0},s.elementRemoved=function(e){this.$useVirtualLayout&&(t.prototype.elementRemoved.call(this,e),this.elementSizeTable.splice(e,1))},s.clearVirtualLayoutCache=function(){this.$useVirtualLayout&&(this.elementSizeTable=[],this.maxElementSize=0)},s.findIndexAt=function(t,e,i){var n=.5*(e+i)|0,s=this.getStartPosition(n),r=this.getElementSize(n);return t>=s&&tt?this.findIndexAt(t,e,Math.max(e,n-1)):this.findIndexAt(t,Math.min(n+1,i),i)},s.scrollPositionChanged=function(){if(t.prototype.scrollPositionChanged.call(this),this.$useVirtualLayout){var e=this.getIndexInView();e&&(this.indexInViewCalculated=!0,this.target.invalidateDisplayList())}},s.getIndexInView=function(){return!1},s.updateDisplayListVirtual=function(t,e){},s.updateDisplayListReal=function(t,e){},s.flexChildrenProportionally=function(t,e,i,n){var s,r=n.length;do{s=!0;var a=e-t*i/100;a>0?e-=a:a=0;for(var o=e/i,h=0;r>h;h++){var l=n[h],u=l.percent*o;if(u=d?a-=d:(e-=d-a,a=0),s=!1;break}if(u>l.max){var c=l.max;l.size=c,n[h]=n[--r],n[r]=l,i-=l.percent,a>=c?a-=c:(e-=c-a,a=0),s=!1;break}l.size=u}}while(!s)},e}(t.LayoutBase);t.LinearLayoutBase=e,egret.registerClass(e,"eui.LinearLayoutBase")}(eui||(eui={}));var eui;!function(t){var e;!function(t){var e=function(){function t(){this.layoutElement=null,this.size=0,this.percent=0/0,this.min=0/0,this.max=0/0}var e=(__define,t);e.prototype;return t}();t.ChildInfo=e,egret.registerClass(e,"eui.sys.ChildInfo")}(e=t.sys||(t.sys={}))}(eui||(eui={}));var eui;!function(t){var e="eui.UIComponent",i=function(i){function n(){i.apply(this,arguments)}__extends(n,i);var s=(__define,n),r=s.prototype;return r.measureReal=function(){for(var t=this.$target,i=t.numElements,n=i,s=0,r=0,a=egret.$TempRectangle,o=0;i>o;o++){var h=t.getElementAt(o);egret.is(h,e)&&h.$includeInLayout?(h.getPreferredBounds(a),s+=a.width,r=Math.max(r,a.height)):n--}s+=(n-1)*this.$gap;var l=this.$paddingLeft+this.$paddingRight,u=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(s+l,r+u)},r.measureVirtual=function(){for(var t=this.$target,i=this.$typicalWidth,n=this.getElementTotalSize(),s=Math.max(this.maxElementSize,this.$typicalHeight),r=egret.$TempRectangle,a=this.endIndex,o=this.elementSizeTable,h=this.startIndex;a>h;h++){var l=t.getElementAt(h);egret.is(l,e)&&l.$includeInLayout&&(l.getPreferredBounds(r),n+=r.width,n-=isNaN(o[h])?i:o[h],s=Math.max(s,r.height))}var u=this.$paddingLeft+this.$paddingRight,d=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(n+u,s+d)},r.updateDisplayListReal=function(i,n){var s=this.$target,r=this.$paddingLeft,a=this.$paddingRight,o=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=Math.max(0,i-r-a),d=Math.max(0,n-o-h),c=this.$horizontalAlign==t.JustifyAlign.JUSTIFY,p=this.$verticalAlign==t.JustifyAlign.JUSTIFY||this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0; +p||(this.$verticalAlign==egret.VerticalAlign.MIDDLE?v=.5:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(v=1));var f,g,m,y=s.numElements,C=y,$=r,E=o,_=0,T=0,x=[],I=u,S=this.maxElementSize,L=egret.$TempRectangle;for(f=0;y>f;f++){var g=s.getElementAt(f);if(egret.is(g,e)&&g.$includeInLayout)if(g.getPreferredBounds(L),S=Math.max(S,L.height),c)_+=L.width;else{var P=g.$UIComponent;isNaN(P[6])?I-=L.width:(T+=P[6],m=new t.sys.ChildInfo,m.layoutElement=g,m.percent=P[6],m.min=P[12],m.max=P[13],x.push(m))}else C--}I-=l*(C-1),I=I>0?I:0;var N,A=u-_-l*(C-1),b=C,R={};if(c){if(0>A){for(N=I/C,f=0;y>f;f++)g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(L),L.width<=N&&(I-=L.width,b--));I=I>0?I:0}}else if(T>0){this.flexChildrenProportionally(u,I,T,x);var B=0,D=x.length;for(f=0;D>f;f++){m=x[f];var M=Math.round(m.size+B);B+=m.size-M,R[m.layoutElement.$hashCode]=M,I-=M}I=I>0?I:0}this.$horizontalAlign==egret.HorizontalAlign.CENTER?$=r+.5*I:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&($=r+I);var O=r,w=o,V=0,H=0,z=Math.ceil(d);this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY&&(z=Math.ceil(Math.max(d,S))),B=0;var U,k;for(f=0;y>f;f++){var G=0;if(g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout){if(g.getPreferredBounds(L),U=0/0,c?(k=0/0,A>0?k=I*L.width/_:0>A&&L.width>N&&(k=I/b),isNaN(k)||(U=Math.round(k+B),B+=k-U)):U=R[g.$hashCode],p)E=o,g.setLayoutBoundsSize(U,z),g.getLayoutBounds(L);else{var F=0/0,P=g.$UIComponent;if(!isNaN(g.percentHeight)){var W=Math.min(100,P[7]);F=Math.round(d*W*.01)}g.setLayoutBoundsSize(U,F),g.getLayoutBounds(L),G=(d-L.height)*v,G=G>0?G:0,E=o+G}g.setLayoutBoundsPosition(Math.round($),Math.round(E)),V=Math.ceil(L.width),H=Math.ceil(L.height),O=Math.max(O,$+V),w=Math.max(w,E+H),$+=V+l}}this.maxElementSize=S,s.setContentSize(O+a,w+h)},r.updateDisplayListVirtual=function(i,n){var s=this.$target;this.indexInViewCalculated?this.indexInViewCalculated=!1:this.getIndexInView();var r,a=this.$paddingRight,o=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=s.numElements;if(-1==this.startIndex||-1==this.endIndex)return r=this.getStartPosition(u)-l+a,void s.setContentSize(r,s.contentHeight);var d=this.endIndex;s.setVirtualElementIndicesInView(this.startIndex,d);var c=this.$verticalAlign==t.JustifyAlign.JUSTIFY||this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,p=this.$verticalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0;c||(this.$verticalAlign==egret.VerticalAlign.MIDDLE?v=.5:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(v=1));var f,g=egret.$TempRectangle,m=Math.max(0,n-o-h),y=Math.ceil(m),C=this.$typicalHeight,$=this.$typicalWidth,E=this.maxElementSize,_=Math.max(C,this.maxElementSize);if(p){for(var T=this.startIndex;d>=T;T++)f=s.getVirtualElementAt(T),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),E=Math.max(E,g.height));y=Math.ceil(Math.max(m,E))}for(var x,I=0,S=0,L=0,P=!1,N=this.elementSizeTable,A=this.startIndex;d>=A;A++){var b=0;f=s.getVirtualElementAt(A),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),p||(E=Math.max(E,g.height)),c?(S=o,f.setLayoutBoundsSize(0/0,y),f.getLayoutBounds(g)):(f.getLayoutBounds(g),b=(m-g.height)*v,b=b>0?b:0,S=o+b),L=Math.max(L,g.height),P||(x=isNaN(N[A])?$:N[A],x!=g.width&&(P=!0)),N[A]=g.width,I=this.getStartPosition(A),f.setLayoutBoundsPosition(Math.round(I),Math.round(S)))}L+=o+h,r=this.getStartPosition(u)-l+a,this.maxElementSize=E,s.setContentSize(r,L),(P||_a;a++){var o=r[a];isNaN(o)&&(o=i),n+=o+s}return n},r.getElementSize=function(t){if(this.$useVirtualLayout){var e=this.elementSizeTable[t];return isNaN(e)&&(e=this.$typicalWidth),e}return this.$target?this.$target.getElementAt(t).width:0},r.getElementTotalSize=function(){for(var t=this.$typicalWidth,e=this.$gap,i=0,n=this.$target.numElements,s=this.elementSizeTable,r=0;n>r;r++){var a=s[r];isNaN(a)&&(a=t),i+=a+e}return i-=e},r.elementAdded=function(t){this.useVirtualLayout&&(i.prototype.elementAdded.call(this,t),this.elementSizeTable.splice(t,0,this.$typicalWidth))},r.getIndexInView=function(){var t=this.$target;if(!t||0==t.numElements)return this.startIndex=this.endIndex=-1,!1;var e=t.$UIComponent;if(e[10]<=0||e[11]<=0)return this.startIndex=this.endIndex=-1,!1;var i=t.numElements,n=this.getStartPosition(i-1)+this.elementSizeTable[i-1]+this.$paddingRight,s=t.scrollH;if(s>n-this.$paddingRight)return this.startIndex=-1,this.endIndex=-1,!1;var r=t.scrollH+e[10];if(r0?this._requestedColumnCount:this._columnCount,l=this._requestedRowCount>0?this._requestedRowCount:this._rowCount,u=isNaN(this._horizontalGap)?0:this._horizontalGap,d=isNaN(this._verticalGap)?0:this._verticalGap;h>0&&(r=h*(this._columnWidth+u)-u),l>0&&(a=l*(this._rowHeight+d)-d);var c=this._paddingLeft+this._paddingRight,p=this._paddingTop+this._paddingBottom;t.setMeasuredSize(r+c,a+p),this._columnCount=e,this._rowCount=i,this._columnWidth=n,this._rowHeight=s}},a.calculateRowAndColumn=function(i,n){var s=this.$target,r=isNaN(this._horizontalGap)?0:this._horizontalGap,a=isNaN(this._verticalGap)?0:this._verticalGap;this._rowCount=this._columnCount=-1;for(var o=s.numElements,h=o,l=0;h>l;l++){var u=s.getElementAt(l);!u||egret.is(u,e)&&u.$includeInLayout||o--}if(0==o)return void(this._rowCount=this._columnCount=0);(isNaN(this.explicitColumnWidth)||isNaN(this.explicitRowHeight))&&this.updateMaxElementSize(),isNaN(this.explicitColumnWidth)?this._columnWidth=this.maxElementWidth:this._columnWidth=this.explicitColumnWidth,isNaN(this.explicitRowHeight)?this._rowHeight=this.maxElementHeight:this._rowHeight=this.explicitRowHeight;var d=this._columnWidth+r;0>=d&&(d=1);var c=this._rowHeight+a;0>=c&&(c=1);var p=this._orientation==t.TileOrientation.COLUMNS,v=!isNaN(i),f=!isNaN(n),g=this._paddingLeft,m=this._paddingRight,y=this._paddingTop,C=this._paddingBottom;if(this._requestedColumnCount>0||this._requestedRowCount>0)this._requestedRowCount>0&&(this._rowCount=Math.min(this._requestedRowCount,o)),this._requestedColumnCount>0&&(this._columnCount=Math.min(this._requestedColumnCount,o));else if(v||f)if(!v||f&&p){var $=Math.max(0,n-y-C);this._rowCount=Math.floor(($+a)/c),this._rowCount=Math.max(1,Math.min(this._rowCount,o))}else{var E=Math.max(0,i-g-m);this._columnCount=Math.floor((E+r)/d),this._columnCount=Math.max(1,Math.min(this._columnCount,o))}else{var _=Math.sqrt(o*d*c);p?this._rowCount=Math.max(1,Math.round(_/c)):this._columnCount=Math.max(1,Math.round(_/d))}-1==this._rowCount&&(this._rowCount=Math.max(1,Math.ceil(o/this._columnCount))),-1==this._columnCount&&(this._columnCount=Math.max(1,Math.ceil(o/this._rowCount))),this._requestedColumnCount>0&&this._requestedRowCount>0&&(this._orientation==t.TileOrientation.ROWS?this._rowCount=Math.max(1,Math.ceil(o/this._requestedColumnCount)):this._columnCount=Math.max(1,Math.ceil(o/this._requestedRowCount)))},a.updateMaxElementSize=function(){this.$target&&(this.$useVirtualLayout?(this.maxElementWidth=Math.max(this.maxElementWidth,this.$typicalWidth),this.maxElementHeight=Math.max(this.maxElementHeight,this.$typicalHeight),this.doUpdateMaxElementSize(this.startIndex,this.endIndex)):this.doUpdateMaxElementSize(0,this.$target.numElements-1))},a.doUpdateMaxElementSize=function(t,i){var n=this.maxElementWidth,s=this.maxElementHeight,r=egret.$TempRectangle,a=this.$target;if(-1!=t&&-1!=i)for(var o=t;i>=o;o++){var h=a.getVirtualElementAt(o);egret.is(h,e)&&h.$includeInLayout&&(h.getPreferredBounds(r),n=Math.max(n,r.width),s=Math.max(s,r.height))}this.maxElementWidth=n,this.maxElementHeight=s},a.clearVirtualLayoutCache=function(){i.prototype.clearVirtualLayoutCache.call(this),this.maxElementWidth=0,this.maxElementHeight=0},a.scrollPositionChanged=function(){if(this.$useVirtualLayout){var t=this.getIndexInView();t&&(this.indexInViewCalculated=!0,this.$target.invalidateDisplayList())}},a.getIndexInView=function(){if(!this.$target||0==this.$target.numElements)return this.startIndex=this.endIndex=-1,!1;var e=this.$target,i=e.numElements;if(!this.$useVirtualLayout)return this.startIndex=0,this.endIndex=i-1,!1;var n=e.$UIComponent;if(0==n[10]||0==n[11])return this.startIndex=this.endIndex=-1,!1;var s=this.startIndex,r=this.endIndex,a=this._paddingLeft,o=this._paddingTop,h=isNaN(this._horizontalGap)?0:this._horizontalGap,l=isNaN(this._verticalGap)?0:this._verticalGap;if(this._orientation==t.TileOrientation.COLUMNS){var u=this._columnWidth+h;if(0>=u)return this.startIndex=0,this.endIndex=i-1,!1;var d=e.scrollH,c=d+n[10],p=Math.floor((d-a)/u);0>p&&(p=0);var v=Math.ceil((c-a)/u);0>v&&(v=0),this.startIndex=Math.min(i-1,Math.max(0,p*this._rowCount)),this.endIndex=Math.min(i-1,Math.max(0,v*this._rowCount-1))}else{var f=this._rowHeight+l;if(0>=f)return this.startIndex=0,this.endIndex=i-1,!1;var g=e.scrollV,m=g+n[11],y=Math.floor((g-o)/f);0>y&&(y=0);var C=Math.ceil((m-o)/f);0>C&&(C=0),this.startIndex=Math.min(i-1,Math.max(0,y*this._columnCount)),this.endIndex=Math.min(i-1,Math.max(0,C*this._columnCount-1))}return this.startIndex!=s||this.endIndex!=r},a.updateDisplayList=function(n,s){if(i.prototype.updateDisplayList.call(this,n,s),this.$target){var r=this.$target,a=this._paddingLeft,o=this._paddingRight,h=this._paddingTop,l=this._paddingBottom;if(this.indexInViewCalculated)this.indexInViewCalculated=!1;else{if(this.calculateRowAndColumn(n,s),0==this._rowCount||0==this._columnCount)return void r.setContentSize(a+o,h+l);this.adjustForJustify(n,s),this.getIndexInView()}if(this.$useVirtualLayout&&(this.calculateRowAndColumn(n,s),this.adjustForJustify(n,s)),-1==this.startIndex||-1==this.endIndex)return void r.setContentSize(0,0);var u=this.endIndex;r.setVirtualElementIndicesInView(this.startIndex,u);for(var d,c,p,v,f,g=this._orientation==t.TileOrientation.COLUMNS,m=this.startIndex,y=isNaN(this._horizontalGap)?0:this._horizontalGap,C=isNaN(this._verticalGap)?0:this._verticalGap,$=this._rowCount,E=this._columnCount,_=this._columnWidth,T=this._rowHeight,x=this.startIndex;u>=x;x++)d=this.$useVirtualLayout?this.target.getVirtualElementAt(x):this.target.getElementAt(x),egret.is(d,e)&&d.$includeInLayout&&(g?(v=Math.ceil((m+1)/$)-1,f=Math.ceil((m+1)%$)-1,-1==f&&(f=$-1)):(v=Math.ceil((m+1)%E)-1,-1==v&&(v=E-1),f=Math.ceil((m+1)/E)-1),c=v*(_+y)+a,p=f*(T+C)+h,this.sizeAndPositionElement(d,c,p,_,T),m++);var I=a+o,S=h+l,L=(_+y)*E-y,P=(T+C)*$-C;r.setContentSize(L+I,P+S)}},a.sizeAndPositionElement=function(e,i,n,s,r){var a=0/0,o=0/0,h=e.$UIComponent;this._horizontalAlign==t.JustifyAlign.JUSTIFY?a=s:isNaN(h[6])||(a=s*h[6]*.01),this._verticalAlign==t.JustifyAlign.JUSTIFY?o=r:isNaN(h[7])||(o=r*h[7]*.01),e.setLayoutBoundsSize(Math.round(a),Math.round(o));var l=i,u=egret.$TempRectangle;switch(e.getLayoutBounds(u),this._horizontalAlign){case egret.HorizontalAlign.RIGHT:l+=s-u.width;break;case egret.HorizontalAlign.CENTER:l=i+(s-u.width)/2}var d=n;switch(this._verticalAlign){case egret.VerticalAlign.BOTTOM:d+=r-u.height;break;case egret.VerticalAlign.MIDDLE:d+=(r-u.height)/2}e.setLayoutBoundsPosition(Math.round(l),Math.round(d))},a.adjustForJustify=function(e,i){var n=this._paddingLeft,s=this._paddingRight,r=this._paddingTop,a=this._paddingBottom,o=Math.max(0,e-n-s),h=Math.max(0,i-r-a);isNaN(this.explicitVerticalGap)||(this._verticalGap=this.explicitVerticalGap),isNaN(this.explicitHorizontalGap)||(this._horizontalGap=this.explicitHorizontalGap),this._verticalGap=isNaN(this._verticalGap)?0:this._verticalGap,this._horizontalGap=isNaN(this._horizontalGap)?0:this._horizontalGap;var l,u=h-this._rowHeight*this._rowCount,d=o-this._columnWidth*this._columnCount;u>0&&(this._rowAlign==t.RowAlign.JUSTIFY_USING_GAP?(l=Math.max(1,this._rowCount-1),this._verticalGap=u/l):this._rowAlign==t.RowAlign.JUSTIFY_USING_HEIGHT&&this._rowCount>0&&(this._rowHeight+=(u-(this._rowCount-1)*this._verticalGap)/this._rowCount)),d>0&&(this._columnAlign==t.ColumnAlign.JUSTIFY_USING_GAP?(l=Math.max(1,this._columnCount-1),this._horizontalGap=d/l):this._columnAlign==t.ColumnAlign.JUSTIFY_USING_WIDTH&&this._columnCount>0&&(this._columnWidth+=(d-(this._columnCount-1)*this._horizontalGap)/this._columnCount))},n}(t.LayoutBase);t.TileLayout=i,egret.registerClass(i,"eui.TileLayout")}(eui||(eui={}));var eui;!function(t){var e=function(){function t(){}var e=(__define,t);e.prototype;return t.ROWS="rows",t.COLUMNS="columns",t}();t.TileOrientation=e,egret.registerClass(e,"eui.TileOrientation")}(eui||(eui={}));var eui;!function(t){var e="eui.UIComponent",i=function(i){function n(){i.apply(this,arguments)}__extends(n,i);var s=(__define,n),r=s.prototype;return r.measureReal=function(){for(var t=this.$target,i=t.numElements,n=i,s=0,r=0,a=egret.$TempRectangle,o=0;i>o;o++){var h=t.getElementAt(o);egret.is(h,e)&&h.$includeInLayout?(h.getPreferredBounds(a),r+=a.height,s=Math.max(s,a.width)):n--}r+=(n-1)*this.$gap;var l=this.$paddingLeft+this.$paddingRight,u=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(s+l,r+u)},r.measureVirtual=function(){for(var t=this.$target,i=this.$typicalHeight,n=this.getElementTotalSize(),s=Math.max(this.maxElementSize,this.$typicalWidth),r=egret.$TempRectangle,a=this.endIndex,o=this.elementSizeTable,h=this.startIndex;a>h;h++){var l=t.getElementAt(h);egret.is(l,e)&&l.$includeInLayout&&(l.getPreferredBounds(r),n+=r.height,n-=isNaN(o[h])?i:o[h],s=Math.max(s,r.width))}var u=this.$paddingLeft+this.$paddingRight,d=this.$paddingTop+this.$paddingBottom;t.setMeasuredSize(s+u,n+d)},r.updateDisplayListReal=function(i,n){var s=this.$target,r=this.$paddingLeft,a=this.$paddingRight,o=this.$paddingTop,h=this.$paddingBottom,l=this.$gap,u=Math.max(0,i-r-a),d=Math.max(0,n-o-h),c=this.$verticalAlign==t.JustifyAlign.JUSTIFY,p=this.$horizontalAlign==t.JustifyAlign.JUSTIFY||this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0;p||(this.$horizontalAlign==egret.HorizontalAlign.CENTER?v=.5:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&(v=1));var f,g,m,y=s.numElements,C=y,$=r,E=o,_=0,T=0,x=[],I=d,S=this.maxElementSize,L=egret.$TempRectangle;for(f=0;y>f;f++){var g=s.getElementAt(f);if(egret.is(g,e)&&g.$includeInLayout)if(g.getPreferredBounds(L),S=Math.max(S,L.width),c)_+=L.height;else{var P=g.$UIComponent;isNaN(P[7])?I-=L.height:(T+=P[7],m=new t.sys.ChildInfo,m.layoutElement=g,m.percent=P[7],m.min=P[14],m.max=P[15],x.push(m))}else C--}I-=l*(C-1),I=I>0?I:0;var N,A=d-_-l*(C-1),b=C,R={};if(c){if(0>A){for(N=I/C,f=0;y>f;f++)g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout&&(g.getPreferredBounds(L),L.height<=N&&(I-=L.height,b--));I=I>0?I:0}}else if(T>0){this.flexChildrenProportionally(d,I,T,x);var B=0,D=x.length;for(f=0;D>f;f++){m=x[f];var M=Math.round(m.size+B);B+=m.size-M,R[m.layoutElement.$hashCode]=M,I-=M}I=I>0?I:0}this.$verticalAlign==egret.VerticalAlign.MIDDLE?E=o+.5*I:this.$verticalAlign==egret.VerticalAlign.BOTTOM&&(E=o+I);var O=r,w=o,V=0,H=0,z=Math.ceil(u);this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY&&(z=Math.ceil(Math.max(u,S))),B=0;var U,k;for(f=0;y>f;f++){var G=0;if(g=s.getElementAt(f),egret.is(g,e)&&g.$includeInLayout){if(g.getPreferredBounds(L),U=0/0,c?(k=0/0,A>0?k=I*L.height/_:0>A&&L.height>N&&(k=I/b),isNaN(k)||(U=Math.round(k+B),B+=k-U)):U=R[g.$hashCode],p)$=r,g.setLayoutBoundsSize(z,U),g.getLayoutBounds(L);else{var F=0/0,P=g.$UIComponent;if(!isNaN(P[6])){var W=Math.min(100,P[6]);F=Math.round(u*W*.01)}g.setLayoutBoundsSize(F,U),g.getLayoutBounds(L),G=(u-L.width)*v,G=G>0?G:0,$=r+G}g.setLayoutBoundsPosition(Math.round($),Math.round(E)),V=Math.ceil(L.width),H=Math.ceil(L.height),O=Math.max(O,$+V),w=Math.max(w,E+H),E+=H+l}}this.maxElementSize=S,s.setContentSize(O+a,w+h)},r.updateDisplayListVirtual=function(i,n){var s=this.$target;this.indexInViewCalculated?this.indexInViewCalculated=!1:this.getIndexInView();var r,a=this.$paddingBottom,o=this.$paddingLeft,h=this.$paddingRight,l=this.$gap,u=s.numElements;if(-1==this.startIndex||-1==this.endIndex)return r=this.getStartPosition(u)-l+a,void s.setContentSize(s.contentWidth,r);var d=this.endIndex;s.setVirtualElementIndicesInView(this.startIndex,d);var c=this.$horizontalAlign==t.JustifyAlign.JUSTIFY||this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,p=this.$horizontalAlign==t.JustifyAlign.CONTENT_JUSTIFY,v=0;c||(this.$horizontalAlign==egret.HorizontalAlign.CENTER?v=.5:this.$horizontalAlign==egret.HorizontalAlign.RIGHT&&(v=1));var f,g=egret.$TempRectangle,m=Math.max(0,i-o-h),y=Math.ceil(m),C=this.$typicalHeight,$=this.$typicalWidth,E=this.maxElementSize,_=Math.max($,this.maxElementSize);if(p){for(var T=this.startIndex;d>=T;T++)f=s.getVirtualElementAt(T),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),E=Math.max(E,g.width));y=Math.ceil(Math.max(m,E))}for(var x,I=0,S=0,L=0,P=!1,N=this.elementSizeTable,A=this.startIndex;d>=A;A++){var b=0;f=s.getVirtualElementAt(A),egret.is(f,e)&&f.$includeInLayout&&(f.getPreferredBounds(g),p||(E=Math.max(E,g.width)),c?(I=o,f.setLayoutBoundsSize(y,0/0),f.getLayoutBounds(g)):(f.getLayoutBounds(g),b=(m-g.width)*v,b=b>0?b:0,I=o+b),L=Math.max(L,g.width),P||(x=isNaN(N[A])?C:N[A],x!=g.height&&(P=!0)),N[A]=g.height,S=this.getStartPosition(A),f.setLayoutBoundsPosition(Math.round(I),Math.round(S)))}L+=o+h,r=this.getStartPosition(u)-l+a,this.maxElementSize=E,s.setContentSize(L,r),(P||_a;a++){var o=r[a];isNaN(o)&&(o=i),n+=o+s}return n},r.getElementSize=function(t){if(this.$useVirtualLayout){var e=this.elementSizeTable[t];return isNaN(e)&&(e=this.$typicalHeight),e}return this.$target?this.$target.getElementAt(t).height:0},r.getElementTotalSize=function(){for(var t=this.$typicalHeight,e=this.$gap,i=0,n=this.$target.numElements,s=this.elementSizeTable,r=0;n>r;r++){var a=s[r];isNaN(a)&&(a=t),i+=a+e}return i-=e},r.elementAdded=function(t){this.$useVirtualLayout&&(i.prototype.elementAdded.call(this,t),this.elementSizeTable.splice(t,0,this.$typicalHeight))},r.getIndexInView=function(){var t=this.$target;if(!t||0==t.numElements)return this.startIndex=this.endIndex=-1,!1;var e=t.$UIComponent;if(0==e[10]||0==e[11])return this.startIndex=this.endIndex=-1,!1;var i=t.numElements,n=this.getStartPosition(i-1)+this.elementSizeTable[i-1]+this.$paddingBottom,s=t.scrollV;if(s>n-this.$paddingBottom)return this.startIndex=-1,this.endIndex=-1,!1;var r=t.scrollV+e[11];if(r-1&&s.splice(r,1)}},t}();t.AddItems=e,egret.registerClass(e,"eui.AddItems",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e=function(){function t(t,e,i){this.target=t,this.name=e,this.value=i}var e=(__define,t),i=e.prototype;return i.apply=function(t,e){var i=this.target?t[this.target]:t;i&&(this.oldValue=i[this.name],this.setPropertyValue(i,this.name,this.value,this.oldValue))},i.remove=function(t,e){var i=this.target?t[this.target]:t;i&&(this.setPropertyValue(i,this.name,this.oldValue,this.oldValue),this.oldValue=null)},i.setPropertyValue=function(t,e,i,n){void 0===i||null===i?t[e]=i:"number"==typeof n?t[e]=+i:"boolean"==typeof n?t[e]=this.toBoolean(i):t[e]=i},i.toBoolean=function(t){return"string"==typeof t?"true"==t.toLowerCase():0!=t},t}();t.SetProperty=e,egret.registerClass(e,"eui.SetProperty",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e=function(){function e(t,e,i,n,s){this.host=t,this.templates=e,this.chainIndex=i,this.target=n,this.prop=s}var i=(__define,e),n=i.prototype;return n.apply=function(e,i){if(this.target){var n=this.target[this.prop];this.oldValue&&this.setPropertyValue(this.target,this.prop,this.oldValue,this.oldValue),n&&(this.oldValue=n),t.Binding.$bindProperties(this.host,this.templates.concat(),this.chainIndex.concat(),this.target,this.prop)}},n.remove=function(t,e){if(this.target){var i=this.oldValue;this.target[this.prop]&&(this.oldValue=this.target[this.prop]),i&&this.setPropertyValue(this.target,this.prop,i,i)}},n.setPropertyValue=function(t,e,i,n){void 0===i||null===i?t[e]=i:"number"==typeof n?t[e]=+i:"boolean"==typeof n?t[e]=this.toBoolean(i):t[e]=i},n.toBoolean=function(t){return"string"==typeof t?"true"==t.toLowerCase():0!=t},e}();t.SetStateProperty=e,egret.registerClass(e,"eui.SetStateProperty",["eui.IOverride"])}(eui||(eui={}));var eui;!function(t){var e;!function(t){function e(t,e,i,n,r,a,o,h,l,u){var d;if(!isNaN(i)&&isNaN(n)){if(d=s(t,e,i,a,i,h,i,u))return d}else if(isNaN(i)&&!isNaN(n)&&(d=s(t,e,r,n,o,n,l,n)))return d;return d=s(t,e,r,a,o,h,l,u)}function i(t,e,i,s,r,a,o,h,l,u){var d;if(!isNaN(i)&&isNaN(s)){if(d=n(t,e,i,a,i,h,i,u))return d}else if(isNaN(i)&&!isNaN(s)&&(d=n(t,e,r,s,o,s,l,s)))return d;return d=n(t,e,r,a,o,h,l,u)}function n(t,e,i,n,s,a,h,l){var u=e.b,d=e.d;if(u>-1e-9&&1e-9>u&&(u=0),d>-1e-9&&1e-9>d&&(d=0),0==u&&0==d)return null;if(0==u&&0==d)return null;if(0==u)return egret.Point.create(i,t/Math.abs(d));if(0==d)return egret.Point.create(t/Math.abs(u),n);var c,p,v,f=u*d>=0?d:-d;if(0!=f&&i>0){var g=1/f;i=Math.max(s,Math.min(h,i)),p=i,v=(t-u*p)*g,v>=a&&l>=v&&u*p+f*v>=0&&(c=egret.Point.create(p,v)),v=(-t-u*p)*g,v>=a&&l>=v&&0>u*p+f*v&&(!c||o(c.x,c.y,e).width>o(p,v,e).width)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(0!=u&&n>0){var m=1/u;n=Math.max(a,Math.min(l,n)),v=n,p=(t-f*v)*m,p>=s&&h>=p&&u*p+f*v>=0&&(!c||o(c.x,c.y,e).width>o(p,v,e).width)&&(c=egret.Point.create(p,v)),p=(-t-f*v)*m,p>=s&&h>=p&&0>u*p+f*v&&(!c||o(c.x,c.y,e).width>o(p,v,e).width)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(c)return c;var y=e.a,C=e.c,$=y*C>=0?C:-C;return r(u,f,t,s,a,h,l,y,$)}function s(t,e,i,n,s,a,h,l){var u=e.a,d=e.c;if(u>-1e-9&&1e-9>u&&(u=0),d>-1e-9&&1e-9>d&&(d=0),0==u&&0==d)return null;if(0==u)return egret.Point.create(i,t/Math.abs(d));if(0==d)return egret.Point.create(t/Math.abs(u),n);var c,p,v,f=u*d>=0?d:-d;if(0!=f&&i>0){var g=1/f;i=Math.max(s,Math.min(h,i)),p=i,v=(t-u*p)*g,v>=a&&l>=v&&u*p+f*v>=0&&(c=egret.Point.create(p,v)),v=(-t-u*p)*g,v>=a&&l>=v&&0>u*p+f*v&&(!c||o(c.x,c.y,e).height>o(p,v,e).height)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(0!=u&&n>0){var m=1/u;n=Math.max(a,Math.min(l,n)),v=n,p=(t-f*v)*m,p>=s&&h>=p&&u*p+f*v>=0&&(!c||o(c.x,c.y,e).height>o(p,v,e).height)&&(egret.Point.release(c),c=egret.Point.create(p,v)),p=(-t-f*v)*m,p>=s&&h>=p&&0>u*p+f*v&&(!c||o(c.x,c.y,e).height>o(p,v,e).height)&&(egret.Point.release(c),c=egret.Point.create(p,v))}if(c)return c;var y=e.b,C=e.d,$=y*C>=0?C:-C;return r(u,f,t,s,a,h,l,y,$)}function r(t,e,i,n,s,r,a,o,h){if(0==t||0==e)return null;var l,u,d=(i-n*t)/e,c=(i-r*t)/e,p=Math.max(s,Math.min(d,c)),v=Math.min(a,Math.max(d,c)),f=o*e-t*h;return v>=p?(u=Math.abs(f)<1e-9?i/(t+e):o*i/f,u=Math.max(p,Math.min(u,v)),l=(i-e*u)/t,egret.Point.create(l,u)):(d=-(n*t+i)/e,c=-(r*t+i)/e,p=Math.max(s,Math.min(d,c)),v=Math.min(a,Math.max(d,c)),v>=p?(u=Math.abs(f)<1e-9?-i/(t+e):-o*i/f,u=Math.max(p,Math.min(u,v)),l=(-i-e*u)/t,egret.Point.create(l,u)):null)}function a(t,e,i,n,s,a,o){var l=i.a,u=i.b,d=i.c,c=i.d;if(l>-1e-9&&1e-9>l&&(l=0),u>-1e-9&&1e-9>u&&(u=0),d>-1e-9&&1e-9>d&&(d=0),c>-1e-9&&1e-9>c&&(c=0),0==u&&0==d)return 0==l||0==c?null:egret.Point.create(t/Math.abs(l),e/Math.abs(c));if(0==l&&0==c)return 0==u||0==d?null:egret.Point.create(e/Math.abs(u),t/Math.abs(d));var p=l*d>=0?d:-d,v=u*c>=0?c:-c,f=l*v-u*p;if(Math.abs(f)<1e-9)return 0==p||0==l||l==-p?null:Math.abs(l*e-u*t)>1e-9?null:r(l,p,t,n,n,a,o,u,v);var g=1/f;t*=g,e*=g;var m;return m=h(l,p,u,v,t,e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x>=0&&u*m.x+v*m.y>=0?m:(m=h(l,p,u,v,t,-e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x>=0&&u*m.x+v*m.y<0?m:(m=h(l,p,u,v,-t,e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x<0&&u*m.x+v*m.y>=0?m:(m=h(l,p,u,v,-t,-e),m&&n<=m.x&&m.x<=a&&s<=m.y&&m.y<=o&&l*m.x+p*m.x<0&&u*m.x+v*m.y<0?m:(egret.Point.release(m),null))))}function o(t,e,i){var n=egret.$TempRectangle.setTo(0,0,t,e);return i.$transformBounds(n),n}function h(t,e,i,n,s,r){return egret.Point.create(n*s-e*r,t*r-i*s)}var l=.1,u=.1,d=function(){function t(){}var n=(__define,t);n.prototype;return t.fitBounds=function(t,n,s,r,h,d,c,p,v,f,g){if(isNaN(t)&&isNaN(n))return egret.Point.create(d,c);var m,y=u>p?0:p-u,C=u>v?0:v-u,$=f+u,E=g+u;if(isNaN(t)||isNaN(n))return isNaN(t)?i(n,s,r,h,d,c,y,C,$,E):e(t,s,r,h,d,c,y,C,$,E);if(m=a(t,n,s,y,C,$,E),!m){var _;if(_=e(t,s,r,h,d,c,y,C,$,E)){var T=o(_.x,_.y,s).height;T-l>n&&(egret.Point.release(_),_=null)}var x;if(x=i(n,s,r,h,d,c,y,C,$,E)){var I=o(x.x,x.y,s).width;I-l>t&&(egret.Point.release(x),x=null)}m=_&&x?_.x*_.y>x.x*x.y?_:x:_?_:x,egret.Point.release(_),egret.Point.release(x)}return m},t}();t.MatrixUtil=d,egret.registerClass(d,"eui.sys.MatrixUtil")}(e=t.sys||(t.sys={}))}(eui||(eui={})); \ No newline at end of file diff --git a/build/socket/socket.js b/build/socket/socket.js index 4b9cb28311..b3d5887d59 100644 --- a/build/socket/socket.js +++ b/build/socket/socket.js @@ -278,12 +278,12 @@ var egret; this._writeMessage += message; } this.flush(); - return; - if (this._isReadySend) { - return; - } - this._isReadySend = true; - egret.callLater(this.flush, this); + // return; + // if (this._isReadySend) { + // return; + // } + // this._isReadySend = true; + // egret.callLater(this.flush, this); }; /** * @language en_US diff --git a/docs/cn/3.1.6_ReleaseNotes.md b/docs/cn/3.1.6_ReleaseNotes.md new file mode 100644 index 0000000000..1a00ad6028 --- /dev/null +++ b/docs/cn/3.1.6_ReleaseNotes.md @@ -0,0 +1,26 @@ +Egret 3.1.6 Release Note +=============================== + + +最近更新时间:2016年8月8日 + + +欢迎您使用Egret + +## 概述 + +Egret Engine 3.0 包含了白鹭时代研发的遵循HTML5标准的2D引擎及全新打造的[3D引擎](https://github.com/egret-labs/egret-3d),它解决了HTML5性能问题及碎片化问题,灵活地满足开发者开发2D或3D游戏的需求,并有着极强的跨平台运行能力。 + +## 更新内容 + +本次更新内容汇总了从引擎 3.1.5 到 3.1.6 的改动。 + +* 新增 egret run 命令可以配置启动参数 +* 新增数据绑定支持复杂表达式 +* 新增 eui 多项属性支持百分比表达式 +* 修复 WebGL 触摸导致卡顿问题 +* 修复 WebSocket 重连成功事件不派发问题 +* 修复 native 下输入文本位置错乱问题 + +#### 路线图 +* 优化滤镜性能 \ No newline at end of file diff --git a/docs/en/3.1.6_ReleaseNotes.md b/docs/en/3.1.6_ReleaseNotes.md new file mode 100644 index 0000000000..ac69b211e2 --- /dev/null +++ b/docs/en/3.1.6_ReleaseNotes.md @@ -0,0 +1,26 @@ +Egret 3.1.6 Release Note +=============================== + + +Updated on: August, 8th, 2016 + + +Welcome to Egret! + +## Overview + +Developed by Egret Technology, Egret Engine 3.0 includes a newly built 3D engine and a 2D engine created based on HTML5. With its robust cross-platform operability and commitment to solving the performance and fragmentation problems of HTML5 APP and games, Egret Engine 3.0 will perfectly meet developers’ needs. We appreciate every suggestion and please send it to Egret team if you have any. + +## Updated items + +This update aggregates all the changes from 3.1.5 to 3.1.6. + +* Added egret run command to configure the startup parameters. +* Added support for complex data-binding expressions. +* Added support eui more attributes percentage expression. +* Fixed WebGL touch cause problems Caton. +* Fixed WebSocket reconnection events are not distributed problem. +* Fixed native text input position under Mansian. + +#### Roadmap +* Filters can be optimized. \ No newline at end of file diff --git a/package.json b/package.json index d000f1a81e..bf878d1d1e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "egret", - "version": "3.1.5", + "version": "3.1.6", "private": true, "author": "egret-labs", "scripts": { @@ -16,7 +16,7 @@ "modules": [ { "name": "egret", - "description": "Egret 核心库", + "description": "egret 核心库", "files": [ { "path": "../Defines.debug.ts", @@ -378,6 +378,14 @@ "dependencies": [ "egret" ] + }, + { + "name": "dragonBones", + "description": "dragonbones 龙骨动画库", + "files": [], + "root": "", + "dependencies": [ + ] } ], "platforms": [ diff --git a/src/egret/display/DisplayObject.ts b/src/egret/display/DisplayObject.ts index 6940c2d62e..85e28918f3 100644 --- a/src/egret/display/DisplayObject.ts +++ b/src/egret/display/DisplayObject.ts @@ -351,16 +351,16 @@ module egret { * @private * 标记矩阵失效 */ - private invalidateMatrix(): void { + $invalidateMatrix(): void { this.$setFlags(sys.DisplayObjectFlags.InvalidMatrix); - this.invalidatePosition(); + this.$invalidatePosition(); } /** * @private * 标记这个显示对象在父级容器的位置发生了改变。 */ - private invalidatePosition(): void { + $invalidatePosition(): void { let self = this; self.$invalidateTransform(); self.$propagateFlagsDown(sys.DisplayObjectFlags.InvalidConcatenatedMatrix | @@ -555,7 +555,7 @@ module egret { values[Keys.rotation] = clampRotation(values[Keys.skewY] * 180 / Math.PI); } self.$removeFlags(sys.DisplayObjectFlags.InvalidMatrix); - self.invalidatePosition(); + self.$invalidatePosition(); return true; } @@ -659,7 +659,7 @@ module egret { return false; } m.tx = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; } @@ -711,7 +711,7 @@ module egret { return false; } m.ty = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; } @@ -760,7 +760,7 @@ module egret { return false; } values[Keys.scaleX] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; } @@ -806,7 +806,7 @@ module egret { return false; } this.$DisplayObject[Keys.scaleY] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; } @@ -858,7 +858,7 @@ module egret { values[Keys.skewX] += angle; values[Keys.skewY] += angle; values[Keys.rotation] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; } @@ -895,7 +895,7 @@ module egret { value = value / 180 * Math.PI; values[Keys.skewX] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; } @@ -932,7 +932,7 @@ module egret { value = value / 180 * Math.PI; values[Keys.skewY] = value; - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; } @@ -1002,7 +1002,7 @@ module egret { // values[Keys.scaleY] = bounds.height / baseHeight; // values[Keys.scaleX] = value / baseWidth; // } - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; } @@ -1072,7 +1072,7 @@ module egret { // values[Keys.scaleY] = value / baseHeight; // values[Keys.scaleX] = bounds.width / baseWidth; // } - this.invalidateMatrix(); + this.$invalidateMatrix(); return true; } @@ -1141,7 +1141,7 @@ module egret { return false; } this.$DisplayObject[Keys.anchorOffsetX] = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; } @@ -1186,7 +1186,7 @@ module egret { return false; } this.$DisplayObject[Keys.anchorOffsetY] = value; - this.invalidatePosition(); + this.$invalidatePosition(); return true; } @@ -1521,7 +1521,7 @@ module egret { else { this.$scrollRect = null; } - this.invalidatePosition(); + this.$invalidatePosition(); return true; } @@ -1664,7 +1664,7 @@ module egret { else { this.$maskRect = null; } - this.invalidatePosition(); + this.$invalidatePosition(); return true; } diff --git a/src/egret/player/Player.ts b/src/egret/player/Player.ts index 526530f49b..3bb7bf1887 100644 --- a/src/egret/player/Player.ts +++ b/src/egret/player/Player.ts @@ -522,7 +522,7 @@ module egret.sys { } ) this.totalTick = 0; - this.totalTime = this.totalTime % 500; + this.totalTime = this.totalTime % 1000; this.drawCalls = 0; this.dirtyRatio = 0; this.costDirty = 0; diff --git a/src/egret/player/SystemTicker.ts b/src/egret/player/SystemTicker.ts index 1b4107b8d3..8f4794bb4f 100644 --- a/src/egret/player/SystemTicker.ts +++ b/src/egret/player/SystemTicker.ts @@ -57,6 +57,8 @@ module egret.sys { $error(1008, "egret.sys.SystemTicker"); } $START_TIME = Date.now(); + this.frameDeltaTime = 1000 / this.$frameRate; + this.lastCount = this.frameInterval = Math.round(60000 / this.$frameRate); } /** @@ -164,7 +166,9 @@ module egret.sys { /** * @private */ - private frameInterval:number = 2000; + private frameInterval:number; + private frameDeltaTime:number; + private lastTimeStamp:number = 0; /** * @private @@ -187,6 +191,7 @@ module egret.sys { egret_native.setFrameRate(value); value = 60; } + this.frameDeltaTime = 1000 / value; //这里用60*1000来避免浮点数计算不准确的问题。 this.lastCount = this.frameInterval = Math.round(60000 / value); return true; @@ -195,7 +200,7 @@ module egret.sys { /** * @private */ - private lastCount:number = 2000; + private lastCount:number; /** * @private * ticker 花销的时间 @@ -219,16 +224,23 @@ module egret.sys { requestRenderingFlag = true; } } - this.lastCount -= 1000; var t2 = egret.getTimer(); - if (this.lastCount > 0) { - if (requestRenderingFlag) { - this.render(false, this.costEnterFrame+t2-t1); + let deltaTime = timeStamp - this.lastTimeStamp; + if (deltaTime >= this.frameDeltaTime) { + this.lastCount = this.frameInterval; + } + else { + this.lastCount -= 1000; + if (this.lastCount > 0) { + if (requestRenderingFlag) { + this.render(false, this.costEnterFrame + t2 - t1); + } + return; } - return; + this.lastCount += this.frameInterval; } - this.lastCount += this.frameInterval; - this.render(true, this.costEnterFrame+t2-t1); + this.lastTimeStamp = timeStamp; + this.render(true, this.costEnterFrame + t2 - t1); var t3 = egret.getTimer(); this.broadcastEnterFrame(); var t4 = egret.getTimer(); diff --git a/src/egret/player/rendering/CanvasRenderer.ts b/src/egret/player/rendering/CanvasRenderer.ts index c125ce9abe..050ec926e8 100644 --- a/src/egret/player/rendering/CanvasRenderer.ts +++ b/src/egret/player/rendering/CanvasRenderer.ts @@ -143,7 +143,11 @@ module egret { if (!child.$visible || child.$alpha <= 0 || child.$maskedObject) { continue; } - if ((child.$blendMode !== 0 || + var filters = child.$getFilters(); + if(filters && filters.length > 0) { + drawCalls += this.drawWithFilter(child, context, dirtyList, matrix, clipRegion, root); + } + else if ((child.$blendMode !== 0 || (child.$mask && (child.$mask.$parentDisplayList || root)))) {//若遮罩不在显示列表中,放弃绘制遮罩。 drawCalls += this.drawWithClip(child, context, dirtyList, matrix, clipRegion, root); } @@ -164,6 +168,92 @@ module egret { return drawCalls; } + /** + * @private + */ + private drawWithFilter(displayObject: DisplayObject, context: CanvasRenderingContext2D, dirtyList: egret.sys.Region[], + matrix: Matrix, clipRegion: sys.Region, root: DisplayObject):number { + var drawCalls = 0; + var filters = displayObject.$getFilters(); + var filtersLen:number = filters.length; + var hasBlendMode = (displayObject.$blendMode !== 0); + if (hasBlendMode) { + var compositeOp = blendModes[displayObject.$blendMode]; + if (!compositeOp) { + compositeOp = defaultCompositeOp; + } + } + + // 获取显示对象的链接矩阵 + var displayMatrix = Matrix.create(); + displayMatrix.copyFrom(displayObject.$getConcatenatedMatrix()); + + // 获取显示对象的矩形区域 + var region: sys.Region; + region = sys.Region.create(); + var bounds = displayObject.$getOriginalBounds(); + region.updateRegion(bounds, displayMatrix); + + // 为显示对象创建一个新的buffer + // todo 这里应该计算 region.x region.y + var displayBuffer = this.createRenderBuffer(region.width, region.height); + var displayContext = displayBuffer.context; + displayContext.setTransform(1, 0, 0, 1, -region.minX, -region.minY); + var offsetM = Matrix.create().setTo(1, 0, 0, 1, -region.minX, -region.minY); + + drawCalls += this.drawDisplayObject(displayObject, displayContext, dirtyList, offsetM, + displayObject.$displayList, region, root); + + Matrix.release(offsetM); + + //绘制结果到屏幕 + if (drawCalls > 0) { + + if (hasBlendMode) { + context.globalCompositeOperation = compositeOp; + } + + drawCalls++; + context.globalAlpha = 1; + context.setTransform(1, 0, 0, 1, region.minX + matrix.tx, region.minY + matrix.ty); + + // 应用滤镜 + var imageData = displayContext.getImageData(0, 0, displayBuffer.surface.width, displayBuffer.surface.height); + for(var i = 0; i < filtersLen; i++) { + var filter = filters[i]; + + if(filter.type == "colorTransform") { + colorFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, (filter).$matrix); + } else if(filter.type == "blur") { + blurFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, (filter).$blurX, (filter).$blurY); + } else if(filter.type == "glow") { + // TODO glow滤镜实现 kickout hideObject + var r = (filter).$red; + var g = (filter).$green; + var b = (filter).$blue; + var a = (filter).$alpha; + dropShadowFilter(imageData.data, displayBuffer.surface.width, displayBuffer.surface.height, [r, g, b, a], (filter).$blurX, (filter).$blurY, + (filter).$angle || 0, (filter).$distance || 0, (filter).$strength); + } + } + displayContext.putImageData(imageData, 0, 0); + + // 绘制结果的时候,应用滤镜 + context.drawImage(displayBuffer.surface, 0, 0); + + if (hasBlendMode) { + context.globalCompositeOperation = defaultCompositeOp; + } + + } + + renderBufferPool.push(displayBuffer); + sys.Region.release(region); + Matrix.release(displayMatrix); + + return drawCalls; + } + private renderingMask = false; /** @@ -730,4 +820,232 @@ module egret { } return gradient; } + + /** + * @private + */ + function colorFilter(buffer, w, h, matrix) { + var r0 = matrix[0], r1 = matrix[1], r2 = matrix[2], r3 = matrix[3], r4 = matrix[4]; + var g0 = matrix[5], g1 = matrix[6], g2 = matrix[7], g3 = matrix[8], g4 = matrix[9]; + var b0 = matrix[10], b1 = matrix[11], b2 = matrix[12], b3 = matrix[13], b4 = matrix[14]; + var a0 = matrix[15], a1 = matrix[16], a2 = matrix[17], a3 = matrix[18], a4 = matrix[19]; + for (var p = 0, e = w * h * 4; p < e; p += 4) { + var r = buffer[p + 0]; + var g = buffer[p + 1]; + var b = buffer[p + 2]; + var a = buffer[p + 3]; + + buffer[p + 0] = r0 * r + r1 * g + r2 * b + r3 * a + r4; + buffer[p + 1] = g0 * r + g1 * g + g2 * b + g3 * a + g4; + buffer[p + 2] = b0 * r + b1 * g + b2 * b + b3 * a + b4; + buffer[p + 3] = a0 * r + a1 * g + a2 * b + a3 * a + a4; + } + } + + /** + * @private + */ + function blurFilter(buffer, w, h, blurX, blurY) { + blurFilterH(buffer, w, h, blurX); + blurFilterV(buffer, w, h, blurY); + } + + /** + * @private + */ + function blurFilterH(buffer, w, h, blurX) { + var lineBuffer = new Uint8ClampedArray(w * 4); + var lineSize = w * 4; + var windowLength = (blurX * 2) + 1; + var windowSize = windowLength * 4; + for (var y = 0; y < h; y++) { + var pLineStart = y * lineSize; + var rs = 0, gs = 0, bs = 0, as = 0, alpha = 0, alpha2 = 0; + // Fill window + for (var ptr = -blurX * 4, end = blurX * 4 + 4; ptr < end; ptr += 4) { + var key = pLineStart + ptr; + if(key < pLineStart || key >= pLineStart + lineSize) { + continue; + } + alpha = buffer[key + 3]; + rs += buffer[key + 0] * alpha; + gs += buffer[key + 1] * alpha; + bs += buffer[key + 2] * alpha; + as += alpha; + } + // Slide window + for (var ptr = pLineStart, end = pLineStart + lineSize, linePtr = 0, lastPtr = ptr - blurX * 4, nextPtr = ptr + (blurX + 1) * 4; ptr < end; ptr += 4, linePtr += 4, nextPtr += 4, lastPtr += 4) { + lineBuffer[linePtr + 0] = rs / as; + lineBuffer[linePtr + 1] = gs / as; + lineBuffer[linePtr + 2] = bs / as; + lineBuffer[linePtr + 3] = as / windowLength; + alpha = buffer[nextPtr + 3]; + alpha2 = buffer[lastPtr + 3]; + + if(alpha || alpha == 0) { + if(alpha2 || alpha2 == 0) { + rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; + gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; + bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; + as += alpha - alpha2; + } else { + rs += buffer[nextPtr + 0] * alpha; + gs += buffer[nextPtr + 1] * alpha; + bs += buffer[nextPtr + 2] * alpha; + as += alpha; + } + } else { + if(alpha2 || alpha2 == 0) { + rs += - buffer[lastPtr + 0] * alpha2; + gs += - buffer[lastPtr + 1] * alpha2; + bs += - buffer[lastPtr + 2] * alpha2; + as += - alpha2; + } else { + // do nothing + } + } + } + // Copy line + buffer.set(lineBuffer, pLineStart); + } + } + + /** + * @private + */ + function blurFilterV(buffer, w, h, blurY) { + var columnBuffer = new Uint8ClampedArray(h * 4); + var stride = w * 4; + var windowLength = (blurY * 2) + 1; + for (var x = 0; x < w; x++) { + var pColumnStart = x * 4; + var rs = 0, gs = 0, bs = 0, as = 0, alpha = 0, alpha2 = 0; + // Fill window + for (var ptr = -blurY * stride, end = blurY * stride + stride; ptr < end; ptr += stride) { + var key = pColumnStart + ptr; + if(key < pColumnStart || key >= pColumnStart + h * stride) { + continue; + } + alpha = buffer[key + 3]; + rs += buffer[key + 0] * alpha; + gs += buffer[key + 1] * alpha; + bs += buffer[key + 2] * alpha; + as += alpha; + } + // Slide window + for (var ptr = pColumnStart, end = pColumnStart + h * stride, columnPtr = 0, lastPtr = pColumnStart - blurY * stride, nextPtr = pColumnStart + ((blurY + 1) * stride); ptr < end; ptr += stride, columnPtr += 4, nextPtr += stride, lastPtr += stride) { + columnBuffer[columnPtr + 0] = rs / as; + columnBuffer[columnPtr + 1] = gs / as; + columnBuffer[columnPtr + 2] = bs / as; + columnBuffer[columnPtr + 3] = as / windowLength; + alpha = buffer[nextPtr + 3]; + alpha2 = buffer[lastPtr + 3]; + + if(alpha || alpha == 0) { + if(alpha2 || alpha2 == 0) { + rs += buffer[nextPtr + 0] * alpha - buffer[lastPtr + 0] * alpha2; + gs += buffer[nextPtr + 1] * alpha - buffer[lastPtr + 1] * alpha2; + bs += buffer[nextPtr + 2] * alpha - buffer[lastPtr + 2] * alpha2; + as += alpha - alpha2; + } else { + rs += buffer[nextPtr + 0] * alpha; + gs += buffer[nextPtr + 1] * alpha; + bs += buffer[nextPtr + 2] * alpha; + as += alpha; + } + } else { + if(alpha2 || alpha2 == 0) { + rs += - buffer[lastPtr + 0] * alpha2; + gs += - buffer[lastPtr + 1] * alpha2; + bs += - buffer[lastPtr + 2] * alpha2; + as += - alpha2; + } else { + // do nothing + } + } + } + // Copy column + for (var i = x * 4, end = i + h * stride, j = 0; i < end; i += stride, j += 4) { + buffer[i + 0] = columnBuffer[j + 0]; + buffer[i + 1] = columnBuffer[j + 1]; + buffer[i + 2] = columnBuffer[j + 2]; + buffer[i + 3] = columnBuffer[j + 3]; + } + } + } + + function glowFilter(buffer, w, h, color, blurX, blurY, strength) { + dropShadowFilter(buffer, w, h, color, blurX, blurY, 0, 0, strength) + } + + function dropShadowFilter(buffer, w, h, color, blurX, blurY, angle, distance, strength) { + var tmp = alphaFilter(buffer, color); + panFilter(tmp, w, h, angle, distance); + blurFilter(tmp, w, h, blurX, blurY); + scaleAlphaChannel(tmp, strength); + compositeSourceOver(tmp, buffer); + buffer.set(tmp); + } + + function alphaFilter(buffer, color) { + if (!color) { + color = [0, 0, 0, 0]; + } + var plane = new Uint8ClampedArray(buffer); + for (var ptr = 0, end = plane.length; ptr < end; ptr += 4) { + var alpha = plane[ptr + 3]; + plane[ptr + 0] = color[0] * alpha; + plane[ptr + 1] = color[1] * alpha; + plane[ptr + 2] = color[2] * alpha; + } + return plane; + } + + function panFilter(buffer, w, h, angle, distance) { + var dy = (Math.sin(angle) * distance) | 0; + var dx = (Math.cos(angle) * distance) | 0; + var oldBuffer = new Int32Array(buffer.buffer); + var newBuffer = new Int32Array(oldBuffer.length); + for (var oy = 0; oy < h; oy++) { + var ny = oy + dy; + if (ny < 0 || ny > h) { + continue; + } + for (var ox = 0; ox < w; ox++) { + var nx = ox + dx; + if (nx < 0 || nx > w) { + continue; + } + newBuffer[ny * w + nx] = oldBuffer[oy * w + ox]; + } + } + oldBuffer.set(newBuffer); + } + + function scaleAlphaChannel(buffer, value) { + for (var ptr = 0, end = buffer.length; ptr < end; ptr += 4) { + buffer[ptr + 3] *= value; + } + } + + function compositeSourceOver(dst, src) { + for (var ptr = 0, end = dst.length; ptr < end; ptr += 4) { + var Dr = dst[ptr + 0]; + var Dg = dst[ptr + 1]; + var Db = dst[ptr + 2]; + var Da = dst[ptr + 3] / 255; + + var Sr = src[ptr + 0]; + var Sg = src[ptr + 1]; + var Sb = src[ptr + 2]; + var Sa = src[ptr + 3] / 255; + + dst[ptr + 0] = Sr + Dr * (1 - Sa); + dst[ptr + 1] = Sg + Dg * (1 - Sa); + dst[ptr + 2] = Sb + Db * (1 - Sa); + dst[ptr + 3] = (Sa + Da * (1 - Sa)) * 255; + } + } + + } diff --git a/src/egret/utils/Timer.ts b/src/egret/utils/Timer.ts index cb189c49b2..0d797d5817 100644 --- a/src/egret/utils/Timer.ts +++ b/src/egret/utils/Timer.ts @@ -203,6 +203,7 @@ module egret { if(this._running) return; this.lastCount = this.updateInterval; + this.lastTimeStamp = getTimer(); sys.$ticker.$startTick(this.$update,this); this._running = true; } @@ -235,23 +236,34 @@ module egret { * @private */ private lastCount:number = 1000; + /** + * @private + */ + private lastTimeStamp:number = 0; /** * @private * Ticker以60FPS频率刷新此方法 */ $update(timeStamp:number):boolean { - this.lastCount -= 1000; - if(this.lastCount>0){ - return false; + let deltaTime = timeStamp - this.lastTimeStamp; + if (deltaTime >= this._delay) { + this.lastCount = this.updateInterval; + } + else { + this.lastCount -= 1000; + if (this.lastCount > 0) { + return false; + } + this.lastCount += this.updateInterval; } - this.lastCount += this.updateInterval; + this.lastTimeStamp = timeStamp; this._currentCount++; - var complete = (this.repeatCount > 0 && this._currentCount >= this.repeatCount); - TimerEvent.dispatchTimerEvent(this,TimerEvent.TIMER); + let complete = (this.repeatCount > 0 && this._currentCount >= this.repeatCount); + TimerEvent.dispatchTimerEvent(this, TimerEvent.TIMER); if (complete) { this.stop(); - TimerEvent.dispatchTimerEvent(this,TimerEvent.TIMER_COMPLETE); + TimerEvent.dispatchTimerEvent(this, TimerEvent.TIMER_COMPLETE); } return false; } diff --git a/src/extension/eui/components/BitmapLabel.ts b/src/extension/eui/components/BitmapLabel.ts index 091f356323..f41baf553a 100644 --- a/src/extension/eui/components/BitmapLabel.ts +++ b/src/extension/eui/components/BitmapLabel.ts @@ -256,7 +256,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public left: number; + public left: number|string; /** * @copy eui.UIComponent#right @@ -265,7 +265,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public right: number; + public right: number|string; /** * @copy eui.UIComponent#top @@ -274,7 +274,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public top: number; + public top: number|string; /** * @copy eui.UIComponent#bottom @@ -283,7 +283,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public bottom: number; + public bottom: number|string; /** * @copy eui.UIComponent#horizontalCenter @@ -292,7 +292,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public horizontalCenter: number; + public horizontalCenter: number|string; /** * @copy eui.UIComponent#verticalCenter @@ -301,7 +301,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public verticalCenter: number; + public verticalCenter: number|string; /** * @copy eui.UIComponent#percentWidth diff --git a/src/extension/eui/components/Component.ts b/src/extension/eui/components/Component.ts index 63f281553b..6e16e74e4b 100644 --- a/src/extension/eui/components/Component.ts +++ b/src/extension/eui/components/Component.ts @@ -776,7 +776,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public left:number; + public left:number|string; /** * @inheritDoc @@ -785,7 +785,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public right:number; + public right:number|string; /** * @inheritDoc @@ -794,7 +794,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public top:number; + public top:number|string; /** * @inheritDoc @@ -803,7 +803,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public bottom:number; + public bottom:number|string; /** * @inheritDoc @@ -812,7 +812,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public horizontalCenter:number; + public horizontalCenter:number|string; /** * @inheritDoc @@ -821,7 +821,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public verticalCenter:number; + public verticalCenter:number|string; /** * @inheritDoc diff --git a/src/extension/eui/components/EditableText.ts b/src/extension/eui/components/EditableText.ts index a404983691..377e15d3c0 100644 --- a/src/extension/eui/components/EditableText.ts +++ b/src/extension/eui/components/EditableText.ts @@ -413,7 +413,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public left: number; + public left: number|string; /** * @inheritDoc @@ -422,7 +422,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public right: number; + public right: number|string; /** * @inheritDoc @@ -431,7 +431,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public top: number; + public top: number|string; /** * @inheritDoc @@ -440,7 +440,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public bottom: number; + public bottom: number|string; /** * @inheritDoc @@ -449,7 +449,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public horizontalCenter: number; + public horizontalCenter: number|string; /** * @inheritDoc @@ -458,7 +458,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public verticalCenter: number; + public verticalCenter: number|string; /** * @inheritDoc diff --git a/src/extension/eui/components/Group.ts b/src/extension/eui/components/Group.ts index 0ff8a05c26..dc335050cd 100755 --- a/src/extension/eui/components/Group.ts +++ b/src/extension/eui/components/Group.ts @@ -659,7 +659,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public left:number; + public left:number|string; /** * @inheritDoc @@ -668,7 +668,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public right:number; + public right:number|string; /** * @inheritDoc @@ -677,7 +677,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public top:number; + public top:number|string; /** * @inheritDoc @@ -686,7 +686,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public bottom:number; + public bottom:number|string; /** * @inheritDoc @@ -695,7 +695,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public horizontalCenter:number; + public horizontalCenter:number|string; /** * @inheritDoc @@ -704,7 +704,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public verticalCenter:number; + public verticalCenter:number|string; /** * @inheritDoc diff --git a/src/extension/eui/components/Image.ts b/src/extension/eui/components/Image.ts index 4db0aaaae8..874d47bf77 100644 --- a/src/extension/eui/components/Image.ts +++ b/src/extension/eui/components/Image.ts @@ -423,7 +423,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public left:number; + public left:number|string; /** * @copy eui.UIComponent#right @@ -432,7 +432,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public right:number; + public right:number|string; /** * @copy eui.UIComponent#top @@ -441,7 +441,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public top:number; + public top:number|string; /** * @copy eui.UIComponent#bottom @@ -450,7 +450,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public bottom:number; + public bottom:number|string; /** * @copy eui.UIComponent#horizontalCenter @@ -459,7 +459,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public horizontalCenter:number; + public horizontalCenter:number|string; /** * @copy eui.UIComponent#verticalCenter @@ -468,7 +468,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public verticalCenter:number; + public verticalCenter:number|string; /** * @copy eui.UIComponent#percentWidth diff --git a/src/extension/eui/components/Label.ts b/src/extension/eui/components/Label.ts index 2201bdebab..8031e94798 100644 --- a/src/extension/eui/components/Label.ts +++ b/src/extension/eui/components/Label.ts @@ -266,7 +266,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public left:number; + public left:number|string; /** * @copy eui.UIComponent#right @@ -275,7 +275,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public right:number; + public right:number|string; /** * @copy eui.UIComponent#top @@ -284,7 +284,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public top:number; + public top:number|string; /** * @copy eui.UIComponent#bottom @@ -293,7 +293,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public bottom:number; + public bottom:number|string; /** * @copy eui.UIComponent#horizontalCenter @@ -302,7 +302,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public horizontalCenter:number; + public horizontalCenter:number|string; /** * @copy eui.UIComponent#verticalCenter @@ -311,7 +311,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public verticalCenter:number; + public verticalCenter:number|string; /** * @copy eui.UIComponent#percentWidth diff --git a/src/extension/eui/components/Rect.ts b/src/extension/eui/components/Rect.ts index ab4167894e..0b955aca2b 100644 --- a/src/extension/eui/components/Rect.ts +++ b/src/extension/eui/components/Rect.ts @@ -43,7 +43,7 @@ module eui { * @platform Web,Native */ export class Rect extends Component { - constructor(width?: number, height?: number, fillColor?: number) { + constructor(width?:number, height?:number, fillColor?:number) { super(); this.touchChildren = false; this.$graphics = new egret.Graphics(); @@ -52,24 +52,26 @@ module eui { this.height = height; this.fillColor = fillColor; } + /** * @private */ - $graphics: egret.Graphics; + $graphics:egret.Graphics; - public get graphics(): egret.Graphics { + public get graphics():egret.Graphics { return this.$graphics; } + /** * @private */ - $measureContentBounds(bounds: egret.Rectangle): void { + $measureContentBounds(bounds:egret.Rectangle):void { if (this.$graphics) { bounds.setTo(0, 0, this.width, this.height); } } - private $fillColor: number = 0x000000; + private $fillColor:number = 0x000000; /** * @language en_US * Fill color @@ -84,18 +86,18 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public get fillColor(): number { + public get fillColor():number { return this.$fillColor; } - public set fillColor(value: number) { + public set fillColor(value:number) { if (value == undefined || this.$fillColor == value) return; this.$fillColor = value; this.invalidateDisplayList(); } - private $fillAlpha: number = 1; + private $fillAlpha:number = 1; /** * @language en_US * Fill alpha @@ -110,18 +112,18 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public get fillAlpha(): number { + public get fillAlpha():number { return this.$fillAlpha; } - public set fillAlpha(value: number) { + public set fillAlpha(value:number) { if (this.$fillAlpha == value) return; this.$fillAlpha = value; this.invalidateDisplayList(); } - private $strokeColor: number = 0x444444; + private $strokeColor:number = 0x444444; /** * @language en_US * The line's color inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn @@ -136,17 +138,18 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public get strokeColor(): number { + public get strokeColor():number { return this.$strokeColor; } - public set strokeColor(value: number) { + public set strokeColor(value:number) { if (this.$strokeColor == value) return; this.$strokeColor = value; this.invalidateDisplayList(); } - private $strokeAlpha: number = 1; + + private $strokeAlpha:number = 1; /** * @language en_US * The line's alpha inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn @@ -161,18 +164,18 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public get strokeAlpha(): number { + public get strokeAlpha():number { return this.$strokeAlpha; } - public set strokeAlpha(value: number) { + public set strokeAlpha(value:number) { if (this.$strokeAlpha == value) return; this.$strokeAlpha = value; this.invalidateDisplayList(); } - private $strokeWeight: number = 0; + private $strokeWeight:number = 0; /** * @language en_US * The line's thickness inside the rect border. Caution: when the strokeWeight is 0, a line is not drawn @@ -187,18 +190,18 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public get strokeWeight(): number { + public get strokeWeight():number { return this.$strokeWeight; } - public set strokeWeight(value: number) { + public set strokeWeight(value:number) { if (this.$strokeWeight == value) return; this.$strokeWeight = value; this.invalidateDisplayList(); } - private $ellipseWidth: number = 0; + private $ellipseWidth:number = 0; /** * @language en_US * Width used to draw an ellipse with rounded corners (in pixels). @@ -213,17 +216,18 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public get ellipseWidth(): number { + public get ellipseWidth():number { return this.$ellipseWidth; } - public set ellipseWidth(value: number) { + + public set ellipseWidth(value:number) { if (this.$ellipseWidth == value) return; this.$ellipseWidth = value; this.invalidateDisplayList(); } - private $ellipseHeight: number = 0; + private $ellipseHeight:number = 0; /** * @language en_US * Height used to draw an ellipse with rounded corners (in pixels). If no value is specified, the default value matches the value of the ellipseWidth parameter. @@ -238,15 +242,17 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - public get ellipseHeight(): number { + public get ellipseHeight():number { return this.$ellipseHeight; } - public set ellipseHeight(value: number) { + + public set ellipseHeight(value:number) { if (this.$ellipseHeight == value) return; this.$ellipseHeight = value; this.invalidateDisplayList(); } + /** * @copy eui.UIComponent#updateDisplayList * @@ -254,25 +260,25 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - protected updateDisplayList(unscaledWidth: number, unscaledHeight: number): void { + protected updateDisplayList(unscaledWidth:number, unscaledHeight:number):void { var g = this.graphics; g.clear(); if (this.$strokeWeight > 0) { g.beginFill(this.$fillColor, 0); g.lineStyle(this.$strokeWeight, this.$strokeColor, this.$strokeAlpha, true, "normal", "square", "miter"); - if (this.$ellipseWidth == 0) { + if (this.$ellipseWidth == 0 && this.$ellipseHeight == 0) { g.drawRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight); } else { - g.drawRoundRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight, this.$ellipseWidth, 0); + g.drawRoundRect(this.$strokeWeight / 2, this.$strokeWeight / 2, unscaledWidth - this.$strokeWeight, unscaledHeight - this.$strokeWeight, this.$ellipseWidth, this.$ellipseHeight); } g.endFill(); } g.beginFill(this.$fillColor, this.$fillAlpha); g.lineStyle(this.$strokeWeight, this.$strokeColor, 0, true, "normal", "square", "miter"); - if (this.$ellipseWidth == 0) { + if (this.$ellipseWidth == 0 && this.$ellipseHeight == 0) { g.drawRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2); } else { - g.drawRoundRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2, this.$ellipseWidth, 0); + g.drawRoundRect(this.$strokeWeight, this.$strokeWeight, unscaledWidth - this.$strokeWeight * 2, unscaledHeight - this.$strokeWeight * 2, this.$ellipseWidth, this.$ellipseHeight); } g.endFill(); this.$invalidateContentBounds(); diff --git a/src/extension/eui/components/supportClasses/TouchScroll.ts b/src/extension/eui/components/supportClasses/TouchScroll.ts index b7d6a1f526..9c1bb0c643 100644 --- a/src/extension/eui/components/supportClasses/TouchScroll.ts +++ b/src/extension/eui/components/supportClasses/TouchScroll.ts @@ -188,6 +188,7 @@ module eui.sys { public isStarted():boolean { return this.started; } + /** * @private * 开始记录位移变化。注意:当使用完毕后,必须调用 finish() 方法结束记录,否则该对象将无法被回收。 @@ -208,7 +209,7 @@ module eui.sys { * 更新当前移动到的位置 * @param touchPoint 当前触摸位置,以像素为单位,通常是stageX或stageY。 */ - public update(touchPoint:number, maxScrollValue:number,scrollValue):void { + public update(touchPoint:number, maxScrollValue:number, scrollValue):void { maxScrollValue = Math.max(maxScrollValue, 0); this.currentPosition = touchPoint; this.maxScrollPos = maxScrollValue; @@ -216,19 +217,19 @@ module eui.sys { var scrollPos = disMove + scrollValue; this.offsetPoint = touchPoint; if (scrollPos < 0) { - if(!this.$bounces) { + if (!this.$bounces) { scrollPos = 0; } else { - scrollPos -= disMove*0.5; + scrollPos -= disMove * 0.5; } } if (scrollPos > maxScrollValue) { - if(!this.$bounces) { + if (!this.$bounces) { scrollPos = maxScrollValue; } else { - scrollPos -= disMove*0.5; + scrollPos -= disMove * 0.5; } } this.currentScrollPos = scrollPos; @@ -286,11 +287,11 @@ module eui.sys { } if (duration > 0) { //如果取消了回弹,保证动画之后不会超出边界 - if(!this.$bounces) { - if(posTo < 0) { + if (!this.$bounces) { + if (posTo < 0) { posTo = 0; } - else if(posTo > maxScrollPos) { + else if (posTo > maxScrollPos) { posTo = maxScrollPos; } } @@ -321,7 +322,6 @@ module eui.sys { } return true; } - /** * @private * @@ -334,7 +334,7 @@ module eui.sys { if (hsp < 0) { hspTo = 0; } - if (maxHsp && hsp > maxHsp) { + if (hsp > maxHsp) { hspTo = maxHsp; } this.throwTo(hspTo, 300); diff --git a/src/extension/eui/core/UIComponent.ts b/src/extension/eui/core/UIComponent.ts index 9e260a064d..514f4064d6 100644 --- a/src/extension/eui/core/UIComponent.ts +++ b/src/extension/eui/core/UIComponent.ts @@ -149,7 +149,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - left:number; + left:number|string; /** * @language en_US @@ -172,7 +172,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - right:number; + right:number|string; /** * @language en_US @@ -195,7 +195,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - top:number; + top:number|string; /** * @language en_US @@ -218,7 +218,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - bottom:number; + bottom:number|string; /** * @language en_US @@ -241,7 +241,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - horizontalCenter:number; + horizontalCenter:number|string; /** * @language en_US @@ -264,7 +264,7 @@ module eui { * @version eui 1.0 * @platform Web,Native */ - verticalCenter:number; + verticalCenter:number|string; /** * @language en_US @@ -880,7 +880,7 @@ module eui.sys { this.$includeInLayout = true; //if egret this.$touchEnabled = true; - //endif*/ + //endif*/ } @@ -997,12 +997,18 @@ module eui.sys { * @private * 距父级容器离左边距离 */ - public get left():number { + public get left():number|string { return this.$UIComponent[UIKeys.left]; } - public set left(value:number) { - value = +value; + public set left(value:number|string) { + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } + var values = this.$UIComponent; if (values[UIKeys.left] === value) return; @@ -1014,12 +1020,17 @@ module eui.sys { * @private * 距父级容器右边距离 */ - public get right():number { + public get right():number|string { return this.$UIComponent[UIKeys.right]; } - public set right(value:number) { - value = +value; + public set right(value:number|string) { + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[UIKeys.right] === value) return; @@ -1031,12 +1042,17 @@ module eui.sys { * @private * 距父级容器顶部距离 */ - public get top():number { + public get top():number|string { return this.$UIComponent[UIKeys.top]; } - public set top(value:number) { - value = +value; + public set top(value:number|string) { + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[UIKeys.top] === value) return; @@ -1048,12 +1064,17 @@ module eui.sys { * @private * 距父级容器底部距离 */ - public get bottom():number { + public get bottom():number|string { return this.$UIComponent[UIKeys.bottom]; } - public set bottom(value:number) { - value = +value; + public set bottom(value:number|string) { + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[UIKeys.bottom] == value) return; @@ -1066,12 +1087,17 @@ module eui.sys { * @private * 在父级容器中距水平中心位置的距离 */ - public get horizontalCenter():number { + public get horizontalCenter():number|string { return this.$UIComponent[UIKeys.horizontalCenter]; } - public set horizontalCenter(value:number) { - value = +value; + public set horizontalCenter(value:number|string) { + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[UIKeys.horizontalCenter] === value) return; @@ -1083,12 +1109,17 @@ module eui.sys { * @private * 在父级容器中距竖直中心位置的距离 */ - public get verticalCenter():number { + public get verticalCenter():number|string { return this.$UIComponent[UIKeys.verticalCenter]; } - public set verticalCenter(value:number) { - value = +value; + public set verticalCenter(value:number|string) { + if (!value || typeof value == "number") { + value = +value; + } + else { + value = value.toString().trim(); + } var values = this.$UIComponent; if (values[UIKeys.verticalCenter] === value) return; @@ -1214,34 +1245,6 @@ module eui.sys { return true; } - /** - * @private - * - * @param value - * @returns - */ - $setScaleX(value:number):boolean { - var change = this.$super.$setScaleX.call(this, value); - if (change) { - this.invalidateParentLayout(); - } - return change; - } - - /** - * @private - * - * @param value - * @returns - */ - $setScaleY(value:number):boolean { - var change = this.$super.$setScaleY.call(this, value); - if (change) { - this.invalidateParentLayout(); - } - return change; - } - /** * @private * 组件的最小宽度,此属性设置为大于maxWidth的值时无效。同时影响测量和自动布局的尺寸。 @@ -1354,6 +1357,38 @@ module eui.sys { } } + /** + * @private + */ + $invalidateMatrix():void { + this.$super.$invalidateMatrix.call(this); + this.invalidateParentLayout(); + } + /** + * @private + */ + $setMatrix(matrix: egret.Matrix, needUpdateProperties: boolean = true): boolean { + this.$super.$setMatrix.call(this,matrix,needUpdateProperties); + this.invalidateParentLayout(); + return true; + } + /** + * @private + */ + $setAnchorOffsetX(value: number): boolean { + this.$super.$setAnchorOffsetX.call(this,value); + this.invalidateParentLayout(); + return true; + } + /** + * @private + */ + $setAnchorOffsetY(value: number): boolean { + this.$super.$setAnchorOffsetY.call(this,value); + this.invalidateParentLayout(); + return true; + } + /** * @private * @@ -1363,7 +1398,6 @@ module eui.sys { $setX(value:number):boolean { var change = this.$super.$setX.call(this, value); if (change) { - this.invalidateParentLayout(); this.invalidateProperties(); } return change; @@ -1378,7 +1412,6 @@ module eui.sys { $setY(value:number):boolean { var change = this.$super.$setY.call(this, value); if (change) { - this.invalidateParentLayout(); this.invalidateProperties(); } return change; @@ -1596,7 +1629,7 @@ module eui.sys { values[sys.UIKeys.layoutHeightExplicitlySet] = true; height = Math.max(minHeight, Math.min(maxHeight, layoutHeight)); } - var matrix = this.$getMatrix(); + var matrix = this.getAnchorMatrix(); if (isDeltaIdentity(matrix)) { this.setActualSize(width, height); return; @@ -1619,7 +1652,7 @@ module eui.sys { */ public setLayoutBoundsPosition(x:number, y:number):void { var matrix = this.$getMatrix(); - if (!isDeltaIdentity(matrix)) { + if (!isDeltaIdentity(matrix) || this.anchorOffsetX != 0 || this.anchorOffsetY != 0) { var bounds = egret.$TempRectangle; this.getLayoutBounds(bounds); x += this.$getX() - bounds.x; @@ -1707,7 +1740,8 @@ module eui.sys { */ private applyMatrix(bounds:egret.Rectangle, w:number, h:number):void { var bounds = bounds.setTo(0, 0, w, h); - var matrix = this.$getMatrix(); + var matrix = this.getAnchorMatrix(); + if (isDeltaIdentity(matrix)) { bounds.x += matrix.tx; bounds.y += matrix.ty; @@ -1716,6 +1750,22 @@ module eui.sys { matrix.$transformBounds(bounds); } } + + + /** + * @private + */ + private getAnchorMatrix():egret.Matrix { + var matrix = this.$getMatrix(); + var offsetX = this.anchorOffsetX; + var offsetY = this.anchorOffsetY; + if (offsetX != 0 || offsetY != 0) { + var tempM = egret.$TempMatrix; + matrix.$preMultiplyInto(tempM.setTo(1, 0, 0, 1, -offsetX, -offsetY), tempM); + return tempM; + } + return matrix; + } } /** @@ -1775,6 +1825,12 @@ module eui.sys { var prototype = descendant.prototype; prototype.$super = base.prototype; + registerProperty(descendant, "left", "any"); + registerProperty(descendant, "right", "any"); + registerProperty(descendant, "top", "any"); + registerProperty(descendant, "bottom", "any"); + registerProperty(descendant, "horizontalCenter", "any"); + registerProperty(descendant, "verticalCenter", "any"); if (isContainer) { prototype.$childAdded = function (child:egret.DisplayObject, index:number):void { this.invalidateSize(); diff --git a/src/extension/eui/exml/CodeFactory.ts b/src/extension/eui/exml/CodeFactory.ts index c67068981f..65531c7199 100644 --- a/src/extension/eui/exml/CodeFactory.ts +++ b/src/extension/eui/exml/CodeFactory.ts @@ -679,6 +679,11 @@ module eui.sys { */ public constructor(target:string, property:string, templates:string[], chainIndex:number[]) { super(); + if (target) { + target = "this." + target; + } else { + target = "this"; + } this.target = target; this.property = property; this.templates = templates; diff --git a/src/extension/eui/exml/EXMLParser.ts b/src/extension/eui/exml/EXMLParser.ts index 00e2de3167..f05a95489f 100644 --- a/src/extension/eui/exml/EXMLParser.ts +++ b/src/extension/eui/exml/EXMLParser.ts @@ -381,6 +381,9 @@ module eui.sys { else if (node.nodeType === 1) { var id = node.attributes["id"]; if (id) { + if (id.indexOf(" ") > -1) { + egret.$warn(2022, id); + } if (this.skinParts.indexOf(id) == -1) { this.skinParts.push(id); } diff --git a/src/extension/eui/i18n/en_US.ts b/src/extension/eui/i18n/en_US.ts index 2aae524617..0e40f30668 100644 --- a/src/extension/eui/i18n/en_US.ts +++ b/src/extension/eui/i18n/en_US.ts @@ -54,6 +54,7 @@ module eui { locale_strings[2019] = "EXML parsing error {0}: the container’s child item must be visible nodes: {1}"; locale_strings[2020] = "EXML parsing error {0}: for child nodes in w: Declarations, the includeIn and excludeFrom properties are not allowed to use \n {1}"; locale_strings[2021] = "Compile errors in {0}, the attribute name: {1}, the attribute value: {2}."; + locale_strings[2022] = "EXML parsing error: there can be no Spaces in the id `{0}`"; locale_strings[2101] = "EXML parsing warnning : fail to register the class property : {0},there is already a class with the same name in the global,please try to rename the class name for the exml. \n {1}"; locale_strings[2102] = "EXML parsing warnning {0}: no child node can be found on the property code \n {1}"; diff --git a/src/extension/eui/i18n/zh_CN.ts b/src/extension/eui/i18n/zh_CN.ts index ad8531db99..134354d129 100644 --- a/src/extension/eui/i18n/zh_CN.ts +++ b/src/extension/eui/i18n/zh_CN.ts @@ -56,6 +56,7 @@ module eui { locale_strings[2019] = "EXML解析错误 {0}: 容器的子项必须是可视节点:{1}"; locale_strings[2020] = "EXML解析错误 {0}: 在w:Declarations内的子节点,不允许使用includeIn和excludeFrom属性\n{1}"; locale_strings[2021] = "{0} 中存在编译错误,属性名 : {1},属性值 : {2}"; + locale_strings[2022] = "EXML解析错误: id `{0}` 中不可以有空格"; //EXML警告信息 locale_strings[2101] = "EXML解析警告: 在EXML根节点上声明的 class 属性: {0} 注册失败,所对应的类已经存在,请尝试重命名要注册的类名。\n{1}"; diff --git a/src/extension/eui/layouts/BasicLayout.ts b/src/extension/eui/layouts/BasicLayout.ts index 81a2c597a0..721e0a32c2 100644 --- a/src/extension/eui/layouts/BasicLayout.ts +++ b/src/extension/eui/layouts/BasicLayout.ts @@ -115,7 +115,7 @@ module eui { public updateDisplayList(unscaledWidth:number, unscaledHeight:number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); var target = this.$target; - var pos = sys.updateDisplayList(target,unscaledWidth,unscaledHeight); + var pos = sys.updateDisplayList(target, unscaledWidth, unscaledHeight); target.setContentSize(Math.ceil(pos.x), Math.ceil(pos.y)); } } @@ -141,12 +141,30 @@ module eui.sys { var UIComponentClass = "eui.UIComponent"; + /** + * @private + * @param value 要格式化的相对值 + * @param total 在此值方向上的总长度 + */ + function formatRelative(value:number|string, total:number):number { + if (!value || typeof value == "number") { + return value; + } + var str = value; + var index = str.indexOf("%"); + if (index == -1) { + return +str; + } + var percent = +str.substring(0, index); + return percent * 0.01 * total; + } + /** * @private * 一个工具方法,使用BasicLayout规则测量目标对象。 */ - export function measure(target:eui.Group|eui.Component):void{ - if(!target){ + export function measure(target:eui.Group|eui.Component):void { + if (!target) { return; } var width = 0; @@ -155,17 +173,17 @@ module eui.sys { var count = target.numChildren; for (var i = 0; i < count; i++) { var layoutElement = (target.getChildAt(i)); - if (!egret.is(layoutElement,UIComponentClass) || !layoutElement.$includeInLayout) { + if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { continue; } var values = layoutElement.$UIComponent; - var hCenter = values[sys.UIKeys.horizontalCenter]; - var vCenter = values[sys.UIKeys.verticalCenter]; - var left = values[sys.UIKeys.left]; - var right = values[sys.UIKeys.right]; - var top = values[sys.UIKeys.top]; - var bottom = values[sys.UIKeys.bottom]; + var hCenter = +values[sys.UIKeys.horizontalCenter]; + var vCenter = +values[sys.UIKeys.verticalCenter]; + var left = +values[sys.UIKeys.left]; + var right = +values[sys.UIKeys.right]; + var top = +values[sys.UIKeys.top]; + var bottom = +values[sys.UIKeys.bottom]; var extX:number; var extY:number; @@ -206,7 +224,7 @@ module eui.sys { height = Math.ceil(Math.max(height, extY + preferredHeight)); } - target.setMeasuredSize(width,height); + target.setMeasuredSize(width, height); } /** @@ -214,7 +232,7 @@ module eui.sys { * 一个工具方法,使用BasicLayout规则布局目标对象。 */ export function updateDisplayList(target:eui.Group|eui.Component, - unscaledWidth:number, unscaledHeight:number):egret.Point{ + unscaledWidth:number, unscaledHeight:number):egret.Point { if (!target) return; @@ -225,17 +243,17 @@ module eui.sys { var bounds = egret.$TempRectangle; for (var i = 0; i < count; i++) { var layoutElement = (target.getChildAt(i)); - if (!egret.is(layoutElement,UIComponentClass) || !layoutElement.$includeInLayout) { + if (!egret.is(layoutElement, UIComponentClass) || !layoutElement.$includeInLayout) { continue; } var values = layoutElement.$UIComponent; - var hCenter = values[sys.UIKeys.horizontalCenter]; - var vCenter = values[sys.UIKeys.verticalCenter]; - var left = values[sys.UIKeys.left]; - var right = values[sys.UIKeys.right]; - var top = values[sys.UIKeys.top]; - var bottom = values[sys.UIKeys.bottom]; + var hCenter = formatRelative(values[sys.UIKeys.horizontalCenter], unscaledWidth*0.5); + var vCenter = formatRelative(values[sys.UIKeys.verticalCenter], unscaledHeight*0.5); + var left = formatRelative(values[sys.UIKeys.left], unscaledWidth); + var right = formatRelative(values[sys.UIKeys.right], unscaledWidth); + var top = formatRelative(values[sys.UIKeys.top], unscaledHeight); + var bottom = formatRelative(values[sys.UIKeys.bottom], unscaledHeight); var percentWidth = values[sys.UIKeys.percentWidth]; var percentHeight = values[sys.UIKeys.percentHeight]; @@ -288,6 +306,6 @@ module eui.sys { maxX = Math.max(maxX, childX + elementWidth); maxY = Math.max(maxY, childY + elementHeight); } - return egret.$TempPoint.setTo(maxX,maxY); + return egret.$TempPoint.setTo(maxX, maxY); } } \ No newline at end of file diff --git a/src/extension/socket/WebSocket.ts b/src/extension/socket/WebSocket.ts index 9131187c91..a492fcff28 100755 --- a/src/extension/socket/WebSocket.ts +++ b/src/extension/socket/WebSocket.ts @@ -281,12 +281,12 @@ module egret { } this.flush(); - return; - if (this._isReadySend) { - return; - } - this._isReadySend = true; - egret.callLater(this.flush, this); + // return; + // if (this._isReadySend) { + // return; + // } + // this._isReadySend = true; + // egret.callLater(this.flush, this); } /** diff --git a/tools/actions/CompileLark.js b/tools/actions/CompileLark.js index a6dde054d3..548dda2e3e 100644 --- a/tools/actions/CompileLark.js +++ b/tools/actions/CompileLark.js @@ -69,6 +69,9 @@ var CompileLark = (function () { var declareFile = this.getModuleOutputPath(m.name, fileName + ".d.ts", m.outFile); var singleFile = this.getModuleOutputPath(m.name, fileName + ".js", m.outFile); var moduleRoot = FileUtil.joinPath(larkRoot, m.root); + if(!m.root){ + return 0; + } var tss = []; m.files.forEach(function (file) { var path = null; diff --git a/tools/actions/CompileLark.ts b/tools/actions/CompileLark.ts index ad88d82867..8d52a4924b 100644 --- a/tools/actions/CompileLark.ts +++ b/tools/actions/CompileLark.ts @@ -78,6 +78,9 @@ class CompileLark { var declareFile = this.getModuleOutputPath(m.name, fileName + ".d.ts", m.outFile); var singleFile = this.getModuleOutputPath(m.name, fileName + ".js", m.outFile); var moduleRoot = FileUtil.joinPath(larkRoot, m.root); + if(!m.root){ + return 0; + } var tss: string[] = []; m.files.forEach(file => { var path: string = null; diff --git a/tools/actions/Project.js b/tools/actions/Project.js index c2f3d16a98..c8c2bbf247 100644 --- a/tools/actions/Project.js +++ b/tools/actions/Project.js @@ -7,8 +7,8 @@ function normalize(project) { project.scaleMode = project.scaleMode || "showAll"; project.orientationMode = project.orientationMode || "auto"; project.frameRate = project.frameRate || 30; - project.contentWidth = project.contentWidth || 480; - project.contentHeight = project.contentHeight || 800; + project.contentWidth = project.contentWidth || 640; + project.contentHeight = project.contentHeight || 1136; project.moduleScripts = project.moduleScripts || []; project.showLog = project.showLog || false; project.logFilter = project.logFilter || ""; diff --git a/tools/actions/Project.ts b/tools/actions/Project.ts index 5751dfb8f1..c89e257790 100644 --- a/tools/actions/Project.ts +++ b/tools/actions/Project.ts @@ -12,8 +12,8 @@ export function normalize(project: egret.ILarkProject) { project.scaleMode = project.scaleMode || "showAll"; project.orientationMode = project.orientationMode || "auto"; project.frameRate = project.frameRate || 30; - project.contentWidth = project.contentWidth || 480; - project.contentHeight = project.contentHeight || 800; + project.contentWidth = project.contentWidth || 640; + project.contentHeight = project.contentHeight || 1136; project.moduleScripts = project.moduleScripts || []; project.showLog = project.showLog || false; project.logFilter = project.logFilter || ""; diff --git a/tools/commands/upgrade.js b/tools/commands/upgrade.js index ae453050f0..0140e585d7 100644 --- a/tools/commands/upgrade.js +++ b/tools/commands/upgrade.js @@ -40,7 +40,7 @@ var UpgradeCommand = (function () { //{"v": "2.4.1"}, { "v": "2.5.0", "command": require("./upgrade/UpgradeCommand_2_4_3") }, { "v": "2.5.1", "command": require("./upgrade/UpgradeCommand_2_5_1") }, - { "v": "3.1.5" } + { "v": "3.1.6" } ]; //升级命令是一个异步命令 内含异步控制流程 this.isAsync = true; diff --git a/tools/commands/upgrade.ts b/tools/commands/upgrade.ts index e937180f87..b1673dbde2 100644 --- a/tools/commands/upgrade.ts +++ b/tools/commands/upgrade.ts @@ -139,7 +139,7 @@ class UpgradeCommand implements egret.Command { //{"v": "2.4.1"}, {"v": "2.5.0", "command": require("./upgrade/UpgradeCommand_2_4_3")}, {"v": "2.5.1", "command": require("./upgrade/UpgradeCommand_2_5_1")}, - {"v": "3.1.5"} + {"v": "3.1.6"} ]; } diff --git a/tools/parser/Parser.js b/tools/parser/Parser.js index cb598d3a46..a9621fefe1 100644 --- a/tools/parser/Parser.js +++ b/tools/parser/Parser.js @@ -175,7 +175,8 @@ function parseCommandLine(commandLine) { } } //create_app命令不强制设置projectDir属性 - if (options.command != "create_app") { + if(options.projectDir == null && options.command == "create_app"){ + }else{ if (!options.projectDir) options.projectDir = process.cwd(); else { diff --git a/tools/parser/Parser.ts b/tools/parser/Parser.ts index 0a8291d124..675ca77df4 100644 --- a/tools/parser/Parser.ts +++ b/tools/parser/Parser.ts @@ -204,8 +204,8 @@ export function parseCommandLine(commandLine: string[]) { } //create_app命令不强制设置projectDir属性 - - if (options.command != "create_app") { + if(options.projectDir == null && options.command == "create_app"){ + }else{ if (!options.projectDir) options.projectDir = process.cwd(); else {