In the context of PHP image manipulation, what are some common pitfalls to avoid when dealing with transparency and color manipulation for display in Flash?

When dealing with transparency and color manipulation for display in Flash, a common pitfall to avoid is not properly handling alpha transparency values. To ensure that transparency is correctly preserved, it is important to use the correct image format (such as PNG) that supports alpha transparency. Additionally, when manipulating colors, be mindful of how Flash interprets color values and ensure that they are converted correctly.

// Ensure correct alpha transparency handling by saving image as PNG
$image = imagecreatefrompng('image.png');
imagealphablending($image, false);
imagesavealpha($image, true);

// Manipulate color values and ensure correct conversion for Flash
$color = imagecolorallocate($image, 255, 0, 0); // Red color
$flashColor = imagecolorallocate($image, 255, 0, 0); // Convert color for Flash

// Output image
header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);