0

これが私のメインフレームのコードです。コードを上から下に 3 回だけ読み取るページが必要です。どうすれば45秒で止まるか考えられても。すみません、私は脳死状態でもう何も考えられません。何かアドバイス?

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

import flash.utils.*;

function doStuff() {

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

    var flipSpeed:Number = .25; 
    var flipSpeedbea:Number = .04; 

    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}))
    tl.append(TweenMax.to(box1.front, flipSpeed, {rotationY:0, visible:true, 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}))
    tb.append(TweenMax.to(box2.front2, flipSpeed, {rotationY:0, visible:true, 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}))
    ins.append(TweenMax.to(box3.front3, flipSpeed, {rotationY:0, visible:true, 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}));

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

    be_a.bea_back.rotationY = -90;
    be_a.bea_back.alpha=0;

    bea.append(TweenMax.to(be_a.bea_front, flipSpeedbea, {rotationY:90, visible:false, ease:Linear.easeNone}))
    bea.append(TweenMax.to(be_a.bea_back, 0, {alpha:1, immediateRender:false}))
    bea.append(TweenMax.to(be_a.bea_back, flipSpeedbea, {rotationY:0, ease:Linear.easeNone}));
    bea.append(TweenMax.to(be_a.bea_front, flipSpeedbea, {rotationY:0, visible:true, ease:Linear.easeNone}))

    stop();

    setTimeout(doStuff, 15000);
}

doStuff();

doStuff に関数を設定して、45 秒間だけ機能し続けることは可能ですか? 基本的に、それぞれ15秒で3回再生するには、「doStuff」関数が必要です。

4

2 に答える 2

0

最初の解決策は、タイマーを使用する必要がないように、変数をカウンターとして使用することです。

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

import flash.utils.*;

var box1:Object;
var box2:Object;
var box3:Object;
var person:Object;
var be_a:Object;

function stop() {}

var stuffCount:uint = 0;

function doStuff() {

    stuffCount++;

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

    var flipSpeed:Number = .25; 
    var flipSpeedbea:Number = .04; 

    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}))
    tl.append(TweenMax.to(box1.front, flipSpeed, {rotationY:0, visible:true, 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}))
    tb.append(TweenMax.to(box2.front2, flipSpeed, {rotationY:0, visible:true, 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}))
    ins.append(TweenMax.to(box3.front3, flipSpeed, {rotationY:0, visible:true, 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}));

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

    be_a.bea_back.rotationY = -90;
    be_a.bea_back.alpha=0;

    bea.append(TweenMax.to(be_a.bea_front, flipSpeedbea, {rotationY:90, visible:false, ease:Linear.easeNone}))
    bea.append(TweenMax.to(be_a.bea_back, 0, {alpha:1, immediateRender:false}))
    bea.append(TweenMax.to(be_a.bea_back, flipSpeedbea, {rotationY:0, ease:Linear.easeNone}));
    bea.append(TweenMax.to(be_a.bea_front, flipSpeedbea, {rotationY:0, visible:true, ease:Linear.easeNone}))

    stop();

    if (stuffCount < 3)
    {
        setTimeout(doStuff, 15000);
    }
}

doStuff();

Timer:を使用した2番目のソリューション

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

import flash.events.TimerEvent;
import flash.utils.*;


function doStuff() {

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

    var flipSpeed:Number = .25; 
    var flipSpeedbea:Number = .04; 

    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}))
    tl.append(TweenMax.to(box1.front, flipSpeed, {rotationY:0, visible:true, 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}))
    tb.append(TweenMax.to(box2.front2, flipSpeed, {rotationY:0, visible:true, 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}))
    ins.append(TweenMax.to(box3.front3, flipSpeed, {rotationY:0, visible:true, 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}));

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

    be_a.bea_back.rotationY = -90;
    be_a.bea_back.alpha=0;

    bea.append(TweenMax.to(be_a.bea_front, flipSpeedbea, {rotationY:90, visible:false, ease:Linear.easeNone}))
    bea.append(TweenMax.to(be_a.bea_back, 0, {alpha:1, immediateRender:false}))
    bea.append(TweenMax.to(be_a.bea_back, flipSpeedbea, {rotationY:0, ease:Linear.easeNone}));
    bea.append(TweenMax.to(be_a.bea_front, flipSpeedbea, {rotationY:0, visible:true, ease:Linear.easeNone}))

    stop();
}

function onTimer(event:TimerEvent):void
{
    doStuff();
}

var myTimer:Timer = new Timer(15000, 3);
myTimer.addEventListener(TimerEvent.TIMER, onTimer);
myTimer.start();
doStuff();
于 2013-03-18T21:32:04.283 に答える
0

doStuff15 秒間隔で 3 回呼び出したい場合は、 のsetTimeout内部からへの呼び出しを削除し、次のdoStuffようにします。

var stuffTimer:Timer = new Timer(15000, 2);
stuffTimer.addEventListener(TimerEvent.TIMER, doStuff)
doStuff(null);
stuffTimer.start();

doStuffTimerEvent を受け入れるようにメソッドを変更する必要があります。

function doStuff(e:TimerEvent):void
{
    [...]
}

関係ありませんが、インポートをdoStuffメソッドの外に移動し、最初のインポートステートメントと一緒にグループ化する必要があります。

于 2013-03-18T21:26:09.877 に答える