グラデーショングローフィルターFlash Player 9 以降、Adobe AIR 1.0 以降 GradientGlowFilter クラスでは、表示オブジェクトまたは BitmapData オブジェクトに強化されたグロー効果を適用することができます。この効果を使用することによって、グローのカラー制御が充実し、グロー効果がいっそうリアルになります。 また、グラデーショングローフィルターでは、オブジェクトの内側、外側、または上側のエッジにグラデーショングローを適用することができます。 次の例では、ステージ上に円を描画し、その円にグラデーショングローフィルターを適用します。 マウスを右方向と下方向に移動すると、それぞれ水平方向と垂直方向で、ぼかしの量が増加します。 また、ステージをクリックすると、ぼかしの強さが増加します。 import flash.events.MouseEvent; import flash.filters.BitmapFilterQuality; import flash.filters.BitmapFilterType; import flash.filters.GradientGlowFilter; // Create a new Shape instance. var shape:Shape = new Shape(); // Draw the shape. shape.graphics.beginFill(0xFF0000, 100); shape.graphics.moveTo(0, 0); shape.graphics.lineTo(100, 0); shape.graphics.lineTo(100, 100); shape.graphics.lineTo(0, 100); shape.graphics.lineTo(0, 0); shape.graphics.endFill(); // Position the shape on the Stage. addChild(shape); shape.x = 100; shape.y = 100; // Define a gradient glow. var gradientGlow:GradientGlowFilter = new GradientGlowFilter(); gradientGlow.distance = 0; gradientGlow.angle = 45; gradientGlow.colors = [0x000000, 0xFF0000]; gradientGlow.alphas = [0, 1]; gradientGlow.ratios = [0, 255]; gradientGlow.blurX = 10; gradientGlow.blurY = 10; gradientGlow.strength = 2; gradientGlow.quality = BitmapFilterQuality.HIGH; gradientGlow.type = BitmapFilterType.OUTER; // Define functions to listen for two events. function onClick(event:MouseEvent):void { gradientGlow.strength++; shape.filters = [gradientGlow]; } function onMouseMove(event:MouseEvent):void { gradientGlow.blurX = (stage.mouseX / stage.stageWidth) * 255; gradientGlow.blurY = (stage.mouseY / stage.stageHeight) * 255; shape.filters = [gradientGlow]; } stage.addEventListener(MouseEvent.CLICK, onClick); stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove); |
![]() |