PDA

View Full Version : Tunnel: Iteration



Qwerty the Asdf
February 23rd, 2007, 02:54 AM
This code simulates traveling through a tunnel.

This is a very early work I did (I had known flash for maybe only a month at the time). Since then I have reduced the code from around 50 lines to 25 with a bit more knowledge on actionscript, I'm still an actionscript newbie.

Just posting for some feedback. Thanks.


df = 1.015;
_root.onEnterFrame = function() {
createIter = function() {
i = 200;
x=y=550;
xi = -2;
yi = -5;
var iter = _root.createEmptyMovieClip("iteration", 1);
with (iter) {
lineStyle(1, 0xFF0000, 100);
moveTo(x+50,y+100);
while(i > 0) {
lineTo((x/=xi)+50, y+100);
lineTo(x+50, (y/=yi)+100);
xi/=df;
yi/=df;
lineTo((x*=xi)+50, y+100);
lineTo(x+50, (y*=yi)+100);
xi*=df;
yi*=df;
i--;
}
}
iteration._x = 150;
df -= .0001;
}
createIter();
iteration._alpha = (df-1)/.000045;
};

TheCanadian
February 23rd, 2007, 10:11 AM
Neat, but this contest is over. You should post it in the source/experiments forum.