All pastes #358457 Raw Edit

Anonymous

public text v1 · immutable
·published 2007-02-16 07:40 UTC
rendered paste body
//define number of layer.
var layer = 1;
//number of items in a layer
var items = 1;
//create the bg that holds the layers
this.createEmptyMovieClip("bgHolder", this.getNextHighestDepth());
//this function will update the layers current position
function updateMovies() { 
	//easingStrenth 
	d = 10; 
	this.x = _root._xmouse; 
	this.y = _root._ymouse; 
	//get the linear relation fo x.
	var coef = (Stage.width-this._width)/Stage.width; 
	//update x with easing. 
	this._x -= (this._x-coef*this.x)/d; 
	//get the linear relation fo y.
	coef = (Stage.height-this._height)/Stage.height; 
	//update y with easing. 
	this._y -= (this._y-coef*this.y)/d;
}
//init function for the layers
function init() { 
	for (i=0; i<layer; i++) {  
		//create a layer  
		temp = this.bgHolder.createEmptyMovieClip("bg"+i, this.bgHolder.getNextHighestDepth());  
		depth = temp.getNextHighestDepth();  
		//create a virtual bag for the layer to define it height and width.  
		virtual_mc = temp.attachMovie("virtual", "vitrual"+depth, depth, {_visible:false, _width:(i+2)*Stage.width, _height:(i+2)*Stage.height});  
		//put the items into the layer  
		for (j=0; j<items; j++) {   
			depth = temp.getNextHighestDepth();   
			//attach an item   
			temp1 = temp.attachMovie("float1", "float"+depth, depth);   
			//position it randomly in the current layer   
			temp1._x = 310;   
			temp1._y = 225;   
			//scale it randomly   
			rand = Math.random();   
			temp1._xscale *= 3;   
			temp1._yscale *= 3;   
			//put is opacity randomly   
			temp1._alpha = 100; 
		}  
		//each layer share the same updating function.  
		temp.onEnterFrame = this.updateMovies; 
		}
	}
init();