============================
ApplicationBackground.as
============================
package skins
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Graphics;
import mx.skins.ProgrammaticSkin;
import mx.utils.ColorUtil;
/**
* The skin for application background gradient.
*/
public class ApplicationBackground extends ProgrammaticSkin
{
[ Embed( source='../assets/bg.png' ) ]
private var backgroundImageClass :Class;
private var backgroundImage :Bitmap;
private var backgroundBitmapData :BitmapData;
//--------------------------------------------------------------------------
//
// Constructor
//
//--------------------------------------------------------------------------
/**
* Constructor
*/
public function ApplicationBackground()
{
super();
backgroundImage = new backgroundImageClass();
backgroundBitmapData = new BitmapData( backgroundImage.width, backgroundImage.height );
backgroundBitmapData.draw( backgroundImage );
}
//--------------------------------------------------------------------------
//
// Overridden properties
//
//--------------------------------------------------------------------------
//----------------------------------
// measuredWidth
//----------------------------------
/**
* @private
*/
override public function get measuredWidth():Number
{
return 8;
}
//----------------------------------
// measuredHeight
//----------------------------------
/**
* @private
*/
override public function get measuredHeight():Number
{
return 8;
}
//--------------------------------------------------------------------------
//
// Overridden methods
//
//--------------------------------------------------------------------------
/**
* @private
*/
override protected function updateDisplayList(w:Number, h:Number):void
{
super.updateDisplayList(w, h);
var g:Graphics = graphics;
g.clear();
g.beginBitmapFill( backgroundBitmapData );
g.drawRect(0,0,w,h);
g.endFill();
g.beginFill(0xffffff, 0);
g.lineStyle(1, 0x596873);
g.drawRect(1, 1, w - 2, h - 2);
}
}
}
===========================
|