RobustaBrewer: Put a Tiger in your Mobile

RobustaBrewer: Put a Tiger in your Mobile

The RobustaBrewer class is an adaptation of a very popular slideshow effect, based on the Coffee Shop API. Thus, contrary to the common JavaScript implementations, the RobustaBrewer class provides a very low-resource-consumer slideshow, available from all of the Web configurations that support the Flash Player.

In addition, the RobustaBrewer class offers two major advantages:

  • her flexible and modular API allows to easily create several kind of applications,
  • it creates very lightweight slideshows: the following sample application is only 10kb when you don't embed the images.

Get Adobe Flash player

package {
	
	import flash.display.*;
	import flash.events.*;
	import flash.net.*;
	import org.flashapi.coffeeshop.*;
	import org.flashapi.coffeeshop.coffeebean.*;
	import org.flashapi.coffeeshop.event.*;
	
	public class RobustaBrewerSample extends Sprite {
		
		public function RobustaBrewerSample():void {
			super();
			this.init();
		}
		
		[Embed (source="thumb_01.jpg")]
		private const IMG1:Class;
		[Embed (source="thumb_02.jpg")]
		private const IMG2:Class;
		[Embed (source="thumb_03.jpg")]
		private const IMG3:Class;
		[Embed (source="thumb_04.jpg")]
		private const IMG4:Class;
		[Embed (source="thumb_05.jpg")]
		private const IMG5:Class;
		
		private var _brewser:RobustaBrewer;
		
		private function init():void {
			createBrewser();
			populateBrewser();
			createEvents();
			_brewser.play();
		}
		
		private function createBrewser():void {
			_brewser = new RobustaBrewer(500, 375);
			_brewser.buttonMode = _brewser.loop = true;
			_brewser.transitionDuration = 800;
			_brewser.pauseDuration = 4500;
			_brewser.increaseBeanType = Pixelation;
			this.addChild(_brewser);
		}
		
		private function populateBrewser():void {
			var bean1:RobustaBean = new RobustaBean(
					new IMG1().bitmapData,
					"<b>Bathing Tiger</b><br/><br/>1024 X 768 px, 133 Ko.",
					"bathing_tiger.jpg");
			var bean2:RobustaBean = new RobustaBean(
					new IMG2().bitmapData,
					"<b>Bengal Tiger</b><br/><br/>1600 X 1200 px, 316 Ko.",
					"bengal_tiger.jpg");
			var bean3:RobustaBean = new RobustaBean(
					new IMG3().bitmapData,
					"<b>Siberian Tiger in Snow</b><br/><br/>1280 X 1024 px, 551 Ko.",
					"siberian_tiger_in_snow.jpg");
			var bean4:RobustaBean = new RobustaBean(
					new IMG4().bitmapData,
					"<b>Baby Tigers</b><br/><br/>800 X 600 px, 75.4 Ko.",
					"baby_tigers.jpg");
			var bean5:RobustaBean = new RobustaBean(
					new IMG5().bitmapData,
					"<b>Light and Shadow</b><br/><br/>1920 X 1440 px, 387 Ko.",
					"tiger_in_shadow.jpg");
					
			_brewser.addBean(bean1);
			_brewser.addBean(bean2);
			_brewser.addBean(bean3);
			_brewser.addBean(bean4);
			_brewser.addBean(bean5);
		}
		
		private function createEvents():void {
			_brewser.addEventListener(RobustaBrewerEvent.TRANSITION_START, onTransitionStart);
			_brewser.addEventListener(RobustaBrewerEvent.TRANSITION_FINISH, onTransitionFinish);
			_brewser.addEventListener(MouseEvent.CLICK, onClick);
		}
		
		private function onTransitionStart(e:RobustaBrewerEvent):void {
			_brewser.useHandCursor = false;
		}
		
		private function onTransitionFinish(e:RobustaBrewerEvent):void {
			_brewser.useHandCursor = true;
		}
		
		private function onClick(e:MouseEvent):void {
			if(_brewser.useHandCursor) {
				var url:URLRequest = new URLRequest(_brewser.getCurrentBean().url);
				navigateToURL(url);
			}
		}
	}
}

The Coffee Shop API should be available in the SPAS 3.0 alpha 6.1 release.
The RobustaBrewer class will be available in the Coffee Shop API beta 2.

Share this article:

Comments:

There are no comments yet for this article.

Leave a reply

Your email is required but will not be displayed.

To prevent abusive emails, please enter the numbers you see in the image below:

Security code