So I basically resolved this issue myself by working within FlxSprite and not trying to dick around with BitmapData. It also dawned on my that one of the objects I was trying to get the BitmapData of was an FlxSpriteGroup which is why it was coming up null but not throwing a type error. Anyways, this is my FlxGroup flattening solution in case anyone wants it.
public static function flattenSpriteGroup(source:FlxSpriteGroup):FlxSprite {
/*
* Flattening function, useful for when you're trying to construct
* an asset from multiple different assests, such as a multi-layered tile
* or a character sprite.
*
* Only works for sprites of the same size at (0,0). In theory should have worked
* for any sprite sizes, but there's some weirdness with sprite positioning that
* I can't be bothered with figuring out.
*/
var finalSprite:FlxSprite = new FlxSprite();
source.forEach(function(sprite:Dynamic){
var workingSprite:FlxSprite = sprite;
if (sprite.graphic == null){
//Check if sprite is a group
if (sprite.group != null && sprite.group.length > 0){
Log.trace("recursion");
workingSprite = flattenSpriteGroup(sprite);
}
else {
//If no group is found then sprite just has no graphic so we ignore it
return;
}
}
if (finalSprite.graphic == null){
finalSprite.loadGraphic(workingSprite.graphic);
}
if (workingSprite != null){
//finalSprite.stamp(workingSprite, cast(workingSprite.x, Int), cast(workingSprite.y, Int));
finalSprite.stamp(workingSprite, 0, 0);
}
});
return finalSprite;
}