Myfirstapp.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:ViewNavigatorApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" firstView="views.MyFirstAppHomeView" applicationDPI="240"
splashScreenImage="@Embed('Images/Sflash.jpg')"
>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:ContentCache id="ldr" enableQueueing="true"
maxActiveRequests="1" maxCacheEntries="2"/>
</fx:Declarations>
<fx:Script>
<![CDATA[
[Bindable]
public var key:int = 0 ;
import mx.collections.ArrayCollection;
[Bindable]
[Bindable]
public var tempAc:ArrayCollection=new ArrayCollection(content.split(";"));
]]>
</fx:Script>
</s:ViewNavigatorApplication>
========MyfirstappHomeView.mxml==============
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="My First App"
creationComplete="init()">
<fx:Style>
@namespace s "library://ns.adobe.com/flex/spark";
@namespace mx "library://ns.adobe.com/flex/mx";
s|Image {
enableLoadingState: true;
}
</fx:Style>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.collections.ArrayList;
import mx.core.FlexGlobals;
protected function init():void
{
//add listener
addEventListener(TransformGestureEvent.GESTURE_SWIPE , swipeHandler);
//label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();
//label2.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key +1 ).toString();
//caching image array
var rand:String = new Date().time.toString()
var arrcaching:Array = [];
arrcaching.push({src: FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key + 1).toString() + rand, cache:ldr});
arrcaching.push({src: FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring() + rand, cache:ldr});
var arrList:ArrayList = new ArrayList();
arrList = new ArrayList(arrcaching);
// dataGrp.dataProvider = arrList;
show.source = arrcaching.pop().src;
// show the first picture
// images.source= FlexGlobals.topLevelApplication.tempAc.getItemAt( FlexGlobals.topLevelApplication.key ).toString();
}
protected function swipeHandler (event:TransformGestureEvent):void
{
// Swipe was to the right
if (event.offsetX == 1 ) {
if (FlexGlobals.topLevelApplication.key == 0)
{
FlexGlobals.topLevelApplication.key = 0;
}
else
{
FlexGlobals.topLevelApplication.key = FlexGlobals.topLevelApplication.key - 1 ;
//label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();
navigator.pushView(MyFirstAppHomeView);
}
}
// Swipe was to the left
if (event.offsetX == -1 ) {
if (FlexGlobals.topLevelApplication.key == FlexGlobals.topLevelApplication.tempAc.length-1)
{
FlexGlobals.topLevelApplication.key = FlexGlobals.topLevelApplication.tempAc.length-1;
}
else
{
//no caching
FlexGlobals.topLevelApplication.key= FlexGlobals.topLevelApplication.key +1 ;
// label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();
navigator.pushView(MyFirstAppHomeView);
// caching
//label1.text= FlexGlobals.topLevelApplication.tempAc.getItemAt(FlexGlobals.topLevelApplication.key).toS tring();
// navigator.pushView(MyFirstAppHomeView);
}
}
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<s:ContentCache id="ldr" enableQueueing="true"
maxActiveRequests="1" maxCacheEntries="2"/>
</fx:Declarations>
<s:Image id="show" left="0" right="0" top="0" bottom="0" contentLoader="{ldr}" />
</s:View>