CanvasScript3
>
Tests
> DisplayObject - Mask
Only works on Opera
Code
var stage = new Stage("canvas", 420, 500, 30); //add a bitmap var maskee = new Loader(); maskee.load(new URLRequest("./img/photo01.jpg")); stage.addChild(maskee); var mask = new Sprite(); mask.x = 100; mask.y = 100; mask.graphics.lineStyle(0); mask.graphics.beginFill(0xFF0000); mask.graphics.drawCircle(0, 0, 100); mask.graphics.endFill(); stage.addChild(mask); //add a child to the mask var mask_child = new Sprite(); mask_child.x = 50; mask_child.y = 50; mask_child.graphics.lineStyle(0); mask_child.graphics.beginFill(0x000FF); mask_child.graphics.drawRect(0, 0, 150, 150); mask_child.graphics.endFill(); mask.addChild(mask_child); //add a transparent bitmap to the mask var mask_child2 = new Loader(); mask_child2.x = 100; mask_child2.y = -100; mask_child2.load(new URLRequest("./img/Flap.png")); mask.addChild(mask_child2); //add a child that animates var mask_child3 = new Sprite(); mask_child3.x = 50; mask_child3.y = 200; mask_child3.graphics.lineStyle(0); mask_child3.graphics.beginFill(0x000FF); mask_child3.graphics.drawRect(0, 0, 200, 200); mask_child3.graphics.endFill(); mask.addChild(mask_child3); //set the mask maskee.mask = mask; mask_child3.addEventListener(Event.ENTER_FRAME, function(e) { this.rotation += 1; });
Canvas
Output