Hi, I’ve using this code for a color picker, in AS2, but I’m trying to make it to AS3
this is the code
import flash.display.*;
import flash.geom.*;
var image_bitmap = new BitmapData(img_mc._width, img_mc._height);
image_bitmap.draw(img_mc);
onMouseDown = function () {
if (img_mc.hitTest(_xmouse, _ymouse, true)) {
var curr_color:Number = image_bitmap.getPixel(img_mc._xmouse, img_mc._ymouse);
var preview_colortansform = new ColorTransform();
preview_colortansform.rgb = curr_color;
target_mc.transform.colorTransform = preview_colortansform;
trace(curr_color.toString(16));
};
}
I know I gotta replace _xmouse and _ymouse with mouseX and mouseY but, the next error it gives me is about the “onMouseDown” shrug wat to do?
(my english SUCKS lol sorry :S)
-koopakilla
You will have to listen for the MouseDown event:
This in AS 2:
onMouseDown = function ()
{
// function contents
}
Turns into this in AS3:
import flash.events.MouseEvent;
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void
{
// function contents
}
holycrap, that was fast.
Uhm…
AS3 = Supercomplicated.
thank you 
Mshhhhhhhh
now, that I got it, I got some more errors ¬¬
_height is no longer supported
hitTest is no longer supported
X_X
import flash.events.MouseEvent;
import flash.display.*;
import flash.geom.*;
var image_bitmap = new BitmapData(img_mc.DisplayObject.height, img_mc.DisplayObject.width);
image_bitmap.draw(img_mc);
addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
function mouseDownHandler(event:MouseEvent):void
{
if (img_mc.DisplayObject.hitTestObject(mouseX,mouseY, true)) {
var curr_color:Number = image_bitmap.getPixel(img_mc.mouseX, img_mc.mouseY);
var preview_colortansform = new ColorTransform();
preview_colortansform.rgb = curr_color;
target_mc.transform.colorTransform = preview_colortansform;
trace(curr_color.toString(16));
}
}
has no errors now, it still doesnt work X_X
anyone a clue of what to do?
As a general rule, any properties that had an underscore in AS2 (i.e. mc._width, mc._height), are now called without the underscore (i.e. mc.height, mc.width). Also the hitTest() function has been replaced with hitTestObject() or hitTestPoint().