[Flashcoders] Playing With Fire
Hi; I figured out the reason I couldn't successfully mask out the background from my programatiically created bitmap image was because I added it to a sprite and then tried to mask the sprite; however, by then the background was no longer distinguishable from the rest. Someone suggested I mask the bitmap, but apparently that cannot be done (please correct if wrong). Apparently the way to do this is to convert the bitmap into vector graphics first; however, googling only reveals how to do this through the IDE, and even if I wanted to use the IDE (I don't) that's impossible because the bitmap is generated and regenerated continually by code. So, is it possible to convert the bitmap image into vector graphics programatically? How? Tutorials I couldn't find? TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] Playing With Fire
Date: Fri, 10 Sep 2010 21:33:38 +0200 From: he...@henke37.cjb.net To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Playing With Fire You don't want a mask. You want a bitmap with alpha values. Ok. But that's what I have. As you know, I tried every combination to change the alpha values of the background to 0 and nothing worked. So I guess I'm out of luck. Any other thoughts? TIA, George ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
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?
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?
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?
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?
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?
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?
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
[Flashcoders] Impossible?
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 = TextFieldAutoSize.LEFT; tf.defaultTextFormat = new TextFormat('Verdana', 80, 0xff, true); tf.text = '__'; tf.x = (465 - tf.width
RE: [Flashcoders] (no subject)
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
[Flashcoders] (no subject)
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; 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.COMPLETE, _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).bitmapData; _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():DisplayObject { var tf:TextField = new TextField(); tf.selectable = false; tf.autoSize
Re: [Flashcoders] real time flash interface.
Hi, I think you might could write a simple shell script on server(if unix) to check the update time of that status file, and if it was updated, increase serial number in another file which your Flash client could check (working like a flag), and create another easy read file such as XML formated for Flash for update information. So when your Flash find the serial number is increased, check the XML file then. George Paul Andrews wrote: Hi, I'm about to start a new project which will display the workings of a server based system that's manipulating data and passing it between servers. At each stage of the process a flat file is written that indicates a change in status/readiness of the data for the next stage in the process. My flash project will sit over the top of this indicating what's going on - driven by the flat file status changes. It's unlikely that I can really change the infrastructure at all - probably the best I'll be able to do will be to have the status files copied into a suitable form for the flash project to read. It's going to be interesting if I can't meddle with the infrastructure or get a file format compatible with loadvars or xml.. Since it's unlikely I can add much to the infrastructure, as far as I can tell the best approach is simply to poll for the presence of the status files regularly and read them to pick up any changes. I don't know if I'll be able to expose the files through a web service, or add a socket server. So my current thinking is to poll (read the status files if they are there), then sleep for an interval then poll again (this will be as real-time as I can manage). Effectively I'll be building an event-driven project that generates events to update the interface in reaction to the presence of the status files. Unfortunately, without a socket server I can't push the changes, nor can I reply on other solutions being installed on the server side (such as media server). As the status changes, I'll animate the flash interface to show what's going on on the servers. Anyone done this kind of thing before and have some sage advice/gotchas? Paul -- ipauland.com ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] Node Edge performance question
Has anyone who has worked with very large node/edge graphs within Flash have any ballpark performance numbers? I am looking to build a social network visualizer.. drag nodes, select nodes , zoom , pan, hide edges/nodes etc... I just wanted to get a ballpark figure on limitiations within FP-8. Am I looking at a limitiation in the thousands, tens of thousands, hundreds of thousands of nodes? Thanks, George ___ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com
[Flashcoders] motion detection
hi i was wondering what luck people have had with motion detection. i have been doing motion detection in processing for quite some time, but haven't have too much luck in flash,because of speed issues. i can get basic difference images etc. as per guy watson's tutorial on macromedia, and then get a motion point, but am wondering what the trick is in flash to get more point specific stuff like this without killing the processor http://www.benga.li/cam_exp/cameraActivity_07.swf any hints/code would be much appreciated. thanks all the best george ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders