I created a portion of a piano keyboard, completely from ActionScript (which took longer than expected to code).
Here is the code for one of the white keys:
var k4 = new Shape(); //draw long vertical piano key line k4.graphics.lineStyle(2, 0x999999, 1); k4.graphics.moveTo(164, 51); k4.graphics.lineTo(95, 158); //draw lower, short vertical piano key line k4.graphics.lineStyle(2, 0x000000, 1); k4.graphics.lineTo(99, 187); //draw horizontal key line k4.graphics.lineStyle(2, 0x9D9D9D, 1); k4.graphics.moveTo(88, 159); k4.graphics.lineTo(58, 159); addChild(k4);
Here is the code for one of the black keys:
var b4 = new Shape(); //draw top face of key b4.graphics.beginFill(0x555555); b4.graphics.moveTo(207, 51); b4.graphics.lineTo(222, 51); b4.graphics.lineTo(203, 95); b4.graphics.lineTo(186, 95); b4.graphics.lineTo(207, 51); //draw front face of key b4.graphics.beginFill(0x777777); b4.graphics.moveTo(201, 95); b4.graphics.lineTo(199, 115); b4.graphics.lineTo(184, 115); b4.graphics.lineTo(186, 95); b4.graphics.lineTo(201, 95); //draw side face of key b4.graphics.lineStyle(2, 0x000000, 1); b4.graphics.beginFill(0x000000); b4.graphics.moveTo(222, 52); b4.graphics.lineTo(228, 52); b4.graphics.lineTo(200, 114); b4.graphics.lineTo(202, 95); b4.graphics.lineTo(222, 52); addChild(b4);