桌面背景布局

  • 居中
  • 平鋪
  • 拉伸

DesktopBackgroundLayout

  • LayoutManager.CENTER
  • LayoutManager.TILE
  • LayoutManager.STRETCH

 重點是在
flash.display.Graphics
beginBitmapFill(bitmap:BitmapData, matrix:Matrix = null, repeat:Boolean = true, smooth:Boolean = false):void
在matrix和repeat的應用上。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//...
backgroundUI.graphics.clear();
if(layoutManagerStr == "stretch") {
	bitmap = new BitmapData(loader.width, loader.height);
	bitmap.draw(loader);
	matrix.scale((backgroundUI.width / loader.width) , (backgroundUI.height / loader.height));
	backgroundUI.graphics.beginBitmapFill(bitmap, matrix, false, true);
	backgroundUI.graphics.drawRect(0, 0, backgroundUI.width, backgroundUI.height);
} else if(layoutManagerStr == "tile") {
	bitmap = new BitmapData(loader.width,loader.height);
	bitmap.draw(loader);
	backgroundUI.graphics.beginBitmapFill(bitmap, null, true, true);
	backgroundUI.graphics.drawRect(0, 0, backgroundUI.width, backgroundUI.height);
} else if(layoutManagerStr == "center") {
	bitmap = new BitmapData(unitW, unitH);
	bitmap.draw(loader);
	var centerX:Number = backgroundUI.width / 2 - loader.width / 2;
	var centerY:Number = backgroundUI.height / 2 - loader.height / 2;
	matrix.tx = centerX;
	matrix.ty = centerY;
	backgroundUI.graphics.beginBitmapFill(bitmap, matrix, false, true);
	backgroundUI.graphics.drawRect(centerX, centerY, loader.width, loader.height);
}
backgroundUI.graphics.endFill();
//...

This movie requires Flash Player 9