Coffee Shop API for Mobile Devices

Coffee Shop API for Mobile Devices

The new SPAS 3.0 Coffee Shop API has especially been designed to work with mobile devices. The most common use of Coffee Shop API is to create Web banners and advertisings; but it is particulary adapted to implement transitions between views on mobile devices.

There are many different ways to implement such a process. The following sample application emulates a mobile application composed of two views.
In this example there is only one "blitting transition" used to create the transition effect. An this "blitting transition" cans be used by all of the views available in the application, regardless of the total number of views.

Get Adobe Flash player

The following code, available in the next beta release, shows how the transition between both views is implemented:

private var _timer:ElectricDrip;
private var _transition:BlitTransition;
private const TOTAL_FRAMES:uint = 500;

private function onClick(e:UIMouseEvent):void {
	_container.index == 0 ?
		initBitmaps(_view1, _view2, 1) : initBitmaps(_view2, _view1, 0);
	_transition.update(0);
	_container.index = 2;
	_timer.play();
}

private function createTransition(TransitionRef:Class):void {
	_transition = new TransitionRef(
	_viewport.bitmapData, getBitmap(), getBitmap()
	);
	_transition.framesNum = TOTAL_FRAMES;
}

private function initBitmaps(view1:Box, view2:Box, nextIndex:uint):void {
	_transition.getInitialBitmap().draw(view1.container);
	_transition.getFinalBitmap().draw(view2.container);
	_nextIndex = nextIndex;
}

private function createTimer():void {
	_timer = new ElectricDrip();
	_timer.addEventListener(CafetiereEvent.COFFEE_DROP, onDrop);
}

private function onDrop(e:CafetiereEvent):void {
	var pos:int = _timer.getPosition();
	if (pos >= TOTAL_FRAMES) {
	_timer.stop();
	_timer.reset();
	_container.index = _nextIndex;
	} else _transition.update(pos);
}

private function getBitmap():BitmapData {
	return new BitmapData(350, 450, false);
}

The Coffee Shop API should be available in the SPAS 3.0 alpha 6.1 release.

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