Basic carousel

We are going to learn how to make a carousel in flash made with haXe.

output

Alternative content

Get Adobe Flash player

The carousel depends on an xml file which contains links to pictures we want to display

<carousel>
<item bubble="kick ass" src="http://localhost/Carousel/src/1.png"/>
<item bubble="kick ass" src="http://localhost/Carousel/src/2.png"/>
<item bubble="kick ass" src="http://localhost/Carousel/src/3.png"/> 
<item bubble="kick ass" src="http://localhost/Carousel/src/4.png"/> 
<item bubble="kick ass" src="http://localhost/Carousel/src/5.png"/> 
<item bubble="kick ass" src="http://localhost/Carousel/src/6.png"/> 
</carousel>

So below my first class : Item wich defines a part of the carousel

class Item extends Sprite
{
	/*the loader object which allows us to load a picture and 
	to add it on our Sprite*/
	private var image:Loader; 
	/*As we are going to use linked list instead of an array to stocks items
	an item have a next one after it.*/
	public var next:Item;
	 
	public var angle:Float;
	public var bubble:TextField; 
	public var textFormat:TextFormat;
	
	/*constructor takes in parameter path of the picture to load*/
	public function new(path:String)
	{
		super();
		/*create a loader object and load the picture*/
 		image = new Loader();
		image.contentLoaderInfo.addEventListener(Event.COMPLETE, imageLoaded);
 		image.load(new URLRequest(path)); 
 		   
 		/*create a textFields that allows us to display some text*/   
 		bubble = new TextField();
 		bubble.selectable = false; 
 		textFormat = new TextFormat("Arial", null, 0xFFFFFF, true);
 		bubble.defaultTextFormat = textFormat;
	}
	private function imageLoaded(e:Event)
	{ 			 
		/*as soon as loading is complete, just add on the Item the picture
		and the textfield*/
		this.addChild(image); 
		bubble.x = image.x;
		bubble.y = image.y + image.height; 
		bubble.autoSize = TextFieldAutoSize.CENTER;
		this.addChild(bubble);
			  
		image.contentLoaderInfo.removeEventListener(Event.COMPLETE, imageLoaded); 
		image.close(); 
	}
}