Creating 3 button state images from image

Subscribe to Creating 3 button state images from image 4 posts

avatar for Arloistale Arloistale 65 posts
Flag Post

I have a ImageButton class that extends SimpleButton. I need it to generate the 3 button states (up, down, over) from just one image. The up state will be the regular image, the over state will have the non-blank parts of the image slightly tinted, and the down state will be a kind of glow (I’m assuming this can be achieved with some kind of filter).

Right now I have

public class ImageButton extends SimpleButton
{
    public function ImageButton(image:Bitmap) 
    {
        var originalData:BitmapData = image.bitmapData;
        var stateData:Array = new Array();
        for (var i:uint = 0; i < 3; i++)
        {
            var newData:BitmapData = new BitmapData(
                originalData.width, originalData.height, true,
                0x00FFFFFF);

            newData.copyPixels(originalData, originalData.rect, new Point(0, 0));
    
            stateData.push(newData);
        }
 
        var upImage:Bitmap = new Bitmap(stateData[0]);
        var overImage:Bitmap = new Bitmap(stateData[1]);
        var downImage:Bitmap = new Bitmap(stateData[2]);

        super(upImage, overImage, downImage, upImage);
    }
}

How can I apply filters or something to the 3 generated images so that they look like what I described? Help! :(

 
avatar for vesperbot vesperbot 1883 posts
Flag Post

BitmapData.applyFilter() and use whatever filters you fancy. GlowFilter, ColorMatrixFilter, ShaderFilter should you be able to make shaders.

 
avatar for Arloistale Arloistale 65 posts
Flag Post

These filters require matrices, though and I’m not really sure how I’m supposed to create and manipulate matrices for the filters.

 
avatar for NineFiveThree NineFiveThree 1378 posts
Flag Post

If you need a duplicate of a BitmapData, you can clone() it.
Why not keep one BitmapData and apply the filters to the Bitmap?

Originally posted by Arloistale:

These filters require matrices, though and I’m not really sure how I’m supposed to create and manipulate matrices for the filters.

just google it
http://active.tutsplus.com/tutorials/effects/manipulate-visual-effects-with-the-colormatrixfilter-and-convolutionfilter/