TransitionManager (2)
/**
* Copyright ProjectNya ( http://wonderfl.net/user/ProjectNya )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/bqJ3
*/
////////////////////////////////////////////////////////////////////////////////
// TransitionManager
////////////////////////////////////////////////////////////////////////////////
package {
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.Event;
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.utils.Timer;
import flash.events.TimerEvent;
[SWF(backgroundColor="#FFFFFF", width="465", height="465", frameRate="30")]
public class Main extends Sprite {
private var back:MovieClip;
private var redImage:MovieClip;
private var blueImage:MovieClip;
private var tm1:TransitionManager;
private var tm2:TransitionManager;
private var tm3:TransitionManager;
private var param1:Object;
private var param2:Object;
private var param3:Object;
public function Main() {
//Wonderfl.capture_delay(1);
init();
}
private function init():void {
back = new MovieClip();
addChild(back);
back.x = 32;
back.y = 32;
back.graphics.beginFill(0x000000);
back.graphics.drawRect(0, 0, 400, 400);
back.graphics.endFill();
//
redImage = new MovieClip();
addChild(redImage);
redImage.x = 32;
redImage.y = 32;
redImage.graphics.beginFill(0xFF0000);
redImage.graphics.drawRect(0, 0, 400, 400);
redImage.graphics.endFill();
//
blueImage = new MovieClip();
addChild(blueImage);
blueImage.x = 32;
blueImage.y = 32;
blueImage.graphics.beginFill(0x0000FF);
blueImage.graphics.drawRect(0, 0, 400, 400);
blueImage.graphics.endFill();
//
//none --> red
tm1 = new TransitionManager(redImage);
param1 = {
type: PixelDissolve,
direction: Transition.IN,
duration: 3,
easing: None.easeNone,
xSections: 70, ySections: 15
};
tm1.addEventListener("allTransitionsInDone", done1, false, 0, true);
//
//red --> blue
tm2 = new TransitionManager(blueImage);
param2 = {
type: Blinds,
direction: Transition.IN,
duration: 3,
easing: None.easeNone,
numStrips: 10,
dimension: 0
};
tm2.addEventListener("allTransitionsInDone", done2, false, 0, true);
//
//blue --> none
tm3 = new TransitionManager(blueImage);
param3 = {
type: Iris,
direction: Transition.OUT,
duration: 3,
easing: Strong.easeOut,
startPoint: 5,
shape:Iris.CIRCLE
};
tm3.addEventListener("allTransitionsOutDone", done3, false, 0, true);
//
blueImage.visible = false;
tm1.startTransition(param1);
}
private function done1(evt:Event): void {
var timer:Timer = new Timer(2000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, next1, false, 0, true);
timer.start();
}
private function next1(evt:TimerEvent): void {
evt.target.removeEventListener(TimerEvent.TIMER_COMPLETE, next1);
tm2.startTransition(param2);
}
private function done2(evt:Event): void {
redImage.visible = false;
var timer:Timer = new Timer(2000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, next2, false, 0, true);
timer.start();
}
private function next2(evt:TimerEvent): void {
evt.target.removeEventListener(TimerEvent.TIMER_COMPLETE, next2);
tm3.startTransition(param3);
}
private function done3(evt:Event): void {
blueImage.visible = false;
var timer:Timer = new Timer(2000, 1);
timer.addEventListener(TimerEvent.TIMER_COMPLETE, next3, false, 0, true);
timer.start();
}
private function next3(evt:TimerEvent): void {
evt.target.removeEventListener(TimerEvent.TIMER_COMPLETE, next3);
tm1.startTransition(param1);
}
}
}