# Movieclip

**URL:** <https://forum.kirupa.com/t/movieclip/324880>\
**Category:** Uncategorized\
**Created:** [September 13, 2011, 11:22am UTC](https://forum.kirupa.com/t/movieclip/324880 "2011-09-13T11:22:14Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![msksanthu](https://avatars.discourse-cdn.com/v4/letter/m/4bbf92/32.png) [@msksanthu](https://forum.kirupa.com/u/msksanthu)\
**Post date:** [September 13, 2011, 11:22am UTC](https://forum.kirupa.com/t/movieclip/324880/1 "2011-09-13T11:22:14Z")

</div>

i need to display this dynamically generating buttons from xml into moveclip with scrollbar in as3 pls help me…i had attached my code…

var yPlacement:int = 230;  
var xPlacement:int = 66;  
var distance:int = 100;  
var format:TextFormat = new TextFormat();  
format.color = 0x000000;  
format.font = “Verdana”;  
format.size = 18;  
format.bold = true;  
[//format.kerning](https://format.kerning) = false;  
//var items:Array = new Array();  
var myXML:XML = new XML();  
var XML\_URL:String = “evs.xml”;  
var myXMLURL:URLRequest = new URLRequest(XML\_URL);  
var myLoader:URLLoader = new URLLoader(myXMLURL);  
myLoader.addEventListener(“complete”, xmlLoaded);

// Create the xmlLoaded function  
function xmlLoaded(event:Event):void {

```
// Place the xml data into the myXML object
myXML = XML(myLoader.data);
// Initialize and give var name to the new external XMLDocument
var xmlDoc:XMLDocument = new XMLDocument();
// Ignore spacing around nodes
xmlDoc.ignoreWhite = true;
// Define a new name for the loaded XML that is the data in myLoader
var menuXML:XML = XML(myLoader.data);
// Parse the XML data into a readable format
xmlDoc.parseXML(menuXML.toXMLString());

	

// Set the index number of our loop, increments automatically
var i:Number = 0;
// Run the "for each" loop to iterate through all of the menu items listed in the external XML file
for each (var topic:XML in myXML..topic) {

// Access the value of the "itemLabel" node in our external XML file
var listLabel:String = topic.itemLabel.toString();
// Access the value of the "urlstring" node in our external XML file
var listurl:String = topic.urlstring.toString();

// Just some trace I used while testiing
 //trace(listurl);
 
                         // This all pertains to the style of the button, alter values to your liking
                         var type:String = GradientType.LINEAR;
                         var colors:Array = [0xFFFFFF, 0xCCCCCC];
                         var alphas:Array = [1, 1];
                         var ratios:Array = [0, 255];
                         var spreadMethod:String = SpreadMethod.PAD;
                         var interp:String = InterpolationMethod.LINEAR_RGB;
                         var focalPtRatio:Number = 0;
                         var matrix:Matrix = new Matrix();
                         var boxWidth:Number = 200;
                         var boxHeight:Number = 40;
                         var boxRotation:Number = Math.PI/2; // 90&#730;
                         var tx:Number = 0;
                         var ty:Number = 0;
                         matrix.createGradientBox(boxWidth, boxHeight, boxRotation, tx, ty);
                         var rect:Shape = new Shape;
                         rect.graphics.beginGradientFill(type, colors, alphas, ratios, matrix, spreadMethod, interp, focalPtRatio);
						 rect.graphics.lineStyle(1, 0x999999);
                         rect.graphics.drawRect(0, 0, 200, 40);
						 
				         // This all pertains to the text fields that give our buttons their label, alter values to your liking
                         var myText:TextField = new TextField();
						//myText.embedFonts = true;
                         myText.autoSize = TextFieldAutoSize.CENTER;
                         myText.antiAliasType = AntiAliasType.ADVANCED;
                         myText.defaultTextFormat = format;
                         myText.selectable = false;
                         myText.mouseEnabled = false;
                         myText.text = listLabel;
						 myText.x = 2;
						 myText.y = 2;
	                     addChild(myText);
 
	                     // Create MovieClip holder for each button graphic and text label
	                  	 var clip_mc = new MovieClip();
						 // Add the rectangle graphic
	                     layout_mc.clip_mc.addChild(rect);
						 // Add the text field
	                     layout_mc.clip_mc.addChild(myText);
						 // Put the new movieClip on stage now
	                     addChild(clip_mc);
						 // Make the mouse button mode true for the movieclip so user knows it is a button
                    	 layout_mc.clip_mc.buttonMode = true;						 
						 
						 // Offset each one in the loop to make sure they don't just get put right on top of each other
						 yPlacement = yPlacement + 50;
						 // Now apply it in its offset Y position to the stage
						 layout_mc.clip_mc.y = yPlacement; 
						 // X position it will be placed on stage
                    	 layout_mc.clip_mc.x = xPlacement;           
                         
						 // Access the URL value and ready it for setting up the Click listener, and function
                         layout_mc.clip_mc.clickToPage = listurl;
						 // Add the mouse event listener to the moviClip button
                         layout_mc.clip_mc.addEventListener (MouseEvent.CLICK, clipClick);
                         //Add event listeners (used for animating the buttons)
	                     layout_mc.clip_mc.addEventListener (MouseEvent.MOUSE_OVER, onMouseOver);
	                     layout_mc.clip_mc.addEventListener (MouseEvent.MOUSE_OUT, onMouseOut);
						 
                         // Set the function for what happens when that button gets clicked
                         function clipClick(e:Event):void {
                            var targetURL:String = e.target.clickToPage;
                            var urlRequest:URLRequest = new URLRequest(targetURL);
                            navigateToURL(urlRequest);
                         }
                         i++;
}

}

```

// Set the mouse over function for all movieclip buttons  
function onMouseOver (e:Event):void {

// Create the filters and add them to an array  
var bevel:BevelFilter = new BevelFilter();  
bevel.distance = 1;  
bevel.angle = 45;  
bevel.shadowColor = 0x666666;  
bevel.shadowAlpha = 0.5;  
bevel.strength = 4;  
bevel.quality = BitmapFilterQuality.MEDIUM;  
bevel.type = BitmapFilterType.INNER;  
bevel.knockout = false;  
var glow:GlowFilter = new GlowFilter();  
glow.color = 0x79B3E1;  
glow.alpha = 1;  
glow.quality = BitmapFilterQuality.MEDIUM;  
// Pack the filter paramters into the array variable  
var filtersArray:Array = new Array(bevel, glow);

// Assign the filters array to the display object to apply the filter  
e.target.filters = filtersArray;

}

// Set the mouse out function for all movieclip buttons  
function onMouseOut (e:Event):void {

```
// Remove the Filters on Mouse Out
e.target.filters = null;

```

}
