3 Replies Latest reply on Oct 30, 2006 9:52 PM by kglad

    ColorTransform on a loadMovie

    j-eggs
      I'm trying to do a color transform on a loaded movie completely within action script. I can do the transform on a dynamically created movieclip. I can do the color transform on a movieClip that has been imported, but I can't do the transform on a loaded movieclip. The following code works to change the color of a box, but when I uncomment the loadmovie option, the box disappears and the loaded movieclip is displayed without any hitArea.


      import flash.geom.Transform;
      import flash.geom.ColorTransform;

      var building:MovieClip = createRectangle(300,80,0, true);
      //loadMovie("file://localhost/Users/eggers/Desktop/abelson.swf",building);
      building.hitArea = createRectangle(300,300,0, false);

      var trans:Transform = new Transform(building);
      trace(trans.colorTransform);
      // (redMultiplier=1, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=0, alphaOffset=0)

      var blueColorTransform:ColorTransform = new ColorTransform(0, 1, 1, 1, 0, 0, 255, 0);

      building.onPress = function() {
      trans.colorTransform = blueColorTransform;
      trace(trans.colorTransform);
      // (redMultiplier=0, greenMultiplier=1, blueMultiplier=1, alphaMultiplier=1, redOffset=0, greenOffset=0, blueOffset=255, alphaOffset=0)
      }

      function createRectangle(width:Number, height:Number, color:Number, vis:Boolean):MovieClip {
      scope = this
      var depth:Number = scope.getNextHighestDepth();
      var mc:MovieClip = scope.createEmptyMovieClip("mc_" + depth, depth);
      mc.beginFill(color);
      mc.lineTo(0, height);
      mc.lineTo(width, height);
      mc.lineTo(width, 0);
      mc.lineTo(0, 0);
      mc._visible = vis;
      return mc;
      }