# Displaying dynamic text and images from a menu

**URL:** <https://forum.kirupa.com/t/displaying-dynamic-text-and-images-from-a-menu/251530>\
**Category:** flash\
**Created:** [February 9, 2008, 7:53pm UTC](https://forum.kirupa.com/t/displaying-dynamic-text-and-images-from-a-menu/251530 "2008-02-09T19:53:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mebabyme](https://avatars.discourse-cdn.com/v4/letter/m/4da419/32.png) [@mebabyme](https://forum.kirupa.com/u/mebabyme)\
**Post date:** [February 9, 2008, 7:53pm UTC](https://forum.kirupa.com/t/displaying-dynamic-text-and-images-from-a-menu/251530/1 "2008-02-09T19:53:39Z")

</div>

Hi,

I have been using senocular’s excellent ‘squirrel finder’ tutorial ([http://www.kirupa.com/web/xml/examples/squirrelfinder.htm](http://www.kirupa.com/web/xml/examples/squirrelfinder.htm)) to try and create a fairly simple xml-fed flash interface. Basically, i need to have a list of architectural projects in a menu, and when each one is clicked the project info is loaded into a dynamic text field and a series of maybe 2 or 3 images are also sent to movie clips on the stage.

I’ve got this far using the tutorial: [http://beentheunseen.ae-hosting.com/projects.html](http://beentheunseen.ae-hosting.com/projects.html)

This is my xml file:

[COLOR=DarkRed]**\<?xml version=“1.0” ?\>  
\<menu\>  
\<menuitems\>  
\<item type=“school”\>  
\<name\>Chapin School\</name\>  
\<info\>  
\<**![CDATA[This school has been under development for many years…]]**\>  
\</info\>  
\<image1\>face.jpg\</image1\>  
\<image2\>face2.jpg\</image2\>  
\<image3\>face3.jpg\</image3\>  
\</item\>  
\<item type=“school”\>  
\<name\>Molloy School\</name\>  
\<info\>  
\<**![CDATA[Our work with Molloy has been…]]**\>  
\</info\>  
\<image1\>molloy.jpg\</image1\>  
\<image2\>molloy2.jpg\</image2\>  
\<image3\>molloy3.jpg\</image3\>  
\</item\>  
\<item type=“school”\>  
\<name\>Deerfield Academy\</name\>  
\<info\>  
\<**![CDATA[Text text text…]]**\>  
\</info\>  
\<image1\>deerfield.jpg\</image1\>  
\<image2\>deerfield2.jpg\</image2\>  
\<image3\>deerfield3.jpg\</image3\>  
\</item\>  
\<item type=“school”\>  
\<name\>Canterbury School\</name\>  
\<info\>  
\<**![CDATA[Text text text…]]**\>  
\</info\>  
\<image1\>canterbury.jpg\</image1\>  
\<image2\>canterbury2.jpg\</image2\>  
\<image3\>canterbury3.jpg\</image3\>  
\</item\>  
\</menuitems\>  
\</menu\>**[/COLOR]

And this is the AS code:

[COLOR=Navy]\*\*function DisplayInfo(){

```
infobox_mc._visible = true;
infobox_mc.content_txt.text = this.location_text;

```

}

var item\_spacing = 18;  
var item\_count = 0;

function CreateMenu(menu\_xml){

```
var items = menu_xml.firstChild.firstChild.childNodes; 
for (var i=0; i&lt;items.length; i++) {

    if (items*.attributes.type == "school") { 

        var species = items*.firstChild; 
        var location = items*.childNodes[1];
        
        var item_mc = menu_mc.attachMovie("menu_item","item"+item_count, item_count);
        item_mc._y = item_count * item_spacing;
        item_count++;
        
        item_mc.species_txt.text = species.firstChild.nodeValue;
        item_mc.main_btn.location_text = location.firstChild.nodeValue;

        item_mc.main_btn.onRelease = DisplayInfo;
    }
}

```

}

var squirrel\_xml = new XML();  
squirrel\_xml.ignoreWhite = true;

squirrel\_xml.onLoad = function(success){  
if (success) CreateMenu(this);  
else trace(“Error loading XML file”);  
}

squirrel\_xml.load(“projects.xml”);\*\*[/COLOR]

Unfortunately the code is still mildly squirrel themed, lol. Could anyone help me to incorporate a way to display the images specified in the XML file at the same time as the project information? I assume i need to make a couple of movie clips on the stage and send the file url information to them somehow. I’ve tried adding bits of script from a number of tutorials and forums, but i don’t seem to be able to make it work…

Thanks!

Ben
