Results 1 to 3 of 3

Thread: HELP NEEDED: Loading XML Gallery

  1. #1
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation HELP NEEDED: Loading XML Gallery

    Hello All

    I seek your help regarding , loading of XML gallery swf (PORT.SWF) into a EMPTY_MC (MAIN.SWF)

    I have a XML gallery (PORT.SWF & PORT.XML). Larger images are loaded with horizontal scrolling thumbnails at the bottom. these thumbnails can be scrolled to right or left through action script as these thumbnails are loaded dynamically from the path mentioned in the XML file.

    This works perfectly if i open PORT.SWF from explorer. But,
    when i load it into a EMPTY_MC of MAIN.SWF though the code below, it loads perfectly with images and thumbnails. but scroll for thumbnails is not working.
    ------------
    on (release) {
    loadMovie("PORT.SWF", "EMPTY_MC");
    }

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

    Here is a code which is in a PORT.SWF

    --------------------
    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("PORT.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 = 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);
    }

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


    what changes needs to be made in this actionscript so that this file can be loaded in another filel's movieclip and also get the scrolling work.

    please help
    thank you in advance. . .

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    That's because you're using _root. You should never use this for the exact reason that problems like this will occur.

    Within PORT.SWF, _root refers to the main timeline. When you import it into EMPTY_MC, it now refers to the main timeline of PORT.SWF.

    Either remove the _root references all together. Or, replaces them with the this._parent reference syntax.
    Last edited by Medyman; 08-18-2008 at 11:53 AM.

  3. #3
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hello Medyman
    Thank you so much for your reply. Will try it with your solution,
    But

    Before reading this post, i have managed to resolve the issue for that particular project.

    I had my EMPTY_MC with 100, 100 as X, Y co-ordinates. I relocated the EMPTY_MC with 0, 0 as X,Y co-ordinates and my thumbnail scroller worked.

    Will update you once i re-do it with this._parent thing.

    Thanks a ton.

Bookmarks

Posting Permissions

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