| Flashscript classes (ActionScript 3) | Home | MX | MX 2004 | Flash 8 | Flash 9 |Flash 10 |PHP |Components | Snippets | Contact | |
NewColorMatrix |
|
|
| Method | Defined By |
|---|---|
|
NewColorMatrix(myBitmap:DisplayObject, newColor:String)
Creates a new instance of the NewColorMatrix class. |
NewColorMatrix |
|
setFillColor()
Will change the filled areas of an image but not the lines. |
NewColorMatrix |
|
setOutlineColor()
Will change the line areas of an image but not th fill. |
NewColorMatrix |
|
transformColor()
Will do a simple color transformation to the new color set. |
NewColorMatrix |
|
setColorMatrix(mulPly:Number=1, setBright:Number=0, setContrast:Number=200, setHue:Number=0, setSat:Number=0)
Will do a complex change to different brightness, hue and saturation. |
NewColorMatrix |
| Event | Defined By |
|---|---|
|
All events of the Sprite class |
Sprite |
| Constructor Detail |
|---|
|
NewColorMatrix(myBitmap:DisplayObject, newColor:String) Constructor
public function NewColorMatrix(myBitmap:DisplayObject, newColor:String) |
| Intializes a new NewColorMatrix instance. |
Parameters
|
| Method Detail |
|---|
|
setFillColor() method
Will change the filled areas of an image but not the lines. |
|
setOutlineColor() method
Will change the line areas of an image but not th fill. |
|
transformColor() method
Will do a simple color transformation to the new color set. |
|
setColorMatrix() method
Will do a complex change to different brightness, hue and saturation. |
Parameters
|
| Examples |
|---|
Create a new fla file and name it NewColorMatrix.fla. Place the fla in the same folder as the biz folder. Put a ColorPicker component (cp), and one Button component (changeBut) on the stage. Then create an Actionscript file, name it Newcolormatrix.as and place this script.
package
{
import flash.display.*;
import flash.events.*;
import fl.controls.ColorPicker;
import fl.controls.Button;
import biz.flashscript.utils.LoaderClassStatic;
import biz.flashscript.bitmap.NewColorMatrix;
public class Newcolormatrix extends Sprite
{
public var changeBut:Button;
public var cp:ColorPicker;
private var mc:MovieClip;
private var bmp:Bitmap;
private var bd:BitmapData;
private var myLoader:LoaderClassStatic;
private static var cColor:Boolean = false;
public function Newcolormatrix ():void
{
changeBut.label = "Change ColorMethod";
changeBut.addEventListener(MouseEvent.CLICK, changeHandler);
myLoader = new LoaderClassStatic();
var url:String = "images/A0.jpg";
myLoader.initLoader (url, completed, this);
cp.addEventListener (Event.CHANGE, colorChange);
}
private function completed (e:Event):void
{
if(mc != null)
{
removeChild(mc);
mc = null;
}
mc=new MovieClip();
mc.x = 200;
mc.y = 100;
addChild (mc);
bmp = (Bitmap(e.currentTarget.content));
bmp.scaleX = 0.5;
bmp.scaleY = 0.5;
mc.addChild (bmp);
}
private function colorChange (event:Event):void
{
var newColor:String = ColorPicker(event.currentTarget).hexValue;
var _ncm:NewColorMatrix = new NewColorMatrix(mc, newColor);
if(cColor)
{
_ncm.setFillColor ();
}
else
{
_ncm.setOutlineColor ();
}
}
private function changeHandler (event:Event):void
{
if(cColor)
{
cColor = false;
}
else
{
cColor = true;
}
var url:String = "images/A0.jpg";
myLoader.initLoader (url, completed, this);
}
}
}
|