XML Image Gallery with Star Style
| Category | : Flash | Views | : 69834 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : xml-image-gallery-with-star-style.zip | ||
| Result | : See the result | ||||
Code Explanation
import flash.display.BitmapData;
import flash.geom.Matrix
Import the libraries for the BitmapData and Matrix objects, we will use them to save the loaded images and scale them to fit the frame.
var image_xml = new XML()
image_xml.ignoreWhite = true;
image_xml.load("images.xml")
Load the XML file.
var images_path = new Array();
This array will keep the paths to the images.
var frames = 0
We will use this variable to give unique names to the duplicated MCs.
image_xml.onLoad = function()
{
When the XML load, run this code.
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;
Populate the images_path array with the content of the attribute title from the current node.
_root.createEmptyMovieClip("frames" + i, _root.getNextHighestDepth());
Create an MC just to load the image, this MC will be deleted after loaded because it won't have any other use.
_root.MCloader.loadClip(_root.images_path[i], _root["frames" + i]);
}
}
Call the function loadClip() of the MovieClipLoader object to load the image inside the MC we just created.This function has these parameters:
loadClip(path,target);
Now the code for the MCLoader:
MCloader = new MovieClipLoader();
Create a new MovieClipLoader object.
listener = new Object();
Create an object just to make the Event Handler we need.
MCloader.addListener(listener);
Add the object "listener" to the MCloader as a listener so that any Event Handler created on this object will be used for the MCloader.We will create an Event Handler to be called when the image, which we asked the MCloader to load, is done loading.
var frames_array = new Array();
This array will be populated with all "frame" MCs we create so we only need to use an element inside this array to call an specific MC.
![]() |
![]() |
![]() |
![]() |
![]() |







