Hi Everyone
I have created a presentation in flex. the data is retrieved from a
XML file. i have also added key listeners to the space bar and right
and left key. but i find the keys not so responsive at times, could
anybody give me some suggestions , the code is below
-----------------------------------------------------------------------------------------------------------------------------------------------------------------
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
backgroundImage="../img/Background.JPG" styleName="application"
horizontalAlign="right" creationComplete="allowAccess()"
verticalAlign="middle" xmlns:MyComp="*">
<mx:HTTPService url="../data/Data.xml" id="siteData"
resultFormat="e4x"/>
<!--ResourcePack-->
<mx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.controls.Button;
import mx.containers.Tile;
import mx.containers.Panel;
import mx.controls.Text;
import mx.controls.Alert;
import mx.managers.PopUpManager;
//for the XML file
private var siteContent:XMLList;
[Bindable]
private var currentItems:int=0;
[Bindable]
private var totalItemss:int=3;
private function allowAccess():void
{
siteData.send();
Application.application.addEventListener
(KeyboardEvent.KEY_UP,keyEvent);
}
private function keyEvent(key:KeyboardEvent):void
{
if(key.keyCode.toString()=='32' ||
key.keyCode.toString()
=='39' )
{
moveNextSlide();
}
else if(key.keyCode.toString()=='37')
{
movePreviousSlide();
}
}
private function moveNextSlide():void
{
currentItems=currentItems + 1;
if(totalItemss==currentItems)
{
currentItems=currentItems-1;
}
if(currentItems==0)
{
Next.enabled=true;
Previous.enabled=false;
}else if(totalItemss-currentItems==1)
{
Next.enabled=false;
Previous.enabled=true;
}else
{
Next.enabled=true;
Previous.enabled=true;
}
}
private function movePreviousSlide():void
{
currentItems=currentItems- 1;
if(currentItems<0)
{
currentItems=0;
}
if(currentItems==0)
{
Next.enabled=true;
Previous.enabled=false;
}else if(totalItemss-currentItems==1)
{
Next.enabled=false;
Previous.enabled=true;
}else
{
Next.enabled=true;
Previous.enabled=true;
}
}
private function closeHandler(event:CloseEvent)
{
PopUpManager.removePopUp(event.target.valueOf());
}
]]>
</mx:Script>
<mx:Zoom id="zoomin" zoomHeightFrom="1.0" zoomHeightTo="2.0"
zoomWidthFrom="355" zoomWidthTo="500" duration="1000"/>
<mx:Zoom id="zoomout" zoomHeightTo="1.0" zoomWidthTo="355" />
<mx:Sequence id="previousImage" target="{img}">
<mx:Fade alphaFrom="1" alphaTo="0" duration="10" />
<mx:Fade alphaFrom="0" alphaTo="1" duration="10"/>
</mx:Sequence>
<mx:Sequence id="nextImage" target="{img}">
<mx:Fade alphaFrom="1" alphaTo="0" duration="10" />
<mx:Fade alphaFrom="0" alphaTo="1" duration="10"/>
</mx:Sequence>
<mx:Label width="1121" id="header" color="#045B6E" height="43"
alpha="0.77" fontWeight="bold" fontSize="20"
textDecoration="underline" textAlign="center"
text="{siteData.lastResult.page.header[currentItems]}"/>
<mx:HBox width="1119" height="472" borderSides="3"
borderStyle="inset" borderThickness="5" verticalAlign="middle"
horizontalGap="2" horizontalAlign="center">
<mx:Image width="1020" verticalAlign="middle" id="img"
source="{siteData.lastResult.page.source[currentItems]}"
scaleContent="true" height="462"/>
</mx:HBox>
<mx:HBox width="1122" height="41" horizontalAlign="center">
<mx:Button label="Previous" id="Previous" width="266"
height="30" click="movePreviousSlide()" fillAlphas="[0.6, 0.4, 0.75,
0.65]"/>
<mx:Button label="Next" id="Next" toggle="false" width="266"
height="30" click="moveNextSlide()" />
</mx:HBox>
</mx:Application>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Flex
India Community" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---