ActionScript 3 AS3填充可用屏幕区域(正方形)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ActionScript 3 AS3填充可用屏幕区域(正方形)相关的知识,希望对你有一定的参考价值。
// Display as many blocks on the screen as will fit
var BLOCK_SIZE:Number = 1;
var BLOCK_BUFFER:uint = 3;
var blockSize:uint = this.inchesToPixels(BLOCK_SIZE);
var blockTotal:uint = blockSize + BLOCK_BUFFER;
var cols:uint = Math.floor(this.stage.stageWidth / blockTotal);
var rows:uint = Math.floor((this.stage.stageHeight) / blockTotal);
var blockXStart:uint = (this.stage.stageWidth - ((cols * blockSize) + ((cols - 1) * BLOCK_BUFFER))) / 2;
var blockX:uint = blockXStart;
var blockY:uint = ((this.stage.stageHeight) - ((rows * blockSize) + ((rows - 1) * BLOCK_BUFFER))) / 2;
for (var colIndex:uint = 0; colIndex < rows; ++colIndex) {
for (var rowIndex:uint = 0; rowIndex < cols; ++rowIndex) {
var block:Sprite = this.getBlock(blockSize);
block.x = blockX;
block.y = blockY;
this.addChild(block);
blockX += blockTotal;
}
blockY += blockTotal;
blockX = blockXStart;
}
function getBlock(blockSize:uint):Sprite
{
var block:Sprite = new Sprite();
block.graphics.beginFill(0xAAC228);
block.graphics.drawRect(0, 0, blockSize, blockSize);
block.graphics.endFill();
block.cacheAsBitmap = true;
return block;
}
function inchesToPixels(inches:Number):uint
{
return Math.round(Capabilities.screenDPI * inches);
}
以上是关于ActionScript 3 AS3填充可用屏幕区域(正方形)的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3 AS3填充具有指定零数的整数
ActionScript 3 AS3 3D图库 - 屏幕到屏幕效果
Actionscript 3 简单 Cookie
ActionScript 3 AS3 SWFtrospection(as3swf)
ActionScript 3 AS3 TextField和StyleSheet示例(在ActionScript中创建)
[ActionScript 3.0] AS3.0 水面波纹效果