# Loading swf with XML on Click

**URL:** <https://forum.kirupa.com/t/loading-swf-with-xml-on-click/295006>\
**Category:** Uncategorized\
**Created:** [August 24, 2009, 10:19am UTC](https://forum.kirupa.com/t/loading-swf-with-xml-on-click/295006 "2009-08-24T10:19:00Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![donkeykong](https://avatars.discourse-cdn.com/v4/letter/d/6f9a4e/32.png) [@donkeykong](https://forum.kirupa.com/u/donkeykong)\
**Post date:** [August 24, 2009, 10:19am UTC](https://forum.kirupa.com/t/loading-swf-with-xml-on-click/295006/1 "2009-08-24T10:19:00Z")

</div>

Hi all, can anyone help  
can anyone shine a little light onto a little confusion I am having, I have a menu that already loads in images via an XML file on a menu, what I am trying to do is when an image/meni Item is click I would like to load in an swf into the same place as the image Item loads into! am I making any sense.

on a click event, do I use in the XML file the \<link\>link to swf\</link\> ???

```auto
 
this is what I have in my xml file that loads in the images so far;
<image name="image 12" path="img/img12.jpg" 
title="Lorem ipsum 12" 
text="Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Morbi commodo 12" />

```

what I am getting confused with is what I also put within the AS, I am sure it is not alot but I’m just not sure what needs to go where??

this is what I have within the AS that loads in XML, I hope its ok to paste this code, never like posting to much code incase is scares people off, I just don’t want to leave anything out, hope thats ok with everyone:eek:

```auto
 
// Use URLLoader to load XML
      
xmlLoader = new URLLoader();
xmlLoader.dataFormat = URLLoaderDataFormat.TEXT;
   
// Listen for the complete event
xmlLoader.addEventListener(Event.COMPLETE, onXMLComplete); 
xmlLoader.load(new URLRequest("data.xml"));  
stage.addEventListener( MouseEvent.MOUSE_WHEEL, onMouseWheel );
}
  
//———————————————EVENT HANDLERS
  
private function onXMLComplete(event:Event):void
  {
// Create an XML Object from loaded data
var data:XML = new XML(xmlLoader.data);
   
// Now we can parse it
var images:XMLList = data.image;
   
for(var i:int = 0; i < images.length(); i++) 
   
   
{
// Get info from XML node
var imageName:String = images*.@name;
var imagePath:String = images*.@path;
var titles:String = images*.@title;
var texts:String = images*.@text;
    
    
// Load images using standard Loader
var loader:Loader = new Loader();
    
// Listen for complete so we can center the image
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,onImageComplete); 
loader.load(new URLRequest(imagePath)); 
   
// Create a container for the loader (image)
var holder:MovieClip = new MovieClip();
holder.addChild(loader);
   
var button_main:Button_mr = new Button_mr(); /
holder.addChild(button_main);                
   
var tooltip:ToolTip = new ToolTip();
tooltip.field.text = titles; //loads tooltip 1
tooltip.field2.text = texts; //loads tool tip 2
    
tooltip.x = -350;  
tooltip.y = 0;    
holder.addChild(tooltip);
    
    
// Same proceedure as before
holder.buttonMode = true;
holder.addEventListener( MouseEvent.CLICK, onMenuItemClick );
    
// Add it to the menu
circleMenu.addChild(holder);
    
 }
}

```

many thanks for any help!!
