Sunday, March 9, 2008

A small starfield with a bluring effect..

This was one of my first experiments after reading a few chapters in the "Professional ActionScript 3.0" book.

Granted, the code is not optimized, pretty or in anyother way OO as it should be, but it works. which was the most important thing for me at the time.

For those interested, it's a pretty simple algorithme, a "star" starts it's life in a random postion between -10 and 10 on both the x and y axis, and the cordinate space moves it's 0,0 to the center of the screen,done by adding 1/2 of the screen width,height to the stars upon rendering.

Moving the stars is done by multiplying a randomly assigned acceleration value. so the farther the star get's away from the center, the faster it gets.

It sounds advance, and confusing, but is pretty simple.

Also I added a small pixel based blur effect using the Red component, but afterwards I've learned that flash has it's own filters. I'll have to look into that some day.

Click here to download the swf,fla and as files

It was also written in the rubbish flash cs 3 IDE .. which held me back in a big way.

- Kenneth C

2 comments:

sebastian chedal said...

how can I change this so that the blur is not only on the red channel, but on all channels [so only the alpha is affected in the setPixel32]? thanks!

Kenneth Christensen said...

Hi!

Sorry for the late reply (post concerning this comming soon)

the "screendata.setPixel(x,y,uint(val)<<16);" line needs to be change, by doing the bitrolling 16 (<<16) i use only the R compoent of the RGB .. try messing around, i can't remeber if the format is ARGB og RGBA (try <<24)

Kind regards Kenneth Christensen