English 中文(简体)
科罗拉·鲁德冲走了阴影
原标题:ColorTransform removes shadow

I ve got movie clip on stage that has shadow filter. When I apply ColorTransform to that movie clip, the shadow removes.

        var ct:ColorTransform = new ColorTransform;
        ct.color = 0x99CC00;
        lamp.transform.colorTransform = ct;

如何拯救阴影?

问题回答

设想是

  1. save the filters (shadow) of your clip lamp,
  2. apply the transformation,
  3. put the clip in a master clip and
  4. re-apply the filters to this untransformed parent.

法典:

var lampFilters:Array = lamp.filters.slice();    //save filters

lamp.filters = [];                               //empty filters
var ct:ColorTransform = new ColorTransform();
ct.color = 0x99CC00;
lamp.transform.colorTransform = ct;              //apply your transformation
var superLamp:Sprite = new Sprite();
superLamp.addChild(lamp);                        //nest the clip
addChild(superLamp);

superLamp.filters = lampFilters;                 //re-apply the filters

<代码>Color Transform将改变整个电影剪辑,但不幸的是,过滤器已经包括在内。 我建议你们的层层<代码>lamp,并将这一转变应用于维持底层层(影子)的顶层。

试验实例:

var ball:Sprite = new Sprite();
ball.graphics.beginFill(0x00FF00, 1);
ball.graphics.drawCircle(50, 50, 50);
ball.graphics.endFill();
ball.filters = [new DropShadowFilter()]; //default black
ball.addEventListener(MouseEvent.CLICK, changeColor);
addChild(ball);

//...
private function changeColor(evt:MouseEvent):void {
    var ball:Sprite = evt.target as Sprite;
    var ct:ColorTransform = new ColorTransform();
    ct.color = 0x99CC00; // green-ish
    ball.transform.colorTransform = ct;
    ball.filters = [new DropShadowFilter(4, 45, 0xFFFFFF)]; //now white
}

即便是用“影子”过滤器进行再应用,你也会看到,它仍然会像变革所决定的绿色化。

你们应当使用nes物来实现这一目标。

for instance you can create a movieclip within another movieclip. apply the colortransform to inner movie clip and apply the shadow to outer movie clip. works like a charm for me :)

这里是一种不需要父母反对的替代方法。 你基本上使用AdjustColor和Matrix来改变肤色,而不是改变科罗图。

注:如果你使用“闪电”以外的“电离层”系统,如“灵活或闪电”,则你需要包括闪电。 从共同/构思/行动平台进入你的图书馆 3.0/libs/flash.swc for the fl.motion.AdjustorCol Pack/class. 你们也可以是谷歌。

    var mc:Sprite = new Sprite();
    mc.graphics.beginFill(0xFF0000);
    mc.graphics.drawCircle(100, 100, 100);
    mc.graphics.endFill();
    addChild(mc); 

    // White out the entire shape first
    var whiteAC:AdjustColor = new AdjustColor();
    whiteAC.brightness = 100;
    whiteAC.contrast = 100;
    whiteAC.saturation = -100;
    whiteAC.hue = 0;            
    var whiteMatrix:Array = whiteAC.CalculateFinalFlatArray();
    var whiteCMF:ColorMatrixFilter = new ColorMatrixFilter(whiteMatrix);

    // Now use ColorMatrixFilter to change color
    var colorMatrix:Array = hexToMatrix(0x0000FF);
    var colorCMF:ColorMatrixFilter = new ColorMatrixFilter(colorMatrix);

    // Create Drop Shadow 
    var myDropShadow:DropShadowFilter = new DropShadow();

    mc.filters = [whiteCMF, colorCMF, myDropShadow];

    function hexToMatrix ( hex:uint, alpha:Number = 1 ) 
    {
        var r:Number = ((hex & 0xFF0000) >> 16);
        var g:Number = ((hex & 0x00FF00) >> 8);
        var b:Number = ((hex & 0x0000FF));

        var matrix:Array = [];
        matrix = matrix.concat([r, 0, 0, 0, 0]); // red
        matrix = matrix.concat([0, g, 0, 0, 0]); // green
        matrix = matrix.concat([0, 0, b, 0, 0]); // blue
        matrix = matrix.concat([0, 0, 0, alpha, 0]); // alpha
        return matrix;
    }




相关问题
Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...

热门标签