How create another instance of an object from a menu link

Discussion in 'JavaScript' started by icue, Feb 18, 2012.

  1. #1
    Hi,

    I am very new to javascript and would like to make a change to a script I found online.
    I am not sure how much code I can post here so here is the link to the full script:
    http://www.dhteumeuleu.com/theories-of-mind/4/

    The script is for a coverFlow style gallery that uses an xml file to load the initial gallery
    images. I would like to know if it is possible to click on a link to load a different xml file
    to change the images in the gallery.

    I am not sure but I think the following is used to initalise or create the gallery object:
    imf.create("imageFlow", 'cities.xml', 0.75, 0.15, 1.8, 10, 8, 4);

    I need to be able to call the above from a menu and have tried the following:
    <a href="javascript:void(0)" onClick="imf.create('imageFlow', 'london.xml', 0.75, 0.15, 1.8, 10, 8, 4));">London</a>
    and
    <a href="#" onclick="imf.create("imageFlow", 'london.xml', 0.75, 0.15, 1.8, 10, 8, 4);">London</a>
    and
    <a href="url_to_xml_filel" onclick="imf.create("imageFlow", 'london.xml', 0.75, 0.15, 1.8, 10, 8, 4);">London</a>

    The first two examples do nothing and the last opens the xml file in a window.

    Can someone please offer some advice.

    Thanks in advance.

    Below is another section of the script:
    /* //////////// ==== public methods ==== //////////// */
    return {
    /* ==== initialize script ==== */
    create : function (div, xmlfile, horizon, size, zoom, border, start, interval) {
    /* ---- instanciate imageFlow ---- */
    var load = function () {
    var loaded = false;
    var i = instances.length;
    while (i--) if (instances.oCont == div) loaded = true;
    if (!loaded) {
    /* ---- push new imageFlow instance ---- */
    instances.push(
    new ImageFlow(div, xmlfile, horizon, size, zoom, border, start, interval)
    );
    /* ---- init script (once) ---- */
    if (!imf.initialized) {
    imf.initialized = true;
    /* ---- window resize event ---- */
    addEvent(window, 'resize', function () {
    var i = instances.length;
    while (i--) instances.resize();
    });
    /* ---- stop drag N drop ---- */
    addEvent(document.getElementById(div), 'mouseout', function (e) {
    if (!e) e = window.event;
    var tg = e.relatedTarget || e.toElement;
    if (tg && tg.tagName == 'HTML') {
    var i = instances.length;
    while (i--) instances.oc.onmousemove = null;
    }
    return false;
    });
    /* ---- set interval loop ---- */
    setInterval(function () {
    var i = instances.length;
    while (i--) instances.run();
    }, 16);
    }
    }
    }
    /* ---- window onload event ---- */
    addEvent(window, 'load', function () { load(); });
    }
    }
    }();

    /* ==== create imageFlow ==== */
    // div ID, imagesbank, horizon, size, zoom, border, autoscroll_start, autoscroll_interval
    imf.create("imageFlow", 'middle-eastern.xml', 0.75, 0.15, 1.8, 10, 8, 4);
     
    icue, Feb 18, 2012 IP