/*
Compile with flash8 / AS2 / frame rate 20-25 ips
*/
//
//---------------------------------------------------------------------------
//----------------- init ----------------------------------------------------
//---------------------------------------------------------------------------
//
// *** ici in french means "here" ***
ici_mc = this;
//
// levels
//
var levelBackground:Number = 100;
var levelBitmap:Number = 200;
var levelMotion:Number = 300;
//
// colors
//
var colorBackground:Number = 0xFFFFFF;
//
// import
//
import flash.display.*;
import flash.geom.*;
//
// Stage properties
//
Stage.align = "tl";
Stage.scaleMode = "noscale";
StageListener = new Object();
Stage.addListener(StageListener);
StageListener.onResize = function() {
ajust();
};
function ajust() {
background_mc._width = Stage.width;
background_mc._height = Stage.height;
}
//
// create background
//
background_mc = ici_mc.createEmptyMovieClip("background_mc", levelBackground);
background_mc.lineStyle(0,colorBackground,100);
background_mc.beginFill(colorBackground,100);
background_mc.lineTo(100,0);
background_mc.lineTo(100,100);
background_mc.lineTo(0,100);
background_mc.lineTo(0,0);
background_mc.endFill();
//
// create empty clip for bitmap save
//
bitmap_mc = ici_mc.createEmptyMovieClip("bitmap_mc", levelBitmap);
//
// create empty clip for motions
//
motion_mc = ici_mc.createEmptyMovieClip("motion_mc", levelMotion);
//
//---------------------------------------------------------------------------
//----------------- basic functions -----------------------------------------
//---------------------------------------------------------------------------
//
_global.random2 = function(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random()*(max-min+1))+min;
return randomNum;
};
//
//---------------------------------------------------------------------------
//----------------- random properties functions -----------------------------
//---------------------------------------------------------------------------
//
//
// letter size
//
function getLetterSize() {
var size_array;
size_array = new Array(9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 15, 15, 15, 15, 100, 3

return size_array[random2(0, size_array.length-1)];
}
//
// letters
//
numLetter = -1;
function getLetter() {
var letter_array;
letter_array = String("nick bell ").split("");
numLetter = numLetter>=letter_array.length-1 ? 0 : numLetter+1;
return letter_array[numLetter];
}
//
// colors
//
function getColor() {
var colorz_array;
colorz_array = new Array(0x000000, 0x000000, 0x000000, 0xffffff);
return colorz_array[random2(0, colorz_array.length-2)];
}
//
// fonts
//
var system_font_array:Array = TextField.getFontList();
system_font_array.sort();
fonts_array = new Array();
okidokifont_array = String("georgia,times,garamond,palatino").split(",");
var i;
var ii;
for (i=0; i<system_font_array.length; i++) {
for (ii=0; ii<okidokifont_array.length; ii++) {
if (String(system_font_array[i]).toLowerCase().indexOf(okidokifont_array[ii])>-1) {
fonts_array.push(system_font_array[i]);
}
}
}
function getFont() {
//if (!actual_font || random2(0, 500) == 0) {
actual_font = fonts_array[random2(0, fonts_array.length-1)];
//}
return actual_font;
}
//
// position of the elements are not totaly random...
//
posX = random2(150, Stage.width-150);
posY = random2(150, Stage.height-150);
speedX = random2(-20, 20);
function setPosXY(m_mc) {
var m_mc;
//
// limit positions
//
if (posX>Stage.width-150) {
speedX = random2(-20, 0);
}
if (posX<150) {
speedX = random2(0, 20);
}
//
// sometime random pos & speed
//
if (random2(0, 100) == 0) {
posX = random2(150, Stage.width-150);
posY = random2(150, Stage.height-150);
speedX = random2(-20, 20);
}
posX += speedX;
m_mc._x = posX-m_mc._width/2;
m_mc._y = posY-m_mc._height/2;
//sometimes a movie clip makes his own story
if (random2(0, 40) == 0) {
m_mc.prop = random2(0, 1) == 0 ? "_x" : "_y";
m_mc.val = random2(0, 1) == 0 ? -1 : 1;
m_mc.onEnterFrame = function() {
this[this.prop] += this.val;
};

}
}
//
//---------------------------------------------------------------------------
//----------------- drawing functions ---------------------------------------
//---------------------------------------------------------------------------
//
function doLetter() {
var m_mc;
var t_txt;
var tf;
m_mc = motion_mc.createEmptyMovieClip("m"+motion_mc.getNextHighestDepth(), motion_mc.getNextHighestDepth
t_txt = m_mc.createTextField("t_txt", 1, 0, 0, 100, 100);
t_txt.autoSize = "left";
t_txt.multiline = false;
t_txt.text = getLetter();
tf = new TextFormat();
tf.size = getLetterSize();
tf.color = getColor();
tf.font = getFont();
t_txt.setTextFormat(tf);
setPosXY(m_mc);
return (m_mc);
}
function doRectangle() {
var m_mc;
m_mc = motion_mc.createEmptyMovieClip("m"+motion_mc.getNextHighestDepth(), motion_mc.getNextHighestDepth
m_mc.lineStyle(1,getColor(),100);
r_width = random2(50, 300);
r_height = random2(50, 300);
m_mc.lineTo(r_width,0);
m_mc.lineTo(r_width,r_height);
m_mc.lineTo(0,r_height);
m_mc.lineTo(0,0);
setPosXY(m_mc);
}
function doShape() {
var m_mc;
m_mc = motion_mc.createEmptyMovieClip("m"+motion_mc.getNextHighestDepth(), motion_mc.getNextHighestDepth
bmp_mc = m_mc.createEmptyMovieClip("bmp_mc", 1);
m_mc.lineStyle(0,0xFF0000,0);
r_width = random2(50, 300);
r_height = random2(50, 300);
m_mc.beginBitmapFill(bmp);
m_mc.lineTo(r_width+random(300),random(300));
m_mc.lineTo(r_width+random(300),r_height+random(300));
m_mc.lineTo(random(300),r_height+random(300));
m_mc.lineTo(0,0);
m_mc.endFill();
m_mc._alpha = 0;
m_mc._rotation = 90*random2(0, 360/90);
m_mc.onEnterFrame = function() {
if (this._alpha++>100) {
delete this.onEnterFrame;
}
};
setPosXY(m_mc);
}
function doRectangle2() {
var m_mc;
m_mc = motion_mc.createEmptyMovieClip("m"+motion_mc.getNextHighestDepth(), motion_mc.getNextHighestDepth
var c;
c = getColor();
m_mc.lineStyle(1,c,100);
m_mc.beginFill(c,100);
r_width = random2(10, 30);
r_height = random2(10, 30);
m_mc.lineTo(r_width,0);
m_mc.lineTo(r_width,r_height);
m_mc.lineTo(0,r_height);
m_mc.lineTo(0,0);
setPosXY(m_mc);
}
function doLine() {
var m_mc;
m_mc = motion_mc.createEmptyMovieClip("m"+motion_mc.getNextHighestDepth(), motion_mc.getNextHighestDepth
m_mc.lineStyle(1,getColor(),100);
r = d_date.getSeconds()*5;
3/4
if (d_date.getMinutes()/2 == Math.floor(d_date.getMinutes()/2)) {
m_mc.lineTo(r,0);
} else {
m_mc.lineTo(0,r);
}
setPosXY(m_mc);
}
function makeBitmap() {
old_bmp = bmp;
bmp = new BitmapData(Stage.width, Stage.height, true, 0xFFFF00);
bmp.draw(ici_mc);
bitmap_mc._alpha = 100;
bitmap_mc.attachBitmap(bmp,1,"Never",true);
bitmap_mc._alpha = 100;
bitmap_mc._yscale = 100;
bitmap_mc._xscale = 100;
bitmap_mc._y = 0;
bitmap_mc._x = 0;
if (random2(0, 1) == 0) {
bitmap_mc.randSpeedHeight = random2(3, 5);
bitmap_mc.randSpeedWidth = 0;
} else {
bitmap_mc.randSpeedHeight = 0;
bitmap_mc.randSpeedWidth = random2(3, 5);
}
bitmap_mc.randSpeedWidth = random2(-2, 2)/10;
bitmap_mc.randSpeedX = random2(-2, 2)/10;
bitmap_mc.randSpeedAlpha = random2(5, 10)/100;
bitmap_mc.onEnterFrame = function() {
this._alpha -= this.randSpeedAlpha;
this._width += this.randSpeedWidth;
this._yscale = this._xscale;
//this._width += this.randSpeedWidth;
//this._x = Stage.width/2-this._width/2;
//this._y = Stage.height/2-this._height/2;
this._x += this.randSpeedX;
};
bitmap_mc.onEnterFrame.call(bitmap_mc);
//delete all movie clips
motion_mc = ici_mc.createEmptyMovieClip("motion_mc", levelMotion);
//old_bmp.dispose();
}
//
//
//---------------------------------------------------------------------------
//----------------- oki doki.... play ---------------------------------------
//---------------------------------------------------------------------------
//
//
ajust();
ici_mc.onEnterFrame = function() {
d_date = new Date();
doLetter();
if (random2(0, 500) == 0) {
doRectangle();
}
if (random2(0, 30) == 0) {
doLine();
}
if (random2(0, 50) == 0) {
doShape();
}
if (random2(0, 50) == 0) {
doRectangle2();
}
if (random2(0, 100) == 0) {
makeBitmap();
}
};