RE: [Flashcoders] Impossible?
George, Karl, et al, Check out the link below. http://keithreinfeld.home.comcast.net/~keithreinfeld/Demos/Fire/Fire.html I'm not entirely satisfied with the results. I can't quite manage to get rid of the black rim around the flames. Here are the additions I made to Fire.as: // declare private var _flame:Sprite = new Sprite(); private var _bmdFlame:BitmapData; // set WIDTH and HEIGHT to whatever you need private var WIDTH:Number = 400; private var HEIGHT:Number = 300; // in the _onLoaded () function // do not add _fire to the displaylist //addChild(new Bitmap(_fire)); // this transparency must be set to true _bmdFlame = new BitmapData(WIDTH, HEIGHT, true, 0xFF00); //addChild(new Bitmap(_bmdFlame));// this works too _flame.x = _flame.y = 0;// but _flame can be repositioned addChild(_flame); // in the _update() function (at the end of the function) _bmdFlame.draw(new Bitmap(_fire)); _bmdFlame.threshold(_bmdFlame, _bmdFlame.rect, ZERO_POINT, , 0x0010, 0x, 0x00F0, false); if(_flame.numChildren 0){ _flame.removeChildAt(0); } _flame.addChild(new Bitmap(_bmdFlame)); You can try tweaking the threshold values, but these are working. If anyone is interested, the original source files can be found here: http://wonderfl.net/c/3g08 Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Impossible?
I can't quite manage to get rid of the black rim around the flames. The problem was with the palette. http://keithreinfeld.home.comcast.net/~keithreinfeld/Demos/Fire/Fire.html Regards, Keith Reinfeld Home Page: http://keithreinfeld.home.comcast.net ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
@George, Ran across this link I think might interest you. Its a flame effect with transparency in as2 and as3. Haven't tested, but thought you might be able to dissect it to fix yours. Unless you gave up that is... :) http://www.actionscript.org/forums/showthread.php3?t=138056 HTH, Best, Karl On Sep 9, 2010, at 7:47 AM, George Jones wrote: From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Thu, 9 Sep 2010 07:39:51 -0500 To: flashcoders@chattyfig.figleaf.com Sorry, didn't see your comment at the bottom. Yeah. I'm about ready to throw in the towel on this one. I don't think it's possible. George Karl On Sep 9, 2010, at 7:28 AM, George Jones wrote: From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Wed, 8 Sep 2010 16:18:36 -0500 To: flashcoders@chattyfig.figleaf.com On Sep 8, 2010, at 1:15 PM, George Jones wrote: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); Shouldn't this be _blueArray.push(0); and only alphaArray should be set to 255? That may be why your getting a blue background. First up, I fixed the flame coming back. As I supposed, that was easy. The problem remains with making the background disappear. I've reworked the code some: gp = _fireColor.getPixel(i, 0); if (_bitmapFlag == true gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else if (_bitmapFlag == false gp 1050112) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } I've changed the if statement. Values of gp less than 1050112 are that which are not the flame, therefore are the background which should be set to alpha=0. When _bitmapFlag == true, then it's the mask that's being painted; otherwise, the sprite being masked (the else if statement). The final else statement is for the flame itself. Interestingly, changing the value of either the blue, green or alpha of that final else statement to 255 gives a blue flame with white border and very attractive, though not what I want. I wonder why changing the alpha especially would have that effect. I guess what I'm not clear about is the values I'm pushing. If I push 255 for the red, green and blue arrays, does that result in white? If I push 0 for alpha, is that the same as alpha=0 or alpha=1? Here again is the code for building the sprites: private function _onLoadedAll(e:Event):void { _onLoadedContent(e, _bitmapFlag = false); _onLoadedContent(e, _bitmapFlag = true); } private function _onLoadedContent(e:Event, _bitmapFlag:Boolean):void { _fireColor = Bitmap(LoaderInfo (e.target).loader.content).bitmapData; ... if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } I'm wondering now if this is possible, to mask the flame only and let the background show. The following combinations give me a blue background and flame: if (gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(255); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); This gives me
RE: [Flashcoders] Impossible?
From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Wed, 8 Sep 2010 16:18:36 -0500 To: flashcoders@chattyfig.figleaf.com On Sep 8, 2010, at 1:15 PM, George Jones wrote: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); Shouldn't this be _blueArray.push(0); and only alphaArray should be set to 255? That may be why your getting a blue background. First up, I fixed the flame coming back. As I supposed, that was easy. The problem remains with making the background disappear. I've reworked the code some: gp = _fireColor.getPixel(i, 0); if (_bitmapFlag == true gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else if (_bitmapFlag == false gp 1050112) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } I've changed the if statement. Values of gp less than 1050112 are that which are not the flame, therefore are the background which should be set to alpha=0. When _bitmapFlag == true, then it's the mask that's being painted; otherwise, the sprite being masked (the else if statement). The final else statement is for the flame itself. Interestingly, changing the value of either the blue, green or alpha of that final else statement to 255 gives a blue flame with white border and very attractive, though not what I want. I wonder why changing the alpha especially would have that effect. I guess what I'm not clear about is the values I'm pushing. If I push 255 for the red, green and blue arrays, does that result in white? If I push 0 for alpha, is that the same as alpha=0 or alpha=1? Here again is the code for building the sprites: private function _onLoadedAll(e:Event):void { _onLoadedContent(e, _bitmapFlag = false); _onLoadedContent(e, _bitmapFlag = true); } private function _onLoadedContent(e:Event, _bitmapFlag:Boolean):void { _fireColor = Bitmap(LoaderInfo(e.target).loader.content).bitmapData; ... if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } I'm wondering now if this is possible, to mask the flame only and let the background show. The following combinations give me a blue background and flame: if (gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(255); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); This gives me a black background: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(0); TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
I believe this will get you transparent black pixels? _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(0); Best, Karl On Sep 9, 2010, at 7:28 AM, George Jones wrote: From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Wed, 8 Sep 2010 16:18:36 -0500 To: flashcoders@chattyfig.figleaf.com On Sep 8, 2010, at 1:15 PM, George Jones wrote: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); Shouldn't this be _blueArray.push(0); and only alphaArray should be set to 255? That may be why your getting a blue background. First up, I fixed the flame coming back. As I supposed, that was easy. The problem remains with making the background disappear. I've reworked the code some: gp = _fireColor.getPixel(i, 0); if (_bitmapFlag == true gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else if (_bitmapFlag == false gp 1050112) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } I've changed the if statement. Values of gp less than 1050112 are that which are not the flame, therefore are the background which should be set to alpha=0. When _bitmapFlag == true, then it's the mask that's being painted; otherwise, the sprite being masked (the else if statement). The final else statement is for the flame itself. Interestingly, changing the value of either the blue, green or alpha of that final else statement to 255 gives a blue flame with white border and very attractive, though not what I want. I wonder why changing the alpha especially would have that effect. I guess what I'm not clear about is the values I'm pushing. If I push 255 for the red, green and blue arrays, does that result in white? If I push 0 for alpha, is that the same as alpha=0 or alpha=1? Here again is the code for building the sprites: private function _onLoadedAll(e:Event):void { _onLoadedContent(e, _bitmapFlag = false); _onLoadedContent(e, _bitmapFlag = true); } private function _onLoadedContent(e:Event, _bitmapFlag:Boolean):void { _fireColor = Bitmap(LoaderInfo (e.target).loader.content).bitmapData; ... if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } I'm wondering now if this is possible, to mask the flame only and let the background show. The following combinations give me a blue background and flame: if (gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(255); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); This gives me a black background: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(0); TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo
Re: [Flashcoders] Impossible?
Sorry, didn't see your comment at the bottom. Karl On Sep 9, 2010, at 7:28 AM, George Jones wrote: From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Wed, 8 Sep 2010 16:18:36 -0500 To: flashcoders@chattyfig.figleaf.com On Sep 8, 2010, at 1:15 PM, George Jones wrote: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); Shouldn't this be _blueArray.push(0); and only alphaArray should be set to 255? That may be why your getting a blue background. First up, I fixed the flame coming back. As I supposed, that was easy. The problem remains with making the background disappear. I've reworked the code some: gp = _fireColor.getPixel(i, 0); if (_bitmapFlag == true gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else if (_bitmapFlag == false gp 1050112) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } I've changed the if statement. Values of gp less than 1050112 are that which are not the flame, therefore are the background which should be set to alpha=0. When _bitmapFlag == true, then it's the mask that's being painted; otherwise, the sprite being masked (the else if statement). The final else statement is for the flame itself. Interestingly, changing the value of either the blue, green or alpha of that final else statement to 255 gives a blue flame with white border and very attractive, though not what I want. I wonder why changing the alpha especially would have that effect. I guess what I'm not clear about is the values I'm pushing. If I push 255 for the red, green and blue arrays, does that result in white? If I push 0 for alpha, is that the same as alpha=0 or alpha=1? Here again is the code for building the sprites: private function _onLoadedAll(e:Event):void { _onLoadedContent(e, _bitmapFlag = false); _onLoadedContent(e, _bitmapFlag = true); } private function _onLoadedContent(e:Event, _bitmapFlag:Boolean):void { _fireColor = Bitmap(LoaderInfo (e.target).loader.content).bitmapData; ... if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } I'm wondering now if this is possible, to mask the flame only and let the background show. The following combinations give me a blue background and flame: if (gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(255); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); This gives me a black background: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(0); TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Karl DeSaulniers Design Drumm http://designdrumm.com
RE: [Flashcoders] Impossible?
From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Thu, 9 Sep 2010 07:39:51 -0500 To: flashcoders@chattyfig.figleaf.com Sorry, didn't see your comment at the bottom. Yeah. I'm about ready to throw in the towel on this one. I don't think it's possible. George Karl On Sep 9, 2010, at 7:28 AM, George Jones wrote: From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Wed, 8 Sep 2010 16:18:36 -0500 To: flashcoders@chattyfig.figleaf.com On Sep 8, 2010, at 1:15 PM, George Jones wrote: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); Shouldn't this be _blueArray.push(0); and only alphaArray should be set to 255? That may be why your getting a blue background. First up, I fixed the flame coming back. As I supposed, that was easy. The problem remains with making the background disappear. I've reworked the code some: gp = _fireColor.getPixel(i, 0); if (_bitmapFlag == true gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else if (_bitmapFlag == false gp 1050112) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } I've changed the if statement. Values of gp less than 1050112 are that which are not the flame, therefore are the background which should be set to alpha=0. When _bitmapFlag == true, then it's the mask that's being painted; otherwise, the sprite being masked (the else if statement). The final else statement is for the flame itself. Interestingly, changing the value of either the blue, green or alpha of that final else statement to 255 gives a blue flame with white border and very attractive, though not what I want. I wonder why changing the alpha especially would have that effect. I guess what I'm not clear about is the values I'm pushing. If I push 255 for the red, green and blue arrays, does that result in white? If I push 0 for alpha, is that the same as alpha=0 or alpha=1? Here again is the code for building the sprites: private function _onLoadedAll(e:Event):void { _onLoadedContent(e, _bitmapFlag = false); _onLoadedContent(e, _bitmapFlag = true); } private function _onLoadedContent(e:Event, _bitmapFlag:Boolean):void { _fireColor = Bitmap(LoaderInfo (e.target).loader.content).bitmapData; ... if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } I'm wondering now if this is possible, to mask the flame only and let the background show. The following combinations give me a blue background and flame: if (gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); if (gp 1050112) { _redArray.push(255); _alphaArray.push(255); _greenArray.push(255); _blueArray.push(255); This gives me a black background: if (gp 1050112
Re: [Flashcoders] Impossible?
Oh but your so close. :) Do you have a link to the results your getting? All you want is red fire on a transparent background right? I know that in PHP image creation, you have to set how the pixels blend as well after you get the color matrix. EG: overlay, subtract, add, etc. Is there maybe something missing here? Blendmode? also, if the pixels that are gp are the ones you want transparent, would if (_bitmapFlag == true gp 1050112) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } else if (_bitmapFlag == false gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(gp); _blueArray.push(gp); } else { _redArray.push(255); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } work? Karl On Sep 9, 2010, at 7:47 AM, George Jones wrote: From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Thu, 9 Sep 2010 07:39:51 -0500 To: flashcoders@chattyfig.figleaf.com Sorry, didn't see your comment at the bottom. Yeah. I'm about ready to throw in the towel on this one. I don't think it's possible. George Karl On Sep 9, 2010, at 7:28 AM, George Jones wrote: From: k...@designdrumm.com Subject: Re: [Flashcoders] Impossible? Date: Wed, 8 Sep 2010 16:18:36 -0500 To: flashcoders@chattyfig.figleaf.com On Sep 8, 2010, at 1:15 PM, George Jones wrote: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); Shouldn't this be _blueArray.push(0); and only alphaArray should be set to 255? That may be why your getting a blue background. First up, I fixed the flame coming back. As I supposed, that was easy. The problem remains with making the background disappear. I've reworked the code some: gp = _fireColor.getPixel(i, 0); if (_bitmapFlag == true gp 1050112) { _redArray.push(255); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else if (_bitmapFlag == false gp 1050112) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(255); _blueArray.push(255); } else { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } I've changed the if statement. Values of gp less than 1050112 are that which are not the flame, therefore are the background which should be set to alpha=0. When _bitmapFlag == true, then it's the mask that's being painted; otherwise, the sprite being masked (the else if statement). The final else statement is for the flame itself. Interestingly, changing the value of either the blue, green or alpha of that final else statement to 255 gives a blue flame with white border and very attractive, though not what I want. I wonder why changing the alpha especially would have that effect. I guess what I'm not clear about is the values I'm pushing. If I push 255 for the red, green and blue arrays, does that result in white? If I push 0 for alpha, is that the same as alpha=0 or alpha=1? Here again is the code for building the sprites: private function _onLoadedAll(e:Event):void { _onLoadedContent(e, _bitmapFlag = false); _onLoadedContent(e, _bitmapFlag = true); } private function _onLoadedContent(e:Event, _bitmapFlag:Boolean):void { _fireColor = Bitmap(LoaderInfo (e.target).loader.content).bitmapData; ... if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } I'm wondering now if this is possible, to mask the flame only and let the background show. The following combinations give me a blue background and flame: if (gp 1050112) { _redArray.push(255
Re: [Flashcoders] Impossible?
what henrik said, or stick them in sprites first and mask the sprites... On 7 September 2010 21:16, Henrik Andersson he...@henke37.cjb.net wrote: Mask the Bitmap, not the BitmapData. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Impossible?
From: tom.rho...@gmail.com Date: Wed, 8 Sep 2010 11:01:21 +0200 Subject: Re: [Flashcoders] Impossible? To: flashcoders@chattyfig.figleaf.com what henrik said, or stick them in sprites first and mask the sprites... I'm a little lost. I've followed your suggestion and it *appears* I've correctly added my sprites to stage, but nothing shows up, which either means the sprites are not correctly added or, more probably I think, that the mask is masking everything. Here's my code: if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; trace(_fireSprite.mask); _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } _createCooling(0.16); _createPalette(_currentFireColor = 0, _bitmapFlag); ... private function _createPalette(idx:int, _bitmapFlag:Boolean):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(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); } else if (_bitmapFlag == false) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } else { _redArray.push(0); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } } } The trace traces that there is a sprite there, so that would indicate that both sprites have successfully been added to the stage. Again, the if statement where the var gp is less than 1050112 indicates that which should appear transparent. Presuming it is a problem of masking too much, what do? TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
When in doubt about masking, skip the step where you assign the mask property, but leave the mask shape added, it will show what parts the mask will apply to. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Impossible?
Date: Wed, 8 Sep 2010 18:16:44 +0200 From: he...@henke37.cjb.net To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Impossible? When in doubt about masking, skip the step where you assign the mask property, but leave the mask shape added, it will show what parts the mask will apply to. I did that. I commented out this line: _fireSprite.mask = _fireMaskSprite; and nothing prints to screen. Therefore, it would appear that the mask is applying to all of it. This is where I get confused. I'm thinking I must have a problem in where I'm assigning my various values: for (var i:int = 0; i 256; i++) { var gp:int = new int(); gp = _fireColor.getPixel(i, 0); if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); } else if (_bitmapFlag == false) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } else { _redArray.push(0); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } } When _bitmapFlag = true it's the mask; otherwise, that which is masked. When gp 1050112 it's that which should be transparent. Any thoughts? TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
George Jones skriver: Date: Wed, 8 Sep 2010 18:16:44 +0200 From: he...@henke37.cjb.net To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Impossible? When in doubt about masking, skip the step where you assign the mask property, but leave the mask shape added, it will show what parts the mask will apply to. I did that. I commented out this line: _fireSprite.mask = _fireMaskSprite; and nothing prints to screen. Therefore, it would appear that the mask is applying to all of it. Incorrect, the mask isn't even added to the screen. And I doubt that the content is visible either. The mask clearly isn't the issue here, since it's not even used. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Impossible?
Date: Wed, 8 Sep 2010 18:46:52 +0200 From: he...@henke37.cjb.net To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Impossible? Incorrect, the mask isn't even added to the screen. And I doubt that the content is visible either. _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); This code executes. It doesn't add the mask to the stage? Please advise. TIA. George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
George Jones skriver: This code executes. It doesn't add the mask to the stage? Please advise. Forget about the mask until you get the output to work without it. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Impossible?
Date: Wed, 8 Sep 2010 19:20:05 +0200 From: he...@henke37.cjb.net To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Impossible? Forget about the mask until you get the output to work without it. There was a fundamental error, now corrected. However, now what I get is black fire against a blue background: if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fireSprite.addChild(new Bitmap(_fireMask)); addChild(_fireSprite); _fireSprite.mask = _fireMaskSprite; _fireSprite.cacheAsBitmap = true; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); _fireMaskSprite.addChild(new Bitmap(_fireMask)); addChild(_fireMaskSprite); _fireMaskSprite.cacheAsBitmap = true; } ... private function _createPalette(idx:int, _bitmapFlag:Boolean):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(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); } else if (_bitmapFlag == false) { _redArray.push(gp); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } else { _redArray.push(0); _alphaArray.push(0); _greenArray.push(0); _blueArray.push(0); } } } Most important is masking out the blue background. Please advise. TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
On Sep 8, 2010, at 1:15 PM, George Jones wrote: if (gp 1050112) { _redArray.push(0); _alphaArray.push(255); _greenArray.push(0); _blueArray.push(255); Shouldn't this be _blueArray.push(0); and only alphaArray should be set to 255? That may be why your getting a blue background. Karl DeSaulniers Design Drumm http://designdrumm.com ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Impossible?
From: tom.rho...@gmail.com Date: Fri, 3 Sep 2010 16:03:08 +0200 Subject: Re: [Flashcoders] Impossible? To: flashcoders@chattyfig.figleaf.com why not make 2 bitmaps, one transparent and one not, mask the non transparent one to reveal the transparent one, will look the same as what you are trying to acheive i think... I'm getting tripped up on trying to make a mask with bitmaps like I would with movie clips: private function _onLoadedAll(e:Event):void { _onLoadedContent(e, _bitmapFlag = false); _onLoadedContent(e, _bitmapFlag = true); } private function _onLoadedContent(e:Event, _bitmapFlag:Boolean):void { ... if (_bitmapFlag == false) { _fire = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fire)); _fire.mask = _fireMask; } else { _fireMask = new BitmapData(865, 92, _bitmapFlag, 0xff); addChild(new Bitmap(_fireMask)); } which throws this error: 1119: Access of possibly undefined property mask through a reference with static type flash.display:BitmapData. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Impossible?
Date: Fri, 3 Sep 2010 14:01:55 +0100 From: g...@engineeredarts.co.uk To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Impossible? Hi, Not sure if it's any help, but I did something similar overlaying perlin clouds on a background - have a look at this post and see if it gives any clues. Just looking over this quickly, it appears that you're not working with transparent bitmaps. If I'm wrong please set me right. What I need to do is create opaque fire over a transparent background within a bitmap. It may be possible with the masking that another poster posted. Please let me know. TIA, George http://www.mail-archive.com/flashcoders@chattyfig.figleaf.com/msg44114.html I will try and look at my code when I get home later. Glen ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
Mask the Bitmap, not the BitmapData. ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
On 03/09/2010 13:32, George Jones wrote: Hi; I think I've done my homework on this, but I can find no answers. Is it possible, using BitmapData, to make part--and only part--of a bitmap transparent? I'm presuming the answer is no. If that is the case, would you be so kind as to inform me so that I quit beating my head against the wall? I've asked the following question on about 5 forums and nobody has answered it, which I presume means it's over most people's heads...but certainly not this list. The net effect which I'm trying to create is programmically created fire that burns over a background image I select. What I now have is such fire over a black background (or any other color I choose), not over a jpg, for example. Hi, Not sure if it's any help, but I did something similar overlaying perlin clouds on a background - have a look at this post and see if it gives any clues. http://www.mail-archive.com/flashcoders@chattyfig.figleaf.com/msg44114.html I will try and look at my code when I get home later. Glen ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
why not make 2 bitmaps, one transparent and one not, mask the non transparent one to reveal the transparent one, will look the same as what you are trying to acheive i think... On 3 September 2010 15:01, Glen Pike g...@engineeredarts.co.uk wrote: On 03/09/2010 13:32, George Jones wrote: Hi; I think I've done my homework on this, but I can find no answers. Is it possible, using BitmapData, to make part--and only part--of a bitmap transparent? I'm presuming the answer is no. If that is the case, would you be so kind as to inform me so that I quit beating my head against the wall? I've asked the following question on about 5 forums and nobody has answered it, which I presume means it's over most people's heads...but certainly not this list. The net effect which I'm trying to create is programmically created fire that burns over a background image I select. What I now have is such fire over a black background (or any other color I choose), not over a jpg, for example. Hi, Not sure if it's any help, but I did something similar overlaying perlin clouds on a background - have a look at this post and see if it gives any clues. http://www.mail-archive.com/flashcoders@chattyfig.figleaf.com/msg44114.html I will try and look at my code when I get home later. Glen ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
On 03/09/2010 13:32, George Jones wrote: Hi; I think I've done my homework on this, but I can find no answers. Is it possible, using BitmapData, to make part--and only part--of a bitmap transparent? I'm presuming the answer is no. If that is the case, would you be so kind as to inform me so that I quit beating my head against the wall? I've asked the following question on about 5 forums and nobody has answered it, which I presume means it's over most people's heads...but certainly not this list. The net effect which I'm trying to create is programmically created fire that burns over a background image I select. What I now have is such fire over a black background (or any other color I choose), not over a jpg, for example. 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, It certainly is. Bitmaps aren't transparent unless the flag is set to true. You are wasting your time trying to make bits of an opaque bitmap transparent. Paul ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
A bitmap either has transparency or it doesn't; you need to set the alpha flag to true or you cannot get transparency data. Another thought would be blend modes - screen the flame w/black bg on your image and draw() the result. I know that doesn't answer your q but it will give you the intended result if you're not able to get any further. Sent from my iPhone On Sep 3, 2010, at 7:29 AM, Paul Andrews p...@ipauland.com wrote: On 03/09/2010 13:32, George Jones wrote: Hi; I think I've done my homework on this, but I can find no answers. Is it possible, using BitmapData, to make part--and only part--of a bitmap transparent? I'm presuming the answer is no. If that is the case, would you be so kind as to inform me so that I quit beating my head against the wall? I've asked the following question on about 5 forums and nobody has answered it, which I presume means it's over most people's heads...but certainly not this list. The net effect which I'm trying to create is programmically created fire that burns over a background image I select. What I now have is such fire over a black background (or any other color I choose), not over a jpg, for example. 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, It certainly is. Bitmaps aren't transparent unless the flag is set to true. You are wasting your time trying to make bits of an opaque bitmap transparent. Paul ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] Impossible?
I think it's coming out blue because your using SUBTRACT when applying the cooling filter. Thus it subtracts all other colors and adds that blue. Karl Sent from losPhone On Sep 3, 2010, at 7:32 AM, George Jones flashergeo...@hotmail.com wrote: Hi; I think I've done my homework on this, but I can find no answers. Is it possible, using BitmapData, to make part--and only part--of a bitmap transparent? I'm presuming the answer is no. If that is the case, would you be so kind as to inform me so that I quit beating my head against the wall? I've asked the following question on about 5 forums and nobody has answered it, which I presume means it's over most people's heads...but certainly not this list. The net effect which I'm trying to create is programmically created fire that burns over a background image I select. What I now have is such fire over a black background (or any other color I choose), not over a jpg, for example. 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; private var _redArray:Array; private var _zeroArray:Array; private var _greenArray:Array; private var _blueArray:Array; private var _alphaArray:Array; public function Fire() { //stage.scaleMode = StageScaleMode.NO_SCALE; //stage.quality = StageQuality.LOW; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.CO MPLETE, _onLoaded); loader.load(new URLRequest('images/fire-color.png'), new LoaderContext(true)); } private function _onLoaded(e:Event):void { _fireColor = Bitmap(LoaderInfo(e.target).loader.content).bitmap Data; _canvas = new Sprite(); _canvas.graphics.beginFill(0xff, 0); _canvas.graphics.drawRect(0, 0, 865, 465); _canvas.graphics.endFill(); _canvas.addChild(_createEmitter()); _grey = new BitmapData(865, 465, false, 0xff); _spread = new ConvolutionFilter(3, 3, [0, 1, 0, 1, 1, 1, 0, 1, 0], 5); _cooling = new BitmapData(865, 465, false, 0xff); _offset = [new Point(), new Point()]; _fire = new BitmapData(865, 92, false, 0xff); addChild(new Bitmap(_fire)); _createCooling(0.16); _createPalette(_currentFireColor = 0); addEventListener(Event.ENTER_FRAME, _update); //stage.addEventListener(MouseEvent.CLICK, _onClick); } private function _onClick(e:MouseEvent):void { if (++_currentFireColor == int(_fireColor.height / 32)) { _currentFireColor = 0; } _createPalette(_currentFireColor); } private function _createEmitter()isplayObject { var tf:TextField = new TextField(); tf.selectable = false; tf.autoSize =