Hi,
I’ve run into a snag while using the XML image gallery @ kirupa.com as inspiration.
I have a series of thumbnail image buttons stored in an array:
var thumbsArray:Array = ["thumbs_mc.thumb_01", "thumbs_mc.thumb_02", "thumbs_mc.thumb_03", "thumbs_mc.thumb_04"];//Would access to the buttons be a string?
Each Corresponds to an image stored in an array from an xml file
imageArray* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
When a thumbNail* is released I need to call the function to move the viewer and load the corresponding imageArray* into the viewer
loadViewer();
and place the corresponding image into the container clip and display the caption in the caption field:
following is the code I’ve created so far:
//Initializing Variables attaching frame
var galleryTimeline:Object = this;
//attaching the frame
attachFrame();
var thumbsArray:Array = ["thumbs_mc.thumb_01", "thumbs_mc.thumb_02", "thumbs_mc.thumb_03", "thumbs_mc.thumb_04", "thumbs_mc.thumb_05", "thumbs_mc.thumb_06", "thumbs_mc.thumb_07", "thumbs_mc.thumb_08", "thumbs_mc.thumb_09", "thumbs_mc.thumb_10", "thumbs_mc.thumb_11", "thumbs_mc.thumb_12", "thumbs_mc.thumb_13", "thumbs_mc.thumb_14", "thumbs_mc.thumb_15", "thumbs_mc.thumb_16"];
//load an image
for(var i=0;i<thumbsArray.length;i++){
trace(thumbsArray*);
}
//frame_mc=f.
function attachFrame():Void {
galleryTimeline.attachMovie("frame_mc", "f", 1);
f._x = 404;
f._y = 294;
}
//Control Functions
function loadXML(loaded):Void {
//xml data here
if (loaded) {
var xmlNode:XMLNode = this.firstChild;
var imageArray:Array = [];
var captionsArray:Array = [];
var total = xmlNode.childNodes.length;
for (var i = 0; i<total; i++) {
imageArray* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
captionsArray* = xmlNode.childNodes[1].firstChild.nodeValue;
}
} else {
v.container_mc.test_txt.text = "file not loaded";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("x/images.xml");
function moveViewer():Void {
mx.transitions.TransitionManager.start(v, {type:mx.transitions.Fly, direction:0, duration:2, easing:mx.transitions.easing.Back.easeOut, startPoint:2, param2:empty});
}
function loadViewer():Void {
//viewer_mc=v
galleryTimeline.attachMovie("viewer_mc", "v", 0);
v._x = 150;
v._y = 100;
moveViewer();
trace("Viewer Loaded");
//disable focus of thumbs?
//calling the createDisplayAndCaption function
createDisplayMC();
}
function createDisplayMC():Void {
v.createEmptyMovieClip("container_mc", this.getNextHighestDepth());
v.container_mc._x = 0;
v.container_mc._y = 0;
v.container_mc.createTextField("test_txt", 1, 0, 0, 200, 20);
//omit after testing.
v.container_mc.test_txt.border = true;
v.container_mc.test_txt.text = "Display clip created";
//omit after testing.
//
//call create caption
createCaptionMC();
}
function createCaptionMC():Void {
v.container_mc.createEmptyMovieClip("caption_mc", this.getNextHighestDepth());
//place caption_mc
var captionClip = v.container_mc.caption_mc;
//shortcut to caption clip
captionClip._x = 300;
captionClip._y = 30;
//create caption text field
captionClip.createTextField("caption_txt", 2, 0, 0, 200, 20);
//create caption styles.
firstLetter = new textFormat();
firstLetter.bold = true;
captionClip.styles = new TextField.StyleSheet();
captionClip.styles.setStyle("p", {fontFamily:'Verdana,Arial,Helvetica,sans-serif', fontSize:'12px', color:'#000000'});
//
var captionField = v.container_mc.caption_mc.caption_txt;
//short cut to caption text field.
captionField.wordWrap = true;
captionField.multiline = true;
captionField.autoSize = "left";
captionField.html = true;
captionField.styleSheet = v.container_mc.caption_mc.styles;
captionField.htmlText = caption_text;
captionField.setTextFormat(0, 1, firstLetter);
}
//loadViewer();
function closeViewer() {
}