| There are many free, open source ActionScript libraries available on the web that can save you a lot of time and frustration when creating Flash projects. One of my readers recently sent me an email asking how to install a water ripple script that he found on the web. He found the script on the Emanuele Feronato website (emanueleferonato.com) and downloaded the zip file that contained the standalone Rippler class. The problem was that he was having trouble installing the class in his own project. I thought this would make a good tutorial about how to use a top-level document class. In ActionScript 3, you can associate a class with a swf file at the top-level and Flash will automatically make an instance of this Document class as a top-level object when the swf loads. This is a fancy way of saying that Flash will import an external ActionScript file when the swf loads into the Flash Player. For the Ripple class from the Emanuele Feronato website you will find four files in the water.zip download file (water.fla, water.swf, Ripple.as and Rippler.as). http://www.emanueleferonato.com/2011/01/19/creation-of-realistic-flash-water-ripples-with-as3/ We can open the water.fla file and check out how the author has set up the animation. The fla file is empty of any ActionScript and only has one thing which is a movie clip. The top-level Document class associated with the swf file is the Ripple.as file. The ripple effect is applied to the movie clip named toRipple. This movie clip is empty except for the background jpg graphic. The ActionScript will create the ripple effect on top of this jpg. To use this class with your project, you will need to copy the Ripple.as and Rippler.as files into the same folder as your project's fla file. Next, you need to setup your project fla to match the default settings for the class.
Join us in the Flash forum. | Join us in the Digital Art and Design forum. | |


















