topical media & game development
#graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSimpleShadeBitmapMaterial.ax
#graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSimpleShadeBitmapMaterial.ax
[swf]
[flash]
flex
package be.nascom.flash10_tests.widgets{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Shape;
import flash.display.Sprite;
public class @ax-graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSimpleShadeBitmapMaterial extends Sprite implements ISimpleShaderMaterial{
protected var _side_width:Number;
protected var _side_height:Number;
protected var _half_width:int;
protected var _half_height:int;
protected var _shader_shape:Shape;
public function @ax-graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSimpleShadeBitmapMaterial(w:uint,h:uint,bmd:Bitmap){
_shader_shape=new Shape();
_side_width=w;
_side_height=h;
_half_width=Math.round(-w/2);
_half_height=Math.round(-h/2);
bmd.x=_half_width;
bmd.y=_half_height;
addChild(bmd);
this.addChild(_shader_shape);
}
//expectes number between 0 and 1
public function updateShader(value:Number):void{
if(value<0)value=0;
if(value>1)value=1;
_shader_shape.graphics.clear();
_shader_shape.graphics.beginFill(0x000000,value);
_shader_shape.graphics.drawRect(_half_width,_half_height,this._side_width,this._side_height);
_shader_shape.graphics.endFill();
}
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.