var focalLength = 500; // environmental constant var centerX = Stage.width/2; // Stage Center X var centerY = Stage.height/2; // Stage Center Y var maxFrequency=5; // frequency at which to create clips var itemDepth =0; // depth of clips var maxLife = 450; // lifespan of each clip var maxSpeed = 5; var radius = 20; this.initCamera = function(){ // 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 = maxSpeed; // 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.attachMovie("item","item_mc_"+itemDepth,itemDepth); // set clip properties clip.z=0; clip.life= 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; // make z go towards user this.z-= maxSpeed; // 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.z*Math.PI/180)*scale)*radius + centerX; this._y = (Math.cos(this.z*Math.PI/180)*scale)*radius + centerY; // set size this._xscale = this._yscale = scale*100; // Swap depths this._alpha = scale*100; // renmove if ni lifespan left else reduce lifespan (this.life ==0) ? this.removeMovieClip(): this.life--; } // 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. ________________________________________________ */