Mask Test #1

by Zahurdias.Calimero
♥0 | Line 41 | Modified 2012-12-02 03:21:14 | MIT License
play

ActionScript3 source code

/**
 * 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/hKnS
 */

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 fileRequest:URLRequest = new URLRequest("http://www.kalingagroup.in/Image/background455.gif");
        private var mask1:Sprite,mask2:Sprite,mask3:Sprite,mask4: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

            mask1 = new Sprite();
            //mask1.blendMode = BlendMode.INVERT; // that's the trick.
            mask1.graphics.beginFill(0, 1); 
            mask1.graphics.drawRect(0, 0, 95,95);
            mask1.graphics.endFill();
            mask1.x = 25;
            mask1.y = 200;

            mask2 = new Sprite();
            mask2.blendMode = BlendMode.INVERT; // that's the trick.
            mask2.graphics.beginFill(0, 1); 
            mask2.graphics.drawRect(0, 0, 95,95);
            mask2.graphics.endFill();
            mask2.x = 125;
            mask2.y = 200;

            mask3 = new Sprite();
            mask3.blendMode = BlendMode.OVERLAY; // that's the trick.
            mask3.graphics.beginFill(0, 1); 
            mask3.graphics.drawRect(0, 0, 95,95);
            mask3.graphics.endFill();
            mask3.x = 225;
            mask3.y = 200;

            addChild( myImgLoader );
            addChild(mask1);
            addChild(mask2);
            addChild(mask3);
        }
    }
}

Forked