home page icon Flash Bestiary / Oddments / Jolly Roger
   

Jolly Roger

This script provides an actionscript-based method for producing a waving flag effect on any image. The next two movies provide similar examples with different images.

The image is divided up into narrow vertical strips using masks. Then the strips are rotated slightly using sin waves. This produces apparent motion in both the x and y directions.

The motion propagates from the left edge of the flag to the right edge, producing the effect that the wind is blowing from the left.

The function that animates the flag reads as follows:

flag0.onEnterFrame = function()
{
  for (var i = kNbrStrips-1; i>0; --i) {
    flags[i]._rotation = flags[i-1]._rotation;
  }
  var t = getTimer();
  this._rotation = Math.sin(t*.001+Math.cos(t*.0005)*Math.PI*2)*2;
};

 

sourcecode iconDownload the flash project
book iconJim's Favorite Actionscript Books
wiki iconAsk Jim about Actionscript
Next: American Flag

Having trouble opening the project? You may need to Upgrade to Flash MX 2004



Copyright © 2003,2004 by Jim Bumgardner. All Rights Reserved.        Leave Jim some feedback