flash on 2015-11-27
♥0 |
Line 53 |
Modified 2015-11-27 06:29:43 |
MIT License
archived:2017-03-30 11:41:16
ActionScript3 source code
/**
* Copyright mutantleg ( http://wonderfl.net/user/mutantleg )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/e9Xw
*/
package {
import flash.events.Event;
import flash.display.Sprite;
public class FlashTest extends Sprite {
public function FlashTest() {
var i:int;
vecOcc = new Vector.<int>(640, false);
for (i=0;i<640;i+=1) { vecOcc[i] = 0;}
graphics.clear();
graphics.lineStyle(2, 0);
//addRect(140, 90, 120, 0xFF0000);
addRect(100, 120, 100, 0x808080);
addRect(260, 20, 100, 0x202080);
addRect(60, 270, 40, 0xFFffFFff*Math.random());
// addRect(20, 370, 20, 0xFFffFFff*Math.random());
graphics.drawCircle(16,16, 32);
}//ctor
public var vecOcc:Vector.<int> = new Vector.<int>(640, false);
public function addRect(ax:int, aw:int, dp:int, c:uint=0):void
{
// graphics.drawRect(ax, 80, aw, 80);
var i:int; var num:int;
var k:int;
num = aw;
var ay:Number;
ay = 80;
var sx:int;
sx = ax;
for (i=0;i<num;i+=1)
{
k = ax + i;
if (k >= 640) { break; }
if (vecOcc[k] < dp) { vecOcc[k] = dp; }
else
{
if (k-sx > 1)
{
graphics.beginFill(c, 1);
graphics.drawRect(sx, ay, k-sx, 80);
graphics.endFill();
graphics.moveTo(sx, ay);
graphics.lineTo(k, ay+80);
ay += 32;
sx=k;
}//endif2
sx=k;
}//endif
}//nexti
//graphics.drawCircle(160, 16, 8);
graphics.beginFill(c, 1);
graphics.drawRect(sx, ay, k-sx, 80);
graphics.endFill();
graphics.moveTo(sx, ay);
graphics.lineTo(k, ay+80);
}//addrect
}//classend
}