flex 加载图片时的相关问题
桌面背景布局
居中
平鋪
拉伸
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的應用上。
//...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();//...