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

Load Image

Get Adobe Flash player
by Zahurdias.Calimero 29 Nov 2012
    Embed
/**
 * Copyright Zahurdias.Calimero ( http://wonderfl.net/user/Zahurdias.Calimero )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/cLh4
 */

package  
{
    import flash.display.*;
    import flash.events.*;
    import flash.net.URLRequest;

    public class Main extends Sprite
    {
        private var myImgLoader:Loader = new Loader();
        private var fileRequest:URLRequest = new URLRequest("http://images3.wikia.nocookie.net/__cb20120208033702/angrybirds/es/images/thumb/5/50/Wiki-background/640px-Wiki-background.jpeg");
        private var _inverseMask:Sprite;
 
        public function Main() 
        {
            Wonderfl.capture_delay(3);
            myImgLoader.load(fileRequest);
            //myImgLoader.blendMode = BlendMode.NORMAL;
            
            // create the inverse mask and place it inside the container with the LAYER blending mode

            _inverseMask = new Sprite();
            _inverseMask.blendMode = BlendMode.INVERT; // that's the trick.

            // draw a circle for the mask

            _inverseMask.graphics.beginFill(0, 1); 
            _inverseMask.graphics.drawCircle(0, 0, 80);
            _inverseMask.graphics.endFill();

            // place the mask in the middle by default

            _inverseMask.x = stage.stageWidth * 0.5;
            _inverseMask.y = stage.stageHeight * 0.5 - 40;

            _inverseMask.addEventListener(MouseEvent.MOUSE_DOWN, startDragMask);
            _inverseMask.addEventListener(MouseEvent.MOUSE_UP, stopDragMask);

            addChild( myImgLoader );
            addChild(_inverseMask);
        }
        
        private function startDragMask(e:MouseEvent):void 
        {
            _inverseMask.startDrag(false, stage.getBounds(stage));
        }

        private function stopDragMask(e:MouseEvent):void 
        {
            _inverseMask.stopDrag();
        }
    }
}