Friday 9 December 2011

A farewell to SWF's and hello to gestures

Flex development for iOS is a new adventure for me, it has taken about 3 years to gain a reasonable proficiency with Flex but as with all things, nothing stands still and the pressure to keep moving with the times is ever present. It seems to me that the announcement to halt developing Flash for mobile devices represents a step forward rather than a retreat. The plugin architecture has plainly had its day and device manufacturers are demanding control of the programs which run on their hardware via the App stores which are now ubiquitous.

The problem is that my BI platform is entirely crafted on Flex and therefore relies on the flash plugin for use as I have never felt the urge to move over to AIR before now. That has all changed and it has actually been a very positive prod to investigate the new capabilities of Flash Builder and to begin to think about designing in a new way. Cross platform RIA used to mean Flash and I suppose it still does but as I understand it you are now looking at packaged Flash rather than swf files ready for the plugin and a series of GUI's crafted for each of the expected deployment platforms.

Anyhow enough of my view, its hardly an original train of thought and its well documented, on to the small nugget of code I wish to preserve for my cluttered memory. Along with the new platforms which flex supports there are also some new specific mobile features, in particular the ability to handle gestures or "finger swipes" on mobile touch screens. Its actually beautifully simple and the code follows for an empty view where I wanted to backup the back button in the action bar with a swipe feature for moving back to the previous view.

in the View tag you need the following code

gestureSwipe="handleSwipe(event)"

and then the following in the script.

import spark.transitions.SlideViewTransition;

import spark.transitions.ViewTransitionDirection;

private function handleSwipe(event:TransformGestureEvent):void{

var slideViewTransition:SlideViewTransition = new SlideViewTransition();

if (event.offsetX == 1 ) {

slideViewTransition.direction = ViewTransitionDirection.RIGHT;

navigator.popView(slideViewTransition);

}

}

Now if you deploy your app to a touch screen device you can move to the previous view simply by swiping your finger, it takes the app into the brave new world!

No comments:

A view from the rack is the personal blog of an IT manager who works for a pub company - hence beer