Ultimate Gear War
Join the alien war, prepare your gear and protect your base at all cost!
4.23 / 5.00 14,041 ViewsAS: Black and White
I've seen a few people asking how to do this with the new flash 8, so I thought i'd post a solution. It converts your movie/game's color matrix filters so it has no saturation, which ultima5tely means it's black and white.
NOTE: It can and WILL lag your movie/game, but not so much. But enough to make a difference
I'm sure the code could be cleaned up more than it is, and I don't care about that. Don't turn this into some kind of contest to see how can shorten it the most.
function blackAndWhite(clear) {
lastBW.bm.dispose();
lastBW.mc.removeMovieClip();
if(clear) return
var mc = createEmptyMovieClip("bw"+getNextHighestDe
pth(), getNextHighestDepth());
var bm = new flash.display.BitmapData(Stage.width, Stage.height);
mc.attachBitmap(bm, 0);
bm.draw(_root);
BWMATRIX = [.3086,.6094,.082,0,0,.3086,.6094,.082,0,0
,.3086,.6094,.082,0,0,0,0,0,1,0];
var cm = new flash.filters.ColorMatrixFilter(BWMATRIX);
bm.applyFilter(bm, bm.rectangle, new Point(0, 0), cm);
lastBW = {mc:mc, bm:bm};
}
The first few lines and last line save the last movieclips and bitmapdatas made and removes them next frame, so it doesn't waste memory.
NOTE: To turn OFF black and white, you need to call it with true as an argument.
To turn black and white, keep calling it every frame.
EXAMPLES:
Discontinued christmas project
Click the mouse on both of the examples to switch between color and B&W
wtfbbqhax
I don't have Flash 8, wish I did, but nice tutorial :D
At 12/10/05 01:44 PM, Christmas-Neashir wrote: I don't have Flash 8, wish I did, but nice tutorial :D
Thanks. You have the player 8, right? You should be able to see it.
Another thing,
var mc = createEmptyMovieClip("bw"+getNextHighestDe
pth(), getNextHighestDepth());
BWMATRIX = [.3086,.6094,.082,0,0,.3086,.6094,.082,0,0
,.3086,.6094,.082,0,0,0,0,0,1,0];
Those four lines are supposed to be two
wtfbbqhax
At 12/10/05 01:42 PM, fwe wrote: Black and White
Nice, I didn't notice much lag on the christmas game but the second game lagged a lot.
Yeah - cool tutorial.
Sup, bitches :)
omg lags like shit with b&w on.
not bad though.
why did you discontinue them? there good.
o and inc tut
At 12/10/05 01:45 PM, fwe wrote: Discontinued fallout remake
Who's Ighor? It's supposed to be Inglor! >:(
At 12/10/05 01:49 PM, -Toast- wrote:At 12/10/05 01:45 PM, fwe wrote: Discontinued fallout remakeWho's Ighor? It's supposed to be Inglor! >:(
That's my name!
Russian family, i swear they were drunk when they named me
wtfbbqhax
At 12/10/05 01:45 PM, fwe wrote: cool stuff
Awesome Job!
At 12/10/05 01:50 PM, fwe wrote: That's my name!
Russian family, i swear they were drunk when they named me
What a nice name it is, too.
Sup, bitches :)
Heh, that's a pretty nice tut you got there. It'd be awesome for switching between B/W and color Kill Bill style ;P
- Matt, Rustyarcade.com
At 12/10/05 01:55 PM, -Christmas- wrote:At 12/10/05 01:50 PM, fwe wrote: That's my name!What a nice name it is, too.
Russian family, i swear they were drunk when they named me
Yes, it's true that it's a cool name. I would buy it for a dozen of dollars.
I_g_or || Inglor || Ighor. Funny, eh? :D
Anyway, very nice effect, Ighor ;)
At 12/10/05 02:16 PM, -Toast- wrote: Anyway, very nice effect, Ighor ;)
Just call me fwe
wtfbbqhax
Nice script but it doesn't really explain the code.
Maybe Foss material?
At 12/11/05 03:27 AM, GuyWithHisComp wrote: Nice script but it doesn't really explain the code.
Maybe Foss material?
Too late now
wtfbbqhax
Excuse me if I'm saying something stupid now, I know nothing about actionscripting filters
But...
I might be mistaken, but when I make my game black and white manually in Flash, ie without actionscript, I didn't notice any lag. Now, I haven't been able to get this code to work to compare it (I don't know how to use/where to put functions), but...
Do you have to create a bitmap overlay (if that's what the code is doing)? Can't you just change the _root colorMatrixFilter property or whatever? Again, I have no idea if this is possible as I know nothing about coding with filters, but just a thought.
At 12/27/05 12:33 AM, superbrightfuture wrote: Excuse me if I'm saying something stupid now, I know nothing about actionscripting filters
But...
I might be mistaken, but when I make my game black and white manually in Flash, ie without actionscript, I didn't notice any lag. Now, I haven't been able to get this code to work to compare it (I don't know how to use/where to put functions), but...
Do you have to create a bitmap overlay (if that's what the code is doing)? Can't you just change the _root colorMatrixFilter property or whatever? Again, I have no idea if this is possible as I know nothing about coding with filters, but just a thought.
I do the bitmap overlay solution. I'm not sure if you can make a ColorMatrixFilter on the root, I am probably mistaken, but I think it needs to be on a bitmapData object.
wtfbbqhax
...that's cool, but totally not worth it :p
import flash.filters.ColorMatrixFilter;
MovieClip.prototype.blackAndWhite = function(clear) {
myFilters = this.filters;
if (!clear) {
BWMatrix = [.3086, .6094, .082, 0, 0, .3086, .6094, .082, 0, 0, .3086, .6094, .082, 0, 0, 0, 0, 0, 1, 0];
this.BWFilterSpot == undefined ? this.BWFilterSpot = myFilters.length : null;
myFilters[this.BWFilterSpot] = new ColorMatrixFilter(BWMatrix);
} else {
myFilters[this.BWFilterSpot] = undefined;
}
this.filters = myFilters;
};
blackAndWhite(false);
i just took out the bitmap. its a huge hassle. i still dont funnly understand this filter so all credit still goes to fwe... my bestest fwend.
At 12/27/05 01:27 AM, ImpotentBoy2 wrote: code
worship me, WORSHIP ME
funnly
fully
attention whore
lol...stupid AS:main link...you suck...lol
Pretty nice but I don't really see why you would need black and white. Just make verything black and white in the first place. Also, if you are like me, you make your games with movie clips and buttons only and they can all have the saturation taken away without lag.