AS2 TweenLite:补间到帧

时间:2011-06-23 10:18:08

标签: actionscript actionscript-2 tweenlite

我已加载以下设置:

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([FramePlugin]);
OverwriteManager.init(OverwriteManager.AUTO);

并使用以下代码将mc补间到第20帧。

    TweenLite.to(circle, 1, {frame:20, ease:Elastic.easeOut});

问题没有发生,圆圈是一个包含我的mc和痕迹的变量。

的输出
trace(circle); = _level0.circle

任何人都可以看到为什么这不起作用? MC包含一个shapetween。

编辑:

好的,所以我在同一个MC的新版本中对它进行了测试,并且它不是MC,它与我的代码的其他部分阻止它的问题有关。

这是我的整个代码......任何人都可以看到任何会阻止补间框架工作的东西吗?如果我删除for (MovieClip in txts) { txts[MovieClip]._alpha = 0; }并将补间放在它上面就可以了,但是只要它再次进入翻转,它就不会。

整个代码:

import com.greensock.*;
import com.greensock.easing.*;
import com.greensock.plugins.*;
TweenPlugin.activate([ColorTransformPlugin, FramePlugin]);
OverwriteManager.init(OverwriteManager.AUTO);
var angle:Number = 0;
var originX:Number = Stage.width/2;
var originY:Number = Stage.height/2;
var radiusX:Number = 320.5;
var radiusY:Number = 247.5;
var steps:Number = 360;
var speed:Number = 0.4/steps;
var circle:MovieClip = this.circle;
var circleTxt:MovieClip = this.circle.titleTxt;
var squareHeight:Number = 340.2;
var buttons:Array = new Array(this.faith, this.social, this.ability, this.age, this.orientation, this.ethnicity, this.sex);
var txts:Array = new Array("faithTxt", "socialTxt", "abilityTxt", "ageTxt", "orientationTxt", "ethnicityTxt", "sexTxt");
var tweens:Array = new Array();
for (MovieClip in txts) {
    txts[MovieClip]._alpha = 0;
}
for (i=0; i<buttons.length; i++) {
    buttons[i].onRollOver = function() {
        var current:MovieClip = this;
        circle.onEnterFrame = function() {
            if (this._currentframe == 20) {
                delete this.onEnterFrame;
                delete circleTxt.onEnterFrame;
                current.txt._alpha = 100;
            }
        };
        noScale(circleTxt);
        txtName = current._name+"Txt";
        current.txt = this._parent.attachMovie(txtName, txtName, this._parent.getNextHighestDepth());
        current.txt._alpha = 0;
        circle.txtHeight = circle.active.txt._height/2+40;
        var oppX:Number = Stage.width-this._x;
        var oppY:Number = Stage.height-this._y;
        if (oppX-227.8<=20) {
            var difference:Number = Math.abs(20-(oppX-227.8));
            oppX += difference;
        } else if (oppX+227.8>=Stage.width-20) {
            var difference:Number = Math.abs(780-(oppX+227.8));
            oppX -= difference;
        }
        if (oppY-172.1<=20) {
            var difference:Number = Math.abs(20-(oppY-172.1));
            oppY += difference;
        } else if (oppY+172.1>=580) {
            var difference:Number = Math.abs(580-(oppY+172.1));
            oppY -= difference;
        }
        circle.active.txt._x = oppX;
        circle.active.txt._y = oppY;
        TweenLite.to(circle,1,{frame:20});
        TweenLite.to(circle,0.5,{_height:circle.txtHeight});
        TweenLite.to(circle,1,{_x:oppX, _y:oppY, ease:Quint.easeInOut});
        TweenLite.to(circleTxt,1,{_alpha:0});
        TweenLite.to(this,0.5,{colorTransform:{tint:0x99ff00, tintAmount:0.5}});
        for (MovieClip in buttons) {
            delete buttons[MovieClip].onEnterFrame;
            if (buttons[MovieClip] != this) {
                TweenLite.to(buttons[MovieClip],0.5,{colorTransform:{tint:0xffffff, tintAmount:0.9}});
                TweenLite.to(buttons[MovieClip]._line,0.5,{colorTransform:{tint:0xffffff, tintAmount:0.9}});
            }
        }
    };
    buttons[i].onRollOut = function() {
        removeMovieClip(this.txt);
        circle.onEnterFrame = function() {
            if (this._currentframe == 1) {
                delete this.onEnterFrame;
                delete circleTxt.onEnterFrame;
            }
        };
        noScale(circleTxt);
        TweenLite.to(circle,0.2,{_height:173});
        TweenLite.to(circle,0.5,{_x:Stage.width/2, _y:Stage.height/2});
        TweenLite.to(circleTxt,1,{_alpha:100});
        for (MovieClip in buttons) {
            buttons[MovieClip].onEnterFrame = function() {
                moveButtons(this);
                controlButtons(this);
            };
            TweenLite.to(buttons[MovieClip],0.5,{colorTransform:{tint:null, tintAmount:0}});
            TweenLite.to(buttons[MovieClip]._line,0.5,{colorTransform:{tint:null, tintAmount:0}});
        }
    };
    buttons[i].onEnterFrame = function() {
        moveButtons(this);
        controlButtons(this);
    };
    buttons[i]._order = (360/buttons.length)*1000+(i+1);
    buttons[i]._linedepth = buttons[i].getDepth()-1000;
}
function noScale(mc) {
    mc.onEnterFrame = function() {
        this._yscale = 10000/this._parent._yscale;
    };
}
function moveButtons(e) {
    var lineName:String = new String(e._name+"line");
    var lineMC:MovieClip = createEmptyMovieClip(lineName, e._linedepth);
    with (lineMC) {
        beginFill();
        lineStyle(2,0x000000,100);
        moveTo(e._x,e._y);
        lineTo(Stage.width/2,Stage.height/2);
        endFill();
    }
    e.rotation = Math.atan2(e._y-Stage.height/2, e._x-Stage.width/2);
    e._line.dist = Math.sqrt(Math.abs(e._x-Stage.width/2) ^ 2+Math.abs(e._y-Stage.height/2) ^ 2);
    e._line = lineMC;
    e._anglePhase = (angle+e._order)/Math.PI*2.8;
    e._x = originX+Math.sin(e._anglePhase)*radiusX;
    e._y = originY+Math.cos(e._anglePhase)*radiusY;

}
function controlButtons(e) {
    angle += speed;
    if (angle>=360) {
        angle -= 360;
    }
}

1 个答案:

答案 0 :(得分:0)

Heh Solved,由于某种原因,它不喜欢代码中的for (MovieClip in Array){},所以如果我用for (a in Array){}代替它,它似乎有效。奇