Hello everyone.
I’m trying to combine rhame’s xml gallery with stringy’s thumbnail bonus code.
In short when i click a thumb excpet from the large main image i want to get buttons 1 2 3 4 for bonus images.
Ok i managed to get the bonus from the first image to display.
But when i click the next thumb bonus disappear and even on the first image are not showing anymore. I have temporarily disabled the mask so i can see whats going on.
I believe it has to do something with the bonusarray* it doesnt seem to listen after the first ones. I mean the mask is scaling and working.
here is the actionscript and in red the script i think its the problem:
scroller.InstanceName_1._alpha += 100;
stop();
//set the initial postitions/properties of every thing.
mtClip._alpha = 0;
// define the vars
var frwrd:Boolean = true;
var pictures:Array = new Array();
var thumbs:Array = new Array();
var p:Number = -1;
var z:Number;
var clickCount:Number = 0;
var howMclick:Number;
var slideCount:Number = -1;
var images:Array = new Array();
var numOfBtns:Array = new Array();
var xml:XML = new XML();
var fadeOut:Boolean;
var setIt:Boolean = false;
var playFast:Boolean;
var nextImage;
var mainColor;
var nextLink;
bonusarray=[]
// set the colors
//Load the XML and set all the arrays, blah blah blah....
xml.ignoreWhite = true;
xml.onLoad = function(ok) {
if (ok) {
allData = this.firstChild.childNodes;
for (var i = 0; i<allData.length; i++) {
[COLOR="Red"]bonusarray*=[]
for(var obj in allData*.attributes){
bonusarray*.push(allData*.attributes[obj])
}[/COLOR]
trace(this.firstChild.childNodes*.attributes.bonus1)
var newBut:MovieClip = scroller.container.attachMovie("thumbMC", "thumb"+i, i);
total = xmlNode.childNodes.length;
newBut.descript = allData*.firstChild.firstChild;
newBut.image = allData*.firstChild.nextSibling.nextSibling.firstChild;
thumbs.push(allData*.firstChild.nextSibling.firstChild);
pictures.push(allData*.firstChild.nextSibling.nextSibling.firstChild);
numOfBtns* = "but"+i;
newBut.slideCounter = i;
newBut.num.numtext = newBut.descript;
newBut._visible = false;
newBut.endY = i*(31);
newBut.endX = 0;
newBut._x = 0;
howMclick = Math.floor(scroller.container._height/100);
newBut.onRelease = function() {
checkThumbs();
if (showSlide == false) {
slideCount = this.slideCounter;
}
infoBox.infoText.text = this.descript;
nextImage = this.image;
fadeOut = true;
fadeMain();
[COLOR="Red"]getButtons();[/COLOR]
this.enabled = false;
if ((this.slideCounter+1)>=10){
counterText_mc.loadingText.text = "0" + (this.slideCounter+1);
}else{
counterText_mc.loadingText.text = "00" + (this.slideCounter+1);
}
counterText_mc.totalText.text = "/0" + pictures.length;
};
newBut.onRollOver = function() {
this.num.fadeIn = true;
this.thumbClip.fadeIn = true;
this.thumbClip.fade();
this.num.fade();
};
newBut.onRollOut = function() {
this.num.fadeIn = false;
this.thumbClip.fadeIn = false;
this.thumbClip.fade();
this.num.fade();
};
}
// when all done with above caca, load the first thumb
nextPic();
}
};
[COLOR="red"]mask._visible =true;
function getButtons(){
barray = [];
mask._width = 100;
mask._visible = true;
var clip =this.createEmptyMovieClip("paper",10000)
clip._y = 222
clip._x=20
for(var i=0;i<bonusarray[p].length;i++){
var clap =clip.attachMovie("btn","btn"+i,i)
clap._alpha = 100;
clap._x =(clap._width+2)*i
clap.ivar =i
barray.push(clap);
clap.p = p;
clap.myText.text ="0"+(i)
clap.onPress =dopress
clap.onRelease = clap.onReleaseOutside =dorelease
}
barray[0].enabled = false
mask.onEnterFrame =grow
}
function grow(){
this._width+=(paper._width-this._width)/5
if(Math.abs(paper._width-this._width)<2){
this._width = paper._width
delete this.onEnterFrame
}
}
function dorelease(){
for (var obj in barray) {
barray[obj].enabled = true;
bckmc.bck.bckbtn.enabled= false;
barray[obj].colorTo(0x686563,0.5,"easeOutCubic");
}
this.enabled = false;
this.colorTo(0xADAAA7,0.5,"easeOutCubic");
fcuk = this.ivar;
fcup = this.p;
fadeOut = true;
fadeMain2();
loadMainImage2();
}
barray[0].enabled = true[/COLOR]
function getDesc(){
infoBox.infoText.alphaTo(100,0.5,"easeOutBack");
}
// slide the info box down
////load each thumb incrementaliy
// Step one, check to see if p is less than pictures array
function nextPic() {
p++;
if (p<pictures.length) {
moveThumbs();
} else {
counterText_mc.loadingText.text = "001";
counterText_mc.totalText.text = "/0" + pictures.length;
}
}
next_btn.onRelease = function() {
moveThumbs();
};
// Step two, call the function to show the thumb
function moveThumbs() {
var but:MovieClip = scroller.container["thumb"+p];
but.showThumbs();
}
// Step three, show the thumb by sliding it up or blinking it in. After its showing, preload the image
MovieClip.prototype.showThumbs = function() {
if (nav == "buttons") {
if (navani == "slide") {
this._y = 120;
this._x = this.endX;
this._visible = true;
this.tween("_y", this.endY, thumbUpTweenSpeed, upEaseType, 0, loadThumbs);
}
if (navani == "blink") {
this._visible = true;
this._x = this.endX;
loadThumbs();
}
} else if (nav == "nobuttons") {
if (navani == "slide") {
this._visible = true;
this._y = 0;
this._x = this.endX;
scroller.container.tween("_x", Stage.width/2-scroller.container._width/2, .5, "easeOutQuad");
this.tween("_y", this.endY, thumbUpTweenSpeed, upEaseType, 0, loadThumbs);
if (this._x>Stage.width-this._width) {
setIt = true;
}
}
if (navani == "blink") {
this._visible = true;
this._x = 0;
this._y = this.endY;
//scroller.container.tween("_x", Stage.width/2-scroller.container._width/2, .5, "easeOutQuad");
loadThumbs();
}
}
};
// load the thumb image
function loadThumbs() {
var but:MovieClip = scroller.container["thumb"+p];
but.thumbClip.loadMovie("landscapes/thumbs/"+thumbs[p]);
var temp:MovieClip = _root.createEmptyMovieClip("temp"+p, p);
if ((p+1)>=10){
counterText_mc.loadingText.text = "0"+(p+1);
}else{
counterText_mc.loadingText.text = "00"+(p+1);
}
counterText_mc.totalText.text = "/0" + pictures.length;
temp.onEnterFrame = function() {
BL = but.thumbClip.getBytesLoaded();
BT = but.thumbClip.getBytesTotal();
percent = Math.round(BL/BT*100);
but.bar.gotoAndStop(percent);
if (BL == BT && but.thumbClip._width>1 && but.thumbClip._height>1) {
but.bar.gotoAndStop(1);
but.thumbClip._width = 30;
but.thumbClip._height = 30;
if (firstLoad == 1) {
but.onRelease();
but.fadeIn = true;
but.thumbClip._alpha = 100;
firstLoad = false;
} else {
but.fadeIn = false;
but.thumbClip.fade();
but.num.fade();
}
nextPic();
delete temp.onEnterFrame;
}
};
}
//re-enable the disabled thumb button when another is clicked
function checkThumbs() {
for (var j = 0; j<=numOfBtns.length; j++) {
var theThumb:MovieClip = scroller.container["thumb"+j];
if (theThumb.enabled == false) {
theThumb.enabled = true;
theThumb.thumbClip.fadeIn = false;
theThumb.num.fadeIn = false;
theThumb.thumbClip.fade();
theThumb.num.fade();
}
}
}
// fade IN/OUT the thumb image on rollOver rollOut
MovieClip.prototype.fade = function() {
if (this.fadeIn == true) {
this.alphaTo(100,0.5,"linear");
} else {
this.alphaTo(30,0.3,"linear");
}
};
/*loadMain image. Even though it already preloaded in the thumb,
we want to make sure its there before we reveal it, plus we need to make sure all the other crap happens*/
function loadMainImage() {
mtClip.loadMovie("landscapes/images/"+nextImage);
var temp:MovieClip = _root.createEmptyMovieClip("temp", 99999);
preloader_mc._visible = true;
temp.onEnterFrame = function() {
IL = mtClip.getBytesLoaded();
IT = mtClip.getBytesTotal();
percentage = Math.round(IL/IT*100);
preloader_mc.gotoAndPlay(percentage);
if (mtClip._width>5 && mtClip._height>5 && IL == IT) {
if (showSlide == true) {
timer_mc.gotoAndPlay(2);
}
preloader_mc._visible = false;
preloader_mc.gotoAndStop(1);
fadeOut = false;
fadeMain();
delete temp.onEnterFrame;
}
};
}
function loadMainImage2() {
mtClip.loadMovie("landscapes/images/"+bonusarray[fcup][fcuk]);
var temp:MovieClip = _root.createEmptyMovieClip("temp", 99999);
preloader_mc._visible = true;
temp.onEnterFrame = function() {
IL = mtClip.getBytesLoaded();
IT = mtClip.getBytesTotal();
percentage = Math.round(IL/IT*100);
preloader_mc.gotoAndPlay(percentage);
if (mtClip._width>5 && mtClip._height>5 && IL == IT) {
if (showSlide == true) {
timer_mc.gotoAndPlay(2);
}
preloader_mc._visible = false;
preloader_mc.gotoAndStop(1);
fadeOut = false;
fadeMain2();
delete temp.onEnterFrame;
}
};
}
// fade IN/OUT the main image
function fadeMain() {
if (this.fadeOut == true) {
mtClip.tween("_alpha", 0, fadeOutMainSpeed, "easeOutQuad", 0, loadMainImage);
} else {
mtClip.tween("_alpha", 100, fadeInMainSpeed, "easeOutQuad");
}
}
function fadeMain2() {
if (this.fadeOut == true) {
mtClip.tween("_alpha", 0, fadeOutMainSpeed, "easeOutQuad", 0, loadMainImage2);
} else {
mtClip.tween("_alpha", 100, fadeInMainSpeed, "easeOutQuad");
}
}
//slide the thumbs left or right if set to "buttons"
// slide show function
//button actions
// fire it all off! BAM!
xml.load("landscapes/landscapes.xml");
and the 2 first images in xml file:
?xml version="1.0" encoding="iso-8859-1"?>
<gallery>
<image b="McAir3.jpg" b1="McAir2.jpg">
<description>AIR</description>
<thumb>McAir_sm.jpg</thumb>
<pic>McAir.jpg</pic>
</image>
<image b="McAir4.jpg" b1="McAlimos.jpg">
<description>.</description>
<thumb>McAir2_sm.jpg</thumb>
<pic>McAir2.jpg</pic>
</image>
</gallery>
any ideas?
P.S. Thank you to Rhamej, Stringy and Scotty. AS GURUS!!!