OOPs: More Classes

Get Adobe Flash player
  1. Download the Water.as class and save it in your project directory.
  2. Download the pond project and save it in the same directory.
The code for the Flag class is shown below:
package {
	import flash.display.*;
	import flash.geom.*;
	import flash.filters.*;
	import flash.events.*;
	public class Water extends MovieClip {
   		 	var bm:BitmapData;
            var disp:DisplacementMapFilter;
            var pt1:Point = new Point(0,0);
            var pt2:Point = new Point(0,0);
            var perlinOffset:Array = [pt1, pt2];
            public function Water() {//constructor
                bm=new BitmapData(this.width, this.height);
				disp=new DisplacementMapFilter(bm,new Point(0,0),1,2,10,60);
                addEventListener(Event.ENTER_FRAME, frames);
           function frames(e:Event):void {
               perlinOffset[0].x +=1;
               perlinOffset[1].y +=0.1;
               bm.perlinNoise(45,9,2,50,true,false, 7,true,perlinOffset);
		   } //frames
     } //class
} //package
The pond is just a blue rectangle with a few streaks of other colors in it:
pond water

NEXT: A Flag Class