我有一個使用TileList和UILoader的照片庫。它工作得很好。當我點擊TileList中的縮略圖時,整個圖片出現在UILoader中,但我正在嘗試添加下一個和上一個按鈕,並能夠瀏覽圖片。我只是不確定如何創建函數/編寫代碼才能做到這一點。我需要使用循環嗎?這可能嗎??我已經通過Google進行搜索,找不到答案。我確實發現了[this] [1],但沒有提供代碼,這個問題是針對Flex的。如何使用按鈕瀏覽Flash AS3.0中的磁貼列表?
這是到目前爲止我的代碼:
import flash.display.Loader;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.MouseEvent;
import fl.data.DataProvider;
import fl.controls.TileList;
import fl.controls.ScrollBarDirection;
import fl.transitions.Tween;
import fl.transitions.easing.None;
var XMLgallery:XML = <items>
<item source="img/DSC_0.jpg" />
<item source="img/DSC_1.jpg" />
<item source="img/DSC_2.jpg" />
<item source="img/DSC_3.jpg" />
<item source="img/DSC_4.jpg" />
<item source="img/DSC_5.jpg" />
<item source="img/DSC_6.jpg" />
<item source="img/DSC_7.jpg" />
<item source="img/DSC_8.jpg" />
<item source="img/DSC_9.jpg" />
<item source="img/DSC_10.jpg" />
<item source="img/DSC_11.jpg" />
<item source="img/DSC_12.jpg" />
<item source="img/DSC_13.jpg" />
<item source="img/DSC_14.jpg" />
<item source="img/DSC_15.jpg" />
</items>;
tileList.dataProvider = new DataProvider(XMLgallery);
tileList.setSize(795, 130);
tileList.columnWidth = 195;
tileList.rowHeight = 130;
tileList.direction = ScrollBarDirection.HORIZONTAL;
tileList.addEventListener(Event.CHANGE, imageChanger);
progressBar.visible = false;
mainLoader.load(new URLRequest("img/DSC_0.jpg"));
function imageChanger(event:Event):void{
progressBar.visible = true;
mainLoader.source = tileList.selectedItem.source;
var myTween:Tween = new Tween(mainLoader, "alpha", None.easeNone,.3,1,18,false);
}
mainLoader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void{
progressBar.visible = false;
}
prev_mc.addEventListener(MouseEvent.CLICK, prevF);
next_mc.addEventListener(MouseEvent.CLICK, nextF);
你想要下一個/上一級按鈕的主要圖像,或縮略圖圖像滾動? – Vipul 2013-03-01 05:02:45