XML Image Gallery with World Style
| Category | : Flash | Views | : 39732 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : xml-image-gallery-with-world-style.zip | ||
| Result | : See the result | ||||
Code Explanation
import flash.display.BitmapData;
import flash.geom.Matrix
These two lines import the libraries for the BitmapData and Matrix objects, they are used to salve the images in the corret size inside every frame MC.
var image_xml = new XML();
image_xml.ignoreWhite = true;
image_xml.load("images.xml")
Load the XML file from where we are going to get the paths to the images.
var images_path = new Array();
This array will keep all paths to the images.
var frames = 0
We will use this variable to give unique names to duplicated MCs.
image_xml.onLoad = function()
{
for(i = 0; i < image_xml.firstChild.firstChild.childNodes.length; i++)
{
Loop this code by the number of node inside the XML.
_root.images_path[i] = image_xml.firstChild.firstChild.childNodes[i].attributes.title;
Get the path from each node using the attribute title.
_root.createEmptyMovieClip("frames" + i, _root.getNextHighestDepth());
Create a new MC just to load the image.
_root.MCloader.loadClip(_root.images_path[i], _root["frames" + i]);
}
}
Load the image using a MovieClipLoader object that we will create below. This function takes the following parameters:
loadClip(path,target)
Below goes the code for the MCloader.
frame._alpha = 0;
We won't load any image inside the MC that is on the stage so we hide it by set its alpha to 0.
MCloader = new MovieClipLoader();
listener = new Object();
Here we create a MovieClipLoader object to load every image and to trigger an Event Handler when the image is loaded.But to create the Event we need to create a new object and create the event inside it.
MCloader.addListener(listener);
Then we add that object as a listener to the MCloader, which will make the Event Handler below to be used in the MovieClipLoader object.
listener.onLoadInit = function(target)
{
This event happens when each image is loaded.
![]() |
![]() |
![]() |
![]() |
![]() |







