Hi there,
Im trying to adapt this code but im finding it very hard to understand.
http://www.photo.alanwallace.co.uk is the gallery that i have at present. What
i would like to do is have the first image to be displayed when the page loads
up, rather than just have the space until a thumb is selected.
Basically the thumbs and images are loaded up from a xml file, i'll put a
sample of the xml code under the action script.
Here's the code
verticalspace = 20;
horizspace = 10;
originx =550;
originy = 100;
w = 20;
h = 20;
cloparray = ;
myxml = new XML();
myxml.ignoreWhite = true;
myxml.onload = parseMe;
createEmptyMovieClip("lc", 5423);
myxml.load("
http://www.photo.alanwallace.co.uk/p.xml");
mainarray = ;
sectionarray = ;
function parseMe(success) {
if (success) {
for (var k = 0; k<this.firstChild.childNodes.length; k++) {
var pictures = this.firstChild.childNodes.childNodes;
_root = ;
for (var i = 0; i<pictures.length; i++) {
var obj = {};
for (var j in pictures.attributes) {
obj = pictures.attributes;
}
_root.push(obj);
}
mainarray.push(_root);
startfunction();
}
} else {
"FAILED TO LOAD DATA";
}
}
MovieClip.prototype.tweenTo = function(targetsObj, speed, callbackObj, func,
arg) {
var noo;
if (this.temp) {
noo = this.temp;
} else {
noo = this.createEmptyMovieClip("temp", this.depth++);
}
noo.targetsObj = targetsObj;
noo.onEnterFrame = function() {
var i;
for (var prop in this.targetsObj) {
this._parent += (this.targetsObj-this._parent)/speed;
if (Math.abs(this.targetsObj-this._parent)<1) {
this._parent = this.targetsObj;
delete this.targetsObj;
}
i++;
}
if (!i) {
callBackObj(arg);
this.removeMovieClip();
}
};
};
linem = function (top, fill) {
top.clear();
top.beginFill(fill);
top.lineStyle(0, 0xFF9900, 100);
top.lineTo(w, 0);
top.lineTo(w, h);
top.lineTo(0, h);
top.lineTo(0, 0);
top.endFill();
};
function section() {
for (var i = 0; i<sectionarray.length; i++) {
var mm = attachMovie("s", "s"+i, -5-i);
mm.myText.text = sectionarray;
mm.myText2.text = sectionarray;
mm._x = originx-spacing-mm._width;
mm._y = originy+i*(verticalspace+h);
}
}
function startfunction() {
section();
for (var i = 0; i<mainarray.length; i++) {
var clip = this.createEmptyMovieClip("holder"+i, i);
for (var j = 0; j<mainarray.length; j++) {
clop = clip.createEmptyMovieClip("h"+j, j);
clop.j = j;
clop.i = i;
clop._y = 700+random(500);
clop._x = random(4000)-2000;
clop.y = originy+i*(verticalspace+h);
clop.x = originx+j*(horizspace+w);
//clop.loadMovie(mainarray.image)
}
}
for (var obj in clip) {
if (typeof clip == "movieclip") {
cloparray.push({clip:clip, j:clip.j, i:clip.i, x:clip.x, y:clip.y});
}
}
loader();
}
function preloadf(mc) {
if (mc.getBytesLoaded()>=mc.getBytesTotal() && mc.getBytesTotal()>0) {
clearInterval(arguments.callee.interval);
var io = mc.createEmptyMovieClip("io", 10000);
linem(io);
for (var obj in cloparray) {
if (cloparray.clip == mc) {
cloparray.clip.startx = cloparray.x;
var o = {_x:cloparray.x, _y:cloparray.y};
cloparray.clip.tweenTo(o, 3, boo, "cb");
}
}
mc.onPress = mypress;
mc.onRollOver = myrollover;
mc.onRollOut = myrollout;
mc.enabled = false;
if (d<cloparray.length) {
d++;
loader();
}
}
}
var mmclip = createEmptyMovieClip("container", 2000);
mmclip._x = 500;
mmclip._y = 40;
function mypress() {
var gob =this
boo.onEnterFrame = function(){
container._alpha-=10
if(container._alpha <=0){
delete this.onEnterFrame
for (var obj in cloparray) {
linem(cloparray.clip.io);
if (cloparray.clip == gob) {
title.myText.text = sectionarray.i]+" "+mainarray.i].j].title;
container.loadMovie(mainarray.i].j].movie);
prel(container)
linem(cloparray.clip.io, 0xFFFFFF);
trace(cloparray.clip.io);
}
}
}
}
}
function myrollover() {
for (var obj in cloparray) {
if (cloparray.clip == this) {
//title.myText.text = mainarray.i].j].title;
var i = cloparray.i;
var j = cloparray.j;
var o = {_x:cloparray.clip.startx, _xscale:200, _yscale:200};
cloparray.clip.tweenTo(o, 5);
} else if (cloparray.i == i && cloparray.j>j) {
trace(cloparray.clip);
var o1 = {_x:cloparray.clip.startx+w, _xscale:100, _yscale:100};
cloparray.clip.tweento(o1, 5);
} else {
var o = {_x:cloparray.clip.startx, _xscale:100, _yscale:100};
cloparray.clip.tweenTo(o, 5);
}
}
}
var boo = this;
function myrollout() {
//title.myText.text = "";
for (var obj in cloparray) {
var o = {_x:cloparray.clip.startx, _xscale:100, _yscale:100};
cloparray.clip.tweenTo(o, 5);
}
}
var counter = 0;
function cb() {
counter++;
if (counter == cloparray.length) {
for (var obj in cloparray) {
cloparray.clip.enabled = true;
}
}
}
var d = 0;
function loader() {
clearInterval(preloadf.interval);
cloparray.clip.loadMovie(mainarray.i].j].image);
preloadf.interval = setInterval(preloadf, 40, cloparray.clip);
}
/*
for (var i = 0; i<4; i++) {
this.ivar = i;
this.onPress = pressf;
}
delete i;
function pressf() {
for (var obj in mainarray) {
trace(mainarray.image+" "+mainarray.caption);
}
}
*/
And the Xml is.....
<?xml version="1.0" encoding="iso-8859-1"?>
<pictures>
<1.>
<pic image="
http://www.photo.alanwallace.co.uk/t1.jpg" title="Alicia
Wallace" title2="Alicia Wallace blah blah"
movie="
http://www.photo.alanwallace.co.uk/p1.jpg"/>
<pic image="
http://www.photo.alanwallace.co.uk/t2.jpg" title="Picture 2"
movie="
http://www.photo.alanwallace.co.uk/p2.jpg"/>
And so on.
Any help isvery much apreciated
Cheers
Alan