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

穴を開けたような表現

ステージに穴が開いたような表現をお絵描きソフト風にテスト。
処理自体はDropShadowFilterの内側と外側を使って表現してみました(47行目〜50行目)。深さの表現はフィルタのxとyのぼかし量を調整したらできるのかなぁ?

[操作方法]
ドラッグ:描画
escキー:消去
Get Adobe Flash player
by geko 05 Feb 2011
    Embed
/**
 * Copyright geko ( http://wonderfl.net/user/geko )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/3apP
 */

package {
    import flash.display.Sprite;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.ui.Keyboard;
    
    [SWF(backgroundColor="0x444444")]
    public class FlashTest extends Sprite {
        public var st:HoleStage;
        public var mouseDown:Boolean = false;
        
        public function FlashTest() {
            Wonderfl.disable_capture();
            st = addChild(new HoleStage()) as HoleStage;
            
            stage.addEventListener(MouseEvent.MOUSE_MOVE, function move(event:MouseEvent):void{
                if(!mouseDown) return;
                st.graphics.beginFill(0x00dfdf);
                st.graphics.drawCircle(mouseX, mouseY, 8);
                st.graphics.endFill();
                event.updateAfterEvent();
            });
            stage.addEventListener(MouseEvent.MOUSE_DOWN, function down(event:MouseEvent):void{
                mouseDown = true;
                st.graphics.beginFill(0x00dfdf);
                st.graphics.drawCircle(mouseX, mouseY, 8);
                st.graphics.endFill();
                event.updateAfterEvent();
            });
            stage.addEventListener(MouseEvent.MOUSE_UP, function up(event:MouseEvent):void{
                mouseDown = false;
            });
            stage.addEventListener(KeyboardEvent.KEY_DOWN, function keydown(event:KeyboardEvent):void{
                if(event.keyCode == Keyboard.ESCAPE) st.graphics.clear();
            });
        }
    }
}


import flash.display.Sprite;
import flash.filters.DropShadowFilter;

class HoleStage extends Sprite{
    private var angle:Number = 90;
    
    public function HoleStage(){
        filters = [new DropShadowFilter(6, 90, 0x000000, 0.8, 8, 8, 0.8, 3, true),
                   new DropShadowFilter(-0.5, 90, 0x000000, 0.6, 1.5, 1.5, 1.6, 3),
                   new DropShadowFilter(0.5, 90, 0xFFFFFF, 0.6, 1.2, 1.2, 1.8, 3)];
    }
}