5 Replies Latest reply on Mar 16, 2012 6:04 AM by kglad

    Filter effect

    santhosh kumar mallepaddy Level 1

      Hi all,

       

       

      I tryed to crate a water wave effect using as3.0. I wrote the script like this,

       

       

      import flash.filters.*

      import flash.geom.*

      import flash.display.*;

      import flash.events.Event;

       

       

      var offset:Array

      var filterList

       

      //water_mc is the target movie clip

       

      createWater(water_mc);

       

       

      function createWater(target:MovieClip):void {

                target.counter=1;

                target.pt=new Point(0,0);

                target.mpoint=new Point(0,0);

                target.myBitmap=new BitmapData(target.width,target.height,false,0);

                target.myDispl=new DisplacementMapFilter(target.myBitmap,target.mpoint,10,2,0.1,0.15,"clamp");

       

       

                target.myList = new Array();

                target.myList.push(target.myDispl);

                target.filters=target.myList;

       

                target.addEventListener(Event.ENTER_FRAME, onenter)

                function onenter(event){

                               filterList = target.filters

                               offset=new Array()

                               offset[1]=new Object()

                               offset[1].x = target.counter

             offset[1].y = target.counter/8

             target.myBitmap.perlinNoise(45,5,3,50,true,false,5,true,offset)

                               filterList.mapBitmap = target.myBitmap;

                               target.filters = filterList;

                               target.counter++;

                }

      }

       

       

      this is I got from some website. I got as2.0 script, I tried to convert that into as3.0,but it is not working. Please help me on converting as2 to as3........

       

      Thanks in Advance

       

       

       

       

       

      Thanks and Regards

      Santhosh Kumar M

        • 1. Re: Filter effect
          kglad Adobe Community Professional & MVP

          copy and paste the working as2 code.

          • 2. Re: Filter effect
            santhosh kumar mallepaddy Level 1

            Hi Kglad,

             

            here is the code......

             

             

            import flash.display.*;

            import flash.geom.*;

            import flash.filters.*;

             

            createWater(water_mc);

             

            function createWater(target:MovieClip):Void

            {

                      target.counter = 1;

                      target.pt = new Point(0, 0);

                      target.mpoint = new Point(0, 0);

                      target.myBitmap = new BitmapData(target._width, target._height, false, 0);

                      target.myDispl = new DisplacementMapFilter(target.myBitmap, target.mpoint, 10, 2, 10, 15, "clamp");

             

                      target.myList = new Array();

                      target.myList.push(target.myDispl);

                      target.filters = target.myList;

             

                      target.onEnterFrame = function() {

                                filterList = target.filters;

                                offset = new Array();

                                offset[1] = new Object();

                                offset[1].x = target.counter;

                                offset[1].y = target.counter/8;

                                target.myBitmap.perlinNoise(45,5,3,50,true,false,7,true,offset);

                                filterList.mapBitmap = target.myBitmap;

                                target.filters = filterList;

             

                                target.counter++;

                      };

            }

            • 3. Re: Filter effect
              kglad Adobe Community Professional & MVP

              use:

               

               

              createWater(water_mc);

               

              function createWater(target:MovieClip):void {

                  target.counter=1;

                  target.pt=new Point(0,0);

                  target.mpoint=new Point(0,0);

                  target.myBitmap=new BitmapData(target.width,target.height,false,0);

                  target.myDispl=new DisplacementMapFilter(target.myBitmap,target.mpoint,10,2,10,15,"clamp");

               

                  target.myList = new Array();

                  target.myList.push(target.myDispl);

                  target.filters=target.myList;

               

                  target.addEventListener(Event.ENTER_FRAME,enterframeF);

              }

               

              function enterframeF(e:Event):void {

                  var target:MovieClip = MovieClip(e.currentTarget)

                  var filterList:Array=target.filters;

                  var offset:Array = new Array(new Point(target.counter,target.counter/8));

                  target.myBitmap.perlinNoise(45,5,3,50,true,false,7,true,offset);

                  target.filters=filterList;

                  target.counter++;

              }

              • 4. Re: Filter effect
                santhosh kumar mallepaddy Level 1

                Thanks kglad it's working....... thank you very much.

                • 5. Re: Filter effect
                  kglad Adobe Community Professional & MVP

                  you're welcome.