All pastes #251541 Raw Edit

Mine

public text v1 · immutable
#251541 ·published 2006-11-18 09:11 UTC
rendered paste body
import flash.display.BitmapData;
import flash.filters.DropShadowFilter;
import flash.filters.GradientGlowFilter ;
import flash.filters.DisplacementMapFilter;
import flash.filters.BlurFilter;
import flash.geom.Point;

var mouseListener = new Object();

var perlinBmp:BitmapData = BitmapData.loadBitmap("displacement.jpg");
//perlinBmp.perlinNoise(200, 200, 10, 1, false, true, 1, false); 

var displacementMap:DisplacementMapFilter;

var Photos = new Array();
var totalPhotos = 0;
var movieLoaded = false;

var shadowFilter = new DropShadowFilter(0, 45, 0x000000, 0.5, 30, 30, 1, 1, false, false, false);
var blurFilter = new BlurFilter(5, 5, 3);
var displacementFilter = new DisplacementMapFilter(perlinBmp, new Point(0, 0), 1, 1, 50, 50, "color"); 
var glowFilter = new GradientGlowFilter(0, 0, [0x000000, 0x000000], [0, 0.3], [0, 255], 30, 30, 1, 1, "outer");

mouseListener.onMouseUp = function()
{
	for(i=0;i<_root.totalPhotos;i++)
	{
		_root.Photos[i].held = false;
	}
}

function getDistance(x1, y1, x2, y2)
{
	var xDist = Math.round(x1 - x2);
	var yDist = Math.round(y1 - y2);
	var distance = Math.round(Math.sqrt((xDist * xDist) + (yDist * yDist)));	
	
	return distance;
}

function bringToFront(topPhoto)
{	
	topPhoto.swapDepths(this.getNextHighestDepth());
}

function rotate(photo)
{
	var newAngle = Math.atan2((_root._xmouse-photo._x), (_root._ymouse-photo._y)) * (180.0 / Math.PI);
	
	photo._rotation = (-newAngle) + photo.cornerAngle;
	
	distance = getDistance(_root._xmouse, _root._ymouse, photo._x, photo._y);

	photo._xscale = distance*0.8;
	photo._yscale = distance*0.8;
	
	if(photo._xscale < 50)
		photo._xscale = 50;
	if(photo._yscale < 50)
		photo._yscale = 50;			

	if(photo._xscale > 250)
		photo._xscale = 250;
	if(photo._yscale > 250)
		photo._yscale = 250;

}

function addPhoto(image, imagew, imageh)
{
	var current = Photos.length;
	
	imagew = Number(imagew);
	imageh = Number(imageh);
	
	// Container
	Photos[current] = _root.createEmptyMovieClip("Container"+current, this.getNextHighestDepth());
	
	// Background
	var bitmapData = new BitmapData(imagew+20, imageh+20, true, 0xFFFFFFFF);
	Photos[current].Background = Photos[current].createEmptyMovieClip("Photo"+current, this.getNextHighestDepth());
	Photos[current].Background.attachBitmap(bitmapData, this.getNextHighestDepth());
	Photos[current].Background._x = -(imagew/2)-10;
	Photos[current].Background._y = -(imageh/2)-10;
	
	// Filters
	var photoFilters = new Array();
	//photoFilters.push(shadowFilter);
	//photoFilters.push(blurFilter);
	//photoFilters.push(displacementFilter);
	photoFilters.push(glowFilter);
	Photos[current].filters = photoFilters;
	Photos[current]._x = random(Stage.width);
	Photos[current]._y = -50;
	Photos[current].direction = -360+random(360);
	Photos[current].initx = random(Stage.width);
	Photos[current].inity = random(Stage.height);
	Photos[current].init = true;
	Photos[current].held = false;
	Photos[current]._xscale = 80;
	Photos[current]._yscale = 80;
	Photos[current].cornerAngle = Math.atan2(((Photos[current]._x+Photos[current]._width)-Photos[current]._x), ((Photos[current]._y+Photos[current]._height)-Photos[current]._y)) * (180.0 / Math.PI);
	
	// Photo Image
	Photos[current].Image = Photos[current].createEmptyMovieClip("PhotoImage"+current, Photos[current].getNextHighestDepth());
	Photos[current].Image.loadMovie("gallery/"+image);
	Photos[current].Image._x = -(imagew/2);
	Photos[current].Image._y = -(imageh/2);
	Photos[current].Image.loaded = false;
	
	// Handle
	var bitmapData = new BitmapData(30, 30, true, 0xFFFFFFFF);
	Photos[current].Handle = Photos[current].createEmptyMovieClip("Handle"+current, Photos[current].getNextHighestDepth());
	Photos[current].Handle.attachBitmap(bitmapData, this.getNextHighestDepth());
	//Photos[current].Handle = Photos[current].attachMovie("Handle", "Handle", Photos[current].getNextHighestDepth());
	//Photos[current].Handle._x = imagew/2-20;
	//Photos[current].Handle._y = imageh/2-20;
	
	Photos[current].onEnterFrame = function()
	{						
		if(this.Image._width > 0)
			this.Image.loaded = true;

		if(this.Image.loaded)
		{
			this.Image._width = imagew;
			this.Image._height = imageh;
			this.Handle._x = imagew/2-20;
			this.Handle._y = imageh/2-20;
		}
		else
		{
			this._y = -imageh;
		}
		
		if(this.init)
		{				
			this.Handle._x = this.Image._width;
			
			if(this._y < this.inity-5)
			{
				this._y += (this.inity-this._y)/15;
				this._rotation+=(this.inity-this._y)/50;
			}
			else
				this.init = false;
				
			this.Handle._alpha = 0;
		}
		else
		{
			if(this.Handle._alpha < 100)
				this.Handle._alpha+=5;
		}
		//mouseDist = getDistance(_root._xmouse, _root._ymouse, this._x, this._y);

		//this.Image._alpha  = 100-(mouseDist/10) * (100/this._xscale);
				
		if(this.held)
		{
			rotate(this);
		}
	}
	
	Photos[current].onPress = function()
	{
		this.init = false;
		
		bringToFront(this);
		
		if(Photos[current].Handle.hitTest(_root._xmouse, _root._ymouse, true))
			this.held = true;
		else
			this.startDrag();
	}
	
	Photos[current].onRelease = function()
	{
		this.held = false;
		this.stopDrag();
	}
	
	_root.totalPhotos++;
}

// Loads in the list of images and spawn them
function loadScript()
{
	var XMLLoader = new XML();
	
	XMLLoader.ignoreWhite = true;
	
	XMLLoader.onLoad = function()
	{
		for(node in XMLLoader.firstChild.childNodes)
		{		
			thisNode = XMLLoader.firstChild.childNodes[node];

			addPhoto(thisNode.attributes.thumb, thisNode.attributes.width, thisNode.attributes.height);
		}
	}

	XMLLoader.load("images.txt");
	
	return true;
}

Mouse.addListener(mouseListener);

loadScript();