Tutorials, extensions, and source files for ActionScript, Flash, and other Adobe products.

 

senocular.com ActionScript Library

outline.as

Name: outline - Drawing method [MX] draws the bounding box around a movieclip in any scope.
Author: senocular: www.senocular.com
Date: 1899-12-31T00:01:52.800
Documentation:
MovieClip OUTLINE: Outlines a movieclip - effectively
draws a movieclips bounding box.  The clip the method
is used on is drawn in and the bounding box outlined
is either itself or any movieclip passed.

Arguments:
- clip: (MovieClip, optional) The movieclip to be outlined. Default: this.

Returns:
- the movieclip the method was used on.

Example:
// this outlines a clip (myClip) within itself
// and within the parent scope.  Because
// myClip is rotated, the outlines will differ
myClip._rotation = 45;
myClip.lineStyle(1,0,100);
myClip.outline();
this.lineStyle(1,0,100);
this.outline(myClip);

1
2
3
4
5
6
7
8
9
MovieClip.prototype.outline = function(clip){
	var b = (clip) ? clip.getBounds(this) : this.getBounds(this);
	this.moveTo(b.xmin, b.ymin);
	this.lineTo(b.xmax, b.ymin);
	this.lineTo(b.xmax, b.ymax);
	this.lineTo(b.xmin, b.ymax);
	this.lineTo(b.xmin, b.ymin);
	return this;
}