22 June 2009

Flash gravity example (black hole simulation)

Have you ever wondered how it looks like when black hole or some other massive gravity object bends space-time fabric? Me too. I don't know why, maybe I watch Discovery too much.

Anyway, here is small Flash example (experiment) which allows you to see gravity in action. You can do 2 things here, move gravity object around the Stage (grey circle) and turn gravity on /off.

Here is actionscript code for single line. Just add more lines and that's it.


onLoad = function() {
var gravity = false;
g_txt.text = "gravity: OFF";
}
onEnterFrame = function() {
createEmptyMovieClip("line0", 0);
line0.lineStyle(0, 0xFFFFFF);
line0.moveTo(100, 50);

if(gravity) {
line0.curveTo(point1._x, point1._y, 500, 50);
g_txt.text = "gravity: ON";
} else {
line0.curveTo(100, 50, 500, 50);
g_txt.text = "gravity: OFF";
}
}
switch_mc.onRelease = function() {
if(gravity) {
gravity = false;
} else {
gravity = true;
}
}


movie example






*_*

2 comments:

pepeu said...

Hah! Fun, simple and straightforward example that gave me some ideas.

Thanks mate! Keep up the good work! :O)

Anonymous said...

SWF is blank. ??!!

 

template by blogger templates