<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="1024" minHeight="768">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
private var t:Timer=new Timer(2000);
private var index:int=1;
protected function start_clickHandler(event:MouseEvent):void
{
t.addEventListener(TimerEvent.TIMER,doTimer);
t.start();
}
private function doTimer(evt:TimerEvent):void{
index++;
if(this.index>=7){
this.index=1;
}
this.img.source="../images/"+index+".jpg";
}
protected function stop_clickHandler(event:MouseEvent):void
{
this.t.stop();
}
protected function next_clickHandler(event:MouseEvent):void
{
index++;
if(this.index>=7){
this.index=1;
}
this.img.source="../images/"+index+".jpg";
}
protected function prev_clickHandler(event:MouseEvent):void
{
index--;
if(this.index<=0){
this.index=6;
}
this.img.source="../images/"+index+".jpg";
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:Panel x="10" y="0" width="783" height="604">
<s:Group x="23" y="5" width="715" height="389">
<mx:Image id="img" x="124" y="9" width="416" height="343" source="../images/1.jpg"/>
</s:Group>
<s:Group x="23" y="419" width="715" height="72">
<s:Button x="323" y="24" id="next" label="上一张" click="next_clickHandler(event)"/>
<s:Button x="427" y="24" label="下一张" id="prev" click="prev_clickHandler(event)"/>
<s:Button x="58" y="24" id="start" label="开始" click="start_clickHandler(event)"/>
<s:Button x="172" y="24" label="停止" id="stop" click="stop_clickHandler(event)"/>
</s:Group>
</s:Panel>
</s:Application>