8 Replies Latest reply on Jul 6, 2009 6:23 AM by kglad

    Problem with the reflection of a movieClip(image)

    Sreelash Level 1

      Hi,

                               I am trying to provide  a reflection for the images(movieclips) that I loaded on the stage. For this purpose I am using a reflection class. The class can be used with action script 2. the reflection is working finely. Also after loading the image or movieclip, I tried to give tweening for that image or movieclips. Thus also it works finely. The reflection of that also moves along with the actual image. The problem comes with the resizing the actual image. If I resize the actual image, the reflection would not be seen under the actual image.Can anybody know why it may happening like that. After searching for a long time, I got this class. I was happpy on cing them. But unfortunately, the reflection would not be working when the image or moviclip resizes. If anybody  have idea of being like this, plz inform meWaiting for ur reply.I have attached the class with this thread.Plz refer it.

       

      Thanks and regards,

                      Sreelash.S

             .

        • 1. Re: Problem with the reflection of a movieClip(image)
          Sreelash Level 1

          Following class was used for reflection. Can anybody make a look on it.

           

           

           

          import flash.display.BitmapData;

           

          class Reflect {

           

            
             
              private var version:String = "2.0";
             
              private var mcBMP:BitmapData;
             
              private var reflectionBMP:BitmapData;
             
              private var updateInt:Number;
             
             
             
              function Reflect(mc:MovieClip, alpha:Number, ratio:Number, updateTime:Number) {
             
              //create a bmp obj out of it
             
              mcBMP = new BitmapData(mc._width, mc._height, true, 0xFFFFFF);
             
              mcBMP.draw(mc);
             
              reflectionBMP = new BitmapData(mc._width, mc._height, true, 0xFFFFFF);
             
              reflectionBMP.draw(mc);
             
              mc.createEmptyMovieClip("reflection_mc", mc.getNextHighestDepth());
             
              mc.reflection_mc.attachBitmap(mcBMP, 1);
             
              mc.reflection_mc._yscale = -100;
             
              mc.reflection_mc._y = mc._height;
             
             
             
              //create the gradient mask
             
              mc.createEmptyMovieClip("gradientMask_mc", mc.getNextHighestDepth());
             
              var fillType:String = "linear";
             
              var colors:Array = [0xFFFFFF, 0xFFFFFF];
             
              var alphas:Array = [alpha, 0];
             
              var ratios:Array = [0, ratio];
             
              var matrix = {matrixType:"box", x:0, y:0, w:mc._width, h:mc._height/4, r:(90/180)*Math.PI};
             
              var spreadMethod:String = "pad";
             
              mc.gradientMask_mc.beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod);
             
              mc.gradientMask_mc.moveTo(0, 0);
             
              mc.gradientMask_mc.lineTo(0, mc._height/2);
             
              mc.gradientMask_mc.lineTo(mc._width, mc._height/2);
             
              mc.gradientMask_mc.lineTo(mc._width, 0);
             
              mc.gradientMask_mc.lineTo(0, 0);
             
              mc.gradientMask_mc.endFill();
             
              mc.gradientMask_mc._y = mc._height/2;
             
              mc.reflection_mc.cacheAsBitmap = true;
             
              mc.gradientMask_mc.cacheAsBitmap = true;
             
              mc.reflection_mc.setMask(mc.gradientMask_mc);
             
              updateInt = setInterval(this, "update", updateTime, mc);
             
             
              }
             
              private function update(mc):Void{
             
              mcBMP.draw(mc);
             
              reflectionBMP.draw(mc);
             
              mc.reflection_mc.attachBitmap(mcBMP, 1);
             
              }

           

          }

          • 2. Re: Problem with the reflection of a movieClip(image)
            kglad Adobe Community Professional & MVP

            you can probably just use:

             


                mc.reflection_mc._y = mc._height;

             

            where mc is your movieclip that you passed to the class.

            • 3. Re: Problem with the reflection of a movieClip(image)
              Sreelash Level 1

              Hi k_glad,

                                                      Actually I didn't get what you meant. Can you just explain it. Did you understand my problem. Is there any need to explain more about my problem.

              • 4. Re: Problem with the reflection of a movieClip(image)
                kglad Adobe Community Professional & MVP

                when you call Reflect(), you pass several parameters.  the first is a movieclip reference (say, mc).

                 

                and when you change that movieclip's height, the reflection doesn't look right.  so, when you change the movieclip's height (by scaling or any other means), use the code i showed above.

                • 5. Re: Problem with the reflection of a movieClip(image)
                  Sreelash Level 1

                  ok glad, i ll check it inform you . thank u.

                  • 7. Re: Problem with the reflection of a movieClip(image)
                    Sreelash Level 1

                    Hi kglad, The time that u specified this problem, I cudn't try it immediately. Actullay a line of code that u specified is already written in the Reflect class. Where should I write the folowing piece of code?

                     

                     

                    mc.reflection_mc._y = mc._height;

                    • 8. Re: Problem with the reflection of a movieClip(image)
                      kglad Adobe Community Professional & MVP

                      that line should execute after you resize an image that has a reflection.