From: k...@designdrumm.com
Subject: Re: [Flashcoders] (no subject)
Date: Wed, 1 Sep 2010 18:51:38 -0500
To: flashcoders@chattyfig.figleaf.com
I dont think that setting the alpha to true was your problem.
It may not be showing anything because it may be making ALL the
pixels transparent?
I assume that's what's happening, yes, but I don't know how to change that. How
could I set the alpha in
_fire = new BitmapData(865, 92, false, 0xff);
to true for *just* certain bitmap data? I don't imagine that's possible, and
therein, I believe, lies my problem.
Maybe look into that? Also try blendmode overlay. That may help the
opaque pixels lay over the transparent ones. or vice versa
I don't have an example per say, but had the same problem with a php
image creation script I was writing and the blendmode overlay helped
there.
May do the same for you.
Yeah, no such luck, Karl. I forgot to mention I tried every combination to see
what would happen. If there were some way I could catch the values, for
example, coming out of this function:
private function _createPalette(idx:int):void {
_redArray = [];
_greenArray = [];
_blueArray = [];
_alphaArray = [];
for (var i:int = 0; i 256; i++) {
var gp:int = new int();
gp = _fireColor.getPixel(i, 0);
if (gp 1050112)
{
_redArray.push(255);
_alphaArray.push(255);
} else {
_redArray.push(gp);
_alphaArray.push(0);
}
_greenArray.push(0);
_blueArray.push(0);
}
}
where I catch the values under a certain numeric value in my if statement with
the var gp, then somehow set the alpha of those values to 0 and leave the rest
at alpha=1, I'd be set, but I can't figure out how to do that.
TIA,
George
On Sep 1, 2010, at 7:15 AM, George Jones wrote:
Hi;
I'm trying to tweak a script I found online to work for my
application. The problem I am having is to make a certain part of
the bitmap that is created by code transparent...but only a certain
part of it. The code has the following:
_fire = new BitmapData(865, 92, false, 0xff);
Note
the alpha flag must be set to false, which is the source of my
problem,
or nothing prints to screen at all. I need to make certain pixels
transparent. _fire is added to the stage and then called thus:
_fire.paletteMap(_grey, _grey.rect, ZERO_POINT,
_redArray, _greenArray, _blueArray, _alphaArray);
at the end of the script. The colors for the arrays are created
thusly:
private function _createPalette(idx:int):void {
_redArray = [];
_greenArray = [];
_blueArray = [];
_alphaArray = [];
for (var i:int = 0; i 256; i++) {
var gp:int = new int();
gp = _fireColor.getPixel(i, 0);
if (gp 1050112)
{
_redArray.push(255);
_alphaArray.push(255);
} else {
_redArray.push(gp);
_alphaArray.push(0);
}
_greenArray.push(0);
_blueArray.push(0);
}
}
I
added that if clause to capture when the color is black because
that's
where I need to make it transparent. The problem is that where I
need it
to be transparent, it's blue (why blue I don't know). Is there any
way
to make it transparent? The entire code follows.
TIA,
George
package {
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.DisplayObject;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.Sprite;
import flash.display.StageQuality;
import flash.display.StageScaleMode;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.filters.ColorMatrixFilter;
import flash.filters.ConvolutionFilter;
import flash.geom.ColorTransform;
import flash.geom.Point;
import flash.system.LoaderContext;
import flash.net.SharedObject;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
[SWF(width=465, height=92, backgroundColor=0xff,
frameRate=30)]
public class Fire extends Sprite {
private static const ZERO_POINT:Point = new Point();
private var _fireColor:BitmapData;
private var _currentFireColor:int;
private var _canvas:Sprite;
private var _grey:BitmapData;
private var _spread:ConvolutionFilter;
private var _cooling:BitmapData;
private var _color:ColorMatrixFilter;
private var _offset:Array;
private var _fire:BitmapData;