* Compliant CommentButton Polyfill For BiliScriptEngine
| 8 | * Compliant CommentButton Polyfill For BiliScriptEngine |
| 9 | */ |
| 10 | class CommentButton extends UIComponent implements IComment { |
| 11 | private _mM:MotionManager = new MotionManager(this); |
| 12 | private _label:string = ""; |
| 13 | |
| 14 | constructor(params:Object) { |
| 15 | super(); |
| 16 | this.setDefaults(params); |
| 17 | this.initStyle(params); |
| 18 | Runtime.registerObject(this); |
| 19 | this.bindParent(params); |
| 20 | this._mM.play(); |
| 21 | } |
| 22 | |
| 23 | get motionManager():MotionManager { |
| 24 | return this._mM; |
| 25 | } |
| 26 | |
| 27 | set motionManager(m:MotionManager) { |
| 28 | __trace("IComment.motionManager is read-only", "warn"); |
| 29 | } |
| 30 | |
| 31 | private bindParent(params:Object):void { |
| 32 | if (params.hasOwnProperty("parent")) { |
| 33 | (<DisplayObject> params["parent"]).addChild(this); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | public initStyle(style:Object):void { |
| 38 | if (typeof style === 'undefined' || style === null) { |
| 39 | style = {}; |
| 40 | } |
| 41 | if ("lifeTime" in style) { |
| 42 | this._mM.dur = style["lifeTime"] * 1000; |
| 43 | } else { |
| 44 | this._mM.dur = 4000; |
| 45 | } |
| 46 | if (style.hasOwnProperty("text")) { |
| 47 | this._label = style["text"]; |
| 48 | } |
| 49 | if (style.hasOwnProperty("motionGroup")) { |
| 50 | this._mM.initTweenGroup(style["motionGroup"], this._mM.dur); |
| 51 | } else if (style.hasOwnProperty("motion")) { |
| 52 | this._mM.initTween(style["motion"], false); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | public serialize():Object { |
| 57 | var serialized:Object = super.serialize(); |
| 58 | serialized["class"] = "Button"; |
| 59 | serialized["text"] = this._label; |
| 60 | return serialized; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | export function createButton(params:Object):any { |
| 65 | return new CommentButton(params); |
nothing calls this directly
no outgoing calls
no test coverage detected