PDA

View Full Version : xml photo gallery in flash mx 2004



sundeep_02tv26
01-29-2007, 05:15 AM
hai to all plz help me

i want to know about xml photo gallery. i tried but i couldnot understand.

i have two pics and description for it in xml--its is fine

i used attributes for filename url and desc.

i had loaded one pic in the temp movieclip in flash but i couldnot load another pic in another movieclip. plz help me

BLiZZaRD
01-29-2007, 05:22 AM
It would help if you posted the code you are using. Also you only need one topic per question. Starting multiple threads about the same thing is frowned upon in most communities, including this one.

Post your code here and we will go from there.

sundeep_02tv26
01-29-2007, 11:17 AM
i am sorry for it

i tried with two files

first files :-
var main:Array = new Array();
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
var numimages = this.firstChild.childNodes.length;
trace(numimages);
vspacing = 100;
for (i=0; i<numimages; i++) {
this.holder_mc = this.firstChild.childNodes[i];
this.thumb_mc = thumb_mc.createEmptyMovieClip("thumb_mc"+i, i);
this.thumb_mc._y = i*vspacing;
this.thumbLoader = this.thumb_mc.createEmptyMovieClip("thumb_mc"+i, 0);
this.thumbLoader.loadMovie(this.holder_mc.attributes.thmb);
_root.desc_txt.text = this.holder_mc.attributes.desc;
trace(_root.desc_txt.text);
this.thumb_mc.main[i] = this.holder_mc.attributes.pics;
trace(this.thumb_mc.main[i]);
this.thumb_mc.onPress = function() {
holder_mc.loadMovie(this.main);
desc_txt.text = this.desc;
};
}
};
myPhoto.load("cont.xml");

second file:
var thmpics:Array = new Array();
var mainpics:Array = new Array();
var desc:Array = new Array();
var xl:XML = new XML();
xl.load("cont.xml");
xl.ignoreWhite = true;
xl.onLoad = function(ok) {
if (ok) {
total = xl.firstChild.childNodes.length;
for (i=0; i<total; i++) {
thmpics[i] = xl.firstChild.childNodes[i].attributes.thmb;
trace(thmpics[i]);
mainpics[i] = xl.firstChild.childNodes[i].attributes.pics;
trace(mainpics[i]);
desc[i] = xl.firstChild.childNodes[i].attributes.desc;
trace(desc[i]);
_root.thumb_mc.createEmptyMovieClip("thumb_mc"+i, i);
thmpics[i];
"thumb_mc"+i.loadMovie(thmpics[i]);
trace("loded");
//_root.thumb_mc.loadMovie(thmpics[i]);
//thumb_mc._x = thumb_mc._x*10;
thumb_mc.onPress = function() {
_root.holder_mc.loadMovie(mainpics[i]);
_root.desc_txt.text = desc[i];
};
}
} else {
trace("XML not loaded");
}
};

BLiZZaRD
01-29-2007, 02:08 PM
The first one looks fine.. unless I am missing something. What does your XML look like?

Here is a working AS file for loading thumbnails and photos into the file:



myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.load("xmlphoto.xml");
myPhoto.onLoad = function(success) {
numimages = this.firstChild.childNodes.length;
spacing = 70;
for (i=0; i<numimages; i++) {
picHolder = this.firstChild.childNodes[i];
this.thumbHolder = _root.thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._x = i*spacing;
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.main = this.picHolder.attributes.main;

this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image"+i, i);
this.thumbLoader.loadMovie(picHolder.attributes.thmb);


thumbHolder.onRelease = function() {
loader.loadMovie(this.main);
title_txt.text = this.title;
};
}
};


Take a look and see if you are missing anything...

sundeep_02tv26
01-31-2007, 09:05 AM
hai to all
here thumbs r loaded dynamic but what i want is when i click on them the main pics should be loaded in holder_mc. and on rollover they should be alpha=100% plz correct them and send plzzzzzzzzzzz

i am enable to upload file how to upload here?

BLiZZaRD
01-31-2007, 01:52 PM
Make sure you go to "Advanced" Reply. Then under the text box is the "manage attachments" option.

The allowed file types are listed there along with the "browse" to find it locally.

Alternately you can upload it to your server and link to it in a post.

sundeep_02tv26
02-01-2007, 09:49 AM
here i dont have a server to upload

BLiZZaRD
02-01-2007, 02:08 PM
Oops... after you browse to your file, make sure you click the "upload" button as well :)

If it is an invalid file type (swf, fla etc) put it in a zip file first. Then upload the zip file.

sundeep_02tv26
02-02-2007, 11:01 AM
it's ok

i have a prob here what i did is i made a gallery its work fine.

i made a mc. in that the gallery is there. so that i can link that photogallery mc to scroll pane its worked fine.
on top of it i have a dynamic textbox where if i press on the thumbs the correspondent desc should loaded in that textbox.say how to do

i know this will confuse u becoz no source kada ok

thx for the help

BLiZZaRD
02-02-2007, 04:03 PM
So the gallery works fine?

The text box works fine?

The loading of the full picture into the holder_MC does not work?

Is this correct?

sundeep_02tv26
02-03-2007, 12:45 PM
now the pictures r loading fine. i am struck at one point. here is the code
can u help plz...

pic_mc._visible = false;
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.load("davidartgall.xml");
my_xml.onLoad = function() {
rootElement = my_xml.firstChild;
children = rootElement.firstChild.childNodes;
//adding the main image node
mainImageNode = rootElement.childNodes[1].childNodes;
trace("mainImageNode="+mainImageNode);
descNode = rootElement.childNodes[2].childNodes;
trace(desc);
hspace = my_xml.firstChild.attributes.hspace;
//trace("hspace="+hspace);
vspace = my_xml.firstChild.attributes.vspace;
//trace("vspace="+vspace);
nofimagesperrow = my_xml.firstChild.firstChild.attributes.nofimagesperrow;
//trace(nofimagesperrow);
nofimagespercol = my_xml.firstChild.firstChild.attributes.nofimagespercol;
//trace(nofimagespercol);
startx = my_xml.firstChild.firstChild.attributes.starty;
//trace("startx"=+startx);
starty = my_xml.firstChild.firstChild.attributes.starty;
//trace("starty"=+starty);
m = nofimagesperrow*nofimagespercol;
//trace(m);
duplicateMovie();
};
function duplicateMovie() {
l = children.length;
for (var i = 0; i<l; i++) {
pic_mc.duplicateMovieClip("pic_"+i, i*100);
if (i<nofimagesperrow && i<nofimagespercol) {
setProperty("pic_"+i, _x, i*hspace+10);
setProperty("pic_"+i, _y, starty);
}
if (i>=nofimagesperrow && i>=nofimagespercol) {
setProperty("pic_"+i, _x, i*hspace+10);
setProperty("pic_"+i, _y, starty);
}
if (i>=nofimagesperrow*2 && i>=nofimagespercol*2) {
setProperty("pic_"+i, _x, i*hspace+10);
setProperty("pic_"+i, _y, starty);
}
if (i>=nofimagesperrow*3 && i>=nofimagespercol*3) {
setProperty("pic_"+i, _x, i*hspace+10);
setProperty("pic_"+i, _y, starty);
}
if (i>=nofimagesperrow*4 && i>=nofimagespercol*4) {
setProperty("pic_"+i, _x, i*hspace+10);
setProperty("pic_"+i, _y, starty);
}
// to diplay more than 8 photos, make another if statement here.
this["pic_"+i].external_mc.loadMovie(children[i].attributes.thumb);
this["pic_"+i].external_mc._alpha = 0;
//making a custom property
trace("mainImageNode"+i+mainImageNode[i]);
this["pic_"+i].image = mainImageNode[i].attributes.main;
var text1:Array = new Array();
text1[i] = descNode[i].attributes.desc;
trace(text1[i]);
}
}
this.onEnterFrame = function() {
for (var i = 0; i<children.length; i++) {
if (this["pic_"+i].external_mc._alpha<100) {
this["pic_"+i].external_mc._alpha += 5;
}
if (this["pic_"+i].external_mc._alpha>100) {
this["pic_"+i].external_mc._alpha = 100;
delete this.onEnterFrame;
}
this["pic_"+i].onPress = function() {
//getting the custom proprty, which is imageID
var imageToLoad:String = this.image;
trace(imageToLoad);
_root.holder_mc.loadMovie(imageToLoad);
_root.holder_mc._xscale = 65;
_root.holder_mc._yscale = 65;
_root.holder_mc._x = 440;
_root.holder_mc._y = 38;
_root.desc_txt.text = text[i];---i think here is the mistake can u correct it plzzzz
trace("="+desc_txt);
};
}
};

BLiZZaRD
02-04-2007, 03:22 PM
It looks like fine code to me. But then again you didn't tell us what the problem is or isn't doing?

From what I can tell it appears your not getting the image description text when you mouse over the thumbnails?

sundeep_02tv26
02-05-2007, 07:09 AM
thx for the reply
here everything is working fine tha thumbs, main images ok
now what i want is when i click on the thumbs the desc for pics should be displayed in desc box which is on top layer.

here davidgallery is davidgallery.xml which is in /david_gallery/davidgallery.xml

here is the code:-
pic_mc._visible = false;
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.load("david/david_gallery/davidartgall.xml");
my_xml.onLoad = function() {
rootElement = my_xml.firstChild;
children = rootElement.firstChild.childNodes;
//adding the main image node
mainImageNode = rootElement.childNodes[1].childNodes;
trace("mainImageNode="+mainImageNode);
descNode = rootElement.childNodes[2].childNodes;
trace(desc);
hspace = my_xml.firstChild.attributes.hspace;
//trace("hspace="+hspace);
vspace = my_xml.firstChild.attributes.vspace;
//trace("vspace="+vspace);
nofimagesperrow = my_xml.firstChild.firstChild.attributes.nofimagesperrow;
//trace(nofimagesperrow);
nofimagespercol = my_xml.firstChild.firstChild.attributes.nofimagespercol;
//trace(nofimagespercol);
startx = my_xml.firstChild.firstChild.attributes.starty;
//trace("startx"=+startx);
starty = my_xml.firstChild.firstChild.attributes.starty;
//trace("starty"=+starty);
m = nofimagesperrow*nofimagespercol;
//trace(m);
duplicateMovie();
};
function duplicateMovie() {
l = children.length;
for (var i = 0; i<l; i++) {
pic_mc.duplicateMovieClip("pic_"+i, i*100);
if (i<nofimagesperrow && i<nofimagespercol) {
setProperty("pic_"+i, _x, i*hspace+10);
setProperty("pic_"+i, _y, starty);
}
if (i>=nofimagesperrow && i>=nofimagespercol) {
setProperty("pic_"+i, _x, i*hspace-400+10);
setProperty("pic_"+i, _y, vspace-starty);
}
if (i>=nofimagesperrow*2 && i>=nofimagespercol*2) {
setProperty("pic_"+i, _x, i*hspace-800+10);
setProperty("pic_"+i, _y, vspace*2-starty*3);
}
if (i>=nofimagesperrow*3 && i>=nofimagespercol*3) {
setProperty("pic_"+i, _x, i*hspace-1200+10);
setProperty("pic_"+i, _y, vspace*3-starty*4);
}
if (i>=nofimagesperrow*4 && i>=nofimagespercol*4) {
setProperty("pic_"+i, _x, i*hspace-1600+10);
setProperty("pic_"+i, _y, vspace*4-starty*5);
}
// to diplay more than 8 photos, make another if statement here.
this["pic_"+i].external_mc.loadMovie(children[i].attributes.thumb);
this["pic_"+i].external_mc._alpha = 0;
//making a custom property
trace("mainImageNode"+i+mainImageNode[i]);
this["pic_"+i].image = mainImageNode[i].attributes.main;
var text1:Array = new Array();
text1[i] = descNode[i].attributes.desc;
trace(text1[i]);
}
}
this.onEnterFrame = function() {
for (var i = 0; i<children.length; i++) {
if (this["pic_"+i].external_mc._alpha<100) {
this["pic_"+i].external_mc._alpha += 5;
}
if (this["pic_"+i].external_mc._alpha>100) {
this["pic_"+i].external_mc._alpha = 100;
delete this.onEnterFrame;
}
this["pic_"+i].onPress = function() {
//getting the custom proprty, which is imageID
var imageToLoad:String = this.image;
trace(imageToLoad);
_root.holder_mc.loadMovie(imageToLoad);
_root.holder_mc._xscale = 65;
_root.holder_mc._yscale = 65;
_root.holder_mc._x = 440;
_root.holder_mc._y = 38;
_root.desc_txt.text = text[i];---here i am getting error any corrections plzzzzz .. it is displaying undefined in the textbox which is dynamic one
trace("="+desc_txt);
};
}
};



here is the xml:-
<photo hspace="100" vspace="120">
<!-- thumbs widthxheight=96x96 -->
<thumb nofimagesperrow="4" nofimagespercol="4" startx="10" starty="10">
<pic thumb="david_gallery/thumb/pic1.jpg"/>
<pic thumb="david_gallery/thumb/pic2.jpg"/>
<pic thumb="david_gallery/thumb/pic3.jpg"/>
<pic thumb="david_gallery/thumb/pic4.jpg"/>
<pic thumb="david_gallery/thumb/pic5.jpg"/>
<pic thumb="david_gallery/thumb/pic6.jpg"/>
<pic thumb="david_gallery/thumb/pic7.jpg"/>
<pic thumb="david_gallery/thumb/pic8.jpg"/>
<pic thumb="david_gallery/thumb/pic9.jpg"/>
<pic thumb="david_gallery/thumb/pic10.jpg"/>
<pic thumb="david_gallery/thumb/pic11.jpg"/>
<pic thumb="david_gallery/thumb/pic12.jpg"/>
<pic thumb="david_gallery/thumb/pic13.jpg"/>
<pic thumb="david_gallery/thumb/pic14.jpg"/>
<pic thumb="david_gallery/thumb/pic15.jpg"/>
<pic thumb="david_gallery/thumb/pic16.jpg"/>
<pic thumb="david_gallery/thumb/pic17.jpg"/>
<pic thumb="david_gallery/thumb/pic18.jpg"/>
</thumb>
<main>
<pic main="david_gallery/main/pic1.jpg"/>
<pic main="david_gallery/main/pic2.jpg"/>
<pic main="david_gallery/main/pic3.jpg"/>
<pic main="david_gallery/main/pic4.jpg"/>
<pic main="david_gallery/main/pic5.jpg"/>
<pic main="david_gallery/main/pic6.jpg"/>
<pic main="david_gallery/main/pic7.jpg"/>
<pic main="david_gallery/main/pic8.jpg"/>
<pic main="david_gallery/main/pic9.jpg"/>
<pic main="david_gallery/main/pic10.jpg"/>
<pic main="david_gallery/main/pic11.jpg"/>
<pic main="david_gallery/main/pic12.jpg"/>
<pic main="david_gallery/main/pic13.jpg"/>
<pic main="david_gallery/main/pic14.jpg"/>
<pic main="david_gallery/main/pic15.jpg"/>
<pic main="david_gallery/main/pic16.jpg"/>
<pic main="david_gallery/main/pic17.jpg"/>
<pic main="david_gallery/main/pic18.jpg"/>
</main>
<desc>
<text desc="this is 1 pic"/>
<text desc="this is 2 pic"/>
<text desc="this is 3 pic"/>
<text desc="this is 4 pic"/>
<text desc="this is 5 pic"/>
<text desc="this is 6 pic"/>
<text desc="this is 7 pic"/>
<text desc="this is 8 pic"/>
<text desc="this is 9 pic"/>
<text desc="this is 10 pic"/>
<text desc="this is 11 pic"/>
<text desc="this is 12 pic"/>
<text desc="this is 13 pic"/>
<text desc="this is 14 pic"/>
<text desc="this is 15 pic"/>
<text desc="this is 16 pic"/>
<text desc="this is 17 pic"/>
<text desc="this is 18 pic"/>
</desc>
</photo>

BLiZZaRD
02-05-2007, 02:22 PM
did you give the dynamic text box a var name of desc, an instance name of desc or both?

sundeep_02tv26
02-06-2007, 04:57 AM
i gave the text box as desc_txt for both var and instance name . but no result

BLiZZaRD
02-06-2007, 11:37 PM
Just use desc. not desc_txt

It is already a text box, Flash will recognize that, you don't need to tell it that :D

Hope it helps.