Masks : Sprite : Development Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Development » Sprite »

 

Masks


 
package
{
    import flash.display.*;
    import flash.events.Event;
    public class Main extends Sprite
    {
        private var circle:Shape;
        private var vBox:Shape;
        private var up:Boolean = false;

        public function Main()
        {
            super();
            stage.scaleMode = "noScale";
            circle = new Shape();
            circle.graphics.beginFill(0xFF66001);

            circle.graphics.drawCircle(250250250);
            vBox = new Shape();
            vBox.graphics.beginFill(0x0000001);
            vBox.graphics.drawRect(00100020);
            circle.mask = vBox;
            addChild(vBox);
            addChild(circle);

            addEventListener(Event.ENTER_FRAME, scrollVertBox);
        }

        private function scrollVertBox(event:Event):void
        {
            if(up)
            {
                vBox.y -= 2;
            else {
                vBox.y += 2;
            }

            if(vBox.y > 520)
            {
                up = true;
            }
            if(vBox.y < 0)
            {
                up = true;
            }
        }
    }
}
 

        



Leave a Comment / Note


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


Flash / Flex / ActionScript examples

 Navioo Development
» Sprite