13 Replies Latest reply on Feb 10, 2011 7:10 AM by kglad

    Runtime image reflection not working

    tatiana1

      Hi all,

       

      I'm trying to create an image reflection at runtime, using this code I found on the WEB. It all seems to work fine as long as I'm loading an image from the local drive, but when I try loading an image from a remote server, the reflection no longer appears. Anyone know why?

       

      import flash.display.BitmapData;
      import flash.geom.Matrix;
      this.createEmptyMovieClip("image_mc", 1);
      var mclListener:Object = new Object();
      mclListener.onLoadInit = function(target_mc:MovieClip) {
      target_mc._x = (Stage.width/2)-(target_mc._width/2);
      target_mc._y = 0;
      reflect(target_mc);
      };
      var image_mcl:MovieClipLoader = new MovieClipLoader();
      image_mcl.addListener(mclListener);
      image_mcl.loadClip("none.jpg", image_mc);
      function reflect(target_mc:MovieClip):Void{
      var myBitmapData:BitmapData = new BitmapData(target_mc._width, target_mc._height, false, 0x00CCCCCC);
      var mc_1:MovieClip = this.createEmptyMovieClip("reflect_mc", 2);
      mc_1.attachBitmap(myBitmapData, 3);
      myBitmapData.draw(target_mc);
      reflect_mc._yscale = -100;
      reflect_mc._y= target_mc._y+target_mc._height*2+20;
      reflect_mc._x = target_mc._x;
      setupReflection(reflect_mc);
      }
      function setupReflection(target_mc:MovieClip):Void{
      this.createEmptyMovieClip("mask_mc",50);
      with (mask_mc)
      {
      colors = [0x000000, 0xFFFFFF];
      fillType = "linear"
      alphas = [100, 100];
      ratios = [127, 255];
      spreadMethod = "pad";
      interpolationMethod = "RGB";
      focalPointRatio = 1;
      matrix = new Matrix();
      matrix.createGradientBox(target_mc._x, target_mc._y, Math.PI/2, 0, -150);
      beginGradientFill(fillType, colors, alphas, ratios, matrix,
      spreadMethod, interpolationMethod, focalPointRatio);
      moveTo(target_mc._x, target_mc._y);
      lineTo(target_mc._x, target_mc._y-target_mc._height);
      lineTo(target_mc._x+target_mc._width, target_mc._y-target_mc._height);
      lineTo(target_mc._x+target_mc._width, target_mc._y);
      lineTo(target_mc._x, target_mc._y);
      endFill();
      }}