home gear home donate
Search Results For

Libraries book

HTML Library CSS Library JavaScript Library PHP Library


PHP and MySQL JavaScript HTML and CSS Vector and 3D Flash Actionscript Android Dev Miscellaneous


Website Hosting Developer Q+A

Download Source Files

<iframe width="560" height="315" src="" frameborder="0" allowfullscreen></iframe>
You can embed this video on your blog or web page by copying the video embed code above and pasting it into the source code of your page. Adjust the width and height to specify the size you would like it to display.
Thumb XML Dynamic Loop Compact Flash Gallery Tutorial Source Files in Actionscript 3.0
Embed Source -
Publish Date - Apr 03, 2009     Author - Adam Khoury
XML Dynamic Loop Compact Flash Gallery Tutorial Source Files in Actionscript 3.0
In this free CS3 + CS4 flash photo gallery tutorial source file package you can learn advanced loop based dynamics. This download package has insight all throughout, and is made intuitively for others to learn from. There are comprehensive code comments in the actionscript 3.0 so you can see which sections perform certain operations in the code. We demonstrate dynamic loop repositioning, loop click functions, and much more. There is no support offered if you do not understand the files.
Lesson Code

// Set the "y" location on stage where the first btn will live
var yPlacement:int = 72;
// Set the "x" location on stage where all btns will line up vertically
var line1xpos:int = -76;
var line2xpos:int = -76;
var line3xpos:int = -76;
var line4xpos:int = -76;
// Set the distance each btn should be apart here
var distance:int = 88;

// Initialize the XML, place the xml file name, initialize the URLRequest
// put URLRequest into a new URLLoader, and add event listener on
// myLoader listening for when the XML loading is complete
var myXML:XML = new XML();
var XML_URL:String = "Vids/AS3_compact_xml_loop_gallery/gallery_config.xml";
var myXMLURL:URLRequest = new URLRequest(XML_URL);
var myLoader:URLLoader = new URLLoader(myXMLURL);
myLoader.addEventListener("complete", xmlLoaded);

// Create the xmlLoaded function
function xmlLoaded(event:Event):void {

// Place the xml data into the myXML object
myXML = XML(;
// Initialize and give var name to the new external XMLDocument
var xmlDoc:XMLDocument = new XMLDocument();
// Ignore spacing around nodes
xmlDoc.ignoreWhite = true;
// Define a new name for the loaded XML that is the data in myLoader
var menuXML:XML = XML(;
// Parse the XML data into a readable format

// Access the value of the "galleryFolder" node in our external XML file
for each (var galleryFolder:XML in myXML..galleryFolder) {
// Access the value of the "pagenum" node in our external XML file
var galleryDir:String = galleryFolder.toString();
trace (galleryDir);

// Set the index number of our loop, increments automatically
var i:Number = 0;
// Run the "for each" loop to iterate through all of the menu items listed in the external XML file
for each (var MenuItem:XML in myXML..MenuItem) {

// Access the value of the "pagenum" node in our external XML file
var picnum:String = MenuItem.picnum.toString();
// Access the value of the "pagetext" node in our external XML file
var Caption:String = MenuItem.Caption.toString();
// Access the value of the "thumb" node in our external XML file
var thumb:String = MenuItem.thumb.toString();
// Access the value of the "pagepicture" node in our external XML file
var picture:String = MenuItem.picture.toString();

// Just some trace I used for testing, tracing helps debug and fix errors

var thumbLdr:Loader = new Loader();
var thumbURLReq:URLRequest = new URLRequest(galleryDir + thumb);
// Create MovieClip holder for each thumb
var thumb_mc = new MovieClip();
addChildAt(thumb_mc, 1);

// Create the rectangle used for the clickable button we will place over each thumb
var rect:Shape = new Shape;;, 0x999999);, 0, 80, 60);
// Create MovieClip holder for each button, and put that rectangle in it,
// make button mode true and set it to invisible
var clip_mc = new MovieClip();
clip_mc.buttonMode = true;
clip_mc.alpha = .0;

// The following four conditionals create the images where the images will live on stage
// by adjusting math through each row we make sure they are laid out good and not stacked
// all on top of one another, or spread out in one long row, we need 4 rows, so the math follows
if (picnum < "06"){

line1xpos = line1xpos + distance; // These lines place row 1 on stage
clip_mc.x = line1xpos;
clip_mc.y = yPlacement;
thumb_mc.x = line1xpos;
thumb_mc.y = yPlacement;

} else if (picnum > "05" && picnum < "11") {

line2xpos = line2xpos + distance; // These lines place row 2 on stage
clip_mc.x = line2xpos;
clip_mc.y = 141;
thumb_mc.x = line2xpos;
thumb_mc.y = 141;

} else if (picnum > "10" && picnum < "16") {

line3xpos = line3xpos + distance; // These lines place row 3 on stage
clip_mc.x = line3xpos;
clip_mc.y = 210;
thumb_mc.x = line3xpos;
thumb_mc.y = 210;

} else if (picnum > "15" && picnum < "21") {

line4xpos = line4xpos + distance; // These lines place row 4 on stage
clip_mc.x = line4xpos;
clip_mc.y = 279;
thumb_mc.x = line4xpos;
thumb_mc.y = 279;


// And now we create the pic loader for the larger images, and load it into "pictLdr"
var pictLdr:Loader = new Loader();
var pictURL:String = picture;
var pictURLReq:URLRequest = new URLRequest(galleryDir + picture);

// Setting up the click function for each thumb within the for each loop is tricky so
// Follow the code comments well, and try your best to analyze fully what is happening
// Access the pic value and ready it for setting up the Click listener, and function
clip_mc.clickToPic = pictLdr;
// Access the text value and ready it for setting up the Click listener, and function
clip_mc.clickToText = Caption;
// Add the mouse event listener to the moviClip button for clicking
clip_mc.addEventListener (MouseEvent.CLICK, clipClick);
//Add event listeners (used for the overClip animation)
clip_mc.addEventListener (MouseEvent.MOUSE_OVER, onMouseOver);
clip_mc.addEventListener (MouseEvent.MOUSE_OUT, onMouseOut);
// Set the function for what happens when that button gets clicked
function clipClick(e:Event):void {

// Populate the parent clip named frameSlide with all of the necessary data
MovieClip(parent).frameSlide.gotoAndPlay("show"); // Makes it appear(slide down)
MovieClip(parent).frameSlide.caption_txt.text =; // Adds the caption
MovieClip(parent).frameSlide.frame_mc.addChild(; // Adds the big pic


// increment the loop index number for trace testing
// i++; // [ i ] is only being used for testing here, you can remove it

} // This closes the "for each" loop

} // And this closes the xmlLoaded function
// Set the mouse over function for all movieclip buttons
function onMouseOver (e:Event):void {
overClip.x =;
overClip.y =;

// Set the mouse out function for all movieclip buttons
function onMouseOut (e:Event):void {
// Remove the overClip if you like by uncommenting this line to use it
// overClip.gotoAndStop(1);

Home   •   Terms of Use   •   T-Shirts   •   RSS   •   Testimonials   •   Subscribe   •   Classroom Chalkboard   •   Developer Q+A   •   Donate   •   Top ↑
Popular In PHP / MySQL E-Commerce Store Production
Social Network Website Building
Image Upload / Photo Processing
CMS Software Programming
Mass Email Systems
Magic XML Data
Search Programming
Popular In JavaScript JSON Programming
Ajax Programming
Animating Elements
WYSIWYG Programming
Date/Time Programming
DOM Scripting
Object Reference
Popular In HTML Canvas Element
New Form Elements
Audio Element
Video Element
Drag and Drop
Event Handling
Element Grouping
Popular In CSS Custom Font Embedding
Dynamic Fit Backgrounds
Theatre Mode
Box Overlays
CSS Level 1 Properties
CSS Level 2 Properties
CSS Level 3 Properties is a growing educational system packed with video and written material that you can access 24/7 100% free. The focus here in 2013 is spread between five technologies: HTML, CSS, JavaScript, PHP and MySQL. Learn programming theory, database interaction, web design, animation, graphics editing, vector art, 3D modeling, and much more. The educational experience here is a hybrid one offering both high quality video tutorials and code libraries that grow more robust every day. The code libraries are being assembled so that developers can discover all of the building blocks of their favorite languages. The libraries coupled with high quality video tutorials will take you deep down the rabbit hole very quickly. You can also ask questions and get free advice at
©2014 HTML5