PDA

View Full Version : Recessed Window


Halapino
01-10-2011, 11:16 PM
I'm using this code to create a recessed window, but I am wondering if there is an easier way?




public var dateBack1:Shape = new Shape();
public var dateBack2:Shape = new Shape();
public var dateBack3:Shape = new Shape();
public var dateBack4:Shape = new Shape();
public var dateBack:Shape = new Shape();
//Draw time background
dateBack1.graphics.beginFill(0x000000, 1);
dateBack1.graphics.drawRoundRect((dText.x)-15, 3, (dText.width), 40, 1, 1)
dateBack2.graphics.beginFill(0x000000, 1);
dateBack2.graphics.drawRoundRect((dText.x)-15, 5, (dText.width), 40, 1, 1)
dateBack3.graphics.beginFill(0x000000, 1);
dateBack3.graphics.drawRoundRect((dText.x)-15, 5, (dText.width), 40, 1, 1)
dateBack4.graphics.beginFill(0x000000, 1);
dateBack4.graphics.drawRoundRect((dText.x)-15, 5, (dText.width), 40, 1, 1)
dateBack.graphics.beginFill(0xffffff, 1);
dateBack.graphics.drawRoundRect((dText.x)-15, 5, (dText.width), 40, 5, 5);
dateBack1.filters = [new DropShadowFilter(5,45,0,1,4,4,1,3,true, false, true)];
dateBack2.filters = [new DropShadowFilter(5,135,0,1,4,4,1,3,true, false, true)];
dateBack3.filters = [new DropShadowFilter(5,225,0,1,4,4,1,3,true, false, true)];
dateBack4.filters = [new DropShadowFilter(5,315,0,1,4,4,1,3,true, false, true)];
dateBack.x = dateBack1.x = dateBack2.x = dateBack3.x = dateBack4.x = 5;
dateBack.y = dateBack1.y = dateBack2.y = dateBack3.y = dateBack4.y = 5;
//activate date/time display and show current time
addChild(dateBack);
addChild(dateBack1);
addChild(dateBack2);
addChild(dateBack3);
addChild(dateBack4);
addChild(dText);
dateBack1.graphics.endFill();
dateBack2.graphics.endFill();
dateBack3.graphics.endFill();
dateBack4.graphics.endFill();
dateBack.graphics.endFill();

Heloed
01-11-2011, 05:03 PM
Well this will simplify the code a bit, but I am not sure about simpler design

var i=0
for(i;i<5;i++) {
var newDateBack:Shape = new Shape();
if(i==0) {
newDateBack.graphics.beginFill(0xffffff, 1);
newDateBack.graphics.drawRoundRect((dText.x)-15, 5, (dText.width), 40, 1, 5);
} else {
newDateBack.graphics.beginFill(0x000000, 1);
if(i==1) {
newDateBack.graphics.drawRoundRect((dText.x)-15, 3, (dText.width), 40, 1, 1);
} else {
newDateBack.graphics.drawRoundRect((dText.x)-15, 5, (dText.width), 40, 1, 1);
}
}
newDateBack.x = newDateBack.y = 5;
if(i != 0) {
newDateBack.filters = [new DropShadowFilter(5,-45+90*i,0,1,4,4,1,3,true, false, true)];
}
addChild(newDateBack);
newDateBack.graphics.endFill();
}
addChild(dText);

Halapino
01-11-2011, 06:24 PM
Thank you very much. Not exactly what I was looking for, but I like it all the same.

I was hoping for some sort of actionscript that would create the dropshadow without having to make 4 instances of it to cover each corner. Oh well, it works all the same and I'll definitely keep this.