In almost every Flash project, there are thumbnails or icons that need to be created and which then will either load video or image on click event. In a recent project, I had to create thumbnails dynamcially and center align them on stage, based on XML elements, but you can also load them from an Array.
In the following ActionScript 3.0 code, I have defined images in an array, although yuo can load these values from an XML doc too and populate them in this Array. Then there’s a Container MovieClip that holds all the thumbnails which are created dynamcially and images are loaded in the nested UILoader component in each thumbnail movieclip.
Finally, the container MovieClip is placed on the center of stage. I have added comments in the code to explain it further.
//define the thumbnails images in thumbsArray
//you may want to load and parse them from XML document
var thumbsArray:Array = new Array(‘image1.jpg’, ‘image2.jpg’, ‘image3.jpg’, ‘image4.jpg’, ‘image5.jpg’);
var myClipWidth:int=0;
var myClipHeight:int=0;
var nextX:int = 25;
var i:int;
var scrollWidth:int;
var scrollHeight:int;
//create container to hold the dynamically created nested thumbClips
var containerClip:container = new container();
for (i=0; i
Hope that helps.
Cheers!
Dear Ali,
Your script is excellent and self explanatory.
Keep it up.
Pls add more scripts like this
Dominic
Riadh
Awesome article! Though, you might want to mention that you created the “container” and “thumb” symbols. I was a little confused until I downloaded the FLA.
I tried to describe the logic how one could create button MovieClips dynamically.
But yes, I have learnt by experience that it’s better to provide fla movie file along side rather than just explaining logic. A functional sample file is best teacher.