Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








"gallery" Reading From Array, Next And Previous Button Headache


Alright, I'm doing this to make a catalogue better for people on dial-up.
Theres two movie clips, one will be hidden at all times, the next image is loaded into the hidden movieclip.

The next button is working fine, although the previous is not, the objIndex changes down although that array index is not called in loadMovie();

I plan to switch over to colin moocks' preloader later when I get this working, make it draw/attach a preloader into each movieclip incase the movie has not loaded before the user presses "next".

Anyway, code is below, looks fine to be but I've been looking at it too long.

Any ideas folks?


Code:
var objIndex = -1;
picPath = "";
pics = ['winterrangep1.jpg', 'winterrangep2.jpg', 'winterrangep3.jpg', 'winterrangep4.jpg', 'winterrangep5.jpg', 'winterrangep6.jpg'];
_root.createEmptyMovieClip("holder_mc", 1);
_root.holder_mc.createEmptyMovieClip("image_1", depth++);
_root.holder_mc.createEmptyMovieClip("image_2", depth++);
var mc_1 = _root.holder_mc.image_1;
var mc_2 = _root.holder_mc.image_2;
mc_2._alpha = 0; // set the second to be hidden *IMPORTANT*
mc_2._x = 500; // move it outta the way while testing so I can see whats going on
MovieClip.prototype.loadPic = function(i, action) {
thisObj = this;
objIndex = (objIndex+i)%_root.pics.length;
thisObj.loadMovie(picPath+_root.pics[objIndex]);
if (objIndex<0) {
objIndex += _root.pics.length;
}
};
MovieClip.prototype.swapVis = function(action) {
trace(this._name+": "+action+" objIndex = "+objIndex);
if (this._alpha == 100) {
this._alpha = 0;
if (action == "prev") {
this.loadPic(-1, "prev");
} else if (action == "next") {
this.loadPic(1, "next");
}
} else if (this._alpha == 0) {
this._alpha = 100;
}
};
mc_1.loadPic(1, "next");
mc_2.loadPic(1, "next");
nextButton.onRelease = function() {
mc_1.swapVis("next");
mc_2.swapVis("next");
};
prevButton.onRelease = function() {
mc_1.swapVis("prev");
mc_1.swapVis("prev");
};




KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 04-09-2004, 11:18 PM


View Complete Forum Thread with Replies

Sponsored Links:

"gallery" Reading From Array, Next And Previous Button Headache
Alright, I'm doing this to make a catalogue better for people on dial-up.
Theres two movie clips, one will be hidden at all times, the next image is loaded into the hidden movieclip.

The next button is working fine, although the previous is not, the objIndex changes down although that array index is not called in loadMovie();

I plan to switch over to colin moocks' preloader later when I get this working, make it draw/attach a preloader into each movieclip incase the movie has not loaded before the user presses "next".

Anyway, code is below, looks fine to be but I've been looking at it too long.

Any ideas folks?


Code:
var objIndex = -1;
picPath = "";
pics = ['winterrangep1.jpg', 'winterrangep2.jpg', 'winterrangep3.jpg', 'winterrangep4.jpg', 'winterrangep5.jpg', 'winterrangep6.jpg'];
_root.createEmptyMovieClip("holder_mc", 1);
_root.holder_mc.createEmptyMovieClip("image_1", depth++);
_root.holder_mc.createEmptyMovieClip("image_2", depth++);
var mc_1 = _root.holder_mc.image_1;
var mc_2 = _root.holder_mc.image_2;
mc_2._alpha = 0; // set the second to be hidden *IMPORTANT*
mc_2._x = 500; // move it outta the way while testing so I can see whats going on
MovieClip.prototype.loadPic = function(i, action) {
thisObj = this;
objIndex = (objIndex+i)%_root.pics.length;
thisObj.loadMovie(picPath+_root.pics[objIndex]);
if (objIndex<0) {
objIndex += _root.pics.length;
}
};
MovieClip.prototype.swapVis = function(action) {
trace(this._name+": "+action+" objIndex = "+objIndex);
if (this._alpha == 100) {
this._alpha = 0;
if (action == "prev") {
this.loadPic(-1, "prev");
} else if (action == "next") {
this.loadPic(1, "next");
}
} else if (this._alpha == 0) {
this._alpha = 100;
}
};
mc_1.loadPic(1, "next");
mc_2.loadPic(1, "next");
nextButton.onRelease = function() {
mc_1.swapVis("next");
mc_2.swapVis("next");
};
prevButton.onRelease = function() {
mc_1.swapVis("prev");
mc_1.swapVis("prev");
};

View Replies !    View Related
XML Gallery - Next/previous Button
Hi All,

I have got some code for an XML gallery which has thumbnails and large images. I have tried a few things and done research, but I am not an actionscript wizz and I can't work out how to adapt this code (below). I want to make "next" and "previous" buttons to go from one image to the next. Anyone got any ideas?


PHP Code:



var generalXML:XML = new XML();
generalXML.ignoreWhite = true;
generalXML.load("general.xml");
generalXML.onLoad = loadGeneralXML;
function loadGeneralXML(loaded) {
    if (loaded) {
        theRootNode = this.firstChild;
        theTitle = theRootNode.childNodes[0].childNodes[0].nodeValue;
        theCopyright = theRootNode.childNodes[1].childNodes[0].nodeValue;
        theEmailText = theRootNode.childNodes[2].childNodes[0].childNodes[0].nodeValue;
        theEmailAddress = theRootNode.childNodes[2].childNodes[1].childNodes[0].nodeValue;
        mc_topTitle.txtTitle.text = theTitle;
        txtCopyright.text = theCopyright;
        mc_email.theEmailText = theEmailText;
        mc_email.txtEmail.text = theEmailText;
        mc_email.theEmailAddress = theEmailAddress;
    }
}
// The following is for the thumbnails and big image
var myXML2:XML = new XML();
myXML2.ignoreWhite = true;
myXML2.load("gallery.xml");
var Name:Array = Array();
var description:Array = Array();
var thumbPath:Array = Array();
var picPath:Array = Array();
var linkURL:Array = Array();
var bgcolor:Array = Array();
var imageWidth:Array = Array();
var imageHeight:Array = Array();
_root.currentCatID = 1;
_root.numberPerRow = 5;//7
_root.gapH = 20;//5
// horizontal space 
_root.gapV = 5;
// vertical space (between rows)
_root.rowPerPage = 4;//2
// how many rows per page
_root.itemsPerPage = _root.numberPerRow*_root.rowPerPage;
_root.currentPage = 1;
myXML2.onLoad = function(success) {
    displayPage();
};
function displayPage() {
    //remove existing thumbnails
    for (var i = 0; i<_root.numberOfItems; i++) {
        removeMovieClip(flash_mc["img"+i]);
    }
    xml = myXML2.firstChild;
    _root.numberOfItems = xml.childNodes.length;
    _root.numberInCategory = 0;
    var itemsInThisCat:Array = Array();
    for (var i = 0; i<_root.numberOfItems; i++) {
        if (xml.childNodes[i].childNodes[7].childNodes[0].nodeValue == _root.currentCatID) {
            _root.numberInCategory++;
            itemsInThisCat.push(i);
        }
    }
    // remove existing pagination
    for (var i = 0; i<_root.lastNumberOfPage; i++) {
        removeMovieClip(mc_pagination["mc_paging"+i]);
    }
    var numberOfPages:Number = Math.ceil(_root.numberInCategory/_root.itemsPerPage);
    _root.lastNumberOfPage = numberOfPages;
    // display page: what/what
    mc_pagination.pageof.text = "Page: "+_root.currentPage+"/"+numberOfPages;
    mc_pagination.mc_paging._visible = false;
    for (var i = 0; i<numberOfPages; i++) {
        mc_pagination.mc_paging.duplicateMovieClip("mc_paging"+i, i);
        mc_pagination["mc_paging"+i].pageNumber.text = i+1;
        // if there is only one page, don't display the pagination buttons
        if (numberOfPages == 1) {
            mc_pagination["mc_paging"+i]._visible = false;
        }
        // disable the current page number button and change its color      
        if (mc_pagination["mc_paging"+i].pageNumber.text == _root.currentPage) {
            myColor1 = new Color(this.mc_pagination["mc_paging"+i].mc_pageBg);
            myColor1.setRGB(0xFB6C1E);
            mc_pagination["mc_paging"+i].enabled = false;
        } else {
            mc_pagination["mc_paging"+i].enabled = true;
        }
        mc_pagination["mc_paging"+i]._x = mc_pagination.mc_paging._x-(mc_pagination.mc_paging._width+4)*(numberOfPages-i-1);
    }
    var firstItemThisPage:Number = _root.itemsPerPage*(_root.currentPage-1);
    var LastItemThisPage:Number = firstItemThisPage+_root.itemsPerPage;
    LastItemThisPage>itemsInThisCat.length ? LastItemThisPage=itemsInThisCat.length : LastItemThisPage=LastItemThisPage;
    j = 0;
    firstItemThisCat = undefined;
    for (var i = firstItemThisPage; i<LastItemThisPage; i++) {
        if (firstItemThisCat == undefined) {
            firstItemThisCat = i;
        }
        Name[i] = xml.childNodes[itemsInThisCat[i]].childNodes[0].childNodes[0].nodeValue;
        description[i] = xml.childNodes[itemsInThisCat[i]].childNodes[1].childNodes[0].nodeValue;
        thumbPath[i] = xml.childNodes[itemsInThisCat[i]].childNodes[2].childNodes[0].nodeValue;
        picPath[i] = xml.childNodes[itemsInThisCat[i]].childNodes[3].childNodes[0].nodeValue;
        linkURL[i] = xml.childNodes[itemsInThisCat[i]].childNodes[4].childNodes[0].nodeValue;
        imageWidth[i] = xml.childNodes[itemsInThisCat[i]].childNodes[5].childNodes[0].nodeValue;
        imageHeight[i] = xml.childNodes[itemsInThisCat[i]].childNodes[6].childNodes[0].nodeValue;
        flash_mc.img.duplicateMovieClip("img"+i, i);
        //_root["movie"+i]._x = movie0._x+(i*180);
        realRow = Math.floor(j/_root.numberPerRow);
        row = realRow-((_root.currentPage-1)*_root.rowPerPage);
        flash_mc["img"+i]._x = flash_mc.img._x+(j-(realRow*_root.numberPerRow))*(flash_mc.img._width+_root.gapH);
        flash_mc["img"+i]._y = flash_mc.img._y+realRow*(flash_mc.img._height+_root.gapV);
        flash_mc["img"+i].img_mc.loadMovie(thumbPath[i]);
        flash_mc["img"+i].theSiteName = Name[i];
        flash_mc["img"+i].theLinkURL = linkURL[i];
        flash_mc["img"+i].thePicPath = picPath[i];
        flash_mc["img"+i].theSiteDesc = description[i];
        flash_mc["img"+i].theWidth = imageWidth[i];
        flash_mc["img"+i].theHeight = imageHeight[i];
        j++;
        if (j>=_root.itemsPerPage) {
            break;
        }
        //load the first big image   
        getFirst(picPath[firstItemThisCat], linkURL[firstItemThisCat], Name[firstItemThisCat], description[firstItemThisCat], imageWidth[firstItemThisCat], imageHeight[firstItemThisCat]);
    }
}

/////////////////// I added the code below, not sure if it's good but it works

function clearIt(thePicPath:String, theLinkURL:String, theSiteName:String, theSiteDesc:String, theWidth:Number, theHeight:Number) {
    theBigImageContainer = _root.mc_main.big_mc.big_mc_image;
    theHelper = _root.mc_main.mc_helper;
    theImageWidth = theWidth;
    theImageHeight = theHeight;
    theDisplayAreaWidth = Stage.width;
    theDisplayAreaHeight = Stage.height-_root.mc_main.mc_topTitle._height-_root.mc_main.mc_thumbArea._height-_root.mc_main.mc_description._height;
    theBigImageContainer.unloadMovie(thePicPath);
    _root.mc_main.mc_bigImageBg._visible = false;
    _root.mc_main.loader._y = 900;
}

back_btn.onRelease = function  () {
    clearIt();
}
     
//////////////////// end of my addition:confused: 

//for loading first big image
function getFirst(thePicPath:String, theLinkURL:String, theSiteName:String, theSiteDesc:String, theWidth:Number, theHeight:Number) {
    theBigImageContainer = _root.mc_main.big_mc.big_mc_image;
    theHelper = _root.mc_main.mc_helper;
    theImageWidth = theWidth;
    theImageHeight = theHeight;
    theDisplayAreaWidth = Stage.width;
    theDisplayAreaHeight = Stage.height-_root.mc_main.mc_topTitle._height-_root.mc_main.mc_thumbArea._height-_root.mc_main.mc_description._height;
    _root.mc_main.loader._x = (theHelper._x+theDisplayAreaWidth/2)-15;
    _root.mc_main.loader._y = theHelper._y+theDisplayAreaHeight/2;
    theBigImageContainer.loadMovie(thePicPath);
    _root.mc_main.big_mc._x = theHelper._x+(theDisplayAreaWidth-theImageWidth)/2;
    _root.mc_main.big_mc._y = theHelper._y+(theDisplayAreaHeight-theImageHeight)/2;
    _root.mc_main.mc_bigImageBg._x = _root.mc_main.big_mc._x-4;
    _root.mc_main.mc_bigImageBg._y = _root.mc_main.big_mc._y-6;
    _root.mc_main.mc_bigImageBg._width = theImageWidth*1+8;
    _root.mc_main.mc_bigImageBg._height = theImageHeight*1+8;
    if (theSiteDesc == undefined) {
        _root.mc_main.textbox.siteName.text = theSiteName;
    } else {
        _root.mc_main.textbox.siteName.text = theSiteName+" - "+theSiteDesc;
    }
    percentage = 0;
    var colorful = new Color("_root.mc_main.mc_bgcolor");
    var theColor = "0x"+theBgColor;
    colorful.setRGB(theColor);
    flash_mc.a_mc.onEnterFrame = function() {
        amountLoaded = theBigImageContainer.getBytesLoaded()/theBigImageContainer.getBytesTotal()*100;
        percentage += (amountLoaded-percentage)/2;
        theBigImageContainer._visible = false;
        _root.mc_main.big_mc.loader.gotoAndStop(Math.round(percentage));
        if (percentage>99) {
            delete flash_mc.a_mc.onEnterFrame;
            theBigImageContainer._visible = true;
            _root.mc_main.big_mc.loader._visible = false;
            _root.mc_main.big_mc.changeColor();
        }
    };
    _root.mc_main.big_mc.onRelease = function() {
        getURL(theLinkURL, "_blank");
    };
    if (theLinkURL == undefined) {
        _root.mc_main.big_mc.enabled = false;
    } else {
        _root.mc_main.big_mc.enabled = true;
    }


View Replies !    View Related
Gallery Issue With Next And Previous Button...
Im trying to create a simple gallery of images with a next and previous button..

when you click next the current image fades out and the next one fades in.. BUT if you hit PREVIOUS, the current image fades out and the previous one fades in... Its basic timeline control but its driving me bonkers...
PLEASE HELP..
thank you..
k

View Replies !    View Related
Xml Gallery Next Previous Button Problem...
Hi there guys

Right here we go, firstly I'm no coder by any stretch of the imagination and thus have a little problem. I have some basterdised gallery code which displays the type of gallery, once the user chooses a gallery all the relevent thumbnails are displayed, the user can then click the thumbnails to show a more hi-res image. My problem is I'm struggling to develop next and previous buttons to cycle through the large images within the chosen gallery. Here is the code guys, any pointers would be great.

ActionScript Code:
var firstLook:Boolean = true;
    var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;
var imagesHolder:MovieClip = imagesHolder_mc;
var descText:TextField = desc_mc.desc_txt;
var imagesInGallery:Array = new Array();
var galleryNames:Array = new Array();
var galleryIntros:Array = new Array();
var descriptions:Array = new Array();
var tracker:Number = new Number();
var whatIsLoading:String = new String();
var galleryBtnLeftMargin:Number = 10;
var galleryBtnUpperMargin:Number = 60;
var galleryBtnVSpace:Number = 112;
var thumbMarginX:Number = 112;
var thumbMarginY:Number = 100;

var radioadButtons:MovieClip = radioad_mc.radioadHolder_mc;

/* -------------------- Aligning and positioning imagesHolder_mc, the logo and the description text field -------------------- */

imagesHolder._x = 45;
imagesHolder._y = 205;

/* -------------------- The welcome text -------------------- */

descText.text = "yak, yak, yak";


/* -------------------- MovieClipLoader & Listener -------------------- */

var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
loader.addListener(myListener);
myListener.onLoadInit = function(target:MovieClip) {
    if (whatIsLoading == "thumb") {
        currentThumbnail.percent_txt._visible = false;
        thumbClickable();
        tracker++;
        if (tracker<howManyImages) {
            loadThumbnail();
        } else {
            enableThumbs();
        }
    } else if (whatIsLoading == "big") {
        target._alpha = 0;
        displayBigImage.percent_txt._visible = false;
        bigClickable();
        fadeIn();
    }
};
myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
    percent = Math.floor(loaded/total*100);
    if (whatIsLoading == "thumb") {
        currentThumbnail.percent_txt._visible = true;
        currentThumbnail.percent_txt.text = percent+"%";
    } else if (whatIsLoading == "big") {
        displayBigImage.percent_txt._visible = true;
        displayBigImage.percent_txt.text = percent+"%";
    }
};



var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = function(success) {
    if (success) {
        parseGalleries();
    } else {
        descText.text = "Sorry the image data just didn't load.";
    }
};
imageGallery.load("gallery.xml");

/* -------------------- parsing XML -------------------- */

function parseGalleries():Void {
    if (imageGallery.firstChild.nodeName == "galleries") {
        var rootNode:XMLNode = imageGallery.firstChild;
        for (i=0; i<rootNode.childNodes.length; i++) {
            if (rootNode.childNodes[i].nodeName == "gallery") {
                currentGallery = rootNode.childNodes[i];
                imagesInGallery.push(currentGallery.childNodes.length);
                galleryNames.push(currentGallery.attributes.title);
                galleryIntros.push(currentGallery.attributes.intro);
                currentGalleryTitle = rootNode.childNodes[i].attributes.title;
                currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
                currentGalleryButton._x = galleryBtnVSpace*i;
                currentGalleryButton._y = 0;
                currentGalleryButton.sectionTitle_txt.text = +currentGalleryTitle.toUpperCase();
                for (j=0; j<currentGallery.childNodes.length; j++) {
                    if (currentGallery.childNodes[j].nodeName == "image") {
                        currentDescription = currentGallery.childNodes[j].firstChild.toString();               
                        descriptions.push(currentDescription);
                    }
                }
            }
        }
    }
    numberOfGalleries = i;
    enableButtons(numberOfGalleries);
}

////////////////////////////////////////////////////////


function enableButtons(numberOfGalleries:Number):Void {
    for (i=0; i<numberOfGalleries; i++) {
        pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];
       
       
        pressedButton.onRollOver = function():Void  {
            this.gotoAndPlay("on");
            //this.sectionTitle_txt.colorTo(0xfff315, 0.1);
        };
        pressedButton.onRollOut = function():Void  {
            this.gotoAndPlay("off");
            //this.sectionTitle_txt.colorTo(0xff0000, 0.1);
        };
        pressedButton.onPress = function():Void  {
            removeMovieClip(thumbsDisplayer);
            removeMovieClip(displayBigImage);
            tracker = 0;
            thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDisplayer_mc", imagesHolder.getNextHighestDepth());
            clickedGallery = Number(this._name.substr(13));
            howManyImages = imagesInGallery[clickedGallery];
            whichGallery = galleryNames[clickedGallery];
            descText.text = galleryIntros[clickedGallery];
            currentRow = 0;
            currentColumn = 0;
            loadThumbnail();
        };
    }
    enableGalleryNavigation();
}

////////////////////////////////////////////////////////////////
           
function loadThumbnail() {
    currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
    target = currentThumbnail.thumbImage_mc;
    if ((tracker%5) == 0 && tracker != 0) {
        currentRow += 1;
    }
    if (currentColumn>3) {
        currentColumn = 0;
    } else if (tracker == 0) {
        currentColumn = 0;
    } else {
        currentColumn += 1;
    }
    currentThumbnail._x = currentColumn*thumbMarginX;
    currentThumbnail._y = currentRow*thumbMarginY;
    currentThumbnail.percent_txt._visible = true;
    thumbNumber = currentThumbnail._name.substr(9);
    thumbPath = "gallery/"+whichGallery+"/thumbs/"+thumbNumber+".jpg";
   
    whatIsLoading = "thumb";
    loader.loadClip(thumbPath, target);
    //
    //     
            if (whichGallery == imageGallery.firstChild.childNodes[3].attributes.title) {
                this.FSMP3Player._visible = true;
                this.attachMovie("FSMP3Player1", "FSMP3Player1", this.getNextHighestDepth());
                this.FSMP3Player._x = 170;
                this.FSMP3Player._y = 250;
            }else {
                this.FSMP3Player._visible = false;
            }
    //
    //
}

////////////////////////////////////////////////////////////

function thumbClickable():Void {
    currentThumbnail.onPress = function() {
        bigNumber = this._name.substr(9);
        displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
        target = displayBigImage.imageHolder_mc;
        bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
        whatIsLoading = "big";
        disableThumbs();
        loader.loadClip(bigImagePath, target);
        if (clickedGallery>0) {
            var descPosition:Number = 0;
            for (i=0; i<clickedGallery; i++) {
                descPosition += imagesInGallery[i];
            }
           
            descPosition = descPosition+Number(bigNumber)-1;
            imageDesc = descriptions[descPosition];
           
        } else {
            imageDesc = descriptions[Number(bigNumber)-1];
        }
        descText.text = imageDesc;
    };
    currentThumbnail.enabled = false;
    ///
    /*Next & Previous buttons*/
    ///
                           
                               
                            img_next.onRelease = function() {
                                //
                                bigNumber = howManyImages;
                                    p=imagesInGallery;
                                    displayBigImage = this.attachMovie("big image holder", "bigImage_mc", this.getNextHighestDepth());
                                   
                                    target = displayBigImage;
                                    bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
                                    whatIsLoading = "big";
                                    if (whatIsLoading == "big") {
                                        //
                                        trace("Gallery " + clickedGallery); //bigImagePath
                                        trace("There are " + howManyImages + " images in this gallery");   
                                        trace("Image Number " + thumbNumber);
                                        trace("There are " + currentGallery);   //bigImagePath
                                        //
                                        disableThumbs();
                                        loader.loadClip(bigImagePath, target);
                                        if (clickedGallery<0) {
                                            var bigNumber:Number = 0;
                                            for (i=0; i<howManyImages; i++) {
                                                bigNumber ++;
                                            }}
                                            } else {
                                                this.enabled = false;
                                            }
                                    //
                                };               
                               
    ///
    /*End Next & Previous buttons*/
    ///
}





    

img_prev.onRelease = function() {
    //
   

    //
};


/////////////////////////////////////////////////////////

function disableThumbs():Void {
    for (i=0; i<howManyImages; i++) {
        thumbsDisplayer["thumbnail"+(i+1)].enabled = false;
        thumbsDisplayer.alphaTo(0, 0.2, "easeInQuad");
        galleryMenu_mc.alphaTo(0, 0.2, "easeInQuad");
    }
}
function enableThumbs():Void {
    for (i=0; i<howManyImages; i++) {
        thumbsDisplayer["thumbnail"+(i+1)].enabled = true;
        thumbsDisplayer.alphaTo(100, 0.2, "easeInQuad");
        galleryMenu_mc.alphaTo(100, 0.2, "easeInQuad");
    }
}

function bigClickable():Void {
    displayBigImage.onPress = function() {
        removeMovieClip(this);
        enableThumbs();
        descText.text = galleryIntros[clickedGallery];
    };
}

function fadeIn():Void {
    target.onEnterFrame = function():Void  {
        this._alpha += 10;
        if (this._alpha>=100) {
            delete this.onEnterFrame;
            this._alpha = 100;
        }
    };
}

function fadeOut():Void {
    target.onEnterFrame = function():Void  {
        this._alpha -= 10;
        if (this._alpha<=0) {
            delete this.onEnterFrame;
            this._alpha = 0;
        }
    };
}
///////////////////////////////////////////////////////

Thanks in advance guys

View Replies !    View Related
Photo Gallery - Next Or Previous Button
Hi,

I am new to Action Script and I have a small issue that I can't seem to figure out...

Probably very easy for you guys... ;)

(1)
I have a Photo Gallery here, kinda like a Photo show and under the picture is a 'Next' and 'Previous' button.

Now when the user will click on e.g. the 'Next' button I want the pic shown to change into the next picture.

I have all my pics in a movieclip all with labels s1, s2, s3 etc. ....

I already have the code setup to go to the appropriate movieclip but I don't know how to tell Flash via Action Script to go to label "s" + 1.... meaning:

if the picture with the label "s2" is shown right now and the user clicks on the 'Next' button Flash need to go to the mc with my pics in it and then to the label "s3" --> "s2" + 1

How do I do that ?

(2)

Another thing I was thinking about:

Let's say I have 7 pics in the photo gallery and user is seeing pic # 7 right now (label "s7") and he clicks the 'Next' button I need to tell Flash to jump to label "s1" (to the first pic) because there is no eigth picture...

How is that done ?

Note: I am using Flash 9 CS3 so either AS2 or AS3 is welcome...

Any help is appreciated and I thank you in advance for that !!! ;)

Mike





























Edited: 06/02/2007 at 05:56:45 PM by Iron_Mike

View Replies !    View Related
Previous Button In Photo Gallery
Hi

Playing around with the photo gallery, and I cant seem to figure out how to do this. Any ideas?

Say its on 1/9, if I click previous, how can I make it go to 9/9? Like a bi-directional I guess.

I'd really appreciate any ideas or examples.

Thanks

View Replies !    View Related
Hide Next Previous Button In Gallery
Here is the end of my code to hide the next and previous button (I used the tutorial from kirupa)

if (current_pos == 1) {
previous_btn._visible = false;
}
else {
previous_btn._visible = true;
}
if (current_pos == total){
next_btn._visible = false;
}
else {
next_btn._visible = true;
}
stop();

but now the only button that disappear is the next one (it does that at start)...
What's the problem ???

Xelaxam

View Replies !    View Related
Xml Gallery Next Previous Button Problem...
Right here we go, firstly I'm no coder by any stretch of the imagination and thus have a little problem. I have some basterdised gallery code which displays the type of gallery, once the user chooses a gallery all the relevent thumbnails are displayed, the user can then click the thumbnails to show a more hi-res image. My problem is I'm struggling to develop next and previous buttons to cycle through the large images within the chosen gallery. Here is the code guys, any pointers would be great.


Code:

var firstLook:Boolean = true;
var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;
var imagesHolder:MovieClip = imagesHolder_mc;
var descText:TextField = desc_mc.desc_txt;
var imagesInGallery:Array = new Array();
var galleryNames:Array = new Array();
var galleryIntros:Array = new Array();
var descriptions:Array = new Array();
var tracker:Number = new Number();
var whatIsLoading:String = new String();
var galleryBtnLeftMargin:Number = 10;
var galleryBtnUpperMargin:Number = 60;
var galleryBtnVSpace:Number = 112;
var thumbMarginX:Number = 112;
var thumbMarginY:Number = 100;

var radioadButtons:MovieClip = radioad_mc.radioadHolder_mc;

/* -------------------- Aligning and positioning imagesHolder_mc, the logo and the description text field -------------------- */

imagesHolder._x = 45;
imagesHolder._y = 205;

/* -------------------- The welcome text -------------------- */

descText.text = "yak, yak, yak.";


/* -------------------- MovieClipLoader & Listener -------------------- */

var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
loader.addListener(myListener);
myListener.onLoadInit = function(target:MovieClip) {
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = false;
thumbClickable();
tracker++;
if (tracker<howManyImages) {
loadThumbnail();
} else {
enableThumbs();
}
} else if (whatIsLoading == "big") {
target._alpha = 0;
displayBigImage.percent_txt._visible = false;
bigClickable();
fadeIn();
}
};
myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
percent = Math.floor(loaded/total*100);
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = true;
currentThumbnail.percent_txt.text = percent+"%";
} else if (whatIsLoading == "big") {
displayBigImage.percent_txt._visible = true;
displayBigImage.percent_txt.text = percent+"%";
}
};

///////////////////////////////////////////////////////////

var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = function(success) {
if (success) {
parseGalleries();
} else {
descText.text = "Sorry the image data just didn't load.";
}
};
imageGallery.load("gallery.xml");

/* -------------------- parsing XML -------------------- */

function parseGalleries():Void {
if (imageGallery.firstChild.nodeName == "galleries") {
var rootNode:XMLNode = imageGallery.firstChild;
for (i=0; i<rootNode.childNodes.length; i++) {
if (rootNode.childNodes[i].nodeName == "gallery") {
currentGallery = rootNode.childNodes[i];
imagesInGallery.push(currentGallery.childNodes.length);
galleryNames.push(currentGallery.attributes.title);
galleryIntros.push(currentGallery.attributes.intro);
currentGalleryTitle = rootNode.childNodes[i].attributes.title;
currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
currentGalleryButton._x = galleryBtnVSpace*i;
currentGalleryButton._y = 0;
currentGalleryButton.sectionTitle_txt.text = +currentGalleryTitle.toUpperCase();
for (j=0; j<currentGallery.childNodes.length; j++) {
if (currentGallery.childNodes[j].nodeName == "image") {
currentDescription = currentGallery.childNodes[j].firstChild.toString();
descriptions.push(currentDescription);
}
}
}
}
}
numberOfGalleries = i;
enableButtons(numberOfGalleries);
}

///////////////////////////////////////////////////////////////////

function enableButtons(numberOfGalleries:Number):Void {
for (i=0; i<numberOfGalleries; i++) {
pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];


pressedButton.onRollOver = function():Void {
this.gotoAndPlay("on");
//this.sectionTitle_txt.colorTo(0xfff315, 0.1);
};
pressedButton.onRollOut = function():Void {
this.gotoAndPlay("off");
//this.sectionTitle_txt.colorTo(0xff0000, 0.1);
};
pressedButton.onPress = function():Void {
removeMovieClip(thumbsDisplayer);
removeMovieClip(displayBigImage);
tracker = 0;
thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDisplayer_mc", imagesHolder.getNextHighestDepth());
clickedGallery = Number(this._name.substr(13));
howManyImages = imagesInGallery[clickedGallery];
whichGallery = galleryNames[clickedGallery];
descText.text = galleryIntros[clickedGallery];
currentRow = 0;
currentColumn = 0;
loadThumbnail();
};
}
enableGalleryNavigation();
}

///////////////////////////////////////////////////////////////////

function loadThumbnail() {
currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
target = currentThumbnail.thumbImage_mc;
if ((tracker%5) == 0 && tracker != 0) {
currentRow += 1;
}
if (currentColumn>3) {
currentColumn = 0;
} else if (tracker == 0) {
currentColumn = 0;
} else {
currentColumn += 1;
}
currentThumbnail._x = currentColumn*thumbMarginX;
currentThumbnail._y = currentRow*thumbMarginY;
currentThumbnail.percent_txt._visible = true;
thumbNumber = currentThumbnail._name.substr(9);
thumbPath = "gallery/"+whichGallery+"/thumbs/"+thumbNumber+".jpg";

whatIsLoading = "thumb";
loader.loadClip(thumbPath, target);
//
//
if (whichGallery == imageGallery.firstChild.childNodes[3].attributes.title) {
this.FSMP3Player._visible = true;
this.attachMovie("FSMP3Player1", "FSMP3Player1", this.getNextHighestDepth());
this.FSMP3Player._x = 170;
this.FSMP3Player._y = 250;
}else {
this.FSMP3Player._visible = false;
}
//
//
}

////////////////////////////////////////////////////////////////////////

function thumbClickable():Void {
currentThumbnail.onPress = function() {
bigNumber = this._name.substr(9);
displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
target = displayBigImage.imageHolder_mc;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery>0) {
var descPosition:Number = 0;
for (i=0; i<clickedGallery; i++) {
descPosition += imagesInGallery[i];
}

descPosition = descPosition+Number(bigNumber)-1;
imageDesc = descriptions[descPosition];

} else {
imageDesc = descriptions[Number(bigNumber)-1];
}
descText.text = imageDesc;
};
currentThumbnail.enabled = false;
///
/*Next & Previous buttons*/
///
/*img_next.onRelease = function() {
//
bigNumber = clickedGallery;
p=imagesInGallery;
displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());

target = displayBigImage.imageHolder_mc;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
if (whatIsLoading == "big") {
//
trace("Gallery " + clickedGallery);//bigImagePath
trace("There are " + howManyImages + " images in this gallery");
trace("Image Number " + thumbNumber);
trace("There are " + currentGallery);//bigImagePath
//
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery<0) {
var bigNumber:Number = 0;
for (i=0; i<clickedGallery; i++) {
bigNumber ++;
}}
} else {
this.enabled = false;
}
//
};*/

img_next.onRelease = function() {
//
bigNumber = howManyImages;
p=imagesInGallery;
displayBigImage = this.attachMovie("big image holder", "bigImage_mc", this.getNextHighestDepth());

target = displayBigImage;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
if (whatIsLoading == "big") {
//
trace("Gallery " + clickedGallery);//bigImagePath
trace("There are " + howManyImages + " images in this gallery");
trace("Image Number " + thumbNumber);
trace("There are " + currentGallery);//bigImagePath
//
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery<0) {
var bigNumber:Number = 0;
for (i=0; i<howManyImages; i++) {
bigNumber ++;
}}
} else {
this.enabled = false;
}
//
};

///
/*End Next & Previous buttons*/
///
}







img_prev.onRelease = function() {
//

//
};



/////////////////////////////////////////////////////
Thanks in advace guys...

View Replies !    View Related
Past Frame Numbers Stored In Array For 'previous' Button
I have an swf with buttons that load to different pages (frames of the swf), and what I'd like to do, each time the frame is changed, is push the current frame into an array so that on a couple of 'previous' and 'next' buttons I can change to pages already visited and back forward again if the user chooses

it's a little tricky for me, considering that I don't want to keep pushing the same pages into the array if someone goes back and forth a few times, so maybe some additional code would be needed to check and see if the frame number is already in the array, and if so, ignore the push code?

I don't know. before I get started, does this approach sound like the simplest/best?

View Replies !    View Related
Next Button And Previous Button To Xml Gallery
Hi . I have a XML Gallery, with thumbnails, but I do not know how to make it a next and a previous button. Can ou help me?

Code:
myPhoto = new XML();
myPhoto.ignoreWhite = true;
myPhoto.onLoad = function(success) {
//portfolioTag = this.firstChild;
numimages = this.firstChild.childNodes.length;
spacing = 40;
var numimages:Array = this.firstChild.childNodes;
for (i=0; i<numimages.length; i++) {
this.picHolder = this.firstChild.childNodes[i];
this.thumbHolder.id = i;
this.thumbHolder = thumbnails.createEmptyMovieClip("thumbnail"+i, i);
this.thumbHolder._x= (i%3) * 60;
this.thumbHolder._y = Math.floor(i/3) * 40;
this.thumbLoader = this.thumbHolder.createEmptyMovieClip("thumbnail_image", 0);
this.thumbLoader.loadMovie(this.picHolder.attributes.thmb);
this.thumbHolder.title = this.picHolder.attributes.title;
this.thumbHolder.url = this.picHolder.attributes.url;
this.thumbHolder.main = this.picHolder.attributes.main;
this.thumbHolder.onRelease = function() {
tellTarget (_global._myTimeline) {
picture.loadMovie(this.main);
p = this.id-1;
detalii.title_txt.text = this.title;
detalii.url.text = this.url;
unloadMovieNum(1);
}
};
}
};
myPhoto.load("xmlphoto.xml");


Thank you in anticipation

View Replies !    View Related
Array, What A Headache
Hi,

i have a drag and drop menu.. evey time an item is dropped it is added to an array. so with three items dropped the arrray looks something like this:


PHP Code:




_level0.hit1_mc.mc1,_level0.hit1_mc.mc2,_level0.hit1_mc.mc3







so how do i remove the correct item from the array? e.g if i click on _level0.hit1_mc.mc1 it is removed for the array.

cheers,
G

View Replies !    View Related
Array Headache
Im pretty much new to arrays and its killing me to figure some stuff out. I have the following script on the main timeline in my movie

ActionScript Code:
Array.prototype.shuffle=function(){   for(i=0;i<this.length;i++){      var tmp=this[i];      var randomNum=random(this.length);      this[i]=this[randomNum];      this[randomNum]=tmp;   }}// USAGE:arr1=["a","b","c","d","e"];arr1.shuffle();trace(arr1);

much thanks to sephiroth for it. Anyways, i created a movie clip with a dynamic textbox in it which i was hoping could pull one of the values from the array. How do i do this?

I uploaded the fla so hopefully one of you guys could tell me where im going wrong

View Replies !    View Related
Array Headache
Im pretty much new to arrays and its killing me to figure some stuff out. I have the following script on the main timeline in my movie

ActionScript Code:
Array.prototype.shuffle=function(){   for(i=0;i<this.length;i++){      var tmp=this[i];      var randomNum=random(this.length);      this[i]=this[randomNum];      this[randomNum]=tmp;   }}// USAGE:arr1=["a","b","c","d","e"];arr1.shuffle();trace(arr1);

much thanks to sephiroth for it. Anyways, i created a movie clip with a dynamic textbox in it which i was hoping could pull one of the values from the array. How do i do this?

I uploaded the fla so hopefully one of you guys could tell me where im going wrong

View Replies !    View Related
Help I'm So Close To Getting This Done Photo Gallery Causing A Headache
Please, all you wiser than me, tell me what is wrong with this thing if you have the time. I'm very new to forums in all together, I've been trying to find answers from older posts, but after several hours I just got confused and a headache. This is a vast place! For a girl in small Finland this all just seems rather confusing

My project uses the sliding menu, done according to the tutorial by kirupa, as the base for my whole webpage and I'm trying to add photo gallerys to the different content-movieclips. I created the photo gallery with thumbnails with the help of the brilliant tutorial by kirupa, and put it in it's own movieclip. Workes great! But when I bring it to the whole project one little part of it doesn't work: the hit_left-function. The thumbnail-scrolling doesn't work to the left anymore, only to the right and every other part of the gallery works just fine.

If anyone knows the answer to this, I would appreciate it ever so much! I'm adding the codes for the sliding menu and the photo gallery if you can spot the problem. The web page would be filled with image gallerys because there are so much products I have to list so it would be crusial that people can scroll the thumbnails back aswell.

Code for the sliding menu:


Code:
var currentPosition:Number = contentHold.content1._x;
var startFlag:Boolean = false;
menuSlide = function (input:MovieClip) {
if (startFlag == false) {

startFlag = true;

var finalDestination:Number = input._x;
var distanceMoved:Number = 0;
var distanceToMove:Number = Math.abs(finalDestination-currentPosition);
var finalSpeed:Number = .3;
var currentSpeed:Number = 0;
var dir:Number = 1;

if (currentPosition<=finalDestination) {
dir = -1;
} else if (currentPosition>finalDestination) {
dir = 1;
}

this.onEnterFrame = function() {
currentSpeed = Math.round((distanceToMove-distanceMoved+1)*finalSpeed);
distanceMoved += currentSpeed;
contentHold._x += dir*currentSpeed;
if (Math.abs(distanceMoved-distanceToMove)<=1) {
contentHold._x = maskMovie._x-currentPosition+dir*distanceToMove;
currentPosition = input._x;
startFlag = false;
delete this.onEnterFrame;
}
};
}
};
b1.onRelease = function() {
menuSlide(contentHold.content1);
};
b2.onRelease = function() {
menuSlide(contentHold.content2);
};
b3.onRelease = function() {
menuSlide(contentHold.content3);
};
b4.onRelease = function() {
menuSlide(contentHold.content4);
};
b5.onRelease = function() {
menuSlide(contentHold.content5);
};
b6.onRelease = function() {
menuSlide(contentHold.content6);
};
b7.onRelease = function() {
menuSlide(contentHold.content7);
};
b8.onRelease = function() {
menuSlide(contentHold.content8);
};
b9.onRelease = function() {
menuSlide(contentHold.content9);
};
Code for the photo gallery:


Code:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
thumbnails[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
thumbnails_fn(i);
}
firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
};
next_btn.onRelease = function() {
nextImage();
};
/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
}
}
};
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
}
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
}
}
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
}
} else {
delete tscroller.onEnterFrame;
}
};
}
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k, thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
};
target_mc.onRollOver = function() {
this._alpha = 80;
thumbNailScroller();
};
target_mc.onRollOut = function() {
this._alpha = 100;
};
};
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k);
}

View Replies !    View Related
AS2 - Xml Gallery Next Previous
Hello all y'all

Guys I'm trying to get next and previous buttons working within each gallery which can only be used when cycling through the larger images...

I is stuck init, please someone put me right...

Code:
var firstLook:Boolean = true;
var menuButtons:MovieClip = galleryMenu_mc.buttonsHolder_mc;
var imagesHolder:MovieClip = imagesHolder_mc;
var descText:TextField = desc_mc.desc_txt;
var imagesInGallery:Array = new Array();
var galleryNames:Array = new Array();
var galleryIntros:Array = new Array();
var descriptions:Array = new Array();
var tracker:Number = new Number();
var whatIsLoading:String = new String();
var galleryBtnLeftMargin:Number = 10;
var galleryBtnUpperMargin:Number = 60;
var galleryBtnVSpace:Number = 112;
var thumbMarginX:Number = 112;
var thumbMarginY:Number = 100;

var radioadButtons:MovieClip = radioad_mc.radioadHolder_mc;

/* -------------------- Aligning and positioning imagesHolder_mc, the logo and the description text field -------------------- */

imagesHolder._x = 40;
imagesHolder._y = 210;

/* -------------------- The welcome text -------------------- */

descText.text = "Blah, blah, blah";


/* -------------------- MovieClipLoader & Listener -------------------- */

var loader:MovieClipLoader = new MovieClipLoader();
var myListener:Object = new Object();
loader.addListener(myListener);
myListener.onLoadInit = function(target:MovieClip) {
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = false;
thumbClickable();
tracker++;
if (tracker<howManyImages) {
loadThumbnail();
} else {
enableThumbs();
}
} else if (whatIsLoading == "big") {
target._alpha = 0;
displayBigImage.percent_txt._visible = false;
bigClickable();
fadeIn();
}
};
myListener.onLoadProgress = function(target:MovieClip, loaded:Number, total:Number) {
percent = Math.floor(loaded/total*100);
if (whatIsLoading == "thumb") {
currentThumbnail.percent_txt._visible = true;
currentThumbnail.percent_txt.text = percent+"%";
} else if (whatIsLoading == "big") {
displayBigImage.percent_txt._visible = true;
displayBigImage.percent_txt.text = percent+"%";
}
};

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// XML Conrtol ////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////

var imageGallery:XML = new XML();
imageGallery.ignoreWhite = true;
imageGallery.onLoad = function(success) {
if (success) {
parseGalleries();
} else {
descText.text = "Sorry the image data just didn't load.";
}
};
imageGallery.load("gallery.xml");

/* -------------------- parsing XML -------------------- */

function parseGalleries():Void {
if (imageGallery.firstChild.nodeName == "galleries") {
var rootNode:XMLNode = imageGallery.firstChild;
for (i=0; i<rootNode.childNodes.length; i++) {
if (rootNode.childNodes[i].nodeName == "gallery") {
currentGallery = rootNode.childNodes[i];
imagesInGallery.push(currentGallery.childNodes.length);
galleryNames.push(currentGallery.attributes.title);
galleryIntros.push(currentGallery.attributes.intro);
currentGalleryTitle = rootNode.childNodes[i].attributes.title;

/*NEW*/
//tooltip =+ rootNode.childNodes[i].childNodes[0].attributes.header;
/*END NEW*/

currentGalleryButton = galleryMenu_mc.buttonsHolder_mc.attachMovie("gallery section button", "galleryButton"+i, galleryMenu_mc.buttonsHolder_mc.getNextHighestDepth());
currentGalleryButton._x = galleryBtnVSpace*i;
currentGalleryButton._y = 0;
currentGalleryButton.sectionTitle_txt.text = +currentGalleryTitle.toUpperCase();
for (j=0; j<currentGallery.childNodes.length; j++) {
if (currentGallery.childNodes[j].nodeName == "image") {
currentDescription = currentGallery.childNodes[j].firstChild.toString();
descriptions.push(currentDescription);
}
}
}
}
}
numberOfGalleries = i;
enableButtons(numberOfGalleries);
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////// sidebar //////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function enableButtons(numberOfGalleries:Number):Void {
for (i=0; i<numberOfGalleries; i++) {
pressedButton = galleryMenu_mc.buttonsHolder_mc["galleryButton"+i];


pressedButton.onRollOver = function():Void {
this.gotoAndPlay("on");
//this.sectionTitle_txt.colorTo(0xfff315, 0.1);
};
pressedButton.onRollOut = function():Void {
this.gotoAndPlay("off");
//this.sectionTitle_txt.colorTo(0xff0000, 0.1);
};
pressedButton.onPress = function():Void {
removeMovieClip(thumbsDisplayer);
removeMovieClip(displayBigImage);
tracker = 0;
thumbsDisplayer = imagesHolder.createEmptyMovieClip("thumbsDisplayer_mc", imagesHolder.getNextHighestDepth());
clickedGallery = Number(this._name.substr(13));
howManyImages = imagesInGallery[clickedGallery];
whichGallery = galleryNames[clickedGallery];
descText.text = galleryIntros[clickedGallery];
currentRow = 0;
currentColumn = 0;
loadThumbnail();
};
}
enableGalleryNavigation();
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////// end sidebar //////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function loadThumbnail() {
currentThumbnail = thumbsDisplayer.attachMovie("thumbnail holder", "thumbnail"+(tracker+1), thumbsDisplayer.getNextHighestDepth());
target = currentThumbnail.thumbImage_mc;
if ((tracker%5) == 0 && tracker != 0) {
currentRow += 1;
}
if (currentColumn>3) {
currentColumn = 0;
} else if (tracker == 0) {
currentColumn = 0;
} else {
currentColumn += 1;
}
currentThumbnail._x = currentColumn*thumbMarginX;
currentThumbnail._y = currentRow*thumbMarginY;
currentThumbnail.percent_txt._visible = true;
thumbNumber = currentThumbnail._name.substr(9);
thumbPath = "gallery/"+whichGallery+"/thumbs/"+thumbNumber+".jpg";

whatIsLoading = "thumb";
loader.loadClip(thumbPath, target);
//
//
if (whichGallery == imageGallery.firstChild.childNodes[3].attributes.title) {
this.FSMP3Player._visible = true;
this.attachMovie("FSMP3Player1", "FSMP3Player1", this.getNextHighestDepth());
this.FSMP3Player._x = 170;
this.FSMP3Player._y = 250;
}else {
this.FSMP3Player._visible = false;
}
//
//
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// thumbnail actions //////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function thumbClickable():Void {
currentThumbnail.onPress = function() {
bigNumber = this._name.substr(9);
displayBigImage = imagesHolder.attachMovie("big image holder", "bigImage_mc", imagesHolder.getNextHighestDepth());
target = displayBigImage.imageHolder_mc;
bigImagePath = "gallery/"+whichGallery+"/"+bigNumber+".jpg";
whatIsLoading = "big";
disableThumbs();
loader.loadClip(bigImagePath, target);
if (clickedGallery>0) {
var descPosition:Number = 0;
for (i=0; i<clickedGallery; i++) {
descPosition += imagesInGallery[i];
}

descPosition = descPosition+Number(bigNumber)-1;
imageDesc = descriptions[descPosition];

} else {
imageDesc = descriptions[Number(bigNumber)-1];
}
descText.text = imageDesc;
};
currentThumbnail.enabled = false;
}



img_next.onRelease = function() {
//
for (j=0; j<currentGallery.childNodes.length; j++) {
if (currentGallery.childNodes[j].nodeName == "image") {
trace("Images: " + currentGallery);
currentGallery[0]++;
}
}
//
};




/*img_next.onRelease = function() {
//
for (j=0; j<currentGallery.childNodes.length; j++) {
if (currentGallery.childNodes[j].nodeName == "image") {
trace("Images: " + currentGallery);
currentGallery[0]++;
}
}
//
};*/

img_prev.onRelease = function() {
//
imagesInGallery--;
//
};



///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// end thumbnail actions /////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function disableThumbs():Void {
for (i=0; i<howManyImages; i++) {
thumbsDisplayer["thumbnail"+(i+1)].enabled = false;
thumbsDisplayer.alphaTo(0, 0.2, "easeInQuad");
galleryMenu_mc.alphaTo(0, 0.2, "easeInQuad");
}
}
function enableThumbs():Void {
for (i=0; i<howManyImages; i++) {
thumbsDisplayer["thumbnail"+(i+1)].enabled = true;
thumbsDisplayer.alphaTo(100, 0.2, "easeInQuad");
galleryMenu_mc.alphaTo(100, 0.2, "easeInQuad");
}
}

function bigClickable():Void {
displayBigImage.onPress = function() {
removeMovieClip(this);
enableThumbs();
descText.text = galleryIntros[clickedGallery];
};
}

function fadeIn():Void {
target.onEnterFrame = function():Void {
this._alpha += 10;
if (this._alpha>=100) {
delete this.onEnterFrame;
this._alpha = 100;
}
};
}

function fadeOut():Void {
target.onEnterFrame = function():Void {
this._alpha -= 10;
if (this._alpha<=0) {
delete this.onEnterFrame;
this._alpha = 0;
}
};
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////// content controls ////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Thanks guys

View Replies !    View Related
Xml Image Gallery With Next And Previous And Thumbnails
hello,

I am trying to make an xml image gallery with previous and next buttons, but also with thumbnails. The problem is that the previous and next button work, and the thumbnails work also, but only when used separately.
When I click a thumbnail and than hit the previous or next button the next buttons continue beyond the thumbnails.

I will thus need a way to detect which imagenode is loaded whenever a thumbnail is clicked, so I can continue from there with the next and previous button.

Now the next and previous button start from the first node: firstImageNode = rootNode.firstChild;

They should start from a node that is determined by which thumbnail is clicked.

Does anyone know which action to add to my thumbnail buttons to reset the starting point, when they are clicked?

Thanks in advance!

View Replies !    View Related
XML Gallery : Modify Previous/Next Buttons
Hello,

Thanks for the great tutorial, Kirupa.

I have a quick question, -

Once the user has reached the final image of the gallery, is there a way to make the "Next" button disappear? The same for "Previous" button, is there a way to not display it during the first image in the gallery?

thanks in advance,

Magomed

View Replies !    View Related
XML Gallery And Slideshow Next/previous Buttons Help
First off let me say that this forum is a lifesaver. I managed to figure out the links in xml file myself, but I cant seem to get the next/previous buttons working the way I want them to.

I have got them to work to the point where they will bring up the next image, this is until it gets to the end of the xml node, then it wont start over from the beginning if I hit next.

Can someone help me -

Here is my code:


Code:
//-----------------------
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
url = [];
delay = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
description[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
url[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
delay[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;



}


firstImage();
} else {
content = "file not loaded!";
}
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
/////////////////////////////////////
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
}
};
Key.addListener(listen);
previous_btn.onRelease = function() {
clearInterval(myInterval);
prevImage();
};
next_btn.onRelease = function() {
clearInterval(myInterval);
nextImage();

};

play_btn._visible = 0;
p = 0;
pause_btn.onRelease = function() {
clearInterval(myInterval);
pause_btn._visible = 0;
play_btn._visible = 100;
};
play_btn.onRelease = function() {
myInterval = setInterval(pause_slideshow, delay[p]);
pause_btn._visible = 100;
play_btn._visible = 0;
};

/////////////////////////////////////
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 5;
}
}
};

function nextImage() {
pause_btn._visible = 100;
play_btn._visible = 0;
previous_btn._visible = 100;
next_btn._visible = 100;
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
url_btn = url[p];
picture_num();
slideshow();
}
}
}
function prevImage() {
pause_btn._visible = 100;
play_btn._visible = 0;
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
url_btn = url[p];
picture_num();
}
}
function firstImage() {
previous_btn._visible = 0;
next_btn._visible = 100;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
url_btn = url[0];
picture_num();
slideshow();


}
}
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
}

function slideshow() {
myInterval = setInterval(pause_slideshow, delay[p]);
}

function pause_slideshow() {
clearInterval(myInterval);
if (p == (total-1)) {
p = 0;
firstImage();
} else {
nextImage();
}
}

View Replies !    View Related
Gallery Help, Next/previous Buttons Not Working
Hey

My question is in reference to the hybrid gallery described here http://www.kirupa.com/forum/showthread.php?t=202184

Basically I am attempting to create a next and previous button for this particular version of the gallery. I know what's going wrong, I just don't know *why*. Here's my code:


ActionScript Code:
function dopress() { for (var i = 0; i<cliparray.length; i++) {  scroll.paper["btn"+i].thmb.gotoAndStop(1);  cliparray[i]._visible = 0;  if (scroll.paper["btn"+i].okay == true) {   scroll.paper["btn"+i].enabled = true;   scroll.paper["btn"+i]._alpha = 100;  } }trace(this) this.enabled = false; border.resizeMe(myarray[this.ivar].holder, myarray[this.ivar].holder._width, myarray[this.ivar].holder._height, this.ivar+1); info.text = myarray[this.ivar].title; this._parent._parent._parent.next.onRelease = function() {  if (ivar<cliparray.length-1) {   ivar++;   doPress();  } else {   ivar = 0;   doPress();  } };prev.onRelease = function() { if (ivar>0) {  ivar--;  doPress(); } else {  ivar = cliparray.length-1;  doPress(); }}


The code works fine if I just navigate the gallery pictures via the prev/next buttons, the problem arises when I click on one of the thumbs itself. When I do a trace within the doPress() function, if I click on the prev or next button and then click back on a thumb, somehow "this" becomes _level0, instead of "_level0.scroll.paper["btn"+i]" as it should be. So I think I'm not calling the ivar variable correctly, but everything I've tried has failed. Any help would be appreciated.

-Swan

View Replies !    View Related
Next/ Previous In Xml Menu Array
Hello!

I'm having a heck of time figuring out how to break this set of functions up...
I'm working on a project where a menu list is dynamically created from an xml doc. That list will only show a determined amount of buttons according to a variable set in the attributes of the XML doc (n = amount of btns).

What I need to figure out is how to write a function that determines where the array is at and how to add or subtract in clicking previous or next.

if you can point me in the right direction, I would be so grateful!

View Replies !    View Related
How Do You Get The Previous Number In An Array?
I'm loading data into a movie clip via XML and an array system that duplicates a single movie clip any number of times, as defined by the XML file. The code is working, but what I would like to do now is be able to get the previous number from the array.

Here's the script I'm using:

ActionScript Code:
stop();
var newsXML:XML = new XML();
_level0.homeMC.newsMC.newsClips.newsXML.ignoreWhite = true;
_level0.homeMC.newsMC.newsClips.newsXML.load('news.xml');
_level0.homeMC.newsMC.newsClips.newsXML.onLoad = function():Void  {
    _level0.homeMC.newsMC.newsClips.nodeLength = this.firstChild.childNodes.length;
    for (i=0; i<nodeLength; i++) {
        newsPath = _level0.homeMC.newsMC.newsClips;
        newsPath.newsClipping.duplicateMovieClip('newsClipping'+i, newsPath.getNextHighestDepth());
        newsPath['newsClipping'+i]._y += getProperty(newsPath['newsClipping'+(i-1)], _y)+getProperty(newsPath['newsClipping'+(i-1)], _height);
        newsPath['newsClipping'+i].newsTitle.text = this.childNodes[0].childNodes[i].childNodes[0].firstChild;
        newsPath['newsClipping'+i].newsDate.text = this.childNodes[0].childNodes[i].childNodes[1].firstChild;
        newsPath['newsClipping'+i].newsMessage.text = this.childNodes[0].childNodes[i].childNodes[2].firstChild;
    }
    _level0.homeMC.newsMC.newsClips.newsClipping.unloadMovie();
};

The problem is on line 10 where I try to define the "_y" value for the duplicated movie clips. Since each clip is set to auto-size to fix the text content, I can't have them a set distance apart. What I'm hoping to be able to do is to have it get the "_height" and "_y" values from the previous movie clip (so if it's "newsClipping3" I want the values from "newsClipping2" and so on).

I'm new to the whole usage of arrays in scripting and this is the first time I've used this sort of script before so If anyone can tell me what I need to do or point me in the direction of a tutorial that will explain it that'd be of great help!

Time is a bit of a rush as I need this entire project done by Monday morning though... So the sooner I get an answer the better! Thanks!

View Replies !    View Related
How Do You Get The Previous Array Item?
I'm loading data into a movie clip via XML and an array system that duplicates a single movie clip any number of times, as defined by the XML file. The code is working, but what I would like to do now is be able to get the previous number from the array.

Here's the script I'm using:

ActionScript Code:
stop();var newsXML:XML = new XML();_level0.homeMC.newsMC.newsClips.newsXML.ignoreWhite = true;_level0.homeMC.newsMC.newsClips.newsXML.load('news.xml');_level0.homeMC.newsMC.newsClips.newsXML.onLoad = function():Void  {    _level0.homeMC.newsMC.newsClips.nodeLength = this.firstChild.childNodes.length;    for (i=0; i<nodeLength; i++) {        newsPath = _level0.homeMC.newsMC.newsClips;        newsPath.newsClipping.duplicateMovieClip('newsClipping'+i, newsPath.getNextHighestDepth());        newsPath['newsClipping'+i]._y += getProperty(newsPath['newsClipping'+(i-1)], _y)+getProperty(newsPath['newsClipping'+(i-1)], _height);        newsPath['newsClipping'+i].newsTitle.text = this.childNodes[0].childNodes[i].childNodes[0].firstChild;        newsPath['newsClipping'+i].newsDate.text = this.childNodes[0].childNodes[i].childNodes[1].firstChild;        newsPath['newsClipping'+i].newsMessage.text = this.childNodes[0].childNodes[i].childNodes[2].firstChild;    }    _level0.homeMC.newsMC.newsClips.newsClipping.unloadMovie();};


The problem is on line 10 where I try to define the "_y" value for the duplicated movie clips. Since each clip is set to auto-size to fix the text content, I can't have them a set distance apart. What I'm hoping to be able to do is to have it get the "_height" and "_y" values from the previous movie clip (so if it's "newsClipping3" I want the values from "newsClipping2" and so on).

I'm new to the whole usage of arrays in scripting and this is the first time I've used this sort of script before so If anyone can tell me what I need to do or point me in the direction of a tutorial that will explain it that'd be of great help!

Time is a bit of a rush as I need this entire project done by Monday morning though... So the sooner I get an answer the better! Thanks!

View Replies !    View Related
Headache With Button
Hi,

here is a link to FLA files www.fulek.com/bug/BUG_report.rar (This is another X-file’s example, FLA’s are actually empty but they have 2MB each when extracted).

Short description of problem:

StartFile.swf has one big button which is instance of Button (content is in UP state). Context menu options are added trough action script.

InvisibleButton.swf has on MC (invisibleMC) with invisible button in (content is in HIT state). You add context menu options to invisibleMC trough optionsMC component which is on InvisibleButton.swf Scene.

StartFile.swf loads InvisibleButton.swf.
So, invisible button is above big button in StartFile.swf.

If you start SWF inside Flash it all works fine, each button has its own context menu, but if you start it in Internet Explorer, invisible button is not recognized, you see big button context menu on place of invisible button.

Now if you modify invisible button so it has something in UP state it works fine in IE, you can place transparent object to simulate invisible button.

This problem appears only in IE with FlashPlayer 9 AtiveX control.
Please if someone can take a look on this two FLA files.

Thanks

View Replies !    View Related
Headache With Button
Hi,
Yesterday I post a message with problems that I have but without example.

Here is a link to FLA files www.fulek.com/bug/BUG_report.rar (This is another X-file’s example, FLA’s are actually empty but they have 2MB each when extracted).

Short description of problem:

StartFile.swf has one big button which is instance of Button (content is in UP state). Context menu options are added trough action script.

InvisibleButton.swf has on MC (invisibleMC) with invisible button in (content is in HIT state). You add context menu options to invisibleMC trough optionsMC component which is on InvisibleButton.swf Scene.

StartFile.swf loads InvisibleButton.swf.
So, invisible button is above big button in StartFile.swf.

If you start SWF inside Flash it all works fine, each button has its own context menu, but if you start it in Internet Explorer, invisible button is not recognized, you see big button context menu on place of invisible button.

Now if you modify invisible button so it has something in UP state it works fine in IE, you can place transparent object to simulate invisible button.

This problem appears only in IE with FlashPlayer 9 AtiveX control.
Please if someone can take a look on this two FLA files.

Thanks

View Replies !    View Related
Reading Array, Not Setting Array
Sorry everyone, I think I'm making a simple mistake but I just can't see it.


I'm using an array to store the order of something, I also make a backup of that array as a reference to remember what that first array looked like.

The problem comes when I'm using the values of that backed up array to populate the first array. What happens is that the backed up array gets it values overwritten, when all I wanted to do was read its values, not set its values.

Heres what I'm up to :



Code:
// Sets initial array
var ButtonOrder = new Array("One", "Two", "Three", "Four");

// Makes a backup of the initial array
ButtonOrderBackup = ButtonOrder;

// Changes the initial array with values from the backup
// (This is where I think the problems at)
ButtonOrder[0] = ButtonOrderBackup[3];
ButtonOrder[1] = ButtonOrderBackup[2];
ButtonOrder[2] = ButtonOrderBackup[1];
ButtonOrder[3] = ButtonOrderBackup[0];


// Trace Backup array
for (i = 0; i < ButtonOrderBackup.length; i++)
{
trace("Backup " + i + " " + ButtonOrderBackup[i]);
}
trace("");


// Trace initial array
for (i = 0; i < ButtonOrder.length; i++)
{
trace(i + " " + ButtonOrder[i]);
}
trace("");
Heres what the debugger feeds back to me :


Code:
Backup 0 Four
Backup 1 Three
Backup 2 Three
Backup 3 Four

0 Four
1 Three
2 Three
3 Four
I was wanting the initial array to have the values: Four, Three, Two, One. And the backup array to be how it was originally : One, Two, Three, Four.

What have I done wrong, thank you.

View Replies !    View Related
Targeting Previous Clip In An Array
I can get this to load the next swf in the array but can't seem to create a "previus button" and get it to load the previous swf in the array. Thanks in advance for any help.


Quote:




swfArray = new Array("images/argentina/1.swf", "images/argentina/2.swf", "images/argentina/3.swf");


this.createEmptyMovieClip("target1", 1);
this.createEmptyMovieClip("target2", 2);


target1.loadMovie(swfArray[0]);


target2._alpha = 0;


activeTarget = target1;
currentIndex = 0;


this.onEnterFrame = function() {
if (obj1._alpha>0) {
obj1._alpha -= 10;
}
if (obj2._alpha<100) {
obj2._alpha += 10;
}


nextButton.onRelease = function() {
if (activeTarget == target1) {
obj1 = target1;
obj2 = activeTarget=target2;
} else {
obj1 = target2;
obj2 = activeTarget=target1;
}


if (currentIndex<swfArray.length-1) {
currentIndex++;
} else {
currentIndex = 0;
}


obj2.loadMovie(swfArray[currentIndex]);


obj1.onEnterFrame = function() {
if (this._alpha<=0) {
this.unloadMovie();
delete this.onEnterFrame;
}
};
};

View Replies !    View Related
Accessing Next/previous Items In Array
This is probably something very simple, but I'm not too sure of the code used to access items within an array.

Suppose I have an array like this (using Kirupa's Arrays example):

grocery = ["bananas", "oranges", "apples", "kiwis"];
trace(grocery);

And we've loaded up the corresponding variables/text for "bananas", thus the current item = bananas.
Therefore the next item would be "oranges". How can I tell Flash that I want to access this next item?? (I'd like to be able to access it through a variable so that the same action can be applied when the item is "oranges" to move to the next item, which would now be "apples"). Thanx

View Replies !    View Related
Make New Array From Previous Answers
Need some help. Trying to learn.
I have sections with questions and answers which I can get.
But, I need to save each section into new array and tally all the final scores.
The screen will show the section score of current section that was just completed
and the final score.

I know the code has lots of problems - attached.

For the total scores the dynamic text boxes var's are totalnumcorrect, totalnumIncorrect, totaluserScore.

For the section score the dynamic text boxes var's are numcorrect, totalnumIncorrect, totaluserScore.


The title changes for each section, so I using that with if statement.

Can someone help please.

Thanks

View Replies !    View Related
How To Check For Previous Array Item?
Hi,

I have a loop that is checking to see if the value of a field is the same as the previous item in the array. This was working fine with:

questionlist[i] = [coursename[i],courseid[i], coursecategory[i], coursefriendlydate[i], coursestartdate[i], coursetime[i]];

if (coursecategory[i] != coursecategory[i-1])

but now I have to check for it inside a multidimensional array:

questionlist[i] = [coursename[i],courseid[i], coursecategory[i], coursefriendlydate[i], coursestartdate[i], coursetime[i]];

if (questionlist[i].coursecategory != questionlist[i-1].coursecategory)

but I get "term is not defined" errors.

I have also tried

if (questionlist[i][2] != questionlist[i-1][2])



Any help is appreciated!

Tony

View Replies !    View Related
Movieclip/button Headache
ok, I have a button that i want to scale up when rolled over, that is simple enough. but - what I want to happen also is when you move off the button it should scale back down to the original size, not just flick down to it. has it got something to do with the rollout action on part of the movieclip?

View Replies !    View Related
Flash Button Headache
i am designing a site in a way that i call use actionscript to load movie clips onto the stage in levels, but i am having tons of trouble with the buttons.

I want the buttons to look different (my over state) when you are on a particular page eg: if you are on the contact us page, the contact button will be purple. i cant seem to be able to do this. i saw a file that had this done, but i can not figure it out. here is the code for the button i saw (this is not my code):

on (release) {
if (_root.link<>num) {
_root["item"+_root.link].s_menu.gotoAndPlay("s2");
_root["item"+_root.link].gotoAndPlay("s2");
for(j=1;j<6;j++){
_root.ykoord[j]=_root.K[j];
}
_root.link = num;
for(j=num+1;j<6;j++){
_root.ykoord[j]=_root.K[j]+b._height;
}
s_menu.gotoAndPlay("s1");
getURL("index-1.html");

}

My flash file is located here http://www.lucidigital.com/suite.zip (372KB), please anyone who can please, please, please help me. I am running out of time on this project.
Thank You
Nicky

View Replies !    View Related
[MX04] Sort Array In Same Order Like Previous One
Hi all,
I am willing to sort an array in the same way like another array..
Explained: I have one array with x coordinates that I had sorted descending , now I have another one array , that I would like to sort (same order of indexes) like the first one..??
Thanx in advance for any answers
Meerah

View Replies !    View Related
Array Positions Modify Geoff Stearns >Next <Previous
The script below was initially set to x positions but I have gotten it to work with y positions. Five buttons take me to yPositions but I also want a button that would increment one step at a time, as in >Next <Previous. I know this is a "if" statement but I can't figure it out. I need a detailed explanation please, any vagueness and I'm lost.

Yes, Geoff sent me here to get assistance. Here is his reply but honestly I need a description that is not quite as vague.
_____
if you want back and next buttons, the slider has to know what position it's at - 1 through 5

so the currentSelection var is just a number that tells you what position it's at.

so, every time a user pushes the next button, you add one to currentSelection, and tell the slider to go to that spot in the array.

if they click back, you subtract one from currentSelection and move the slider to that position in the array.

once you have that in place, you want to check to make sure you don't go past the end or the beginning of the array (That's what the if() statement checks for - you can't go past the end of the array, or lower than 0.

i'd recommend checking out flashkit.com or ultrashock.com - they are usually pretty good about helping people out with code needs

Here is the working file
http://www.easternshorevirginia.com/...menu_test.html

fscommand ("allowscale", false);
var yPositions = new Array(0,-481,-142,201,550,897); // this is an array for storing the positions of the slider
function jumpTo (number) { // this function takes the variable "number" that is passed from the buttons and takes the corresponding value from the array of positions, then sets the new position in the slider to the new position.
slider.newY = yPositions[number];
}
stop ();

// Copyright (C) 2001 Ultrashock Inc. // Geoff Stearns. For information regarding terms of use go to http://www.ultrashock.com/legal/terms_of_use.htm

View Replies !    View Related
Reading Array
I have a array in a MC, pt = new Array(2, 4, 2, 3, 8, 6, 7, 8, 6, 9, 1, 4);
Second MC pt2 = new Array(1, 4, 2, 4, 8, 5, 7, 2, 8, 1, 4, 2);

A random number will be choosed from array1 and for array 2, for example Number 2 and Number 5.

Number 2 in the first array is the Number 4
Number 5 in the second array is the number 8
They are not the same so nothing will happen, but now comes my problem.
How can you make a action if both numbers are equal.
Something like If the number in array pt == Number in pt2

Please can anyone help me?

View Replies !    View Related
Reading From Array
I'm trying to make a photo gallery that loads thumbs from an array and when you click the thumb, it brings up the larger image. Pretty straight forward.

The problem is that I don't know how to tell which thumbnail the user clicked on, so that I can pull the appropriate larger image.

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

var thumbArray:Array = new Array("s1.jpg", "s2.jpg", "s3.jpg");
var arrayCount:Number = thumbArray.length;

//placement on stage
var startX:Number = 100;
var startY:Number = 100;
var count:Number = 0;
var shift:Number = 0;

while (count != arrayCount) {
//draw array images
var myThumbLoader:Loader = new Loader();
var url:URLRequest = new URLRequest(thumbArray[count]);
myThumbLoader.load(url);
myThumbLoader.x = startX;
myThumbLoader.y = startY + shift;
addChild(myThumbLoader);
myThumbLoader.addEventListener(MouseEvent.CLICK, makeMeBig);

//shift the next image below it
count = count + 1;
shift = shift + 150;
}

function makeMeBig(e:Event):void {
// what goes here?!
}

View Replies !    View Related
Reading Array Value
Hello, I have a sprite object which contains a textfield.
I have saved that sprite into an array.
How do I construct a trace statement to read the value of the textfield within the sprite, within the array.

thanks for any help.

View Replies !    View Related
( Previous, Start [play], Stop, Next ) Control Panel For Flash Photo Gallery?
Hey everyone.

Does anyone know how to add a control panel ( previous, start ( play ), stop, next ) for this flash photo gallery?


Here are the main files:
http://www.linkshare.org/comboboxGalleryDemo/
http://www.linkshare.org/comboboxGal...oboxgallery.as
http://www.linkshare.org/comboboxGal.../images_cb.xml
Layout
http://www.linkshare.org/comboboxGal...out_names2.jpg

Original files: http://www.mr10.nl/components/gallery/

My project files: (zipped)
http://www.linkshare.org/comboboxGal...o_sept2104.zip

Thanks a lot I would really appreciate the help! Feel free to email me if you have any solutions

View Replies !    View Related
Control Panel ( Previous, Start ( Play ), Stop, Next ) For This Flash Photo Gallery?
control panel ( previous, start ( play ), stop, next ) for this flash photo gallery?

Do you know how to add a control panel ( previous, start ( play ), stop, next ) for this flash photo gallery?


Basically it's just three files - .XML file for data and .SWF file for Presentation, and .AS file for processing
Here are the main files:
http://www.linkshare.org/comboboxGalleryDemo/
http://www.linkshare.org/comboboxGal...oboxgallery.as
http://www.linkshare.org/comboboxGal.../images_cb.xml

Layout: http://www.linkshare.org/comboboxGal...out_names2.jpg

Original files: http://www.mr10.nl/components/gallery/

My project files: (zipped)
http://www.linkshare.org/comboboxGal...o_sept2104.zip

Feel free to email me if you know how to do this!

View Replies !    View Related
Control Panel ( Previous, Start ( Play ), Stop, Next ) For This Flash Photo Gallery?
control panel ( previous, start ( play ), stop, next ) for this flash photo gallery?

Do you know how to add a control panel ( previous, start ( play ), stop, next ) for this flash photo gallery?


Basically it's just three files - .XML file for data and .SWF file for Presentation, and .AS file for processing
Here are the main files:
http://www.linkshare.org/comboboxGalleryDemo/
http://www.linkshare.org/comboboxGal...oboxgallery.as
http://www.linkshare.org/comboboxGal.../images_cb.xml

Layout: http://www.linkshare.org/comboboxGal...out_names2.jpg

Original files: http://www.mr10.nl/components/gallery/

My project files: (zipped)
http://www.linkshare.org/comboboxGal...o_sept2104.zip

Feel free to email me if you know how to do this!

View Replies !    View Related
FLASH GALLERY Reading EXTERNAL JPGs.. HELP....
Hi all...
Im having horrible trouble and just cant seem to get this working.

A simple gallery reading external JPGs... but Id like to use a movie clip as my 'more images' button.
heres an example:

http://allisonsbackstage.com/test/gallerytest.html

I just cant seem to get anything placed in the center, or the movie clip would not work right, etc. Its boggling my mind. Basically i just want this movie to load ext. jpgs, thats all. I zipped up the FLA & images and you can download it here: (Its a positively SAFE download... promise)

http://allisonsbackstage.com/test/flashkit.zip

If anyone can help me with this simple ext image gallery, i would be SOOO appreciative!

Thanks so much!!!! Hope to see some responses SOON!
THANKS
-Allison

View Replies !    View Related
Reading Array Variable
Code:
stop();
for(i=0;i<6;i++){
myHitArea = "ha" + i;
trace(eval(myHitArea));
eval(myHitArea).onRollOver = function() {
locateInArray = i;
var mcLabel = leadership_ary[locateInArray];
var mcName = mcLabel + "_mc";
eval(mcName).gotoAndPlay("rollOver");
}
eval(myHitArea).onRollOut = function() {
var mcLabel = leadership_ary[i];
var mcName = mcLabel + "_mc";
eval(mcName).gotoAndPlay("rollOut");
}
}


why won't the locateInArray variable locate the position in my array? It just says it is undefined. But when I put a 0 in there, it reads it fine!?!?

-Kac

View Replies !    View Related
Probes Reading An Array..I Think.
hi,
I need to get the information in the array left to be reflected in the the red box. using a small circle that changes color depending on the contents of the array cell.

In frame 1 of the root movie a prototype called drawCircle sets out the code to draw a single circle. I then created a function to pass this prototype the x,y and c_color for the circle, but for some reason in stead of drawing a grid of circles reflecting the array It just draws in the same spot or moves diagnal off the screen.
At the moment it just reads the last cell of the array and places it in the location of the first circle......

Please can someone take a look at the FLA file?

the main part of the actionscript is in frame 3 as follows

Code:
// this script scrolls through each cell starting @ 0.0
do {
for (grid_y=0; grid_y<10; grid_y++) { // moves accross left to right +1 each pass
// start turn/pass, every this untill end turn pass will be exicuted untill the all
// cells are calculated
rand_color =random(3); // creates random number between 0 and 2
grid[grid_x][grid_y] = rand_color; // inserts a random number between 0 and 2
c_color = (grid[grid_x][grid_y]); // reads the number/color of the current cell
circle(grid_x, grid_y, c_color); // call to function to draw circle
gridarray = (grid); // sends the text array to a var for display on stage
// end turn/pass
};
grid_x++; //moves the target down 1

} while (grid_x<10); // checks to see if last line of grid. if so contine


function circle(x, y, c_color) {
x = grid_x+6;
y = grid_y+6;
switch (c_color) {// selects hex number for color of each circle
case 0:
hex_color = 0x000000 ;
break;
case 1:
hex_color = 0xff0000 ;
break;
case 2:
hex_color = 0x0000CC ;
break;
default:
trace ("the cell has not been assigned a color")
}

var c = this.createEmptyMovieClip("c", 1);
c.lineStyle(1, 0x000000, 100);
c.beginFill(hex_color, 100);
c.drawCircle(10, x , y);
c.endFill();
}

View Replies !    View Related
Reading From Array PROBLEM
ok this is my code:

var myArray = new Array();
myArray = ["c1", "c2", "c3", "c4", "c5", "c6", "c7", "c8"];


Button:

on (press) {
mc = myArray.splice(random(myArray.length), 1);
}

// this returns: from c1 to c8 randomly, fine
now here is the problem

on (release) {
_level0.cont.mc._alpha = 10;
}

It just do NOTHIG - I've got 8 movieClips inside "cont" MC
i want'em to change their alpha randomly taking the names from the array.

View Replies !    View Related
Reading Xml Data Into An Array
hi,

the code below should read the data from an xml file into an array then into a datagrid but its not working? i get the errors:

"TypeError: Error #1009: Cannot access a property or method of a null object reference.
at xmlreader_fla::MainTimeline/LoadXML()
at flash.events::EventDispatcher/flash.events:EventDispatcher::dispatchEventFunctio n()
at flash.events::EventDispatcher/dispatchEvent()
at flash.net::URLLoader/flash.net:URLLoader:nComplete()"

I'm not sure what any of theses errors really mean so i can't really debug the below code??

the function is called by

Code:
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
Could someone explain the errors to me?


Code:
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);

trace(xmlData);

var nodes = xmlData.firstChild.childNodes;
for(var i:int =0;i<nodes.length;i++){
trace("New Data In Array"+i);
var xml_array:Array = new Array(nodes[i].firstChild.nodeValue);
}

for (var x:int = 0; x < xml_array.length; x++) {
var User_Login:String = xml_array[x];
dataGridMain.addItem({Username:User_Login});
}

dataGridMain.setStyle("fontFamily", "Verdana");
dataGridMain.setStyle("headerColor", "0xA6CBDD");
dataGridMain.setStyle("alternatingRowColors", ["0xF0F0F0", "0xFFFFFF"]);
dataGridMain.setStyle("rollOverColor", "0xDCEBF1");
dataGridMain.setStyle("selectionColor", "0xFFF97D");
dataGridMain.setStyle("selectionDuration", 300);

}
the xmlData variable holds data becuase it gets traced so i know the variable has values in it.

Thanks

Jon

View Replies !    View Related
Reading Array Problem
I cannot figure this one out. Maybe there is a key concept I am missing here and hopefully you guys can help.

The trace commands illustrate the problem - The playString function does not seem to be able to read the array created by the getChord function. I guess my question is why? It reads the default values listed below. Any guidance is greatly appreciated.

private var chordArray:Array = ["6,0","5,0","4,0","3,0","2,0","1,0"];
private var chordArrayCopy:Array = new Array();

A little background - getChord function is called from one class file and playString function is called from another. I don't know if this has anything to do with it. But that's why these are public functions within a public class.

Thanks in advance.







Attach Code

public function getChord(arr:Array):void {
chordArray = arr;
trace(chordArray); //6,1,5,0,4,0,3,0,2,0,1,0 (successful)
updateChordArray();
}

public function updateChordArray():Array {
chordArrayCopy = chordArray;
trace(chordArrayCopy); //6,1,5,0,4,0,3,0,2,0,1,0 (successful)
return chordArrayCopy;
}


public function playString(str:String):void {
var tmpArray:Array = updateChordArray();
for (var i:int; i < tmpArray.length; i++) {
var nestedNoteArray:Array = tmpArray[i].split(",");
if (nestedNoteArray[0] == str) {
playSound(tmpArray[i]);
trace(tmpArray); // 6,0,5,0,4,0,3,0,2,0,1,0 (UNSUCCESSFUL)
} else {
}
}
}

View Replies !    View Related
Reading Info Into 2d Array
hey

ive got a page "news.php?search=" outputting this:

id1=1&titel1=owaaa&text1=content2222212&ort1=Tranå s&
id2=4&titel2=sadas&text2=test tesxt Aneby&ort2=Aneby&
id3=9&titel3=titasd&text3=ingassdssadsdset&ort3=An eby Tranås ÖdeshÖG&

this is just an example of a possible output.
The output varies with what search criteria was given , there could be anywere from 0 to 400 hits, were they are listed in this way.
now im wondering how i would get this into a two dimensional array in flash
so that (array[row,column])

array[0,0]=variable id1, array[0,1]=contents of variable titel1 ... and so on..
so the 4 variables are listed in horizontal manner and
array [1,0]= content of the variable id2 and array[2,2]=contents of titel2 ..a nd so on ..

hope this wasent to confusing

thanks

//VoS

View Replies !    View Related
[AS] Loop Not Reading Array
I can't get my button's to trace out; it's not reading my rollovers. When I manually write it out (bottom) it works. Any help with what's wrong would be appreciated.

var btnAction:Array = new Array (homeBut, aboutBut, portBut, contBut);
// var btnAction:Array = [homeBut, aboutBut, portBut, contBut];
for (var i = 0; i < btnAction.length; i++) {
this.menuMC.btnAction[i].onRollOver = this.menuMC.btnAction[i].onDragOver = function() {
//this._parent.homeTxt.gotoAndStop("on");
trace("bob");
}
};

Written out it works.

/*
this.menuMC.homeBut.onRollOver = this.menuMC.homeBut.onDragOver = function() {
this._parent.homeTxt.gotoAndStop("on");
};*/

View Replies !    View Related
Reading Info Into 2d Array
hey

ive got a page "news.php?search=" outputting this:

id1=1&titel1=owaaa&text1=content2222212&ort1=Tranå s&
id2=4&titel2=sadas&text2=test tesxt Aneby&ort2=Aneby&
id3=9&titel3=titasd&text3=ingassdssadsdset&ort3=An eby Tranås ÖdeshÖG&

this is just an example of a possible output.
The output varies with what search criteria was given , there could be anywere from 0 to 400 hits, were they are listed in this way.
now im wondering how i would get this into a two dimensional array in flash
so that (array[row,column])

array[0,0]=variable id1, array[0,1]=contents of variable titel1 ... and so on..
so the 4 variables are listed in horizontal manner and
array [1,0]= content of the variable id2 and array[2,2]=contents of titel2 ..a nd so on ..

hope this wasent to confusing

thanks

//VoS

View Replies !    View Related
Reading The Array Works, Then It Doesnt...
hell there...i have this function that is supposed to build a menu:


Code:
//create menu items
rnMenu = new Array("Getting Started", "Starting Your Shift","Working With Basic Patient Information",
"Working With Exisisting Orders", "Working With Stage and Transfer Orders",
"Updating Patient Care Data", "Placing Orders", "Shift Change Procedure");


//build main menu
function mainMenu (whichMenu){
trace (whichMenu);
//set starting point for first menu item
startX = 26;
startY = 57;

//loop through array for menu button labels
for (i=0; i<whichMenu.length; i++){
attachMovie (menuButton, "menuButton" + i, i);

//pull button name from menu array
//and assign it to the dynamic text field
//inside the "menuButton" movie clip
_root["menuButton" + i].buttonText = whichMenu[i];
trace (_root["menuButton" + i].buttonText);

//position menu Items
_root["menuButton" + i]._x = startX;
_root["menuButton" + i]._y = startY;

//update startY for next menu item
startY = startY + _root["menuButton" + i]._height;
}
}


i call it with:

Code:
mainMenu (rnMenu);



the first trace in the function works fine, but when i try the second time it comes back as undefined, and the movie clips arent attaching at all.

View Replies !    View Related
[F8] Problem Reading Array Value In Function
does anyone know why "aButtons[i]" inside the "if" and "else" statements are not returning any values? do i have the correct syntax? thanks

code:
function ButtonFade(currentButton):Void {
trace(currentButton);
for (var i:Number = 0; i<aButtons.length; i++) {
trace (aButtons[i]);
if (aButtons[i] == "mcButton"+currentButton) {
trace ("mcButton" + currentButton + " if");
mcTween(aButtons[i], 0, 0, 0, 0, 30, 0);
aButtons[i].useHandCursor = false;
} else {
mcTween(aButtons[i], 0, 0, 0, 0, 100, 0);
aButtons[i].useHandCursor = true;
}
}
}

View Replies !    View Related
[F8] Reading Entire Contents Of 2D Array
I've got a 2D object array that hold varying data:

StudentArray[0].FirstName
StudentArray[0].LastName

StudentArray[1].FirstName
StudentArray[1].LastName
StudentArray[1].Grade

StudentArray[2].FirstName
StudentArray[2].LastName
StudentArray[2].Address

Each index number can hold different attributes (some might have "grade", others "address"), and we don't know what each in each set, as they are read in via outside data sources.

The question: How can I loop through each array element and whatever info might be stored in it, without knowing the name of the attributes ahead of time?

Thanks in advance!

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved