# Attaching a movie from library after an event?

**URL:** <https://forum.kirupa.com/t/attaching-a-movie-from-library-after-an-event/258194>\
**Category:** Uncategorized\
**Created:** [April 21, 2008, 10:07pm UTC](https://forum.kirupa.com/t/attaching-a-movie-from-library-after-an-event/258194 "2008-04-21T22:07:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![stuluk28](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/stuluk28/32/2775_2.png) [@stuluk28](https://forum.kirupa.com/u/stuluk28)\
**Post date:** [April 21, 2008, 10:07pm UTC](https://forum.kirupa.com/t/attaching-a-movie-from-library-after-an-event/258194/1 "2008-04-21T22:07:55Z")

</div>

Hi all,

my base class loads xml data and then creates the navigation etc in the handler method. In the handler tracing ‘this’ still returns the base class but can I cannot use this.addChild(something) to add a new MovieClip to the stage. but if I paste the same code in to the constructor or init methods then it works?? it also works if I use this.someMoveClip.addChild(something) just not directly on this? This is really confusing me, code below

```auto
package
{
	import flash.display.MovieClip;
	import flash.events.Event;
	
	public class Application extends MovieClip
	{
		public var xmlData:XmlData;
		
		private var _navigation:Navigation;
		private var _home:HomePage;
		
		public function Application()
		{
			trace('New Application');
			init();
		}
		
		private function init()
		{
			// load the xml data
			xmlData = new XmlData();
			xmlData.addEventListener("onLoad", initPages);
			xmlData.load('work.xml');
		}
		
		private function initPages(e:Event)
		{
			trace('handleXmlLoaded')

			var s:Square = new Square();
			s.x = 0;
			s.y = 0;
			this.addChild(s);

			// build navigation
			_navigation = new Navigation(this.navigation_mc);
		}
	}
}

```
