Packageaway3d.tools.utils
Classpublic class ColorHitMap
InheritanceColorHitMap Inheritance flash.events.EventDispatcher



Public Properties
 PropertyDefined By
  bitmapData : BitmapData
The source bitmapdata uses for colour readings
ColorHitMap
  offsetX : Number
The offsetX, offsetY by default offsetX and offsetY represent the center of the map.
ColorHitMap
  offsetY : Number
ColorHitMap
  scaleX : Number
defines the scaleX and scaleY.
ColorHitMap
  scaleY : Number
ColorHitMap
Public Methods
 MethodDefined By
  
ColorHitMap(bitmapData:BitmapData, scaleX:Number = 1, scaleY:Number = 1)
Creates a new ColorHitMap
ColorHitMap
  
addColorEvent(color:Number, eventID:String, listener:Function):void
Defines a color event for this class.
ColorHitMap
  
getColorAt(x:Number, y:Number):uint
returns the color at x,y coordinates.
ColorHitMap
  
plotAt(x:Number, y:Number, color:uint = 0xFF0000):void
Another method for debug, if you addChild your bitmapdata on screen, this method will colour a pixel at the coordinates helping you to visualize if your scale factors or entered coordinates are correct.
ColorHitMap
  
read(x:Number, y:Number):void
If at the given coordinates a color is found that matches a defined color event, the color event will be triggered.
ColorHitMap
  
removeColorEvent(eventID:String):void
removes a color event by its id
ColorHitMap
Property Detail
bitmapDataproperty
bitmapData:BitmapData

The source bitmapdata uses for colour readings


Implementation
    public function get bitmapData():BitmapData
    public function set bitmapData(value:BitmapData):void
offsetXproperty 
offsetX:Number

The offsetX, offsetY by default offsetX and offsetY represent the center of the map.


Implementation
    public function get offsetX():Number
    public function set offsetX(value:Number):void
offsetYproperty 
offsetY:Number


Implementation
    public function get offsetY():Number
    public function set offsetY(value:Number):void
scaleXproperty 
scaleX:Number

defines the scaleX and scaleY. Defines the ratio map to the 3d world


Implementation
    public function get scaleX():Number
    public function set scaleX(value:Number):void
scaleYproperty 
scaleY:Number


Implementation
    public function get scaleY():Number
    public function set scaleY(value:Number):void
Constructor Detail
ColorHitMap()Constructor
public function ColorHitMap(bitmapData:BitmapData, scaleX:Number = 1, scaleY:Number = 1)

Creates a new ColorHitMap

Parameters
bitmapData:BitmapData — The bitmapdata with color regions to act as trigger.
 
scaleX:Number (default = 1) — [optional] A factor scale along the X axis. Default is 1.
 
scaleY:Number (default = 1) — [optional] A factor scale along the Y axis. Default is 1. Note that by default the class is considered as centered, like a plane at 0,0,0. Also by default coordinates offset are set. If a map of 256x256 is set, and no custom offsets are set. The read method using the camera position -128 x and -128 z would return the color value found at 0,0 on the map.
Method Detail
addColorEvent()method
public function addColorEvent(color:Number, eventID:String, listener:Function):void

Defines a color event for this class. If read method is called, and the target pixel color has the same value as a previously set listener, an event is triggered.

Parameters

color:Number — A color Number
 
eventID:String — A string to identify that event
 
listener:Function — The function that must be triggered

getColorAt()method 
public function getColorAt(x:Number, y:Number):uint

returns the color at x,y coordinates. This method is made to test if the color is indeed the expected one, (the one you set for an event), as due to compression for instance using the Flash IDE library, compression might have altered the color values.

Parameters

x:Number — X coordinate on the source bitmapData
 
y:Number — Y coordinate on the source bitmapData

Returns
uint — A uint, the color value at coordinates x, y

See also

plotAt
plotAt()method 
public function plotAt(x:Number, y:Number, color:uint = 0xFF0000):void

Another method for debug, if you addChild your bitmapdata on screen, this method will colour a pixel at the coordinates helping you to visualize if your scale factors or entered coordinates are correct.

Parameters

x:Number — X coordinate on the source bitmapData
 
y:Number — Y coordinate on the source bitmapData
 
color:uint (default = 0xFF0000)

read()method 
public function read(x:Number, y:Number):void

If at the given coordinates a color is found that matches a defined color event, the color event will be triggered.

Parameters

x:Number — X coordinate on the source bmd
 
y:Number — Y coordinate on the source bmd

removeColorEvent()method 
public function removeColorEvent(eventID:String):void

removes a color event by its id

Parameters

eventID:String — The Event id