Reputation: 2950
I have about 200 photos that will run in a loop, there will be a fade-i and a fade-out between the images, is there any way to work with an array of images or something like that so I do not apply the same animation for all the images one by one?
I've tried this, but it don't respect my setInterval
:
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.Event;
stage.addEventListener(Event.ENTER_FRAME, sendToBack);
function sendToBack(event:Event):void{
setInterval(function(){
setChildIndex(getChildAt(2), 0);
var my_mc = getChildAt(2);
getChildAt(1).visible = false;
getChildAt(0).visible = false;
TransitionManager.start(my_mc, {
type: Fade
});
}, 2000);
}
Upvotes: 0
Views: 62
Reputation: 2950
I got the desired result with this code:
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.Event;
var childsNum = numChildren,
frameInterval = 3000,
fadeDuration = 0.5;
function hideAll(){
var i;
for (i = 0; i < numChildren; i++) {
getChildAt(i).visible = false;
}
}
hideAll();
function animateFrame(){
var child = getChildAt(childsNum - 1),
myTM:TransitionManager = new TransitionManager(child);
myTM.startTransition({
type: Fade,
duration: fadeDuration
});
myTM.addEventListener("allTransitionsInDone", function(){
setChildIndex(getChildAt(childsNum - 1), 0);
getChildAt(1).visible = false;
});
}
setInterval(function(){
animateFrame();
}, frameInterval);
Upvotes: 1