Class called ‘bg’ dynamically creates a background that varies depending on the stage width & height.
package
{
import flash.display.*;
import flash.events.*;
import flash.utils.*;
public class bg extends MovieClip
{
var radius:int;
var repeat:int;
var circle:Shape;
public function bg()
{
repeat = Math.ceil(stage.stageWidth/160)+4;
for (var i:int = repeat; i > 0; i--)
{
radius = (40*(4*i-1))/2;
circle = new Shape();
circle.graphics.clear();
circle.graphics.beginFill(0x000000);
circle.graphics.drawCircle(0,0,radius);
circle.graphics.drawCircle(0,0,radius-40);
this.addChildAt(circle,1);
circle.graphics.endFill();
circle.alpha = 0.11;
}
this.bgGradient.scaleX = stage.stageWidth;
this.bgGradient.scaleY = stage.stageHeight;
this.bgGradient.x = -(this.bgGradient.width/2);
this.bgGradient.y = -(this.bgGradient.height/2);
}
}
}
Apparently I have no access to the stage from this external class… I have seen one solution that means I need to extend the class as a Sprite…
public class bg extends Sprite { ...
… but doing that means not extending it as a movieclip which is what this class references to.
Can anyone help me?