I have this coding and the animation only play once.
but I want it to play 3 times and stop at the last frame.
I don’t know what kind of action script I should add.
Can you help me?
import gs.TweenLite;
import gs.plugins.;
import gs.easing.;
TweenPlugin.activate([BlurFilterPlugin]);
var scope:MovieClip = this;
var mouseListenerA:Object = {};
var characterA_array:Array = [“owlA”];
var characterB_array:Array = [“owlB”, “owlC”, “owlD”];
var curArray:Array = characterA_array;
var curFrame:String;
init();
function init() {
var temp:MovieClip;
for (i in scope) {
if (typeof (scope*) == “movieclip”) {
temp = scope*;
temp.xPos = temp._x;
temp.yPos = temp._y;
temp.xScl = temp._xscale;
temp.yScl = temp._yscale;
temp.rOtn = temp._rotation;
}
}
frame1();
}
function frame1() {
curFrame = “frame1”;
TweenLite.to(t0,1,{_alpha:100, delay:.5});
TweenLite.to(owlA,1,{_alpha:100});
owlA.onEnterFrame = function() {
var a = Math.floor(Math.random()*100);
if (a<3) {
blink(this);
}
};
mouseListenerA.onMouseMove = eyeFollow;
Mouse.addListener(mouseListenerA);
TweenLite.delayedCall(2.5,frame2a);
}
// these dummy functions are for the purposes of two different delayed calls.
function frame2a() {
TweenLite.killDelayedCallsTo(frame2a);
TweenLite.killDelayedCallsTo(frame2b);
frame3();
}
function frame2b() {
TweenLite.killDelayedCallsTo(frame2a);
TweenLite.killDelayedCallsTo(frame2b);
frame3();
}
function frame3() {
TweenLite.to(t0,.5,{_alpha:0});
t1._y += 30;
TweenLite.to(t1,.5,{_alpha:100, _y:t1.yPos, ease:Strong.easeOut, overwrite:0});
t2._y += 30;
TweenLite.to(t2,.5,{_alpha:100, _y:t2.yPos, ease:Strong.easeOut, delay:.1});
t6._y += 30;
TweenLite.to(t6,.5,{_alpha:100, _y:t6.yPos, ease:Strong.easeOut, delay:.2});
//bump up t1
curFrame = "frame3";
TweenLite.killDelayedCallsTo(frame2b);
curArray = characterB_array;
for (var i = 0; i<curArray.length; i++) {
var me:MovieClip = scope[curArray*];
me._xscale = me._yscale=0;
me.onEnterFrame = function() {
var a = Math.floor(Math.random()*100);
if (a<2) {
blink(this);
}
};
TweenLite.to(me,.3,{_alpha:100, _xscale:me.xScl, _yscale:me.yScl, ease:Back.easeOut, delay:(i*.1)+.5});
}
TweenLite.to(owlA,.3,{_alpha:0, _xscale:0, _yscale:0, ease:Back.easeIn});
delete owlA.onEnterFrame();
TweenLite.delayedCall(4,frame4);
}
function frame4() {
TweenLite.to(owlPic,.01,{blurFilter:{blurX:30, blurY:30}, overwrite:0});
TweenLite.to(owlPic,1,{_alpha:100, overwrite:0});
TweenLite.to(owlPic,2,{blurFilter:{blurX:0, blurY:0}, overwrite:0, delay:.5});
TweenLite.delayedCall(.5,frame5);
}
function frame5() {
TweenLite.to(t1,.3,{_alpha:0, _x:Stage.width+t1._width, ease:Back.easeIn});
TweenLite.to(t2,.3,{_alpha:0, _x:Stage.width+t2._width, ease:Back.easeIn, delay:.2});
TweenLite.to(t6,.3,{_alpha:0, _x:Stage.width+t2._width, ease:Back.easeIn, delay:.4});
// remove eyes
for (var i = 0; i<curArray.length; i++) {
TweenLite.to(scope[curArray*],1,{_alpha:0});
}
t3._x = -t3._width;
TweenLite.to(t3,.4,{_alpha:100, _x:t3.xPos, easE:Back.easeOut, delay:.4});
TweenLite.delayedCall(2,frame6);
}
function frame6() {
TweenLite.to(t3,.3,{_alpha:0, _x:Stage.width+t3._width, ease:Back.easeIn});
TweenLite.to(owlPic,1,{_xscale:owlPicFPO1._xscale, _yscale:owlPicFPO1._yscale, _rotation:owlPicFPO1.rOtn,_x:owlPicFPO1._x, _y:owlPicFPO1._y, ease:Strong.easeOut});
TweenLite.to(owlPic.a,.6,{_alpha:0});
t4._y += 60;
TweenLite.to(t4,.3,{_alpha:100, _y:t4.yPos+30, ease:Strong.easeOut, overwrite:0, delay:.3});
t5._y += 30;
TweenLite.to(t5,.3,{_alpha:100, _y:t5.yPos, ease:Strong.easeOut, delay:.8});
//bump up t4
TweenLite.to(t4,1,{_alpha:100, _y:t4.yPos, ease:Elastic.easeOut, overwrite:0, delay:.9});
realChocolate._xscale = realChocolate._yscale=0;
realChocolate._rotation = 190;
TweenLite.to(realChocolate,1,{_alpha:62, _xscale:realChocolate.xScl, _yscale:realChocolate.yScl, _rotation:realChocolate.rOtn, ease:Back.easeOut, delay:1});
characters._xscale = characters._yscale=0;
TweenLite.to(characters,.6,{_alpha:100, _xscale:characters.xScl, _yscale:characters.yScl, ease:Back.easeOut, delay:1.2});
cta._x -= 30;
TweenLite.to(cta,.4,{_alpha:100, _x:cta.xPos, easE:Back.easeOut, delay:1.5});
ctaRoll();
}
function ctaRoll() {
cta.carat.xPos = cta.carat._x;
cta.txt.xPos = cta.txt._x;
invBtn.onRollOver = function() {
TweenLite.to(cta.carat,.2,{_x:cta.carat.xPos+4, ease:Strong.easeOut});
TweenLite.to(cta.txt,.2,{_x:cta.txt.xPos+4, ease:Strong.easeOut});
};
invBtn.onRollOut = function() {
TweenLite.to(cta.carat,.2,{_x:cta.carat.xPos, ease:Strong.easeOut});
TweenLite.to(cta.txt,.2,{_x:cta.txt.xPos, ease:Strong.easeOut});
};
}
function eyeFollow() {
TweenLite.to(t0,.5,{_alpha:0});
TweenLite.killDelayedCallsTo(frame2a);
var p0:Object = {};
for (var i = 0; i<curArray.length; i++) {
var pupil0:MovieClip = scope[curArray*].eye0.pupil;
var pupil1:MovieClip = scope[curArray*].eye1.pupil;
p0.x = scope[curArray*].eye0._x;
p0.y = scope[curArray*].eye0._y;
scope[curArray*].eye0.localToGlobal(p0);
var coordy0:Number = _ymouse-p0.y;
var coordx0:Number = _xmouse-p0.x;
var angleRadians0:Number = Math.atan2(coordy0, coordx0);
var angleDegrees0:Number = angleRadians0*180/Math.PI;
// move eyes together -- because separately looks really weird.
// and add a little bit of easing to it.
pupil0._rotation -= (pupil0._rotation-angleDegrees0)*.9;
pupil1._rotation = pupil0._rotation;
pupil0.pupil_mc._rotation = -pupil0._rotation;
pupil1.pupil_mc._rotation = -pupil1._rotation;
}
if (curFrame == "frame1") {
TweenLite.delayedCall(5,frame2b);
}
}
function blink(mc) {
for (var i=0; i<2; i++) {
var a = mc[“eye”+i].blackCircleA;
var b = mc[“eye”+i].blackCircleB;
TweenLite.to(a,.2,{_y:-60, ease:Strong.easeIn, overwrite:0});
TweenLite.to(a,.2,{_y:-190, ease:Strong.easeOut, overwrite:0, delay:.15});
TweenLite.to(b,.2,{_y:66, ease:Strong.easeIn, overwrite:0});
TweenLite.to(b,.2,{_y:202, ease:Strong.easeOut, overwrite:0, delay:.15});
}
}