codice:
tp.addTweenWithDelay = function(delay,mc,props,pEnd,sec,eqFunc,callback,extra1,extra2){
with(this){
var il = ints.length;
var intid = setInterval(function(obj){
obj.addTween(mc, props, pEnd, sec, eqFunc, callback, extra1, extra2);
clearInterval(obj.ints[il].intid);
obj.ints[il] = undefined;
},delay*1000,this);
//
ints[il] = {mc: mc, props: props, pend:pEnd, intid:intid}
}
}
//
tp.removeTween = function(mc,props){
with (this){
var all, i, j
all = false;
if(props == undefined){
// props are undefined, remove all tweens
all = true;
}
i = tweenList.length;
while (i--){
if(tweenList[i].mc == mc){
if(all){
tweenList.splice(i,1);
}else{
for(j in props){
if(tweenList[i].pp == props[j]){
tweenList.splice(i,1);
// (because allows add same properties for same mc,
// all tweens must be checked)
} else if (props[j] == "_ct_" && tweenList[i].ctm != undefined){
// removing of colorTransform tweens
tweenList.splice(i,1);
}
}
}
}
}
i = ints.length;
while(i-- && ints[i].mc == mc){
if(all){
// REMOVE ALL
clearInterval(ints[i].intid)
ints[i] = undefined
} else {
// REMOVE PROPERTIES
for(j in props){
for(var k in ints[i].props){
if(ints[i].props[k] == props[j]){
// remove tween properties + property end values
ints[i].props.splice(k,1);
ints[i].pend.splice(k,1);
}
}
if(ints[i].props.length == 0){
clearInterval(ints[i].intid)
// no properties to tween
}
}
}
}
// /*1.1.6*/
if(tweenList.length==0){
// last tween removed, erase onenterframe function
deinit();
}
}// end with
}
tp.isTweening = function(mc){
with(this){
for (var i in tweenList){
if(tweenList[i].mc == mc){
// mc found, so break loop
return true;
break;
}
}
return false;
}
}
tp.getTweens = function(mc){
with(this){
var count = 0;
for (var i in tweenList){
if(tweenList[i].mc == mc){
// found, increase count
count++;
}
}
return count;
}
}
tp.lockTween = function(mc,bool){
this.lockedTweens[targetpath(mc)] = bool;
}
tp.isTweenLocked = function(mc){
if(this.lockedTweens[targetpath(mc)] == undefined){
return false;
}else{
return this.lockedTweens[targetpath(mc)];
}
}
tp.toString = function(){
return "[AS1 tweenManager 1.1.6]";
}
delete tp;
//----------------------------- end of tweenManager
if($tweenManager == undefined){
_global.$tweenManager = new tweenManager();
}
// prototypes
Mp.tween = function(props, pEnd, seconds, animType,
delay, callback, extra1, extra2) {
if ($tweenManager.isTweenLocked(this)){
trace("error: this movieclip is locked");
return;
}
if (arguments.length<2) {
trace("error: props & pEnd must be defined");
return;
}
// parse arguments to valid type:
// parse properties
if (typeof (props) == "string") {
props = [props];
}
// parse end values
// if pEnd is not array
if (pEnd.length == undefined ) {
pEnd = [pEnd];
}
// parse time properties
if(seconds == undefined) {
seconds = 2;
}else if (seconds<0.01){
seconds = 0;
}
//
if (delay<0.01 || delay == undefined) {
delay = 0;
}
// parse animtype to reference to equation function
switch(typeof(animType)){
case "string":
animType = animType.toLowerCase();
if (animType == "linear") {
var eqf = Math.linearTween
} else {
var eqf = Math[animType]
}
break;
case "function":
var eqf = animType;
break;
case "object":
if(animType.pts != undefined && animType.ease != undefined){
var eqf = animType.ease;
var extra1 = animType.pts;
}
}
if (eqf == undefined) {
// set default tweening equation
var eqf = Math.easeOutExpo;
}
// parse callback function
switch(typeof (callback)) {
case "function":
callback = {func:callback, scope:this._parent};
break;
case "string":
var ilp = callback.indexOf("(");
var funcp = callback.slice(0, ilp);
//
var scope = eval(funcp.slice(0, funcp.lastIndexOf(".")));
var func = eval(funcp);
var args = callback.slice(ilp+1, callback.lastIndexOf(")")).split(",");
for (var i = 0; i<args.length; i++) {
var a = eval(args[i]);
if (a != undefined) {
args[i] = a;
}
}
callback = {func:func, scope:scope, args:args };
break;
}
if($tweenManager.autoStop){
// automatic removing tweens as in Zeh proto
$tweenManager.removeTween(this,props)
}
// pass parameters to tweenManager method
if(delay > 0){
$tweenManager.addTweenWithDelay(delay,this, props, pEnd, seconds, eqf, callback, extra1, extra2);
}else{
$tweenManager.addTween(this, props, pEnd, seconds, eqf, callback, extra1, extra2);
}
};
ASSetPropFlags(Mp, "tween", 1, 0);
Mp.stopTween = function(props) {
if (typeof (props) == "string") {
props = [props];
}
$tweenManager.removeTween(this, props);
};
ASSetPropFlags(Mp, "stopTween", 1, 0);
Mp.isTweening = function() {
//returns boolean
return $tweenManager.isTweening(this);
};
ASSetPropFlags(Mp, "isTweening", 1, 0);
Mp.getTweens = function() {
// returns count of running tweens
return $tweenManager.getTweens(this);
};
ASSetPropFlags(Mp, "getTweens", 1, 0);
Mp.lockTween = function() {
$tweenManager.lockTween(this,true);
};
ASSetPropFlags(Mp, "lockTween", 1, 0);
Mp.unlockTween = function() {
$tweenManager.lockTween(this,false);
};
ASSetPropFlags(Mp, "unlockTween", 1, 0);
Mp.isTweenLocked = function() {
return $tweenManager.isTweenLocked(this);
};
ASSetPropFlags(Mp, "isTweenLocked", 1, 0);
// == shortcut methods ==
// these methods only passes parameters to tween method
Mp.alphaTo = function (destAlpha, seconds, animType, delay, callback, extra1, extra2) {
this.tween(["_alpha"],[destAlpha],seconds,animType,delay,callback,extra1,extra2)
}
ASSetPropFlags(Mp, "alphaTo", 1, 0);
Mp.brightnessTo = function (bright, seconds, animType, delay, callback, extra1, extra2) {
// destionation color transform matrix
var percent = 100 - Math.abs(bright);
var offset = 0;
if (bright > 0) offset = 256 * (bright / 100);
var destCt = {ra: percent, rb:offset,
ga: percent, gb:offset,
ba: percent,bb:offset}
//
this.tween(["_ct_"],[destCt],seconds,animType,delay,callback,extra1,extra2)
}
ASSetPropFlags(Mp, "brightnessTo", 1, 0);
Mp.colorTo = function (destColor, seconds, animType, delay, callback, extra1, extra2) {
// destionation color transform matrix
var destCt = {rb: destColor >> 16, ra:0,
gb: (destColor & 0x00FF00) >> 8, ga:0,
bb: destColor & 0x0000FF,ba:0}
//
this.tween(["_ct_"],[destCt],seconds,animType,delay,callback,extra1,extra2)
}
ASSetPropFlags(Mp, "colorTo", 1, 0);
Mp.colorTransformTo = function (ra, rb, ga, gb, ba, bb, aa, ab, seconds, animType, delay, callback, extra1, extra2) {
// destionation color transform matrix
var destCt = {ra: ra ,rb: rb , ga: ga, gb: gb, ba: ba, bb: bb, aa: aa, ab: ab}
//
this.tween(["_ct_"],[destCt],seconds,animType,delay,callback,extra1,extra2)
}
ASSetPropFlags(Mp, "colorTransformTo", 1, 0);
Mp.scaleTo = function (destScale, seconds, animType, delay, callback, extra1, extra2) {
this.tween(["_xscale", "_yscale"],[destScale, destScale],seconds,animType,delay,callback,extra1,extra2)
}
ASSetPropFlags(Mp, "scaleTo", 1, 0);
Mp.slideTo = function (destX, destY, seconds, animType, delay, callback, extra1, extra2) {
this.tween(["_x", "_y"],[destX, destY],seconds,animType,delay,callback,extra1,extra2)
}
ASSetPropFlags(Mp, "slideTo", 1, 0);
Mp.rotateTo = function (destRotation, seconds, animType, delay, callback, extra1, extra2) {
this.tween(["_rotation"],[destRotation],seconds,animType,delay,callback,extra1,extra2)
}
ASSetPropFlags(Mp, "rotateTo", 1, 0);
//
Mp.getFrame = function() {
return this._currentframe;
};
ASSetPropFlags(Mp, "getFrame", 1, 0);
Mp.setFrame = function(fr) {
this.gotoAndStop(Math.round(fr));
};
ASSetPropFlags(Mp, "setFrame", 1, 0);
Mp.addProperty("_frame", Mp.getFrame, Mp.setFrame);
ASSetPropFlags(Mp, "_frame", 1, 0);
//
Mp.frameTo = function(endframe, duration, animType, delay, callback, extra1, extra2) {
if (endframe == undefined) {
endframe = this._totalframes;
}
this.tween("_frame", endframe, duration, animType, delay, callback, extra1, extra2);
};
ASSetPropFlags(Mp, "frameTo", 1, 0);
//
delete Mp;
e lo salvi come lmc_tween_as1.as