In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: Sntk Carousel

Get Adobe Flash player
by sakotsu 17 Jan 2009
// forked from Saqoosha's Sntk Carousel
// write as3 code here..
package {
	
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Loader;
	import flash.display.LoaderInfo;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.URLRequest;
	import flash.system.LoaderContext;
	import flash.utils.getTimer;
	
	import caurina.transitions.Tweener;
	
	
	[SWF(width=465, height=465, backgroundColor=0x0, frameRate=60)]
	
	public class Sntk extends Sprite {
		
		private static const NUM_PANELS:int = 25;
		
		private var _panels:Array;
		
		public function Sntk() {
			var loader:Loader = new Loader();
			loader.contentLoaderInfo.addEventListener(Event.COMPLETE, this._onImageLoaded);
			loader.load(new URLRequest('http://saqoosha.net/images/sntk.jpg'), new LoaderContext(true));
		}
		
		private function _onImageLoaded(e:Event):void {
			var loader:Loader = LoaderInfo(e.target).loader;
			this._panels = [];
			for (var i:int = 0; i < NUM_PANELS; i++) {
				var p:Panel = addChild(new Panel(Bitmap(loader.content).bitmapData)) as Panel;
				this._panels.push(p);
				p.addEventListener(MouseEvent.ROLL_OVER, _onRollOver);
			}
			this.addEventListener(Event.ENTER_FRAME, this._update);
		}
		
		
		private function _onRollOver(e:MouseEvent):void	{
			
			var p:Panel = Panel(e.target);
			Tweener.addTween(p, {
				time: 0.5,
				y:-20,
				transition: "easeOutQuint"
			});
		}
		
		private function _update(e:Event):void {
			var t:Number = getTimer() / 300;
			var r:Number = (Math.sin(getTimer() / 1000) + 1);
			var tmp:Array = [];
			for (var i:int = 0; i < NUM_PANELS; i++) {
				var p:Panel = this._panels[i];
				var a:Number = i / NUM_PANELS * Math.PI * 2 + t;
				p.x = Math.cos(a) * 150 * r + 230;
				p.y = Math.sin(a) * 70 * r + 230;
				tmp.push({
					panel: p,
					y: p.y
				});
			}
			tmp.sortOn('y', Array.NUMERIC);
			for (i = 0; i < NUM_PANELS; i++) {
				this.setChildIndex(tmp[i].panel, i);
			}
		}
	}
}


import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.display.PixelSnapping;
import flash.display.BlendMode;

class Panel extends Sprite {
	
	private var _image:Bitmap;
	
	public function Panel(image:BitmapData) {
		this._image = this.addChild(new Bitmap(image, PixelSnapping.AUTO, true)) as Bitmap;
		this._image.width = this._image.height = 80;
		this._image.x = this._image.y = -50;
		this.blendMode = BlendMode.ADD;
		this.alpha = 0.3;
	}
}