Iām off to bed. Flash is addictive
Thanks darkmotion for the beautiful title
_root.createEmptyMovieClip("container",1);
var d = 1;
var radius = 5;
function addCircleShadow(x,y,z,scale){
var mc = container.attachMovie("CircleShadow", "circle"+d, d++);
mc.x = x;
mc.y = y;
mc.z = z;
mc.t = Math.atan2(mc.z-50,mc.x);
mc.r = Math.sqrt((mc.z-50)*(mc.z-50)+mc.x*mc.x);
mc._alpha=100;
mc._xscale=mc._yscale=20;
mc.onEnterFrame=function()
{
this.rotate(.02);
this.update3D();
}
}
function addCircle(x, y, z, scale) {
var mc = container.attachMovie("Circle", "circle"+d, d++);
mc.x = x;
mc.y = y;
mc.z = z;
mc.vx = 0;//Math.random()-.5;
mc.vy = 0;//Math.random()-.5;
mc.vz = 0;
mc.t = Math.atan2(mc.z-50,mc.x);
mc.r = Math.sqrt((mc.z-50)*(mc.z-50)+mc.x*mc.x);
mc.scale=scale;
mc.colorobj = new Color(mc.coloroverlay);
mc.setHue(.3);
mc.update3D();
mc.onEnterFrame = function() {
this.z += this.vz;
this.y = basey+1.5*Math.sin((t+this.d));
this.x += this.vx;
//this.setHue(this.z/100+.3);
//trace(this.z);
this.setHue(this.y/8+.3,1+Math.pow((this.z+45)/50,2));
this.rotate(.02);
this.update3D();
};
return mc;
}
MovieClip.prototype.rotate=function(t){
this.t+=t;
this.z=this.r*Math.sin(this.t);
this.x=this.r*Math.cos(this.t);
//this.update3D();
}
MovieClip.prototype.setHue = function(x,a) {
//x = 0 - 1
x = Math.max(x*2*Math.PI, 0.01);
var r = 128+128*Math.cos(x)/a;
var g = 128+128*Math.cos(x+Math.PI*2/3)/a;
var b = 128+128*Math.cos(x+Math.PI*4/3)/a;
var hex = r << 16 | g << 8 | b;
this.colorobj.setRGB(hex);
};
MovieClip.prototype.update3D = function() {
var normalizedz = 1-(this.z-cam_z)/maxdepth;
if (normalizedz<=0) {
this._visible = false;
} else {
this._x = (this.x*5-cam_x)*normalizedz+250;
this._y = (this.y*5-cam_y)*normalizedz+300-300;
this._xscale = this._yscale=this.scale*(normalizedz);
this.swapDepths(normalizedz*10000);
this._visible = true;
}
};
MovieClip.prototype.hopTo = function(x, y) {
this.vx = (x-this.x)/40;
this.vy = (y-this.y)/40;
var d = Math.sqrt(Math.pow(x-this.x,2)+Math.pow(y-this.y,2));
var v = Math.sqrt(this.vx*this.vx+this.vy*this.vy);
this.vz = -.5*g*(d/v);
};
var g = .1;
var cam_z = 1;
var cam_x = 0;
var cam_y = -150;
var t = 0;
var maxdepth = 60;
var basey=0;
for(var x =-23;x<23;x+=5){
for(var z =-23+50;z<23+50;z+=5){
var mc = addCircle(x,basey,z,15);
mc.d = Math.sqrt(x*x+Math.pow(z-50,2))/4;
}
}
onEnterFrame=function(){
t+=.1;
}
mx = _xmouse;
my=_ymouse;
var rt=0;
for(var x =-23;x<23;x+=5){
for(var z =-23+50;z<23+50;z+=5){
var mc = addCircleShadow(x+1,basey+5,z+1);
//mc._alpha=10;
//mc.filters=[new flash.filters.BlurFilter(15,15,1.5)];
//mc.d = Math.sqrt(x*x+Math.pow(z-50,2))/4;
}
}
http://ffiles.com/flash/3_dimensional/3d_sine_grid_2193.html