我有一个带有动态XML内容的AS3 Flash文件,我需要它在完成时重新启动

时间:2013-03-15 04:04:10

标签: actionscript-3 loops actionscript flash

我的代码加载了3个随机图片,而我没有使用时间轴。我需要在一段时间后重新启动swf,以便电影可以重新加载新图像并重放电影。目前它不会循环。

import com.greensock.*;
import com.greensock.easing.*


box1.back.rotationY = -90;
box1.back.alpha=0;



var flipSpeed:Number = .25; 



var tl:TimelineMax = new TimelineMax({delay:2});

tl.append(TweenMax.to(box1.front, flipSpeed, {rotationY:90, visible:false, ease:Linear.easeNone}))
tl.append(TweenMax.to(box1.back, 0, {alpha:1, immediateRender:false}))
tl.append(TweenMax.to(box1.back, flipSpeed, {rotationY:0, ease:Linear.easeNone}))

var tb:TimelineMax = new TimelineMax({delay:4});

box2.back2.rotationY = -90;
box2.back2.alpha=0;


tb.append(TweenMax.to(box2.front2, flipSpeed, {rotationY:90, visible:false, ease:Linear.easeNone}))
tb.append(TweenMax.to(box2.back2, 0, {alpha:1, immediateRender:false}))
tb.append(TweenMax.to(box2.back2, flipSpeed, {rotationY:0, ease:Linear.easeNone}))

var ins:TimelineMax = new TimelineMax({delay:6});

box3.back3.rotationY = -90;
box3.back3.alpha=0;

ins.append(TweenMax.to(box3.front3, flipSpeed, {rotationY:90, visible:false, ease:Linear.easeNone}))
ins.append(TweenMax.to(box3.back3, 0, {alpha:1, immediateRender:false}))
ins.append(TweenMax.to(box3.back3, flipSpeed, {rotationY:0, ease:Linear.easeNone}))

var per:TimelineMax = new TimelineMax({delay:7});

person.back_person.rotationY = -90;
person.back_person.alpha=0;

per.append(TweenMax.to(person.front_person, flipSpeed, {rotationY:90, visible:false, ease:Linear.easeNone}))
per.append(TweenMax.to(person.back_person, 0, {alpha:1, immediateRender:false}))
per.append(TweenMax.to(person.back_person, flipSpeed, {rotationY:0, ease:Linear.easeNone}));

- 我还有动画片段中的内容,它们加载来自XML文档的图像,但这就是我在主动作层上的内容。

1 个答案:

答案 0 :(得分:0)

例如,您可以尝试这种方法:

  1. 将您的代码包装成函数
  2. 在一段时间后回忆起自己
  3. 不要忘记在启动时调用该函数
  4. 示例:

    import flash.utils.*;    // required for setTimeout
    
    function doStuff() {
        …
        setTimeout(doStuff, 8000);
    }
    
    doStuff();