var focalLength = 1000; // environmental constant var centerX = Stage.width/2; // Stage Center X var centerY = Stage.height/2; // Stage Center Y var maxFrequency=15; // frequency at which to create clips var itemDepth =0; // depth of clips var maxLife = 250; // lifespan of each clip var radius = 60; this.initCamera = function(){ // creat lines this.createEmptyMovieClip("canvas_mc", 1); //center this.canvas_mc.moveTo(centerX,centerY); // create camera object this.oCamera = new Object(); // Set camera Properties this.oCamera.z = focalLength; // target camera z position this.oCamera.dz = 0; // initial camera z position this.oCamera.s = 20; // camera zoom speed // render camera this.onEnterFrame = function(){ // Move Camera with(this.oCamera){ dz += (z-dz)/s; } // choose random number from frequency amount var frequency = random(maxFrequency); // If that number is 0 then add a new item // this happens randomly once in a while creating the // random frequency of generated clips (frequency == 0) ? addClip() : null; } } // Add a new clip this.addClip = function(){ // add to depth itemDepth-- // create clip and assign as variable var clip = this.createEmptyMovieClip("item_mc_"+itemDepth, itemDepth); // set clip properties clip.z=random(focalLength); clip.zr=0; clip.hr=0; clip.vr=0; clip.life= random(maxLife); // give lifespan // make invisible on initialisation clip._visible=false; // assign render clip.onEnterFrame = render; } //render animatioon this.render = function(){ // make clip visible this._visible = true; // item moves up on z axis this.zr = Math.atan(this.z*Math.PI/180); this.hr+= this.zr*random(12); this.vr+= this.zr*random(3); // Calculating actual scale values according to scale = dz/(z+dz) formula var scale = (this._parent.oCamera.dz + _root.scroll*15)/(focalLength+this.z); // Position this._x = (Math.sin(this.hr*Math.PI/180)*scale)*radius + centerX; this._y = (Math.cos(this.vr*Math.PI/180)*scale)*radius + centerY; // set clip color var c = getRandomColor(); this._parent.canvas_mc.lineStyle(1, (c.r | c.g | c.b ),50); this._parent.canvas_mc.lineTo(this._x,this._y); // set size this._xscale = this._yscale = scale*100; // Swap depths this._alpha = scale*100; // renmove if ni lifespan left else reduce lifespan this.life--; if(this.life ==0) { this._parent.removeMovieCLip(this); this._visible = false; this.onEnterFrame = null; this._parent.canvas_mc.clear(); this._parent.canvas_mc.moveTo(this._x,this._y); } } // Get random colors and apply to clip this.getRandomColor = function (clip) { r = Math.floor(Math.random()*255)<< 16; g = Math.floor(Math.random()*255)<< 8; b = Math.floor(Math.random()*255)<< 1; // return object with rbg values return {r:r,g:g,b:b}; } // Initiate instances in Camera initCamera(); stop(); /* ________________________________________________ 2006, All rights reserved Paul Ortchanian San Francisco CA paul@reflektions.com This code is free; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. ________________________________________________ */