khester
11-13-2008, 08:09 PM
Hello everyone,
I hope someone can help. I have created a site. I am using the below code to create a gradient that scales it self to the browser. It is working fine except for one thing.
When you use this action scripting "stage.align = StageAlign.TOP_LEFT;" is not letting my swf file center within the html page. If I comment the code out then it centers like I tell it to but the gradient gets all messed up in the top left corner. I looked through the code and there isn't such a thing as "stage.align = StageAlign.CENTER;" I wish there was.
Hopefully someone can help out.
Thanks,
Khester
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.ADDED, onStageResize);
stage.addEventListener(Event.RESIZE, onStageResize);
var backgroundGradient:Sprite = new Sprite();
addChildAt(backgroundGradient, 0);
function onStageResize(e:Event):void {
var colors:Array = [0xCCCCCC, 0xEC7702];
var alphas:Array = [0, .75];
var ratios:Array = [0, 0xFF];
var matrix:Matrix = new Matrix();
matrix.createGradientBox(stage.stageWidth, stage.stageHeight, (50 * Math.PI / 2), 0, 10);
var focalPoint:Number = 0;
with (backgroundGradient.graphics) {
clear();
beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, matrix, SpreadMethod.PAD, InterpolationMethod.RGB, focalPoint);
drawRect(0, 0, stage.stageWidth, stage.stageHeight);
endFill();
}
}
I hope someone can help. I have created a site. I am using the below code to create a gradient that scales it self to the browser. It is working fine except for one thing.
When you use this action scripting "stage.align = StageAlign.TOP_LEFT;" is not letting my swf file center within the html page. If I comment the code out then it centers like I tell it to but the gradient gets all messed up in the top left corner. I looked through the code and there isn't such a thing as "stage.align = StageAlign.CENTER;" I wish there was.
Hopefully someone can help out.
Thanks,
Khester
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.addEventListener(Event.ADDED, onStageResize);
stage.addEventListener(Event.RESIZE, onStageResize);
var backgroundGradient:Sprite = new Sprite();
addChildAt(backgroundGradient, 0);
function onStageResize(e:Event):void {
var colors:Array = [0xCCCCCC, 0xEC7702];
var alphas:Array = [0, .75];
var ratios:Array = [0, 0xFF];
var matrix:Matrix = new Matrix();
matrix.createGradientBox(stage.stageWidth, stage.stageHeight, (50 * Math.PI / 2), 0, 10);
var focalPoint:Number = 0;
with (backgroundGradient.graphics) {
clear();
beginGradientFill(GradientType.RADIAL, colors, alphas, ratios, matrix, SpreadMethod.PAD, InterpolationMethod.RGB, focalPoint);
drawRect(0, 0, stage.stageWidth, stage.stageHeight);
endFill();
}
}