Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>colorTransform will apply to the entire movieclip including any children and filters. If you try a drop shadow, you will see what I mean.</p> <p>METHOD #1: You can create a parent object with the bevel filter and attach your movieclip with colorTransform.</p> <pre><code> var parentObject:Sprite = new Sprite(); addChild(parentObject); var mc:Sprite = new Sprite(); mc.graphics.beginFill(0xFFFF00); mc.graphics.drawCircle(100,100, 100); mc.graphics.endFill(); var blue:ColorTransform = new ColorTransform(); blue.color = 0xFF00B8; var myBevel:BevelFilter = new BevelFilter(); myBevel.type = BitmapFilterType.INNER; myBevel.distance = 3; myBevel.highlightColor = 0xFFFFFF; myBevel.shadowColor = 0x000000; myBevel.blurX = 5; myBevel.blurY = 5; parentObject.filters = [myBevel]; parentObject.addChild(mc); mc.transform.colorTransform = blue; </code></pre> <p>METHOD #2: To avoid having a parent object to handle the bevel, I used two ColorMatrixFilters with an AdjustColor to accomplish what you are looking for. You will end up with 3 filters, one to make the object white, one to change to the color you want, and the last bevel filter. If you are using an IDE other than Flash, like Flex or FlashDevelop, you will need to include flash.swc into your library from 'Common/Configuration/ActionScript 3.0/libs/flash.swc' for the fl.motion.AdjustColor package/class.</p> <pre><code> 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 bevel var myBevel:BevelFilter = new BevelFilter(); myBevel.type = BitmapFilterType.INNER; myBevel.distance = 3; myBevel.highlightColor = 0xFFFFFF; myBevel.shadowColor = 0x000000; myBevel.blurX = 5; myBevel.blurY = 5; mc.filters = [whiteCMF, colorCMF, myBevel]; function hexToMatrix ( hex:uint, alpha:Number = 1 ) { var r:Number = ((hex &amp; 0xFF0000) &gt;&gt; 16); var g:Number = ((hex &amp; 0x00FF00) &gt;&gt; 8); var b:Number = ((hex &amp; 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; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload