SHARE
Facebook X Pinterest WhatsApp

Create a Flash Slideshow with MovieClips Using the Fader API

Mar 5, 2010

This tutorial will show you how to create a slideshow using the Fader API. The Fader API can be used to create a sequence of fade animations and slideshows using less code.


Note: In this tutorial we are going to use the Fader API to create a slideshow from DisplayObjects (the base class for all objects that can be placed on the display list) that are present in the stage. This tutorial is written with the basic to intermediate developer in mind.


Difficulty: Basic to Intermediate. Even entry-level programmers and beginners can use this API easily. Some of the features incude:


  • 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 the Fader Class to create our Slideshow/animate DisplayObjects present on the stage. If you are trying to load images from an external URL use FaderFileMaterial instead.


Import the Classes:

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

Importing the external classes makes them available for use in our code.


Defining the duration variables:

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

Duration variables defines the time in seconds that the transition should take.


Create FaderItems:

var _faderItems:FaderItems = new FaderItems( 
fadeInDuration, fadeOutDuration );
_faderItems.addObject(rect1);
_faderItems.addObject(rect2);
_faderItems.addObject(rect3);

FaderItems is used as a 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 it into the animation.


Finally to create the 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 the step above. The second argument is the delay duration. The third argument is Boolean and specifies whether the animation should repeat after EOF and fades DisplayObjects using the given delay. Using the Fader Class, it is easy to create Slideshow or Fade animations.

Online Documents for Classes used



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 a more detailed description see the Documentation:


Download the

example source

to try the code out for yourself!

Recommended for you...

Shopify Alternatives
Helpful Tips for Designing a Landing Page that Converts
Five Essential HTML5 Editors
Best Web Hosting Providers
Enrique Corrales
May 31, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.