Hi Dudes…
I have used 4 hours to trying to give my thumbs in my gallery a position.
Right now, the thumbs being loaded in a stack.
Preview: http://www.insaneme.com/clients/test/main_auto.html
My code its a little bit long but i hope its okay
Here i load my gallery from xml
var largeImageUrl:Array = new Array ();
var kateNavn:Array = new Array ();
var thumbUrl:Array = new Array ();
var titelT:Array = new Array ();
var picNum:Number;
var i = 0;
// Loader XML
var billedGalleri:XML = new XML ();
billedGalleri.ignoreWhite = true;
billedGalleri.onLoad = function () {
trace ("XML LOADED");
loadGalleri (0);
};
billedGalleri.load ("gallery/galleri.xml");
// Function når XML er loadet
function loadGalleri (cat) {
trace ("load gallery: " + cat);
currentImage = 0;
largeImageUrl = *;
thumbUrl = *;
xmlNode = billedGalleri.firstChild;
var kategori:Array = xmlNode.childNodes;
trace (kategori.length);
var images:Array = xmlNode.childNodes[cat].childNodes;
trace (images.length);
for (i = 0; i < images.length; i++) {
picNum = images.length;
//updateCounter(); // opdater display
thumbUrl* = xmlNode.childNodes[cat].childNodes*.childNodes[0].firstChild.nodeValue;
largeImageUrl* = xmlNode.childNodes[cat].childNodes*.childNodes[1].firstChild.nodeValue;
loadThumbs();
target_mc.pictureValue = i;
mcLoader.loadClip (largeImageUrl*,largeImage_mc);
//kill the mouselistener if it is added
}
bund_mc.thumbMask_mc.thumbBox_mc.createEmptyMovieClip ("thumbTrackBg",1);//_root timeline
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg.beginFill (0x000000,0);
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg.moveTo (thumbMask_mc.thumbBox_mc._x,thumbMask_mc.thumbBox_mc._y);
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo (thumbMask_mc.thumbBox_mc._x + thumbMask_mc.thumbBox_mc._width,thumbMask_mc.thumbBox_mc._y);
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo (thumbMask_mc.thumbBox_mc._x + thumbMask_mc.thumbBox_mc._width,thumbMask_mc.thumbBox_mc._y + thumbMask_mc.thumbBox_mc._height);
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo (thumbMask_mc.thumbBox_mc._x,thumbMask_mc.thumbBox_mc._y + thumbMask_mc.thumbBox_mc._height);
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo (thumbMask_mc.thumbBox_mc._x,thumbMask_mc.thumbBox_mc._y);
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg.endFill ();
Mouse.removeListener (mouseListener);
}
and here my thumb function
function loadThumbs () {
//remove the movieclip loade listener on each iteration of this function
Clip.removeListener (mclListener);
//attach and associate with a variable a MC to hold each loaded movieClip
var container:MovieClip = bund_mc.thumbMask_mc.thumbBox_mc.attachMovie ("thumbBox", "thumbBox" + i, bund_mc.thumbMask_mc.thumbBox_mc.getNextHighestDepth (), {_x:imageWidth, _y:0});
//var indErst:MovieClip = thumbBox*;
//create a movieclip loader
var Clip:MovieClipLoader = new MovieClipLoader ();
var mclListener:Object = new Object ();
mclListener.onLoadStart = function (target_mc:MovieClip) {
target_mc._alpha = 0;//set thumb alpha to be zero
};
//handle loading progress - simple counter here
mclListener.onLoadProgress = function (target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
//use this if you want to indicate loading of your thumbnails etc...
//loadTxt.captions_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
};
mclListener.onLoadInit = function (target_mc:MovieClip) {
/*//here we can access our loaded clips properties!
//here is where we attach functions to our clip so that we can dynamically create rollovers etc.*/
//make our thumbnails visible again
container.alphaTo (50,2,"linear");
//subscribe all images to AS broadcast method
//targetThumbs.addListener(this);
//based off image width this places our thumbs next to each other
imageWidth = (target_mc._width);
//moveToD(thumbup,this._y,0,15);
//associate a variable here with our p value, we use this later to load in large images
target_mc.pictureValue = i;
//container._alpha = 50;
var thumbup:MovieClip = target_mc;
//handle image rollovers these are active only on the thumb image!!! Watch the US spelling!
moveToD (bund_mc.thumbup,0,45,15);
target_mc.onRollOver = function () {
container._alpha = 100;
moveToD (bund_mc.thumbup,this._y,45,15);
//TweenFilterLite.to(target_mc,.4,{type:"Color", brightness:0, ease:None.easeOut});
};
target_mc.onRollOut = function () {
//moveToD(thumbup,45,0,30);
container._alpha = 50;
//TweenFilterLite.to(target_mc,4,{type:"Color", brightness:2, ease:None.easeOut});
};
//handle a click on a thumbnailp
target_mc.onRelease = function () {
//moveToD(bund_mc.thumbup,45,0,30);
trace(this);
_root.bund_mc.thumbMask_mc.thumbBox_mc.attachMovie ("tracker","trackernew",100);
_root.bund_mc.thumbMask_mc.thumbBox_mc.trackernew._x = thumbup._x + 25;
//_root.bund_mc.thumbMask_mc.thumbBox_mc.trackernew._y = this._y - 10;
//load large images
container._alpha = 100;
mcLoader.loadClip (largeImageUrl*,largeImage_mc);
};
//target_mc.pictureValue = i;
i++;//increment value to cycle through array
//STORE PILE
prevImage = function () {
target_mc.pictureValue--;
trace ("nu" + target_mc.pictureValue);
sizeListenerB.onResize ();
Stage.addListener (sizeListenerB);
mcLoader.loadClip (largeImageUrl[target_mc.pictureValue],largeImage_mc);
if (target_mc.pictureValue < 0) {
target_mc.pictureValue = picNum;
}
};
nextImage = function () {
target_mc.pictureValue++;
trace ("nu" + target_mc.pictureValue);
if (target_mc.pictureValue >= picNum) {
target_mc.pictureValue = 0;
}
sizeListenerB.onResize ();
Stage.addListener (sizeListenerB);
mcLoader.loadClip (largeImageUrl[target_mc.pictureValue],largeImage_mc);
};
big_left.onRelease = function () {
this.gotoAndPlay (2);
prevImage ();
};
big_right.onRelease = function () {
this.gotoAndPlay (2);
//trace ("go");
nextImage ();
};
if (target_mc.pictureValue < picNum) {
loadThumbs ();//create loop
}
if (target_mc.pictureValue == picNum) {
//we set this variable here because this is where we know the length of our thumbnails containing mc.
// After we have loaded all content in. Makes sense really!
mcWidth = bund_mc.thumbMask_mc.thumbBox_mc._width;
//adjust the width and height of the thumbstrack bg clip
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg._width = mcWidth;
bund_mc.thumbMask_mc.thumbBox_mc.thumbTrackBg._height = bund_mc.thumbMask_mc.thumbBox_mc._height;
//add the mouse listener object to the thumbnail mask. We do this element of our script here so
// we do not enable scrolling of our mc before the images have all loaded in. As this can cause issuse
Mouse.addListener (mouseListener);
}
};
Clip.addListener (mclListener);
Clip.loadClip (thumbUrl*,container);
}
I really hope that somebody could help me out from this nightmare!
best regards
insaneme