spacer

home / experts / dhtml / column25
Developer News
News Flash: Adobe Has iPhone Workaround
Adobe's Flash 10.1 Goes Mobile (Minus iPhone)
A Salute to Visionary CEOs

Logo

Dynamic Headline Fader, Version 2.0
starting the transitions


startIt()

The Version 2 startIt() function is almost identical to its Version 1 predecessor. The one major difference is that startIt() now has one argument, the arNews index:

function startIt(ind){
   newsCount = ind;
   if (finite) loopCount = 0;
   doIt();
   blendTimer = setInterval("doIt()",blendInt*1000)
}

This argument is assigned to newsCount, which will track our position in the array as we move through it. If finite is true, then we should also be counting the full loops through the array. To this end, we declare loopCount.

We then begin the transitions by calling doIt() once to display the first text. When we return from the first display, we use setInterval() to call doIt() repeatedly. We assign this timer to the blendTimer variable.

doIt()

Unlike startIt(), doIt() is quite different from its earlier incarnation. It is much shorter, and relies on two new functions, endIt() and fadeIt(), to perform tasks it once did.

function doIt() {
   if (finite && loopCount==maxLoops) {
      endIt();
      return;
   }
   fadeIt();
   newsCount+=2;
   if (newsCount == arNews.length) {
      newsCount = 0;
      if (finite) loopCount++;
   }
}

First doIt() determines if it should proceed. If finite is false, and endless loops are called for, it proceeds. If finite is true, it compares loopCount and maxLoops. If they are the same, then the transitions should be halted, endIt() is called, and doIt() returns.

If doIt() proceeds, it calls fadeIt() to perform the transition. Once the transition is done, newsCount is incremented by 2 (two array elements for every fader item), and compared to the length of arNews. If they are equal, the end of the array has been reached, so a new loop through the array is called for. newsCount is reinitialized to 0, and loopCount is conditionally incremented.

Simple as that. Now, let's look at fadeIt(), which actually performs the transitions.


Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Building a Banking Application Home Page with OOP · Mixing Scripting Languages · Review: phpFox, a Social Networking CMS with all the Bells and Whistles
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Enterprise 2.0: Social Networking in the Cloud · BroadSoft Marketplace Hastens Pace of Telephony Innovation · Review: HTC Hero for Sprint

All Rights Reserved. Legal Notices.
Created: Sep 07, 1999
Revised: Sep 07, 1999

URL: http://www.webreference.com/dhtml/column25/fade2start.html