Like AS: Basic Movement, only with codes that involve something random. A code for a scrolling starfield:
_root.createEmptyMovieClip("screen_mc", 1); with (screen_mc) { moveTo(0, 0); lineStyle(0, 000000, 100); beginFill(000000); lineTo(0, 400); lineTo(550, 400); lineTo(550, 0); lineTo(0, 0); endFill(); } _root.createEmptyMovieClip("star_mc", 2); with (star_mc) { lineStyle(0, 0xFFFFFF, 100); beginFill(0xFFFFFF); moveTo(0, 0); lineTo(1, 0); lineTo(1, 1); lineTo(0, 1); lineTo(0, 0); endFill(); } inc = 1; for (i=1; i<250; i++) { duplicateMovieClip(star_mc, "star_mc"+i, 2+i); _root["star_mc"+i]._x = random(550); _root["star_mc"+i]._y = random(400); _root["star_mc"+i]._xscale = _root["star_mc"+i]._yscale=random(200); _root["star_mc"+i]._alpha = random(50)+50; } createEmptyMovieClip("text_mc", 300); with (text_mc) { moveTo(0, 0); lineStyle(0, 000000, 100); beginFill(0x27D341); lineTo(25, 0); lineTo(25, 20); lineTo(0, 20); lineTo(0, 0); endFill(); _root["text_mc"].onPress = function() { for (i=1; i<250; i++) { _root["star_mc"+i]._x = random(550); _root["star_mc"+i]._y = random(400); } }; } _root.onEnterFrame = function() { if (Key.isDown(Key.LEFT)) { if (inc>0) { inc--; } } else if (Key.isDown(Key.RIGHT)) { inc++; } for (i=1; i<250; i++) { _root["star_mc"+i]._y += inc; if (_root["star_mc"+i]._y>=400) { _root["star_mc"+i]._y = 0; } } if (Key.isDown(Key.ENTER)) { for (i=1; i<250; i++) { _root["star_mc"+i]._x = random(550); _root["star_mc"+i]._y = random(400); } } };
Paste on first frame of movie. Use left/right to make the starfield scroll slower/faster. Use the green button or enter to get a new starfield.