In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: グラデーションテクスチャーデモ

dot texture gradation demo
self fork
http://www.flickr.com/photos/naoto5959/3391371213/
この写真を貼りました~。なかなか良い。
@author naoto koshikawa
package
{
  import caurina.transitions.Tweener;
  import flash.display.BitmapData;
  import flash.display.BlendMode;
  import flash.display.GradientType;
  import flash.display.Loader;
  import flash.display.Shape;
  import flash.display.Sprite;
  import flash.events.MouseEvent;
  import flash.geom.Matrix;
  import flash.net.URLRequest;
  import flash.system.LoaderContext;
  
  [SWF(width = "465", height = "465", backgroundColor = "0xFFFFFF", frameRate = "60")]
  /**
   * dot texture gradation demo
   * self fork
   * http://www.flickr.com/photos/naoto5959/3391371213/
   * この写真を貼りました~。なかなか良い。
   * @author naoto koshikawa
   */
  public class Demo5 extends Sprite
  {
    private var _dot:Sprite;
    private var _gradation:Shape;
    
    public function Demo5() 
    {
      // 写真をおいてみる
      var loader:Loader = new Loader();
      loader.load(new URLRequest("http://farm4.static.flickr.com/3608/3391371213_d66554c1b4_o.jpg"), new LoaderContext(true));
      addChild(loader);
      
      // ドットテクスチャーを作成
      var dotBitmapData:BitmapData = new BitmapData(2, 2, true, 0);
      dotBitmapData.setPixel32(0, 0, 0xFF000000);
      
      // ドキュメントクラスなのでSpriteで全面を覆い、マウスに反応するようにする
      _dot = new Sprite();
      _dot.graphics.beginBitmapFill(dotBitmapData);
      _dot.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
      addChild(_dot);
      
      // グラデーション作成
      var graMatrix:Matrix = new Matrix();
      graMatrix.createGradientBox(stage.stageWidth * 4, stage.stageHeight * 4, Math.PI/4, 0, 0);
      _gradation = new Shape();
      _gradation.graphics.beginGradientFill(
        GradientType.LINEAR,
        [0xFF0000, 0xFF9900, 0xFFFF00, 0x00FF00, 0x00FFFF, 0x0000FF],
        [1.0, 1.0, 1.0, 1.0, 1.0, 1.0],
        [0, 51, 102, 153, 204, 255],
        graMatrix
      );
      _gradation.graphics.drawRect(0, 0, stage.stageWidth * 4, stage.stageHeight * 4);
      
      // ブレンドモードをスクリーンにして、黒いところだけ表示
      _gradation.blendMode = BlendMode.SCREEN;
      _gradation.x = -stage.stageWidth;
      _gradation.y = -stage.stageHeight;
      addChild(_gradation);
      
      addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);
    }
    
    private function mouseMoveHandler(event:MouseEvent):void
    {
      Tweener.removeTweens(_gradation);
      Tweener.addTween(_gradation, 
        {
          x:(mouseX - stage.stageWidth)*2,
          y:(mouseY - stage.stageHeight) * 2,
          delay:0.3,
          time:5, 
          transition:"easeOutExpo"
        }
      );
    }
  }
}