Tutorials > Slideshow > Instantiate Slideshow using only code
Instantiate Slideshow using only code
Published: 21 August 2009
1. Drag an instance of the Slideshow component in the Library.
2. Instantiate the component and add it to the stage.
import com.flashotaku.slideshow.Slideshow;
var mySlideshow:Slideshow = new Slideshow();
addChild(mySlideshow);
var mySlideshow:Slideshow = new Slideshow();
addChild(mySlideshow);
3. Create an XML file, as explained in this tutorial, and pass it to the xmlPath property.
mySlideshow.xmlPath = "images.xml";
4. Set a few properties
mySlideshow.setSize(400, 250);
mySlideshow.move(20, 10);
mySlideshow.autoSlideshow = true;
mySlideshow.border = true;
mySlideshow.preloaderType = "pie";
mySlideshow.move(20, 10);
mySlideshow.autoSlideshow = true;
mySlideshow.border = true;
mySlideshow.preloaderType = "pie";
Here's the complete code:
//import the Slideshow class
import com.flashotaku.slideshow.Slideshow;
import com.flashotaku.events.SlideshowEvent;
// create an instance of the Slideshow
var mySlideshow:Slideshow = Slideshow();
// add the instance to the display list
addChild(mySlideshow);
// set the source
mySlideshow.xmlPath = "images.xml";
// set the dimension and position
mySlideshow.setSize(500, 300);
mySlideshow.move(20, 10);
// set some properties
mySlideshow.autoSlideshow = true;
mySlideshow.border = true;
mySlideshow.preloaderType = "pie";
import com.flashotaku.slideshow.Slideshow;
import com.flashotaku.events.SlideshowEvent;
// create an instance of the Slideshow
var mySlideshow:Slideshow = Slideshow();
// add the instance to the display list
addChild(mySlideshow);
// set the source
mySlideshow.xmlPath = "images.xml";
// set the dimension and position
mySlideshow.setSize(500, 300);
mySlideshow.move(20, 10);
// set some properties
mySlideshow.autoSlideshow = true;
mySlideshow.border = true;
mySlideshow.preloaderType = "pie";
