Hi all!
I’ve got a little problem with my XML gallery. I want to jump to a specific spot in my XML file - when I click a button, it should jump to picture number 10.
Here is the code:
#include "mc_tween2.as"
Stage.scaleMode = "noScale";
//
import flash.display.BitmapData;
var tile:BitmapData = BitmapData.loadBitmap("pattern");
this.beginBitmapFill(tile);
this.lineTo(Stage.width, 0);
this.lineTo(Stage.width, Stage.height);
this.lineTo(0, Stage.height);
this.lineTo(0, 0);
this.endFill();
//
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
}
proxImg ();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
//
var nId:Number = -2;
var nIm:Number = 0;
//
desc_txt.html = true;
desc_txt.autoSize = "left";
total_txt.html = true;
total_txt.autoSize = "right";
//
function proxImg ():Void {
if (nId == image.length - 1) {
trace ("end");
} else {
nId += 1;
nIm += 1;
_root.attachMovie ("img_mc", "img_mc" + nIm, nIm + 1);
eval (_root["img_mc" + nIm])._x = 37;
eval (_root["img_mc" + nIm])._y = 81;
_root.alphaTo (100, 0, "linear", 0, function () {
eval (_root["img_mc" + nIm]).mcl.loadClip (image[nId], eval (_root["img_mc" + nIm]).alvo_mc);
});
desc_txt.htmlText = (description[nId].toUpperCase ());
desc_txt._alpha = 0;
desc_txt.alphaTo (100, 1);
//
atual = addZero ((nId + 1), 2);
total = addZero (image.length, 2);
total_txt._alpha = 0;
total_txt.alphaTo (100, 1);
total_txt.htmlText = atual + "<font color='#000000'>" + "/" + total + "</font>";
}
}
//
function prevImg ():Void {
if (nId <= 0) {
trace ("end");
} else {
nId -= 1;
nIm += 1;
_root.attachMovie ("img_mc", "img_mc" + nIm, nIm + 1);
eval (_root["img_mc" + nIm])._x = 37;
eval (_root["img_mc" + nIm])._y = 81;
_root.alphaTo (100, 0, "linear", 0, function () {
eval (_root["img_mc" + nIm]).mcl.loadClip (image[nId], eval (_root["img_mc" + nIm]).alvo_mc);
});
desc_txt.htmlText = (description[nId].toUpperCase ());
desc_txt._alpha = 0;
desc_txt.alphaTo (100, 1);
//
atual = addZero ((nId + 1), 2);
total = addZero (image.length, 2);
total_txt._alpha = 0;
total_txt.alphaTo (100, 1);
total_txt.htmlText = atual + "<font color='#000000'>" + "/" + total + "</font>";
}
}
//
function addZero (n, q):String {
var str = Math.pow (10, (q - n.toString ().length)).toString ().substr (1) + n;
return str;
}
//
proxImg ();
//
prox_bt.onRelease = proxImg;
prev_bt.onRelease = prevImg;
//
prev_bt.onRollOver = prox_bt.onRollOver = function () {
this.alphaTo (100, 1);
};
prev_bt.onRollOut = prox_bt.onRollOut = function () {
this.alphaTo (75, 1);
};
//
contact_mc.onRollOver = function () {
this.colorTo(0x9d5b14, 0.1, "linear");
};
contact_mc.onRollOut = function () {
this.colorTo(null, 0.5, "linear");
};
Here is the XML code from images.xml
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
<pic>
<image>art/test2.jpg</image>
<caption>Sky is falling</caption>
</pic>
<pic>
<image>art/test.jpg</image>
<caption>Urban</caption>
</pic>
</images>
Hope you can help me? And understanding what I’m trying to explain …hehe!