First time here? First time here? Newsletter Signup Newsletter
Login | Register | 651326 Members and growing!
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.addObject(rect1);
_faderItems.addObject(rect2);
_faderItems.addObject(rect3);

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);
_fader.addEventListener(ObjectEvent.FADER_ITEM_INIT,
handleItemInit);
_fader.addEventListener(ObjectEvent.FADER_ITEM_COMPLETE,
handleItemComplete);
_fader.addEventListener(ObjectEvent.FADER_COMPLETE,
handleComplete);
_fader.start();

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 );
_faderItems.addObject(rect1);
_faderItems.addObject(rect2);

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);
_fader.start();

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
(10 being the highest)
» 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!

Comments

  • There are no comments yet. Be the first to comment!

  • You must have javascript enabled in order to post comments.

Leave a Comment
  • Your email address will not be published. All fields are required.
Featured Flash FLA
» Author: work2survive
» Title: Girl Walking 1kb
» Description: Walking girl, animation just takes 1kb, using high heels shoes, and fashion model attitude.
Featured Sound Loops
Image for equalize

Audio Player

» Author: BoxCat
» Title: CPU Talk
» Description: From the cyberpunk RPG, "Nameless: the Hackers" Completely Free to use! Keywords: edm hip hop rap electronic mysterious mission hacking chase exciting spy ios ambient chilling love happy sad angry suspense
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: nathan
» Description:

A recorded sound of the Dimensional Fork Gate.