Yes, you can add it in one of those examples if you want. One this you need to do, though, is delete the existing itemClickHandler function because the code I gave you also has a function with the same name.
The complete code is this:
- Code: Select all
import com.flashotaku.events.ScrollerEvent;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.net.URLRequest;
import flash.display.Loader;
// the loader for the big image
var bigImageLoader:Loader = new Loader();
showBigImage();
//listen when the big image is loaded
bigImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, bigImageCompleteHandler);
myScroller.addEventListener(ScrollerEvent.ITEM_CLICK, itemClickHandler);
function itemClickHandler(event:ScrollerEvent):void
{
// select the clicked item
myScroller.select(event.index);
// load the big image
loadBigImage(event.data.bigImage);
}
previous.addEventListener(MouseEvent.CLICK, arrowClickHandler);
next.addEventListener(MouseEvent.CLICK, arrowClickHandler);
next.buttonMode = previous.buttonMode = true;
function arrowClickHandler(event:MouseEvent):void
{
if (event.currentTarget == next)
{
myScroller.selectNext();
}
else if (event.currentTarget == previous)
{
myScroller.selectPrevious();
}
}
function loadBigImage(path:String):void
{
// load the image
bigImageLoader.load(new URLRequest(path));
}
function bigImageCompleteHandler(event:Event):void
{
// resize the image and set its position
bigImageLoader.width = 500;
bigImageLoader.height = 300;
bigImageLoader.x = 200;
bigImageLoader.y = 50;
}
function showBigImage():void
{
addChild(bigImageLoader);
}
function hideBigImage():void
{
removeChild(bigImageLoader);
}
You can delete all the existing code and paste the code above.