Join for FREE | Take the Tour Lost Password?
Shop deviantART for the
holidays and save BIG!
Click here! :holly:
[x]

deviantART

:flirty:
 
[x]  
Shop deviantART for the holidays Click here! :holly:
:iconmwythrandir:
hey, i'm trying to create a portfolio where multiple images are loaded through an array using xml...

i'm a bit lost seeing as i have little experience with xml to flash. creating the xml file and all is easy, but getting flash to grab the images from the xml is taunting me lol.

i trying to get it to load images in this layout:
[0] [1] [2] [3] [4] [5]
[6] [7] [8] [9] [10][11]
[12][13][14][15][16][17]

AND this all needs to be done in AS2...

i've looked at various tutorials, though if you have any suggestion or even the source code lol...

that help heaps

Devious Comments

love 0 0 joy 0 0 wow 0 0 mad 0 0 sad 0 0 fear 0 0 neutral 0 0
:iconl-inc:
I don't remember the exact as2 syntax anymore but basically you just loop through the xml file:

myXml = xmlfile.firstChild;
for(i=0; i<myXml.numChildren; i++){
loadImage(myXml.children[i].url);
}


--
New Browse Feature: browse by advanced critique welcome.... clicky here.
:iconl-inc:
And this is how I do it in AS3... at least most of the code. Should give you an idea how to do it.


private function ProcessXML(e:Event) {
//process xml
searchResult = new XML(e.target.data);
var totalNodes:Number = searchResult.item.length();
//clear arrays
ClearArray(aImgID);
ClearArray(aFileName);
ClearArray(aIndex);
//fetch arrays
for (var j:Number = 0; j<totalNodes; j++) {
aFileName[j] = searchResult.item[j].attribute("fileName");
aImgID[j] = searchResult.item[j].attribute("imgID");
}
//create thumbnails
CreateThumbnails(totalNodes, 12);
}

public function CreateThumbnails(thumbnails:uint, columns:uint) {
fullView = new Fullview();
addChild(fullView);
//remove thumbnails
DeleteThumbnails();
//
var aThumb:Array = new Array(thumbnails);
var nStartColumn:Number = 0;
var nColumn:Number = nStartColumn;
var nRow:Number = 0;
var nCount:Number = 0;
var nIncrease:Number = 60;
for (var j:Number = 0; j<aThumb.length; j++) {
var fileName:String = aFileName[j];
var imgID:Number = aImgID[j];
var sThumbPath:String = server + "/images/thumbs/" + aFileName[j];

aThumb[j] = new Thumbnail();
aThumb[j].x = nColumn;
aThumb[j].y = nRow;
aThumb[j].addEventListener(MouseEvent.CLICK, ClickListener);
aThumb[j].LoadImage(sThumbPath);
thumbContainer.addChild(aThumb[j]);

aIndex[j] = thumbContainer.getChildIndex(aThumb[j]);
aThumb[j].SetIndex(aIndex[j]);

if (nCount == columns-1) {
nColumn = nStartColumn;
nCount = 0;
nRow += nIncrease;
} else {
nCount++;
nColumn += nIncrease;
}
}
}
public function DeleteThumbnails() {
while (thumbContainer.numChildren > 0) {
thumbContainer.removeChildAt(0);
}
}


--
New Browse Feature: browse by advanced critique welcome.... clicky here.
:iconmwythrandir:
you're giving me too much credit in coding lol...

i'll change my knowledge status with xml to flash as very little,
coding is not my strong point but if there's involvement with flash then i'm willing to give it a shot lol

tuts to do something almost exactly like this would be great so i learn it all... or source code with notes even a beginner can understand
:iconl-inc:
I don'¨t know about tutorials. Google is pretty useful for searching those. ;)

--
New Browse Feature: browse by advanced critique welcome.... clicky here.
:iconmwythrandir:
here is some old xml i did university i've been trying to modify, to do my xml grid gallery
with no luck. pardon my possible multiple errors in the coding

if you have any simpler coding, i'm welcome to see it

i'm trying to get the grid to lay out like this:
[0] [1] [2] [3] [4] [5]
[6] [7] [8] [9] [10][11]
[12][13][14][15][16][17]

my coding within the fla file
---------------------------------------

if (thumbnails == undefined) {
thumbnails = [];
} else {
for (var i:Number = 0; i<thumbnails.length; i++) {
thumbnails[i]._alpha = 100;
}
}

while (thumbnails.length>0) {
removeMovieClip(thumbnails.pop());
}

var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = XMLLoaded;


xml.load("lol.xml");

function XMLLoaded(success:Boolean) {

// Success may be false if the server could not be contacted

if (success) {

var rspNode:XMLNode = this.firstChild;
var photosNode:XMLNode = rspNode.firstChild;
var maxThumbsPerRow = 6;
var thumbWidth = Stage.width/maxThumbsPerRow;
var maxResults:Number = 18;
var thumbx:Number = 0;
var thumby:Number = 190;

for (var photoIndex:Number = 0; photoIndex<;photosNode.childNodes.length && photoIndex<maxResults; photoIndex++) {
var photoNode:XMLNode = photosNode.childNodes[photoIndex];

if (photoNode.nodeName == "photo") {
var thumbnail:MovieClip = attachMovie("thumb1", "thumb1"+photoIndex, getNextHighestDepth());

thumbnail._y = thumby;
thumbnail._x = thumbx+(thumbWidth/2);
thumbnail.photoId = [link];
thumbnails.push(thumbnail);

thumbx += thumbWidth;

if ((photoIndex+1)%maxThumbsPerRow == 0) {
thumbx = 0;
thumby += thumbWidth;
}
// Week 7 code:

var photoXML = new XML();
photoXML.ignoreWhite = true;
photoXML.onLoad = photoLoaded;


var parameters = [link];

photoXML.thumbnail = thumbnail;
photoXML.load(parameters);
}
}
} else {
trace("Error invoking web service.");
}
}

function photoLoaded(success:Boolean) {

this.thumbnail.createEmptyMovieClip("image",this.thumbnail.getNextHighestDepth());

var loader:MovieClipLoader = new MovieClipLoader();
var loadListener = new Object();

loadListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number) {
target_mc._x -= target_mc._width/2;
target_mc._y -= target_mc._height/2;
};

loader.addListener(loadListener);
loader.loadClip(thumbnailURL,this.thumbnail.image);

}

var keyListener:Object = new Object();
keyListener.onKeyDown = function() {

if (Key.getCode() == Key.ENTER) {
search_btn.onRelease();
}
};


Key.addListener(keyListener);

--------------------------------------------------

Thumbnails.as file

class Thumbnails extends MovieClip {

//button code for image in the array------------------
var startx:Number;
var starty:Number;
var over:Boolean;
var out:Boolean;

var photoId:String;

function onPress() {
startx = _x;
starty = _y;
}

function onRelease() {
if (this._x == this.startx && this._y == this.starty) {
// Hide thumbnails
for (var i:Number = 0; i<_level0.thumbnails.length; i++) {
_level0.thumbnails[i]._alpha = 0;
}
_level0.gotoAndStop(40);
} else {
this._x = this.startx;
this._y = this.starty;
onMouseMove = null;
}
}
function onRollOver() {
over = true;
out = false;

trace("image id: " + imageId);
}

function onRollOut() {
over = false;
out = true;
}
function onReleaseOutside() {
this._x = this.startx;
this._y = this.starty;
}
function onEnterFrame() {
if (over && _xscale<120) {
_xscale++;
_yscale = _xscale;
}
if (out && _xscale>100) {
_xscale--;
_yscale = _xscale;
}
}
}

--------------------------------------------------------------------

and lastly an example of my xml file...

<?xml version="1.0" encoding="utf-8"?>

<images>
<image id>images/image1.jpg</image id>
<image id>images/image2.jpg</image id>
</images>
:iconmwythrandir:
hey i've fix my code up a bit... got it loading multiple movieclips coordinating with the xml though its not grabbing the images.

heres the url [link] to my code, just wondering if u or someone u know whose good with AS2 could check it out for me
:iconl-inc:
Does it work? You could just put trace statements everywhere to find out what the problem is if there is one.

--
New Browse Feature: browse by advanced critique welcome.... clicky here.
:iconmwythrandir:
did... its got something to do with my imageLoaded function, but i'm clueless how to fix it.

you know of any worthwhile forums excluding DA for actionscripting?

Site Map