📄 tween.as
字号:
// It's an object _global.$addTween(this, ["__special_blur_x__","__special_blur_y__"], [arguments[0].blurX, arguments[0].blurY], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], {__special_blur_quality__:arguments[0].quality}); } else { // Normal parameters _global.$addTween(this, ["__special_blur_x__","__special_blur_y__"], [arguments[0], arguments[0]], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7], {__special_blur_quality__:arguments[1]}); }};ASSetPropFlags(MovieClip.prototype, "blurTo", 1, 0);ASSetPropFlags(TextField.prototype, "blurTo", 1, 0);MovieClip.prototype.xyBlurTo = TextField.prototype.xyBlurTo = function (propDest_blurX, propDest_blurY, quality, timeSeconds, animType, delay, callback, extra1, extra2) { // Blur with different horizontal/vertical values _global.$addTween(this, ["__special_blur_x__","__special_blur_y__"], [propDest_blurX, propDest_blurY], timeSeconds, animType, delay, callback, extra1, extra2, {__special_blur_quality__:quality});};ASSetPropFlags(MovieClip.prototype, "xyBlurTo", 1, 0);ASSetPropFlags(TextField.prototype, "xyBlurTo", 1, 0);MovieClip.prototype.xBlurTo = TextField.prototype.xBlurTo = function (propDest_blur, quality, timeSeconds, animType, delay, callback, extra1, extra2) { // Horizontal blur _global.$addTween(this, "__special_blur_x__", propDest_blur, timeSeconds, animType, delay, callback, extra1, extra2, {__special_blur_quality__:quality});};ASSetPropFlags(MovieClip.prototype, "xBlurTo", 1, 0);ASSetPropFlags(TextField.prototype, "xBlurTo", 1, 0);MovieClip.prototype.yBlurTo = TextField.prototype.yBlurTo = function (propDest_blur, quality, timeSeconds, animType, delay, callback, extra1, extra2) { // Vertical blur _global.$addTween(this, "__special_blur_y__", propDest_blur, timeSeconds, animType, delay, callback, extra1, extra2, {__special_blur_quality__:quality});};ASSetPropFlags(MovieClip.prototype, "yBlurTo", 1, 0);ASSetPropFlags(TextField.prototype, "yBlurTo", 1, 0);// Glow -------------------------MovieClip.prototype.glowTo = TextField.prototype.glowTo = function () { // Applies a glow filter // 1 -> (propDest_color, propDest_alpha, propDest_blur, propDest_strength, quality, inner, knockout, timeSeconds, animType, delay, callback, extra1, extra2) // 2 -> (GlowFilter, timeSeconds, animType, delay, callback, extra1, extra2) if (typeof(arguments[0]) == "object" && arguments[0] != undefined) { // It's an object _global.$addTween(this, ["__special_glow_color__", "__special_glow_alpha__", "__special_glow_blurX__","__special_glow_blurY__", "__special_glow_strength__"], [arguments[0].color, arguments[0].alpha, arguments[0].blurX, arguments[0].blurY, arguments[0].strength], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], {__special_glow_quality__:arguments[0].quality, __special_glow_inner__:arguments[0].inner, __special_glow_knockout__:arguments[0].knockout}); } else { // Normal parameters _global.$addTween(this, ["__special_glow_color__", "__special_glow_alpha__", "__special_glow_blurX__","__special_glow_blurY__", "__special_glow_strength__"], [arguments[0], arguments[1], arguments[2], arguments[2], arguments[3]], arguments[7], arguments[8], arguments[9], arguments[10], arguments[11], arguments[12], {__special_glow_quality__:arguments[4], __special_glow_inner__:arguments[5], __special_glow_knockout__:arguments[6]}); }};ASSetPropFlags(MovieClip.prototype, "glowTo", 1, 0);ASSetPropFlags(TextField.prototype, "glowTo", 1, 0);MovieClip.prototype.xyGlowTo = TextField.prototype.xyGlowTo = function (propDest_color, propDest_alpha, propDest_blurX, propDest_blurY, propDest_strength, quality, inner, knockout, timeSeconds, animType, delay, callback, extra1, extra2) { // Applies a glow filter with different horizontal/vertical values _global.$addTween(this, ["__special_glow_color__", "__special_glow_alpha__", "__special_glow_blurX__","__special_glow_blurY__", "__special_glow_strength__"], [propDest_color, propDest_alpha, propDest_blurX, propDest_blurY, propDest_strength], timeSeconds, animType, delay, callback, extra1, extra2, {__special_glow_quality__:quality, __special_glow_inner__:inner, __special_glow_knockout__:knockout});};ASSetPropFlags(MovieClip.prototype, "xyGlowTo", 1, 0);ASSetPropFlags(TextField.prototype, "xyGlowTo", 1, 0);MovieClip.prototype.xGlowTo = TextField.prototype.xGlowTo = function (propDest_color, propDest_alpha, propDest_blur, propDest_strength, quality, inner, knockout, timeSeconds, animType, delay, callback, extra1, extra2) { // Applies a glow filter horizontally only _global.$addTween(this, ["__special_glow_color__", "__special_glow_alpha__", "__special_glow_blurX__", "__special_glow_strength__"], [propDest_color, propDest_alpha, propDest_blur, propDest_strength], timeSeconds, animType, delay, callback, extra1, extra2, {__special_glow_quality__:quality, __special_glow_inner__:inner, __special_glow_knockout__:knockout});};ASSetPropFlags(MovieClip.prototype, "xGlowTo", 1, 0);ASSetPropFlags(TextField.prototype, "xGlowTo", 1, 0);MovieClip.prototype.yGlowTo = TextField.prototype.yGlowTo = function (propDest_color, propDest_alpha, propDest_blur, propDest_strength, quality, inner, knockout, timeSeconds, animType, delay, callback, extra1, extra2) { // Applies a glow filter vertically only _global.$addTween(this, ["__special_glow_color__", "__special_glow_alpha__", "__special_glow_blurY__", "__special_glow_strength__"], [propDest_color, propDest_alpha, propDest_blur, propDest_strength], timeSeconds, animType, delay, callback, extra1, extra2, {__special_glow_quality__:quality, __special_glow_inner__:inner, __special_glow_knockout__:knockout});};ASSetPropFlags(MovieClip.prototype, "yGlowTo", 1, 0);ASSetPropFlags(TextField.prototype, "yGlowTo", 1, 0);// Bevel ------------------------MovieClip.prototype.bevelTo = TextField.prototype.bevelTo = function () { // Applies a bevel filter // 1 -> (propDest_distance, propDest_angle, propDest_highlightColor, propDest_highlightAlpha, propDest_shadowColor, propDest_shadowAlpha, propDest_blur, propDest_strength, quality, type, knockout, timeSeconds, animType, delay, callback, extra1, extra2) { // 2 -> (bevelFilter, timeSeconds, animType, delay, callback, extra1, extra2) { if (typeof(arguments[0]) == "object" && arguments[0] != undefined) { // It's an object _global.$addTween(this, ["__special_bevel_distance__", "__special_bevel_angle__", "__special_bevel_highlightColor__","__special_bevel_highlightAlpha__", "__special_bevel_shadowColor__", "__special_bevel_shadowAlpha__", "__special_bevel_blurX__", "__special_bevel_blurY__", "__special_bevel_strength__"], [arguments[0].distance, arguments[0].angle, arguments[0].highlightColor, arguments[0].highlightAlpha*100, arguments[0].shadowColor, arguments[0].shadowAlpha*100, arguments[0].blurX, arguments[0].blurY, arguments[0].strength], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], {__special_bevel_quality__:arguments[0].quality, __special_bevel_type__:arguments[0].type, __special_bevel_knockout__:arguments[0].knockout}); } else { // Normal parameters _global.$addTween(this, ["__special_bevel_distance__", "__special_bevel_angle__", "__special_bevel_highlightColor__","__special_bevel_highlightAlpha__", "__special_bevel_shadowColor__", "__special_bevel_shadowAlpha__", "__special_bevel_blurX__", "__special_bevel_blurY__", "__special_bevel_strength__"], [arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[6], arguments[7]], arguments[11], arguments[12], arguments[13], arguments[14], arguments[15], arguments[16], {__special_bevel_quality__:arguments[8], __special_bevel_type__:arguments[9], __special_bevel_knockout__:arguments[10]}); }};ASSetPropFlags(MovieClip.prototype, "bevelTo", 1, 0);ASSetPropFlags(TextField.prototype, "bevelTo", 1, 0);MovieClip.prototype.xyBevelTo = TextField.prototype.xyBevelTo = function (propDest_distance, propDest_angle, propDest_highlightColor, propDest_highlightAlpha, propDest_shadowColor, propDest_shadowAlpha, propDest_blurX, propDest_blurY, propDest_strength, quality, type, knockout, timeSeconds, animType, delay, callback, extra1, extra2) { // Applies a bevel filter with different horizontal/vertical values _global.$addTween(this, ["__special_bevel_distance__", "__special_bevel_angle__", "__special_bevel_highlightColor__","__special_bevel_highlightAlpha__", "__special_bevel_shadowColor__", "__special_bevel_shadowAlpha__", "__special_bevel_blurX__", "__special_bevel_blurY__", "__special_bevel_blurY__", "__special_bevel_strength__"], [propDest_distance, propDest_angle, propDest_highlightColor, propDest_highlightAlpha, propDest_shadowColor, propDest_shadowAlpha, propDest_blur, propDest_blur, propDest_strength], timeSeconds, animType, delay, callback, extra1, extra2, {__special_bevel_quality__:quality, __special_bevel_type__:type, __special_bevel_knockout__:knockout});};ASSetPropFlags(MovieClip.prototype, "xyBevelTo", 1, 0);ASSetPropFlags(TextField.prototype, "xyBevelTo", 1, 0);/*===============================================================================CALCULATION FUNCTIONS-------------------------------------------------------------------------------These functions are used by others methods and functions to find the correctvalues for the tweenings. They're for internal use, but can be used for severalother features out of MC Tween itself.-------------------------------------------------------------------------------*/_global.findPointOnCurve = function (p1x, p1y, cx, cy, p2x, p2y, t) { // Returns the points on a bezier curve for a given time (t is 0-1); // This is based on Robert Penner's Math.pointOnCurve() function // More information: http://actionscript-toolbox.com/samplemx_pathguide.php return {x:p1x + t*(2*(1-t)*(cx-p1x) + t*(p2x - p1x)), y:p1y + t*(2*(1-t)*(cy-p1y) + t*(p2y - p1y))};};ASSetPropFlags(_global, "findPointOnCurve", 1, 0);_global.findTweenColor = function (objProp, tTime) { // Quick way to recalculate color on direct color tweenings var rrs = objProp._propStart >> 16; // r start var rrd = objProp._propDest >> 16; // r destiny var ggs = objProp._propStart >> 8 & 0xff; // g start var ggd = objProp._propDest >> 8 & 0xff; // g destiny var bbs = objProp._propStart & 0xff; // b start var bbd = objProp._propDest & 0xff; // b destiny var newR = Math.round(_global.findTweenValue (rrs, rrd, objProp._timeStart, tTime-(objProp._delay*1000), objProp._timeDest, objProp._animType, objProp._extra1, objProp._extra2)); var newG = Math.round(_global.findTweenValue (ggs, ggd, objProp._timeStart, tTime-(objProp._delay*1000), objProp._timeDest, objProp._animType, objProp._extra1, objProp._extra2)); var newB = Math.round(_global.findTweenValue (bbs, bbd, objProp._timeStart, tTime-(objProp._delay*1000), objProp._timeDest, objProp._animType, objProp._extra1, objProp._extra2)); return (newR << 16) + (newG << 8) + newB;};_global.findTweenValue = function (_propStart, _propDest, _timeStart, _timeNow, _timeDest, _animType, _extra1, _extra2) { // Returns the current value of a property mid-value given the time. // Used by the tween methods to see where the movieclip should be on the current // tweening process. All equations on this function are Robert Penner's work. var t = _timeNow - _timeStart; // current time (frames, seconds) var b = _propStart; // beginning value var c = _propDest - _propStart; // change in value var d = _timeDest - _timeStart; // duration (frames, seconds) var a = _extra1; // amplitude (optional - used only on *elastic easing) var p = _extra2; // period (optional - used only on *elastic easing) var s = _extra1; // overshoot ammount (optional - used only on *back easing) switch (_animType.toLowerCase()) { case "linear": // simple linear tweening - no easing return c*t/d + b; case "easeinquad": // quadratic (t^2) easing in - accelerating from zero velocity return c*(t/=d)*t + b; case "easeoutquad": // quadratic (t^2) easing out - decelerating to zero velocity return -c *(t/=d)*(t-2) + b; case "easeinoutquad": // quadratic (t^2) easing in/out - acceleration until halfway, then deceleration if ((t/=d/2) < 1) return c/2*t*t + b; return -c/2 * ((--t)*(t-2) - 1) + b; case "easeoutinquad": // quadratic (t^2) easing out/in - deceleration until halfway, then acceleration if (t < d/2) return findTweenValue (0, c, 0, t*2, d, "easeOutQuad") * .5 + b; return findTweenValue(0, c, 0, t*2-d, d, "easeInQuad") * .5 + c*.5 + b; case "easeincubic": // cubic (t^3) easing in - accelerating from zero velocity return c*(t/=d)*t*t + b; case "easeoutcubic": // cubic (t^3) easing out - decelerating to zero velocity return c*((t=t/d-1)*t*t + 1) + b; case "easeinoutcubic": // cubic (t^3) easing in/out - acceleration until halfway, then deceleration if ((t/=d/2) < 1) return c/2*t*t*t + b; return c/2*((t-=2)*t*t + 2) + b; case "easeoutincubic": // cubic (t^3) easing out/in - deceleration until halfway, then acceleration if (t < d/2) return findTweenValue (0, c, 0, t*2, d, "easeOutCubic") * .5 + b; return findTweenValue(0, c, 0, t*2-d, d, "easeInCubic") * .5 + c*.5 + b; case "easeinquart": // quartic (t^4) easing in - accelerating from zero velocity return c*(t/=d)*t*t*t + b; case "easeoutquart": // quartic (t^4) easing out - decelerating to zero velocity return -c * ((t=t/d-1)*t*t*t - 1) + b; case "easeinoutquart": // quartic (t^4) easing in/out - acceleration until halfway, then deceleration if ((t/=d/2) < 1) return c/2*t*t*t*t + b; return -c/2 * ((t-=2)*t*t*t - 2) + b; case "easeoutinquart": // quartic (t^4) easing out/in - deceleration until halfway, then acceleration if (t < d/2) return findTweenValue (0, c, 0, t*2, d, "easeOutQuart") * .5 + b; return findTweenValue(0, c, 0, t*2-d, d, "easeInQuart") * .5 + c*.5 + b; case "easeinquint": // quintic (t^5) easing in - accelerating from zero velocity return c*(t/=d)*t*t*t*t + b; case "easeoutquint": // quintic (t^5) easing out - decelerating to zero velocity return c*((t=t/d-1)*t*t*t*t + 1) + b; case "easeinoutquint": // quintic (t^5) easing in/out - acceleration until halfway, then deceleration if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; return c/2*((t-=2)*t*t*t*t + 2) + b; case "easeoutinquint": // quintic (t^5) easing out/in - deceleration until halfway, then acceleration if (t < d/2) return findTweenValue (0, c, 0, t*2, d, "easeOutQuint") * .5 + b; return findTweenValue(0, c, 0, t*2-d, d, "easeInQuint") * .5 + c*.5 + b; case "easeinsine": // sinusoidal (sin(t)) easing in - accelerating from zero velocity return -c * Math.cos(t/d * (Math.PI/2)) + c + b; case "easeoutsine": // sinusoidal (sin(t)) easing out - decelerating to zero velocity return c * Math.sin(t/d * (Math.PI/2)) + b; case "easeinoutsine": // sinusoidal (sin(t)) easing in/out - acceleration until halfway, then deceleration return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; case "easeoutinsine": // sinusoidal (sin(t)) easing out/in - decel
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -