A Flash Developer Resource Site

Results 1 to 1 of 1

Thread: xml photo gallery with a category drop down menu

  1. #1
    Junior Member
    Join Date
    Oct 2001
    Posts
    1

    xml photo gallery with a category drop down menu

    hi guys,
    i need some help with this script, i am building a photo gallery with a drop down menu that reveals many photo libraries and all are xml generated, the idea is to have a gallery where it is updatable without the use of flash knowledge, just xml. so i reached with this script to have a drop down menu that opens and you can choose between the galleries, each gallery reveals thumbnails, the problem is when you choose a photo from the thumbnail, the drop down menu stops working. so i need help where the menu still function after you choose a photo. (when you chose a photo u have the posibility to see the caption of the photo and then go back to thumbnail or continue see the photos by a "next" button) i am attaching the file in zip formate and im attaching the script also. thanx

    this._parent.title._visible = false
    this._parent.info.info._visible = false
    this._parent.info.bg._visible = false
    var t=_root.attachMovie("mc2","t",245)
    t.my.text="Caption"
    t.my._visible = false
    t._visible = false
    t.pressed = true
    t._x = 300
    t._y = 513

    t.onPress = showall
    function showall(){
    if(!this.pressed){
    this._parent.title._visible = true
    this._parent.info.info._visible = true
    this._parent.info.bg._visible = true
    previous_btn._visible = false
    next_btn._visible = false
    this.my.text="HIDE"
    this.pressed=true
    }else{
    this.pressed = false
    this._parent.title._visible = false
    this._parent.info.info._visible = false
    this._parent.info.bg._visible = false
    previous_btn._visible = true
    next_btn._visible = true
    this.my.text="Caption"
    }

    }

    var current = 0
    var allLoaded =false
    function rem(){
    p=0
    for(var obj in thumbnail_mc){
    thumbnail_mc[obj].removeMovieClip()
    }
    }
    cliparray=[]
    var back=_root.attachMovie("mc3","back",600)
    back._x =400
    back._y=515
    back.my.text =""
    back._visible = false
    back.onPress = backo
    function backo(){
    thumbnail_mc._visible = true
    this._parent.info.bg._visible = false
    this._parent.info.info._visible = false
    this._parent.title._visible = false
    picture._visible = false
    next_btn._visible = false
    previous_btn._visible = false
    t.my._visible = false
    t._visible = false
    t.pressed = true
    desc_txt._visible = false
    pos_txt._visible = false
    this._visible = false
    for(var obj in cliparray){
    cliparray[obj]._visible = true
    }
    }
    //gallery btn!
    myvar = false;
    function ro() {
    if (!myvar) {
    _root.sw._visible = true;
    myvar = true;
    this.my.text = "MENU CLOSE";
    } else {
    _root.sw._visible = false;
    myvar = false;
    this.my.text = "MENU OPEN";
    }
    }

    lip = _root.attachMovie("mc", "mc"+45, 345);
    lip.my.text = "MENU OPEN";
    lip._x = 1;
    lip._y = 1;
    _root.createEmptyMovieClip("sw", 100);
    _root.sw._y = lip._y+lip._height;
    _root.sw._visible = false;
    lip.onPress = ro;
    function loadXML(loaded) {
    if (loaded) {
    rem();
    //lip.onRollOut = ro2
    for (var j = 0; j<this.firstChild.childNodes.length; j++) {
    clip = _root.sw.attachMovie("mc", "mc"+j, j);
    clip._x = 1;
    clip._y = 1+j*(clip._height+1);
    clip.my.text = this.firstChild.childNodes[j].attributes.name;
    clip.jvar = j;
    cliparray.push(clip);
    clip.onPress = presto;
    }
    xmlNode = this.firstChild.childNodes[current];
    image = [];
    description = [];
    thumbnails = [];
    title = [];
    info = [];
    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;
    title[i] = xmlNode.childNodes[i].childNodes[3].firstChild.nodeValue;
    info[i] = xmlNode.childNodes[i].childNodes[4].firstChild.nodeValue;
    thumbnails_fn(i);
    }
    firstImage();
    } else {
    content = "file not loaded!";
    }
    }
    function presto(){
    current = this.jvar
    xmlData.load("photos.xml");


    }
    xmlData = new XML();
    xmlData.ignoreWhite = true;
    xmlData.onLoad = loadXML;
    xmlData.load("photos.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._visible = false
    previous_btn.onRelease = function() {
    prevImage();
    pos_txt._visible = true
    };
    next_btn._visible = false
    next_btn.onRelease = function() {
    nextImage();
    pos_txt._visible = true
    };
    /////////////////////////////////////
    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];
    this._parent.title.text=title[p]
    this._parent.info.info.text=info[p]

    picture_num();
    }
    }
    }
    function prevImage() {
    if (p>0) {
    p--;
    picture._alpha = 0;
    picture.loadMovie(image[p], 1);
    desc_txt.text = description[p];
    this._parent.title.text=title[p]
    this._parent.info.info.text=info[p]
    picture_num();
    }
    }
    function firstImage() {
    if (loaded == filesize) {
    picture._alpha = 0;
    picture.unloadMovie(image[0], 1);
    desc_txt.text = description[0];
    desc_txt._visible = false
    this._parent.title.text=title[0]
    this._parent.info.info.text=info[p]
    picture_num();
    }
    }
    cx=1
    cy = 0
    this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();

    preloader._visible = true;
    if (loaded != filesize) {
    preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
    picture._x =cx-picture._width/2
    picture._y = cy-picture._height/2
    preloader._visible = false;
    if (picture._alpha<100) {
    picture._alpha += 10;
    }
    }
    };
    function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
    pos_txt._visible = false
    }
    function thumbNailScroller() {
    // thumbnail code!
    this.createEmptyMovieClip("tscroller", 1000);
    scroll_speed = 0;
    tscroller.onEnterFrame = function() {
    if ((_ymouse>=thumbnail_mc._y) && (_ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
    if ((_xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
    thumbnail_mc._x -= scroll_speed;
    } else if ((_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 = -170+(target_mc._width+15)*(k%5)
    target_mc._y =-10+ Math.floor(k/5)*(target_mc._height+15)

    target_mc.pictureValue = k;
    target_mc.onRelease = function() {
    p = this.pictureValue-1;
    nextImage();
    thumbnail_mc._visible = false
    next_btn._visible = true
    previous_btn._visible = true
    desc_txt._visible = true
    pos_txt._visible = true
    t.my._visible = true
    t._visible = true
    t.pressed = false
    back._visible = true
    for(var obj in cliparray){
    cliparray[obj]._visible =false
    }

    };
    target_mc.onRollOver = function() {
    this._alpha = 50;
    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);
    }
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center