Preview this Apple Style Preloader

Create An Apple Style Preloader Using A Custon Class

Tags: ,

Steven sacks just posted custom class that creates an Apple style preloader.  It’s a simple class that uses the Flash Drawing API which makes it light and efficient. Check it out below.

package net.stevensacks.preloaders
{
	package net.stevensacks.preloaders
	{
		import flash.events.TimerEvent;
		import flash.display.Sprite;
		import flash.display.Shape;
		import flash.utils.Timer;

		public class CircleSlicePreloader extends Sprite
		{
			private var timer:Timer = new Timer(65);
			private static const SLICE_COUNT:int = 12;
			private static const RADIUS:int = 6;

			public function CircleSlicePreloader()
			{
				super();
				draw();
				timer.addEventListener(TimerEvent.TIMER, onTimer, false, 0, true);
				timer.start();
			}

			private function onTimer(event:TimerEvent):void
			{
				rotation = (rotation + (360 / SLICE_COUNT)) % 360;
			}

			private function draw():void
			{
				var i:int = SLICE_COUNT;
				var degrees:int = 360 / SLICE_COUNT;
				while (i--)
				{
					var slice:Shape = getSlice();
					slice.alpha = Math.max(0.2, 1 - (0.1 * i));
					var radianAngle:Number = (degrees * i) * Math.PI / 180;
					slice.rotation = -degrees * i;
					slice.x = Math.sin(radianAngle) * RADIUS;
					slice.y = Math.cos(radianAngle) * RADIUS;
					addChild(slice);
				}
			}

			private function getSlice():Shape
			{
				var slice:Shape = new Shape();
				slice.graphics.beginFill(0x666666);
				slice.graphics.drawRoundRect(-1, 0, 2, 6, 12, 12);
				slice.graphics.endFill();
				return slice;
			}
		}
	}
}

Additional Resources:

Related Posts

Flash Countdown Timer

Create A Flash Countdown Timer in AS3 Using A Class

Mac OS X Mousewheel Support in AS3

road-loader

21+ Cool Flash Preloaders

Create a Loading Spinner Within Flex

Leave a Reply









Latest Theme From WooThemes

Unsigned

By WooThemes

Unsigned is a hugely powerful, cleverly developed, yet super easy theme to use for musicians and bands looking to showcase their music, tours, photos, videos and band members all from within WordPress. It even allows you to sell your albums and merchandise thanks to the WooCommerce integration. It truly is a massive theme that will cover your every need.

Theme Categories: Multimedia, Responsive

Latest Tweets