Rotating Objects with Filters : Gradient « Graphics « Flash / Flex / ActionScript






Rotating Objects with Filters

 

package
{
    import flash.display.Bitmap;
    import flash.display.BitmapData;
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import flash.filters.BlurFilter;
    import flash.geom.Matrix;
    public class Main extends Sprite
    {
        private var circle:Sprite = new Sprite();
        private var circleCopy:Sprite = new Sprite();
    
        public function Main()
        {
            addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
            circle.graphics.beginFill(0x00FF00, 1);
            circle.graphics.drawCircle(0, 0, 15);
            circle.graphics.endFill();
            addChild(circle);
            var bfInstance:BlurFilter = new BlurFilter(10, 40);
            circle.filters = [bfInstance];
            var bmpDataCircle:BitmapData = new BitmapData(circle.width + 20, circle.height + 80);
            bmpDataCircle.draw(circle, new Matrix(1, 0, 0, 1, 10, 40));
            var bmpCircle:Bitmap = new Bitmap(bmpDataCircle);
            circle.visible = false;
            circleCopy.addChild(bmpCircle);
            addChild(circleCopy);
    
        }
    
        private function onMouseMove(mouseEvent:MouseEvent):void
        {
                circleCopy.rotation = (mouseX / 550) * 360;
        }
    }
}

        








Related examples in the same category

1.Line Gradient Test
2.Create Gradient box
3.Create a Ball by using the Gradient
4.Applying Gradients to Lines
5.Set line gradient style with Matrix
6.lineGradientStyle("linear", [0xFFFF00, 0x00FFFF], [100, 100], [0x00, 0xFF], mxBox, "reflect", "linearRGB")
7.lineGradientStyle("radial", [0xFFFF00, 0x00FFFF], [100, 100], [0x00, 0xFF], mxBox, "pad", "linearRGB")
8.lineGradientStyle("radial", [0xFFFF00, 0x00FFFF], [100, 100], [0x00, 0xFF], mxBox, "pad", "linearRGB", 1)
9.Applying Gradient Fills
10.A shape with evenly rounded corners