Flash CS4 Actionscript 3.0 ---让我的脚本循环!

时间:2010-03-03 10:54:11

标签: flash actionscript-3 loops cs4

这是我的脚本......我想做的就是让它不断循环!

import fl.transitions.Tween;

import fl.transitions.easing。*;

yourwebsite_mc.visible=false;
var uptodateFadeTween=new Tween(uptodate_mc,"alpha",Strong.easeOut,0,1,3,true);
var uptodateRotateTween=new Tween(uptodate_mc,"rotation",Strong.easeOut,360,0,3,true);
var uptodateXTween:Tween=new Tween(uptodate_mc,"x",Strong.easeOut,-250,200,3,true);


var uptodateDone:Timer=new Timer(3000,1);
uptodateDone.addEventListener(TimerEvent.TIMER, timerDoneF);
uptodateDone.start();

function timerDoneF(e:TimerEvent):void {
    var uptodateYTween:Tween=new Tween(uptodate_mc,"y",Strong.easeOut,129,-150,3,true);

}

var uptodateFlyUp:Timer=new Timer(3500,1);
uptodateFlyUp.addEventListener(TimerEvent.TIMER, timerDoneG);
uptodateFlyUp.start();


function timerDoneG(e:TimerEvent):void {
    yourwebsite_mc.visible=true;
    var yourwebsiteXTween:Tween=new Tween(yourwebsite_mc,"x",Strong.easeOut,-200,450,1.5,true);
}

2 个答案:

答案 0 :(得分:3)

我不确定你想要连续循环的是什么,所以这是在黑暗中拍摄的......

您可以像这样定义连续循环:

addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(e:Event):void
{
    // any code in here will execute every frame
}

如果您希望每个计时器永远运行,只需将代码修改为以下内容:

var uptodateDone:Timer = new Timer(3000);
uptodateDone.addEventListener(TimerEvent.TIMER, timerDoneF);
uptodateDone.start();

var uptodateFlyUp:Timer=new Timer(3500);
uptodateFlyUp.addEventListener(TimerEvent.TIMER, timerDoneG);
uptodateFlyUp.start();

这将导致每3000毫秒调用timerDoneF并且每3500毫秒调用timerDoneG 永远。希望这是有帮助的。祝你好运!

答案 1 :(得分:0)

好吧,这是我现在所做的。我使用不同的计时器正常运行动作...然后我再次运行一个计时器,在初始设置完成后运行。它不是我想要的100%,但非常接近。对不起是一个菜鸟---如果有人有任何推荐,请告诉我。

import fl.transitions.Tween;
import fl.transitions.easing.*;

yourwebsite_mc.visible = false;

var uptodateFadeTween =new Tween(uptodate_mc, "alpha", Strong.easeOut, 0, 1, 3, true);
var uptodateRotateTween = new Tween(uptodate_mc, "rotation", Strong.easeOut, 360, 0, 3, true);
var uptodateXTween:Tween = new Tween(uptodate_mc, "x", Strong.easeOut, -250, 200, 3, true);

var uptodateDone:Timer = new Timer (3000, 1);
uptodateDone.addEventListener (TimerEvent.TIMER, timerDoneA);
uptodateDone.start();

function timerDoneA(e:TimerEvent):void{
    var uptodateYTween:Tween = new Tween(uptodate_mc, "y", Strong.easeOut, 129, -250, 3, true);

}

var uptodateFlyUp:Timer = new Timer (3500, 1);
uptodateFlyUp.addEventListener(TimerEvent.TIMER, timerDoneB);
uptodateFlyUp.start();

function timerDoneB(e:TimerEvent):void{
    yourwebsite_mc.visible = true;
    var yourwebsiteXTween:Tween = new Tween(yourwebsite_mc, "x", Strong.easeOut, -200, 450, 4, true);

}

var uptodateprojectDone:Timer = new Timer (7500)
uptodateprojectDone.addEventListener (TimerEvent.TIMER, timerDoneH);
uptodateprojectDone.start();

function timerDoneH(e:TimerEvent): void{

uptodate_mc.x = 192.6
uptodate_mc.y = 129
uptodate_mc.visible = true;
yourwebsite_mc.visible = false;

var uptodateFadeTween =new Tween(uptodate_mc, "alpha", Strong.easeOut, 0, 1, 3, true);
var uptodateRotateTween = new Tween(uptodate_mc, "rotation", Strong.easeOut, 360, 0, 3, true);
var uptodateXTween:Tween = new Tween(uptodate_mc, "x", Strong.easeOut, -250, 200, 3, true);


var uptodateDone:Timer = new Timer (3000, 1);
uptodateDone.addEventListener (TimerEvent.TIMER, timerDoneF);
uptodateDone.start();

function timerDoneF(e:TimerEvent):void{
    var uptodateYTween:Tween = new Tween(uptodate_mc, "y", Strong.easeOut, 129, -250, 3, true);

}

var uptodateFlyUp:Timer = new Timer (3500, 1);
uptodateFlyUp.addEventListener(TimerEvent.TIMER, timerDoneG);
uptodateFlyUp.start();

function timerDoneG(e:TimerEvent):void{
    yourwebsite_mc.visible = true;
    var yourwebsiteXTween:Tween = new Tween(yourwebsite_mc, "x", Strong.easeOut, -200, 450, 4, true);

}
}