I'm trying to create a game in which after you click on an object, the object glows. When I embed an image and pass it through a bitmap, it works fine, like this:
package
{
import org.flixel.*;
public class HelloWorld extends FlxState
{
[Embed(source = "pics/Cancer.png")] private var cancerIMG:Class;
private var cancer:FlxSprite;
private var title_text:FlxText;
public function HelloWorld()
{
}
override public function create():void
{
/**
* Glow method test
*/
//Start Test
var bigbitmap:BitmapData = new BitmapData(320, 288, true, 0x00000000);
bigbitmap.copyPixels(Bitmap(new cancerIMG).bitmapData, new Rectangle(0, 0, 160, 288), new Point(16, 16), null, null, true);
cancer = new FlxSprite;
cancer.pixels = bigbitmap;
add(cancer);
//End Test
}
override public function update():void
{
super.update();
}
}
}
However, whenever I try to pass a class sprite using that same method, like this:
_bx = new box(120, 120);
var bigbitmap:BitmapData = new BitmapData(320, 288, true, 0x00000000);
bigbitmap.copyPixels(Bitmap(_bx.pixels).bitmapData, new Rectangle(0, 0, 160, 288), new Point(16, 16), null, null, true);
_bx.pixels = bigbitmap;
add(_bx);
I call the box like this:
public var _bx:box;
Which, itself is a FlxExtendedSprite (reverted it back to a regular FlxSprite though for the test). When I try that, I get the error of:
Error #1034: Type Coercion failed: cannot convert flash.display::BitmapData@3960701 to flash.display.Bitmap.
Is there an way I can fix this effect and get it to work with classes like this?
Thanks in advance!