Advanced Masks : Sprite : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Sprite »

 

Advanced Masks


 
package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    public class Main extends Sprite
    {

        private var maskingSprite:Sprite = new Sprite();
        private var maskedSprite:Sprite = new Sprite();
        private var maskHolder:Sprite = new Sprite();

        public function Main()
        {
            stage.scaleMode = "noScale";
            stage.align = "TL";

            maskedSprite.graphics.beginFill(0xFFCC001);
            maskedSprite.graphics.drawRect(001000600);
            maskedSprite.graphics.lineStyle(200x000000);
            maskedSprite.graphics.lineTo(1000600);
            maskedSprite.graphics.moveTo(10000);
            maskedSprite.graphics.lineTo(0600);
            addChild(maskedSprite);

            maskHolder.graphics.beginFill(0x0000001);
            maskHolder.graphics.drawRect(00120120);

            maskingSprite.graphics.beginFill(0x0000001);
            maskingSprite.graphics.drawRect(00100100);
            maskingSprite.graphics.endFill();
            addChild(maskingSprite);
            maskedSprite.addEventListener(MouseEvent.MOUSE_DOWN, dragMask);
            maskedSprite.addEventListener(MouseEvent.MOUSE_UP, stopDragMask);
            maskedSprite.mask = maskingSprite;
        }

        private function dragMask(mouseEvent:MouseEvent):void
        {
            trace(" drag ");
            maskingSprite.startDrag();
        }

        private function stopDragMask(mouseEvent:MouseEvent):void
        {
            maskingSprite.stopDrag();
        }
    }
}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Development
» Sprite