# XML text: controlling the MC

**URL:** <https://forum.kirupa.com/t/xml-text-controlling-the-mc/284944>\
**Category:** flash\
**Created:** [March 25, 2009, 1:00pm UTC](https://forum.kirupa.com/t/xml-text-controlling-the-mc/284944 "2009-03-25T13:00:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![trick](https://avatars.discourse-cdn.com/v4/letter/t/5fc32e/32.png) [@trick](https://forum.kirupa.com/u/trick)\
**Post date:** [March 25, 2009, 1:00pm UTC](https://forum.kirupa.com/t/xml-text-controlling-the-mc/284944/1 "2009-03-25T13:00:37Z")

</div>

Hi!

I am loading text from an XML file into dynamically created MCs. How do I target those MCs so that I can change where they are, their alpha, etc.? For example, I want them to have zero alpha until the image from the XML node they’re in is loaded, then make them visible.

XML:

```php
<portfolio>
	<piece>
	<image>portfolio/01.jpg</image>
	<description>one</description>
	</piece>
</portfolio>

```

AS:

```php
function xmlLoaded(e:Event):void {
	var loadedxml:XML = new XML(e.target.data);
	for (var i:uint=0; i<loadedxml.piece.length(); i++) {
		var pieceholder:MovieClip = new MovieClip();
		portfolio.addChild(pieceholder); // "portfolio" is a named MC on the stage
		pieceholder.buttonMode = true;
		var pieceloader = new Loader();
		var pictURLReq:URLRequest = new URLRequest(loadedxml.piece.image.text()*);
		pieceholder.addChild(pieceloader);
		pieceloader.load(pictURLReq);

		pieceloader.contentLoaderInfo.addEventListener(Event.COMPLETE, pieceloaderComplete);

		// text
		thedescription = loadedxml.piece.description.text()*;
		words = "Title: " + thedescription;
		var thetext:TextField = new TextField();
		var myFont:Font = new Arial();
		var myFormat:TextFormat = new TextFormat();
		myFormat.font = myFont.fontName;
		myFormat.size = 11;
		myFormat.color = 0x003366;
		myFormat.leading = 1;
		thetext.width = 200;
		thetext.height = 200;
		thetext.multiline = true;
		thetext.defaultTextFormat = myFormat;
		thetext.embedFonts = true;
		thetext.antiAliasType = AntiAliasType.ADVANCED;
		thetext.sharpness = 100;
		thetext.thickness = 500;
		thetext.x = 0;
		thetext.y = 205;
		pieceholder.addChild(thetext);
		thetext.htmlText = words;
		thetext.alpha = .0;
	}
}

function pieceloaderComplete(e:Event):void {
	thetext.alpha = 1; // this doesn't work
}

```

The text is loaded properly and the alpha is set to zero, but when I try and target it in the function pieceloaderComplete I get an error:

```php
ReferenceError: Error #1065: Variable thetext is not defined.
	at mottomo_fla::MainTimeline/pieceloaderComplete()

```

Help! How do I properly target the MC?

Thanks,  
trick
