GetBitmapData

Package:
Class:
Inheritance:
biz.flashscript.bitmap
public class GetBitmapData
N/A
The GetBitmapData class retrieves colors from MovieClips/Sprites and returns their values as hexadecimal values. The class can further create new Bitmaps with colors defined by Multipliers or Offset and either add the new Bitmaps as children of a MovieClip/Sprite or replace the target. Use the method GetBitmapData.getInstance() to create an instance of the class.
Public Properties
Property Defined By
target : Sprite
Optional to set a target.
GetBitmapData
_bitMap : Bitmap
Used when data are retrieved from a Bitmap.
GetBitmapData
_xPos : int
Sets the x value to retrive color information.
GetBitmapData
_yPos : int
Sets the y value to retrive color information.
GetBitmapData
Public Methods
Method Defined By
GetBitmapData.getInstance():GetBitmapData
Creates a new instance of the GetBitmapData class.
GetBitmapData
getColorBitmap():String
Function returns the color information of a Bitmap at default 0, 0 position when _xPos and _yPos is not set. requires to set the _bitMap property.
GetBitmapData
getColorSprite(target:Sprite):String
Function returns the color information of a Sprite at default 0, 0 position when _xPos and _yPos is not set.
GetBitmapData
multiplyColor(_root:Object, red:Number=1, green:Number=1, blue:Number=1, _alpha:Number=1, xPos:int=0, yPos:int=0, _width:int=100, _height:int=100, _replace:Boolean=false):void
Function creates a new Bitmap using Multipliers and places it inside a MovieClip/Sprite or replaces it.
GetBitmapData
offsetColor(_root:Object, red:Number=1, green:Number=1, blue:Number=1, _alpha:Number=1, xPos:int=0, yPos:int=0, _width:int=100, _height:int=100, _replace:Boolean=false):void
Function creates a new Bitmap using Offset colors and places it inside a MovieClip/Sprite or replaces it.
GetBitmapData
Property Detail
target property
target:Sprite [read-write]

Optional, will define a target, which is used in multiplyColor and multiplyColor to set target width and height.

There is no default value. .

Implementation

public static function get target():Sprite
public static function set target(value:Sprite):void
_bitMap property
_bitMap:Bitmap [read-write]

Is required when used in conjunction with the getColorBitmap. An error will be thrown when _bitMap is not defined.

There is no default value. .

.

Implementation

public static function get _bitMap():Bitmap
public static function set _bitMap(value:Bitmap):void
_xPos property
_xPos:int [read-write]

Sets the x value to retrieve color information.

The default value is 0.

.

Implementation

public static function get _xPos():int
public static function set _xPos(value:int):void
_yPos property
_yPos:int [read-write]

Sets the y value to retrieve color information.

The default value is 0.

.

Implementation

public static function get _yPos():int
public static function set _yPos(value:int):void
Constructor Detail
GetBitmapData ()  Constructor
public function GetBitmapData(mp:MakePrivate)
To initialize an instance use GetBitmapData.getInstance().
Method Detail

getColorBitmap()  method
public static function getColorBitmap():String

Function returns the color information of a Bitmap at default 0, 0 position when _xPos and _yPos is not set. Requires to set the _bitMap property.

Method Detail

getColorSprite()  method
public static function getColorSprite(target:Sprite):String

Function returns the color information of a Sprite at default 0, 0 position when _xPos and _yPos is not set.

Parameters

  • target:Sprite ____ Specifies the Sprite object to use data from with regards to width and height.
Method Detail

multiplyColor()  method
public static function multiplyColor(_root:Object, red:Number=1, green:Number=1, blue:Number=1, _alpha:Number=1, xPos:int=0, yPos:int=0, _width:int=100, _height:int=100, _replace:Boolean=false):void

This method creates a new Bitmap using the Multiplier color values. When _replace is false, the Bitmap is placed inside the Object defined by _root . Otherwise the Bitmap replaces the _root object.

The coordinates for the new Bitmap are given by xPos and yPos , which by default are 0.

Parameters

  • _root:Object ____ Specifies the object to place the new Bitmap in or replace it.
  • red:int ____ Specifies the redMultiplier. The default is 1.
  • green:int ____ Specifies the greenMultiplier. The default is 1.
  • blue:int ____ Specifies the blueMultiplier. The default is 1.
  • _alpha:Number ____ Specifies the alphaMultiplier. The default is 1.
  • xPos:int ____ Specifies the x position of the new Bitmap within the _root object or the position on the timeline when the _root object is deleted.
  • yPos:int ____ Specifies the y position of the new Bitmap within the _root object or the position on the timeline when the _root object is deleted.
  • _width:int ____ Specifies the width of the new Bitmap. If target is specified, the width will be the width of the target Sprite. Otherwise the default is 100.
  • _height:int ____ Specifies the height of the new Bitmap. If target is specified, the width will be the height of the target Sprite. Otherwise the default is 100.

offsetColor()  method
public static function offsetColor(_root:Object, red:Number=1, green:Number=1, blue:Number=1, _alpha:Number=1, xPos:int=0, yPos:int=0, _width:int=100, _height:int=100, _replace:Boolean=false):void

This method creates a new Bitmap using the Multiplier color values. When _replace is false, the Bitmap is placed inside the Object defined by _root . Otherwise the Bitmap replaces the _root object.

The coordinates for the new Bitmap are given by xPos and yPos , which by default are 0.

Parameters

  • _root:Object ____ Specifies the object to place the new Bitmap in or replace it.
  • red:int ____ Specifies the redMultiplier. The default is 1.
  • green:int ____ Specifies the greenMultiplier. The default is 1.
  • blue:int ____ Specifies the blueMultiplier. The default is 1.
  • _alpha:Number ____ Specifies the alphaMultiplier. The default is 1.
  • xPos:int ____ Specifies the x position of the new Bitmap within the _root object or the position on the timeline when the _root object is deleted.
  • yPos:int ____ Specifies the y position of the new Bitmap within the _root object or the position on the timeline when the _root object is deleted.
  • _width:int ____ Specifies the width of the new Bitmap. If target is specified, the width will be the width of the target Sprite. Otherwise the default is 100.
  • _height:int ____ Specifies the height of the new Bitmap. If target is specified, the width will be the height of the target Sprite. Otherwise the default is 100.
Event Detail
N/A
Examples
EXAMPLE: Create a new fla file and name it GetBitmapData.fla. Place the fla in the same folder as the biz folder. Place two MovieClips on the main timeline with the identifier mc and mc1. Then create an Actionscript file, name it Getbitmapdata.as and place this script.

package 
{
	import flash.display.Sprite;
	import flash.display.BitmapData;
	import flash.display.Bitmap;
	import biz.flashscript.bitmap.GetBitmapData;
	import flash.display.MovieClip;
	import flash.text.TextField;

	public class Getbitmapdata extends Sprite
	{
		public var mc:MovieClip;
		public var mc1:MovieClip;
		public var myText:TextField;
		public function Getbitmapdata ():void
		{
			var gp:GetBitmapData = GetBitmapData.getInstance();
			GetBitmapData._x = 60;
			GetBitmapData._y = 0;
			myText.appendText ("Color (x 60, y 0): "+GetBitmapData.getColorSprite(mc)+"\n");
			//
			GetBitmapData.target = mc;
			GetBitmapData._x = 0;
			GetBitmapData._y = 0;
			GetBitmapData.multiplyColor(mc1);
			myText.appendText("ColorBitmap (mc1,multiplyColor): "+GetBitmapData.getColorBitmap()+"\n");
			GetBitmapData.offsetColor (mc1, 255, 100, -210, 0.5, 10, 10, 100, 20, false);
			myText.appendText ("ColorBitmap (mc1,offsetColor): "+GetBitmapData.getColorBitmap());
		}
	}
}