topical media & game development
#graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSideMaterial.ax
#graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSideMaterial.ax
[swf]
[flash]
flex
package be.nascom.flash10_tests.widgets{
import flash.display.SimpleButton;
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFormat;
public class @ax-graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSideMaterial extends SimpleButton{
protected var _side_width:Number;
protected var _side_height:Number;
protected var _half_width:int;
protected var _half_height:int;
protected var _use_set_color:Boolean;
protected var _up_color:uint;
protected var _over_color:uint;
protected var _down_color:uint;
public function @ax-graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSideMaterial(w:uint,h:uint,side_id:uint,use_set_color:Boolean=false,up_color:uint=0xFFFFFF,over_color:uint=0xBBBBFF,down_color:uint=0x7777FF){
super();
_side_width=w;
_side_height=h;
_half_width=Math.round(-w/2);
_half_height=Math.round(-h/2);
_use_set_color=use_set_color;
_up_color=up_color;
_over_color=over_color;
_down_color=down_color;
render(w,h,side_id);
trace("@ax-graphic-player-10-cube-be-nascom-flash10-tests-widgets-CubeSideMaterial(w:"+w+",h:"+h+", side_id:"+side_id+")");
}
public function render(w:uint,h:uint,side_id:uint):void{
this.upState=createMaterialState(w,h,_use_set_color ? _up_color : Math.random()*0xFFFFFF,String(side_id));
this.overState=createMaterialState(w,h,_use_set_color ? _over_color : Math.random()*0xFFFFFF,String(side_id));
this.downState=createMaterialState(w,h,_use_set_color ? _down_color : Math.random()*0xFFFFFF,String(side_id));
this.hitTestState=createMaterialState(w,h,0xFFFFFF,String(side_id));
this.useHandCursor=true;
}
public function createMaterialState(w:uint,h:uint,color:uint,material_label:String):Sprite{
var s:Sprite=new Sprite();
s.graphics.beginFill(color,1);
s.graphics.drawRect(_half_width,_half_height,w,h);
s.graphics.endFill();
var tf:TextField=new TextField();
tf.selectable=false;
var tform:TextFormat=new TextFormat();
tform.size=Math.round(_side_width/4);
tform.font="Verdana";
tform.bold=true;
tf.text=String(material_label);
tf.setTextFormat(tform);
s.addChild(tf);
return s;
}
}
}
(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.