📄 mc_tween2.as
字号:
var oldProperties = [mtarget[prop]]; // Old value, as in 0
var newProperties = [propDest]; // New (target) value, as in 100
} else {
// Array of properties
// ****Hm.. this looks strange... test concat() for speed?
var properties = []; // Properties, as in "_x"
var oldProperties = []; // Old value, as in 0
var newProperties = []; // New (target) value, as in 100
for (var i in prop) oldProperties.push (mtarget[prop[i]]);
for (var i in prop) properties.push (prop[i]);
for (var i in propDest) newProperties.push (propDest[i]);
}
var $_callback_assigned = false; // 1.7.4: Knows if callback has already been assigned to an object
// Checks if the master movieClip (which controls all tweens) exists, if not creates it
if (_root.__tweenController__ == undefined) _global.$createTweenController();
var tweenPropList = _root.__tweenController__.$_tweenPropList;
// Now set its data (adds to the list of properties being tweened)
var tTime = _root.__tweenController__.$_tTime; // 2.16.12: laco's suggestion, for a REAL uniform time
for (var i in oldProperties) {
// Set one new object for each property that should be tweened
if (newProperties[i] != undefined && !mtarget.$_isTweenLocked) {
// Only creates tweenings for properties that are not undefined. That way,
// certain properties can be optional on the shortcut functions even though
// they are passed to the tweening function - they're just ignored
// Checks if it's at the tween list already
if (mtarget.$_tweenCount > 0) {
for (var pti=0; pti<tweenPropList.length; pti++) {
if (tweenPropList[pti]._targ == mtarget && tweenPropList[pti]._prop == properties[i]) {
// Exists for the same property... checks if the time is the same (if the NEW's start time would be before the OLD's ending time)
if (tTime + (delay*1000) < tweenPropList[pti]._timeDest) {
// It's a property that is already being tweened, BUT has already started, so it's ok to overwrite.
// So it deletes the old one(s) and THEN creates the new one.
tweenPropList.splice(pti, 1);
pti--;
mtarget.$_tweenCount--;
}
}
}
}
// Finally, adds the new tween data to the list
tweenPropList.push ({
_prop : properties[i],
_targ : mtarget,
_propStart : undefined, // was "oldProperties[i]" (2.14.9). Doesn't set: it must be read at the first update time, to allow animating with correct [new] values when using the delay parameter
_propDest : newProperties[i],
_timeStart : tTime,
_timeDest : tTime+(timeSeconds*1000),
_animType : animType,
_extra1 : extra1,
_extra2 : extra2,
_extras : extras, // 2.25.27: 'extras' for more tween-related data
_delay : delay,
_isPaused : false, // whether it's paused or not
_timePaused : 0, // the time it has been paused
_callback : $_callback_assigned ? undefined : callback
});
// $tweenCount is used for a faster start
mtarget.$_tweenCount = mtarget.$_tweenCount > 0 ? mtarget.$_tweenCount+1 : 1; // to avoid setting ++ to undefined
$_callback_assigned = true; // 1.7.4
}
}
// Hides stuff from public view on the movieclip being tweened
ASSetPropFlags(mtarget, "$_tweenCount", 1, 0); // List of stuff being tweened
};
ASSetPropFlags(_global, "$addTween", 1, 0);
_global.$updateTweens = function() {
// INTERNAL USE: This is ran every frame to update *all* existing tweens
// On each pass, it should check and update the properties
var tTime = this.$_tTime = getTimer();
for (var i=0; i<this.$_tweenPropList.length; i++) {
var objProp = this.$_tweenPropList[i]; // Temporary shortcut to this property controller object
if (objProp._targ.toString() == undefined) {
// Object doesn't exist anymore; so just remove it from the list (2.18.20)
// There's no point in trying to do a clean removal through _global.$stopTween(), so just gets deleted
this.$_tweenPropList.splice(i,1);
i--;
} else {
if (objProp._timeStart + (objProp._delay*1000) <= tTime && !objProp._isPaused) {
// Starts tweening already
// Some of the lines below seem weird because of the nested if/elseif blocks.
// That's because this is meant to be *fast*, not to be readable, so I've chosen to avoid unnecesssary if() checks when possible
// "first-time" update to allow dinamically changed values for delays (2.14.9)
if (objProp._propStart == undefined) {
if (objProp._prop.substr(0, 10) == "__special_") {
// Special hard-coded cases
// 'Advanced' movieclip coloring -------------------------------------------------------------
if (objProp._prop == "__special_mc_frame__") {
objProp._propStart = objProp._targ._currentframe;
} else if (objProp._prop == "__special_mc_ra__") {
objProp._propStart = new Color (objProp._targ).getTransform().ra;
} else if (objProp._prop == "__special_mc_rb__") {
objProp._propStart = new Color (objProp._targ).getTransform().rb;
} else if (objProp._prop == "__special_mc_ga__") {
objProp._propStart = new Color (objProp._targ).getTransform().ga;
} else if (objProp._prop == "__special_mc_gb__") {
objProp._propStart = new Color (objProp._targ).getTransform().gb;
} else if (objProp._prop == "__special_mc_ba__") {
objProp._propStart = new Color (objProp._targ).getTransform().ba;
} else if (objProp._prop == "__special_mc_bb__") {
objProp._propStart = new Color (objProp._targ).getTransform().bb;
} else if (objProp._prop == "__special_mc_aa__") {
objProp._propStart = new Color (objProp._targ).getTransform().aa;
} else if (objProp._prop == "__special_mc_ab__") {
objProp._propStart = new Color (objProp._targ).getTransform().ab;
// Text color --------------------------------------------------------------------------------
} else if (objProp._prop == "__special_text_r__") {
objProp._propStart = objProp._targ.textColor >> 16;
} else if (objProp._prop == "__special_text_g__") {
objProp._propStart = (objProp._targ.textColor & 0x00FF00) >> 8;
} else if (objProp._prop == "__special_text_b__") {
objProp._propStart = objProp._targ.textColor & 0x0000FF;
// Sound properties --------------------------------------------------------------------------
} else if (objProp._prop == "__special_sound_volume__") {
objProp._propStart = objProp._targ.getVolume();
} else if (objProp._prop == "__special_sound_pan__") {
objProp._propStart = objProp._targ.getPan();
// BezierSlideTo -----------------------------------------------------------------------------
} else if (objProp._prop == "__special_bst_t__") {
objProp._propStart = 0;
objProp._extras.__special_bst_ix__ = objProp._targ._x;
objProp._extras.__special_bst_iy__ = objProp._targ._y;
// Flash 8 filters ---------------------------------------------------------------------------
} else if (objProp._prop == "__special_blur_x__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BlurFilter) objProp._propStart = objProp._targ.filters[j].blurX;
if (objProp._propStart == undefined) objProp._propStart = 0;
} else if (objProp._prop == "__special_blur_y__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BlurFilter) objProp._propStart = objProp._targ.filters[j].blurY;
if (objProp._propStart == undefined) objProp._propStart = 0;
} else if (objProp._prop == "__special_glow_color__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.GlowFilter) objProp._propStart = objProp._targ.filters[j].color;
if (objProp._propStart == undefined) objProp._propStart = 0xffffff;
} else if (objProp._prop == "__special_glow_alpha__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.GlowFilter) objProp._propStart = objProp._targ.filters[j].alpha;
if (objProp._propStart == undefined) objProp._propStart = 1;
} else if (objProp._prop == "__special_glow_blurX__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.GlowFilter) objProp._propStart = objProp._targ.filters[j].blurX;
if (objProp._propStart == undefined) objProp._propStart = 0;
} else if (objProp._prop == "__special_glow_blurY__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.GlowFilter) objProp._propStart = objProp._targ.filters[j].blurY;
if (objProp._propStart == undefined) objProp._propStart = 0;
} else if (objProp._prop == "__special_glow_strength__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.GlowFilter) objProp._propStart = objProp._targ.filters[j].strength;
if (objProp._propStart == undefined) objProp._propStart = 1;
} else if (objProp._prop == "__special_bevel_distance__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].distance;
if (objProp._propStart == undefined) objProp._propStart = 0;
} else if (objProp._prop == "__special_bevel_angle__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].angle;
if (objProp._propStart == undefined) objProp._propStart = 45;
} else if (objProp._prop == "__special_bevel_highlightColor__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].highlightColor;
if (objProp._propStart == undefined) objProp._propStart = 0xffffff;
} else if (objProp._prop == "__special_bevel_highlightAlpha__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].highlightAlpha;
if (objProp._propStart == undefined) objProp._propStart = 1;
} else if (objProp._prop == "__special_bevel_shadowColor__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].shadowColor;
if (objProp._propStart == undefined) objProp._propStart = 0x000000;
} else if (objProp._prop == "__special_bevel_shadowAlpha__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].shadowAlpha;
if (objProp._propStart == undefined) objProp._propStart = 1;
} else if (objProp._prop == "__special_bevel_blurX__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].blurX;
if (objProp._propStart == undefined) objProp._propStart = 0;
} else if (objProp._prop == "__special_bevel_blurY__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].blurY;
if (objProp._propStart == undefined) objProp._propStart = 0;
} else if (objProp._prop == "__special_bevel_strength__") {
for (var j=0; j<objProp._targ.filters.length; j++) if (objProp._targ.filters[j] instanceof flash.filters.BevelFilter) objProp._propStart = objProp._targ.filters[j].strength;
if (objProp._propStart == undefined) objProp._propStart = 1;
// ...Something else (hardly) ----------------------------------------------------------------
} else {
objProp._propStart = objProp._targ[objProp._prop];
}
} else {
// Normal cases
objProp._propStart = objProp._targ[objProp._prop];
}
}
var endTime = objProp._timeDest + (objProp._delay*1000);
if (endTime <= tTime) {
// Finished, just use the end value for the last update
var newValue = objProp._propDest;
} else {
// Continue, in-tween
var newValue = _global.findTweenValue (objProp._propStart, objProp._propDest, objProp._timeStart, tTime-(objProp._delay*1000), objProp._timeDest, objProp._animType, objProp._extra1, objProp._extra2);
}
// sets the property value... this is done to have a 'correct' value in the target object
objProp._targ[objProp._prop] = objProp._extras.mustRound ? Math.round(newValue) : newValue; // 2.26.27: option for rounded
// special hard-coded case for movieclip color transformation...
if (objProp._prop == "__special_mc_frame__") {
objProp._targ.gotoAndStop(Math.round(newValue));
} else if (objProp._prop == "__special_mc_ra__") {
new Color(objProp._targ).setTransform({ra:newValue});
} else if (objProp._prop == "__special_mc_rb__") {
new Color(objProp._targ).setTransform({rb:newValue});
} else if (objProp._prop == "__special_mc_ga__") {
new Color(objProp._targ).setTransform({ga:newValue});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -