I have a custom class that extends MovieClip and cannot of the life of me figure out how to get the stage width from within the class. trace(stage) returns null, as well as trace(parent).
here is my class:
// define package
package
{
// import MovieClip class
import flash.display.Stage;
import flash.display.MovieClip;
// define class within package, extend MovieClip
public class Circle extends MovieClip
{
var maxRadius:uint;
var fillColor:Number = 0xFF0000;
public function Circle ()
{
//trace(root); // traces "[object MainTimeline]"
trace(this.parent);
maxRadius = 30;
//this.x = __x;
//this.y = __y;
//this.radius = __radius;
drawCircle();
}
private function drawCircle ()
{
var radius = Math.random() * maxRadius + 4;
this.graphics.clear();
this.graphics.beginFill(fillColor);
this.graphics.drawCircle (0, 0, radius);
}
}
}
and the code in the main timeline:
// instantiate new instance of Circle
var myCircle:Circle = new Circle();
// attach instance myCircle to stage
addChild(myCircle);
Any help would be appreciated! :jail: