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 __());
};
/**
* @module annieUI
*/
var annieUI;
(function (annieUI) {
/**
* 用滚动的方式播放MC,回弹默认关闭,可开启
* @class annieUI.MCScroller
* @public
* @extends annieUI.Scroller
* @since 3.1.5
*/
var MCScroller = (function (_super) {
__extends(MCScroller, _super);
/**
* 构造函数
* @method MCScroller
* @param {annie.MovieClip} mc 要被滑动的mc
* @param {number} rate mc 灵敏度,值越大滑动越慢,默认为10
* @param {boolean} isVertical 是横向还是竖向滑动,默认是竖向
*/
function MCScroller(mc, rate, isVertical) {
if (rate === void 0) { rate = 10; }
if (isVertical === void 0) { isVertical = true; }
_super.call(this, mc, 0, 0, 0, 0);
this._rate = 0;
this._isVertical = true;
var s = this;
s._instanceType = "annieUI.MCScroller";
s.isBounce = false;
s.rate = rate;
s.isVertical = isVertical;
}
Object.defineProperty(MCScroller.prototype, "rate", {
get: function () {
return this._rate;
},
/**
* 滑动的速率,值越大,滑动越慢,默认是10
* @property rate
* @param {number} value
* @since 3.1.5
* @public
*/
set: function (value) {
var s = this;
var mc = s._container;
if (value != s._rate) {
s._rate = value;
var curFrame = s.curFramePos - 1;
var sw = 0, sh = 0;
if (s._isVertical) {
s._curX = -curFrame * value;
sh = mc.totalFrames * value;
}
else {
s._curY = -curFrame * value;
sw = mc.totalFrames * value;
}
s.setScrollWH(sw, sh);
}
},
enumerable: true,
configurable: true
});
;
Object.defineProperty(MCScroller.prototype, "isVertical", {
/**
* 鼠标滑动的方向,默认纵向
* @property isVertical
* @since 3.1.5
* @public
* @return {boolean}
*/
get: function () {
return this._isVertical;
},
set: function (value) {
var s = this;
if (s._isVertical != value) {
if (!value) {
s._curX = s._curY;
s._scrollWidth = s._scrollHeight;
s._scrollHeight = 0;
}
else {
s._curY = s._curX;
s._scrollHeight = s._scrollWidth;
s._scrollWidth = 0;
}
s._isVertical = value;
s._updateViewAndScroll();
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(MCScroller.prototype, "curFramePos", {
/**
* 只读,获取当前mc的frame具体值,带小数
* @property curFramePos
* @readonly
* @return {number}
*/
get: function () {
var s = this;
var frame = 0;
if (s._isVertical) {
frame = s._curY / s._rate;
}
else {
frame = s._curX / s._rate;
}
return Math.abs(frame) + 1;
},
enumerable: true,
configurable: true
});
MCScroller.prototype.onEnterFrame = function (e) {
var s = this;
var mc = s._container;
if (mc.isPlaying) {
if (s._isVertical) {
s._curY = -mc.currentFrame * s._rate;
}
else {
s._curX = -mc.currentFrame * s._rate;
}
}
_super.prototype.onEnterFrame.call(this, e);
};
MCScroller.prototype._translate = function (x, y) {
_super.prototype._translate.call(this, x, y);
var s = this;
var mc = s._container;
mc.gotoAndStop(s.curFramePos);
};
return MCScroller;
}(annieUI.Scroller));
annieUI.MCScroller = MCScroller;
})(annieUI || (annieUI = {}));