DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Actionscript Draw Box

01.26.2007
| 11692 views |
  • submit to reddit
        Function to draw a box with a specified width, height, and color, and return the box MovieClip

function draw_box(w,h,c){
	var new_box = this.createEmptyMovieClip("new_box", this.getNextDepth());
	new_box.beginFill(c);
	new_box.lineStyle(0,0x000000,0);
	new_box.moveTo(0, 0);
	new_box.lineTo(w, 0);
	new_box.lineTo(w, h);
	new_box.lineTo(0, h);
	new_box.lineTo(0, 0);
	new_box.endFill();
	return new_box;
}


Sample function call draws a 200w x 25h pixel, black box:
draw_box(200,25,0x000000);