Skip to main content
Participant
November 10, 2010
Answered

Insert link over an image in XML

  • November 10, 2010
  • 1 reply
  • 1756 views

Hello,

I recently bought this template: http://www.templatemonster.com/flash-templates/27466.html but I have a big problem. I want to add a hyperlink over the big images which appears when you click on bedrooms for example. There are 9 small images in the right side and 1 big image on the left. I changed all the images but I want also to add hyperlinks on some big images. The action script import an xml file like:

<?xml version="1.0" encoding="iso-8859-1"?>
<root>

   
        <pageGallery nameGallery="GALLERY 1" name="gallery1" folder="gallery" line="3" maxImages="9">
                <titleImages>               
                    <smallImages>_gallery_small_images_1.jpg</smallImages>
                    <bigImages>_gallery_big_images_1.jpg</bigImages>
<infoImages><![CDATA[Fusce suscipit varius mi. Cum sociis natoque penatibus et -<br>magnis dis parturient montes, nascetur ridiculus mus. Nulla dui.<br>Fusce feugiat malesuada odio. Morbi nunc odio, gravida at. ]]></infoImages>

                </titleImages>   
           
           
                <titleImages>               
                    <smallImages>_gallery_small_images_2.jpg</smallImages>
                    <bigImages>_gallery_big_images_2.jpg</bigImages>
<infoImages><![CDATA[Fusce suscipit varius mi. Cum sociis natoque penatibus et -<br>magnis dis parturient montes, nascetur ridiculus mus. Nulla dui.<br>Fusce feugiat malesuada odio. Morbi nunc odio, gravida at. ]]></infoImages>
                </titleImages>   
               
               
                <titleImages>               
                    <smallImages>_gallery_small_images_3.jpg</smallImages>
                    <bigImages>_gallery_big_images_3.jpg</bigImages>
<infoImages><![CDATA[Fusce suscipit varius mi. Cum sociis natoque penatibus et -<br>magnis dis parturient montes, nascetur ridiculus mus. Nulla dui.<br>Fusce feugiat malesuada odio. Morbi nunc odio, gravida at. ]]></infoImages>
                </titleImages>   ........

Please help me with the correct syntax to add hyperlink over a big image in XML. I think I have to do some changes in .fla project, but I don't know where...

Thank you !

This topic has been closed for replies.
Correct answer Ned Murphy

The xml is only a data resource, so the best you can do with the xml is to add a tag for the url you want to link to.  For example, here's what you could do with the xml...

                <titleImages>               
                    <smallImages>_gallery_small_images_1.jpg</smallImages>
                    <bigImages>_gallery_big_images_1.jpg</bigImages>
                    <infoImages><![CDATA[Fusce suscipit varius mi. Cum sociis...  ]]></infoImages>

                    <urlImages>http://www.etc.com</urlImages>

                </titleImages>  

Flash has to do the real work with turning that into a useable link.  Making the link work in your Flash file will require understanding your fla's design and knowing how to design/code with Flash.  To get help your best bet is to find the code that involves the objects you indicated and present the relevant portions here.

If you don't understand your fla file and don't have Flash experience, you may need to hire someone to do this for you.  Someone might be willing to walk you thru it step by step or just do it for you... but don't count on it...  it is not necessarily a simple effort.  These forums are primarily to help people with design problems they can demonstrate and to share ideas, not to provide lessons or services.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
November 10, 2010

The xml is only a data resource, so the best you can do with the xml is to add a tag for the url you want to link to.  For example, here's what you could do with the xml...

                <titleImages>               
                    <smallImages>_gallery_small_images_1.jpg</smallImages>
                    <bigImages>_gallery_big_images_1.jpg</bigImages>
                    <infoImages><![CDATA[Fusce suscipit varius mi. Cum sociis...  ]]></infoImages>

                    <urlImages>http://www.etc.com</urlImages>

                </titleImages>  

Flash has to do the real work with turning that into a useable link.  Making the link work in your Flash file will require understanding your fla's design and knowing how to design/code with Flash.  To get help your best bet is to find the code that involves the objects you indicated and present the relevant portions here.

If you don't understand your fla file and don't have Flash experience, you may need to hire someone to do this for you.  Someone might be willing to walk you thru it step by step or just do it for you... but don't count on it...  it is not necessarily a simple effort.  These forums are primarily to help people with design problems they can demonstrate and to share ideas, not to provide lessons or services.

RiKardoruAuthor
Participant
November 10, 2010

This is the as for "load big images"

onClipEvent (load) {
    if (_parent._parent.numLoadTitle == undefined) {

        _parent._parent.numLoadTitle = 0;

        if (_root.part == undefined) {
            xmlNod = _root.xmlNodes.childNodes[0].childNodes[0];
        } else {
            var nameGalleryTytle:Number = _root.xmlNodes.childNodes[0].childNodes[0].childNodes.length;
            var i:Number = 0;
            while (i<nameGalleryTytle) {
                titleNameGallery = _root.xmlNodes.childNodes[0].childNodes.attributes.name;
                if (_root.part == titleNameGallery) {
                    xmlNod = _root.xmlNodes.childNodes[0].childNodes;
                }
                i++;

            }
        }

        AllxmlNode = xmlNod.childNodes[_parent._parent.numLoadTitle];
        images = AllxmlNode.childNodes[1].firstChild.nodeValue;
        titleInfo = AllxmlNode.childNodes[2].firstChild.nodeValue;


        var ifFolder:String = xmlNod.attributes.folder;
        if (ifFolder == undefined) {
            loadMovie(_root.url+images, cont.pic);
        } else if (ifFolder == "") {
            loadMovie(_root.url+images, cont.pic);
        } else {
            loadMovie(ifFolder+"/"+_root.url+images, cont.pic);
        }
    } else {

        if (_root.part == undefined) {
            xmlNod = _root.xmlNodes.childNodes[0].childNodes[0];
        } else {
            var nameGalleryTytle:Number = _root.xmlNodes.childNodes[0].childNodes[0].childNodes.length;
            var i:Number = 0;
            while (i<nameGalleryTytle) {
                titleNameGallery = _root.xmlNodes.childNodes[0].childNodes.attributes.name;
                if (_root.part == titleNameGallery) {
                    xmlNod = _root.xmlNodes.childNodes[0].childNodes;
                }
                i++;

            }
        }

        AllxmlNode = xmlNod.childNodes[_parent._parent.numLoadTitle];
        images = AllxmlNode.childNodes[1].firstChild.nodeValue;
        titleInfo = AllxmlNode.childNodes[2].firstChild.nodeValue;

        var ifFolder:String = xmlNod.attributes.folder;
        if (ifFolder == undefined) {
            loadMovie(_root.url+images, cont.pic);
        } else if (ifFolder == "") {
            loadMovie(_root.url+images, cont.pic);
        } else {
            //loadMovie(ifFolder+"/"+_root.url+small, item["mini"+i].cont.pic);
            loadMovie(ifFolder+"/"+_root.url+images, cont.pic);
        }
    }
}

_________________________________________________________________________________________

***** Here is the first frame frome scene:

import mx.transitions.Tween;
import mx.transitions.easing.*;


Stage.scaleMode = "noScale";
Stage.align = "TL";
setProperty("", _quality, "BEST");
url = "tfile";

_root.linkGallery=0;

_root.titleGallery = 0;

_root.cacheKiller = "true";
import gs.dataTransfer.XMLParser;
function onFinish(success_boolean, results_obj, xml) {//This fhunction gets called as soon as the XML loads and gets parsed.
    if (success_boolean) {
       
    }
}
stop();

var parsed_obj = {};//We'll use this to hold the parsed xml object (once the XML loads and gets parsed successfully).
var unCash = new Date().getTime();
if (_root.cacheKiller == "true") {

    fileToLoad = url+"_main.xml?cacheKiller="+unCash;
    fileToLoad = url+"_main.xml";
} else {
    fileToLoad = url+"_main.xml";
}
XMLParser.load(fileToLoad,onFinish,parsed_obj);

_root.emp.useHandCursor = 0;
///forplayer
_root.mus = 1;
_root.n = 1;
_root.num = 1;

___________________________________________________________________________________________________

*** This is the second frame :

import gs.dataTransfer.XMLParser;
function onFinish(success_boolean, gallery_obj, xml) {//This fhunction gets called as soon as the XML loads and gets parsed.
    if (success_boolean) {
        play();
    }
}

//system settings
// frame number where readMore movieClip is situated
pagesReadMoreFrame = 4;
// frame number of the first content page
firstPageFrame = 1;
//system settings

#include "gs/dataTransfer/xmlFunctions.as"

//_root.link=_root.getMenuSystemOrder(0);
//trace(_root.link)
_root.link = 1;

_root.titleNumPage = 1;

_root.openNewGallery = true

_root.part = _root.xmlNodes.childNodes[0].childNodes[0].attributes.name

_________________________________________________________________________

*** And here is the xmlFunctions.as:

import flash.display.*;
function loadBitmapSmoothed(url:String, target:MovieClip) {
    // Create a movie clip which will contain our
    // unsmoothed bitmap
    var bmc:MovieClip = target.createEmptyMovieClip("bmc", target.getNextHighestDepth());
    // Create a listener which will notify us when
    // the bitmap loaded successfully
    var listener:Object = new Object();
    // Track the target
    listener.tmc = target;
    // If the bitmap loaded successfully we redraw the
    // movie into a BitmapData object and then attach
    // that BitmapData to the target movie clip with
    // the smoothing flag turned on.
    listener.onLoadInit = function(mc:MovieClip) {
        mc._visible = false;
        var bitmap:BitmapData = new BitmapData(mc._width, mc._height, true);
        this.tmc.attachBitmap(bitmap, this.tmc.getNextHighestDepth(), "auto", true);
        bitmap.draw(mc);
    };
    // Do it, load the bitmap now
    var loader:MovieClipLoader = new MovieClipLoader();
    loader.addListener(listener);
    loader.loadClip(url, bmc);
}

var mainObj=_root.parsed_obj;
var galleryObj=_root.gallery_obj;


function textSelectable(selectedObject) {
    isTextSelected=getSettingsValue(mainObj, "textSelectable", "item");
    if (isTextSelected=="true") {
        selectedObject.selectable=true;
       
        }
    }


function getXmlSection (obj, itemName,  sectionName) {
        i=0;
    while (obj[itemName]) {
        if (obj[itemName].name==sectionName) {
            returnedResult=true;
            return (i);
            break;
        }
        i++;
    }
}


function getSettingsValue (obj, itemName, itemType) {
    sectionNum=getXmlSection(obj, "section",  "settings");
    k=0;
    while (obj["section"][sectionNum][itemType]) {
        if (obj["section"][sectionNum][itemType].name==itemName) {
            return (obj.section[sectionNum][itemType].value);
            break;
        }
        k++;
    }
}

function getCopyright (textObj) {
    textObj.htmlText=getSettingsValue(mainObj, "copyright", "item");
    textSelectable(textObj);
}


function getCompanyName (textObj) {
    textObj.htmlText=getSettingsValue(mainObj, "companyName", "item");
    textSelectable(textObj);
}

function getSlogan (textObj) {
    textObj.htmlText=getSettingsValue(mainObj, "slogan", "item");
    textSelectable(textObj);
}


function getSystemValue (textObj, systemOptionName) {
    textObj.htmlText=getSettingsValue(mainObj, systemOptionName, "item");
    textSelectable(textObj);
}


function getMenuLink (textObj, linkNum) {
    sectionNum=getXmlSection(mainObj, "section",  "menu");
    textObj.htmlText=mainObj["section"][sectionNum].link[linkNum].value;
    textSelectable(textObj);
}


function getMenuSystemOrder (linkNum) {
    sectionNum=getXmlSection(mainObj, "section", "menu");
    return (mainObj["section"][sectionNum].link[linkNum].systemOrder);
   
}
//------------------------
function getGlobalText(textObj, textsNumber, optional:Boolean) {
    sectionNum = getXmlSection(mainObj, "section", "global_text");
    textObj.htmlText = mainObj["section"][sectionNum].texts[textsNumber].value;
    if (optional == undefined) {
        textSelectable(textObj);
    } else {
        // do nothing
    }
}
function getGlobalImageName(imageNumber) {
    sectionNum = getXmlSection(mainObj, "section", "global_img");
    //currentPage = _root.link-_root.firstPageFrame;
    imageParams = new Array();
    imageParams['name'] = mainObj["section"][sectionNum]["image"][imageNumber]["imageUrl"];
    imageParams['linkToOpen'] = mainObj["section"][sectionNum]["image"][imageNumber]["link"];
    return (imageParams);
}
//------------------------


function getCurrentText(textObj, textNumber) {
    sectionNum=getXmlSection(mainObj, "section", "pages");
    currentPage=_root.link-_root.firstPageFrame;
    textObj.htmlText=mainObj["section"][sectionNum]["page"][currentPage]["texts"][0]["pageText"][textNumber].value;
    textSelectable(textObj);

}


function getMenuPreviousLink (linkNum) {
    k=0;
    systemOrder=getMenuSystemOrder(k);
    while (systemOrder) {
        if (systemOrder==linkNum) {
            orderResult=k+1;
            break;
        }
        k++;
        systemOrder=getMenuSystemOrder(k);
    }
    return (orderResult);
}


function getCurrentImageName(imageNumber) {
    sectionNum=getXmlSection(mainObj, "section", "pages");
    currentPage=_root.link-_root.firstPageFrame;
    imageParams=new Array();
    imageParams['name']=mainObj["section"][sectionNum]["page"][currentPage]["image"][imageNumber]["imageUrl"];
    imageParams['linkToOpen']=mainObj["section"][sectionNum]["page"][currentPage]["image"][imageNumber]["link"];
    imageParams['target']=mainObj["section"][sectionNum]["page"][currentPage]["image"][imageNumber]["target"];
    return (imageParams);
}

function getCurrentImageName_splash(imageNumber) {
    sectionNum=getXmlSection(mainObj, "section", "settings");
    imageParams=new Array();
    imageParams['name']=mainObj["section"][sectionNum]["image"][imageNumber]["imageUrl"];
    imageParams['linkToOpen']=mainObj["section"][sectionNum]["image"][imageNumber]["link"];
    return (imageParams);
}

function checkLinkType (linkTextType, linkNumber) {
         k=0;
        typeCount=0;
        finalLinkNumber=parseInt(linkNumber)+1;
        currentPage=_root.link-_root.firstPageFrame;
        sectionNum=getXmlSection(mainObj, "section", "pages");
        linkTypeCkeck=mainObj["section"][sectionNum]["page"][currentPage]["link"]["linkType"];
        while (linkTypeCkeck){
            if (linkTypeCkeck==linkTextType) {
                 typeCount++;
            }
            if (typeCount==finalLinkNumber) {
               
                return(k);
                break;
            }
            k++;
            linkTypeCkeck=mainObj["section"][sectionNum]["page"][currentPage]["link"]["linkType"];
        }
}

_root.readMoreFrameType = 'readmore';

function more_click_func(number) {
    tempNumber = number.split(" ");
    number=tempNumber.join("");
    number=number.toLowerCase();
    num=_root.pagesReadMoreFrame;
    currentPage=_root.link-_root.firstPageFrame;
   
    if( isNaN(Number(number)) ) {
        readMoreType = number;
    } else {
        readMoreType = 'readmore';
    }
   
    //if( (_root.link<>num || _root.readMoreFrameType!=readMoreType)) {      

        if (_root.animation){
            //if (_root.link<>5 ){
           
        _root["item" + getMenuPreviousLink(_root.link)].gotoAndPlay("s2");
       
        //_root.menu2["item" + getMenuPreviousLink(_root.link)].gotoAndPlay("s2");
       
        if (number=='privacypolicy') {
            _root.readMoreFrameType = 'privacypolicy';
            sectionNum=getXmlSection(mainObj, "section", "privacyPolicy");
            titleNum=getXmlSection(mainObj.section[sectionNum], "item", "pageTitle");
            textNum=getXmlSection(mainObj.section[sectionNum], "item", "pageText");
            _root.readMoreTitle=mainObj.section[sectionNum]["item"][titleNum].value;
            _root.readMoreText=mainObj.section[sectionNum]["item"][textNum].value;
        } else if (number=='termsofuse') {
            _root.readMoreFrameType = 'termsofuse';
            sectionNum=getXmlSection(mainObj, "section", "termsOfUse");
            titleNum=getXmlSection(mainObj.section[sectionNum], "item", "pageTitle");
            textNum=getXmlSection(mainObj.section[sectionNum], "item", "pageText");
            _root.readMoreTitle=mainObj.section[sectionNum]["item"][titleNum].value;
            _root.readMoreText=mainObj.section[sectionNum]["item"][textNum].value;
        } else {
            _root.readMoreFrameType = 'readmore';
            sectionNum=getXmlSection(mainObj, "section", "pages");
            linkCount=checkLinkType("readMoreLink", number);
            i=0;
            linkTitleNum=getXmlSection(mainObj["section"][sectionNum]["page"][currentPage]["link"][linkCount], "item", "title");           
            linkTextNum=getXmlSection(mainObj["section"][sectionNum]["page"][currentPage]["link"][linkCount], "item", "linkText");
            _root.readMoreTitle=mainObj["section"][sectionNum]["page"][currentPage]["link"][linkCount]["item"][linkTitleNum].value;
            _root.readMoreText=mainObj["section"][sectionNum]["page"][currentPage]["link"][linkCount]["item"][linkTextNum].value;            
        }
                _root.subMenu.subMenu.subMenu["item"+(_root.link-1)].mouseRelease = true;
                _root.link = 8;
                _root.linkClosePanel = false;
                _root.titleNumPage = _root.pagesReadMoreFrame;           
                _root.content.play();           
           
        }
        //}
}

function getContactFormText(textObj, textNumber) {
    sectionNum=getXmlSection(mainObj, "section", "contactForm");
    textObj.htmlText=mainObj["section"][sectionNum]["texts"][0]["pageText"][textNumber].value;
    textSelectable(textObj);
}


function getContactFormText_only(textNumber) {
    sectionNum=getXmlSection(mainObj, "section", "contactForm");
    return htmlText=mainObj["section"][sectionNum]["texts"][0]["pageText"][textNumber].value;

}


function getContactFormParams() {
    sectionNum=getXmlSection(mainObj, "section", "contactForm");
    ContactFormParams=new Array();
    servNum=getXmlSection(mainObj["section"][sectionNum], "item", "serverOption");
    recNum=getXmlSection(mainObj["section"][sectionNum], "item", "recipient");
    ContactFormParams['rec']=mainObj["section"][sectionNum]["item"][recNum].value;
    ContactFormParams['serv']=mainObj["section"][sectionNum]["item"][servNum].value
    return (ContactFormParams);
}


// gallery functions
function getGallerySystemProperty(propName) {
    sectionNum=getXmlSection(galleryObj, "section", "systemOptions");
    propNum=getXmlSection(galleryObj["section"][sectionNum], "option", propName);
    return (galleryObj["section"][sectionNum]["option"][propNum].value);
}

function getGallerySettings(propName) {
    sectionNum=getXmlSection(galleryObj, "section", "settings");
    propNum=getXmlSection(galleryObj["section"][sectionNum], "option", propName);
    return (galleryObj["section"][sectionNum]["option"][propNum].value);
}

function getGalleryImage(imageNum, categoryNum) {
    sectionNum=getXmlSection(galleryObj, "section", "imagesData");
    imageParams=new Array();
    image=galleryObj["section"][sectionNum]["category"][categoryNum]["image"][imageNum];
    nameNum=getXmlSection(image, "item", "imageUrl");
    commentNum=getXmlSection(image, "item", "imageComment");
    imageParams['name']=image['item'][nameNum].value;
    imageParams['comment']=image['item'][commentNum].value;
    return (imageParams);
}

function getCurrentGalleryName(categoryNum) {
    sectionNum=getXmlSection(galleryObj, "section", "imagesData");
    return (galleryObj["section"][sectionNum]["category"][categoryNum].name);
}

Ned Murphy
Legend
November 10, 2010

That's actionscript 2 code, so you're asking for help in the wrong forum.  And that is alot of code for anyone to have to go thru, so your hopes of getting help are going to be low.