First time here? First time here? Newsletter Signup Newsletter
Search tutorials
Author: Saravanan | Website: http://www.designscripting.com/
The aim of this tutorial is to create slideshow using the FaderAPI. Fader API can be used to create Sequence of fade animations, Slideshows with less code.

Note: In this tutorial we are going to use Fader API to create slideshow from DisplayObjects present in stage. Not the dynamic one as we created in previous version. This tutorial is indented for basic – intermediate skill set. Follow the link to create slideshow dynamically using FaderFileMaterial

Difficulty: Basic - Intermediate. Even the entry level programmers and beginners can use this API easily.
Features: Some features are
• Less code
• Slide to slide transition
• No Preloader needed
• Customized events to handle slideshow

Flash Version:
Flash 9 + Actionscript 3.0

Using Fader Class:

We are going to use Fader Class to create Slideshow/animate DisplayObjects present at stage. If you are looking to load image from external URL use FaderFileMaterial.

Import the Classes:

import com.utils.Fader.*;
import com.utils.Fader.FaderItems;
import com.utils.Fader.Events.*;

Importing the external classes makes the external classes available to use in Code.

Defining the duration variables:

var fadeInDuration:Number = 1; var fadeOutDuration:Number = 3;

Duration variables define the time in seconds with the transition should take place.

Create FaderItems:

var _faderItems:FaderItems = new FaderItems(
fadeInDuration, fadeOutDuration );

FaderItems used as stack to store Display Object and TextField, The added items will be taken into account for creating the animation.

Just pass the instance name provided in the property window to add into animation.

Finally to create Fader:

var _fader:Fader = new Fader(_faderItems,5000,true);
_fader.addEventListener(ObjectEvent.FADER_INIT, handleInit);

Here we are just passing the FaderItems Object that we created in above step.

Second argument is the delay duration.

Third argument is Boolean which specifies whether the animation should repeat after EOF.

Fades DisplayObjects on given delay. Using the Fader Class it is easy to create Slideshow or of Fade animation

Online Documents for Classes used

Fader: http://www.designscripting.com/wp-content/uploads/2009/01/fader.html Faderitems: http://www.designscripting.com/wp-content/uploads/2009/01/faderitems.html

Entire Example:
import com.utils.Fader.*;
import com.utils.Fader.FaderItems;
import com.utils.Fader.Events.*;

var fadeInDuration:Number = 1;
var fadeOutDuration:Number = 3;

var _faderItems:FaderItems = new FaderItems( fadeInDuration, fadeOutDuration );

var _fader:Fader = new Fader(_faderItems,5000, true);
_fader.addEventListener(ObjectEvent.FADER_INIT, handleInit);
_fader.addEventListener(ObjectEvent.FADER_ITEM_INIT, handleItemInit);
_fader.addEventListener(ObjectEvent.FADER_ITEM_COMPLETE, handleItemComplete);
_fader.addEventListener(ObjectEvent.FADER_COMPLETE, handleComplete);

function handleInit(e:ObjectEvent):void { trace("::::::::::Fader Started:::::::::") }
function handleItemInit(e:ObjectEvent):void { trace("init:: "+e.targetObject.name) }
function handleItemComplete(e:ObjectEvent):void { trace("complete:: "+e.targetObject.name) }
function handleComplete(e:ObjectEvent):void { trace(":::::::::Fader Complete:::::::::") }

stop_mc.addEventListener(MouseEvent.CLICK, handleStop) function handleStop(e:MouseEvent):void{ _fader.stop(); }

play_mc.addEventListener(MouseEvent.CLICK, handlePlay) function handlePlay(e:MouseEvent):void{ _fader.start(); }

For more detailed description use the Documentation.

Fader Class http://www.designscripting.com/wp-content/uploads/2009/01/fader.html Faderitems Class http://www.designscripting.com/wp-content/uploads/2009/01/faderitems.html FaderURL Class http://www.designscripting.com/wp-content/uploads/2009/01/faderurl.html FaderFileMaterial http://www.designscripting.com/wp-content/uploads/2009/01/faderfilematerial.html

Find the example source for creating SlideShow using Fader with the source file.
» Level Intermediate

Added: 2009-02-13
Rating: 8 Votes: 5
» Author
saravanan Sr.Flash Developer. Running website http://www.designscripting.com/ Contains more advanced and intermediate tutorials.
» Download
Download the files used in this tutorial.
» Forums
More help? Search our boards for quick answers!
Featured Flash FLA
» Author: Inocreato
» Title: RaiseTheBlocks
» Description: Raise all the blocks to win the game
Featured Sound Loops
Image for equalize

Audio Player

» Author: TomCat Carty
» Title: The Wood
» Description: Just a little game ending or it can maybe be looped. Recorders with music box and percussion to give the feel of well, I don't know, the woods? Free to use, just credit me. thank you
Latest Font
» Author: Fábio FAFERS
» Description: I created this font for free use. Everyone can apply it in personal or business texts. Its free, but I want to be communicated in case of business use. Donations are accepted to keep the project of free fonts alive! Thank you all
Featured Sound Fx
Image for equalize

Audio Player

» Author: Davisigner
» Description: Hmm... what to say about this one? It's reminiscent of the closing notes of the opening music from the Three Stooges done in a church organ style with a closing cymbal crash. I'll give this one away gratis, but feel free to check out my free loops and potential upcoming license-mandated ones over in the respective part of Flashkit.