While my simplified test case (pasted below) is in Flex, my question is actually an ActionScript 3 one.
I have a small card game, where I currently draw the background as a not very exciting looking greenish radial gradient:

Here is my very simple test code (just put it into a new Flash Builder project):
TestBg.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:comps="*">
<comps:MyBg width="100%" height="100%" />
</s:Application>
MyBg.as (a custom component):
package {
import flash.display.GradientType;
import flash.display.InterpolationMethod;
import flash.display.Shape;
import flash.display.SpreadMethod;
import flash.geom.Matrix;
import mx.core.BitmapAsset;
import mx.core.UIComponent;
public class MyBg extends UIComponent {
[Embed('bg.png')]
private static const BG_ASSET:Class;
private static const BG:BitmapAsset = new BG_ASSET() as BitmapAsset;
private static const COLORS:Array = [0xCCFFCC, 0x669966];
private static const ALPHAS:Array = [1, 1];
private static const RATIOS:Array = [0, 255];
private var _matrix:Matrix = new Matrix();
private var _bg:Shape = new Shape();
override protected function createChildren():void {
super.createChildren();
addChild(_bg);
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
super.updateDisplayList(unscaledWidth, unscaledHeight);
_bg.graphics.clear();
//_bg.graphics.beginBitmapFill(BG.bitmapData);
_matrix.createGradientBox(unscaledWidth, unscaledHeight, 0, 0, -unscaledHeight / 6);
_bg.graphics.beginGradientFill(GradientType.RADIAL,
COLORS,
ALPHAS,
RATIOS,
_matrix,
SpreadMethod.PAD,
InterpolationMethod.LINEAR_RGB,
0);
_bg.graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
_bg.graphics.endFill();
}
}
}
I would like to use a seamless tile instead of the gradient:
bg.png:

mask.png (currently not used):

to make my background look similar to the (arguably) good looking Apple Game Center shown at the bottom of this Stackoverflow question.
So I uncomment the beginBitmapFill call above and comment the beginGradientFill and get the following dark and dull looking background:

My question is: how to add a light spot to my background an make it look bit lighter overall?
Can I use the mask.png somehow for that or maybe some of the blendModes?
I would use two layers, a
_bgTexturewith just the texture as you have, and a_bgShadingwith some greyscale lighting above that based on your original, but with ablendModeofBlendMode.OVERLAY, then expand the radial gradient a bit to avoid the sharp edges and add an inner shadow.Just testing in the Flash IDE, I’ve used
COLORS:Array = [0xDDDDDD, 0x777777], the texture exported as aBackgroundTextureclass, and the following method based off yourupdateDisplayListto get this: