View Single Post

  #1 (permalink)  
Old 07-02-08, 12:03
motown motown is offline
Junior Member
 
Join Date: Feb 2008
Posts: 1
Rep Power: 0
motown is on a distinguished road
xml gallery - scroll

Hello!
I have this xml gallery only made in actionscript 3. I would like to be able to add unlimited pictures and then scroll through the thumbnail horizontally. So I guess I should add a mask and a scrolling function but I don't know how to do this in AS3? Can anyone help and do I explain myself properly???
Here is my code:

import fl.transitions.Tween;
import fl.transitions.easing.*;

var fadeTween:Tween;

var imageText:TextField = new TextField();

var imageLoader:Loader;
var xml:XML;
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest("images.xml"));

xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);

function xmlLoaded(event:Event):void
{
xml = XML(event.target.data);
xmlList = xml.children();

for(var i:int = 0; i < xmlList.length(); i++)
{
imageLoader = new Loader();
imageLoader.load(new URLRequest(xmlList[i].attribute("thumb")));
imageLoader.x = i * 125 + 25;
imageLoader.y = 5;
imageLoader.name = xmlList[i].attribute("source");
addChild(imageLoader);
imageLoader.addEventListener(MouseEvent.CLICK, showPicture);
}

}

function showPicture(event:MouseEvent):void
{
imageLoader = new Loader();
imageLoader.load(new URLRequest(event.target.name));
imageLoader.x = 25;
imageLoader.y = 125;
addChild(imageLoader);
imageText.x = imageLoader.x;
imageText.y = 530;
for(var j:int = 0; j < xmlList.length(); j++)
{
if(xmlList[j].attribute("source") == event.target.name)
{
imageText.text = xmlList[j];
}
}
fadeTween = new Tween(imageLoader, "alpha",None.easeNone,0,1,1,true);
}
imageText.autoSize = TextFieldAutoSize.LEFT;
addChild(imageText);
Reply With Quote