flex 加载图片时的相关问题

[size=large]桌面背景布局

居中
平鋪
拉伸
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的應用上。[/size]


//...
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();
//...
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值