In our DocumentClass we first need to import the NavBtn Class.  Then we need to declare a private var called _navBtn and declare it as a NavBtn.  See the code below:

package com.identityMine.documentClass
{
 import flash.display.MovieClip;
 import NavBtn;
 public class DocumentClass extends MovieClip
 {
  private var _navBtn:NavBtn
  public function DocumentClass()
  {
   trace("DocumentClass Initialized");
   
  }
 }
}


Now inside the Constructor we can instantiate a new NavBtn like I did in the code below:

package com.identityMine.documentClass
{
 import flash.display.MovieClip;
 import NavBtn;
 public class DocumentClass extends MovieClip
 {
  private var _navBtn:NavBtn
  public function DocumentClass()
  {
   trace("DocumentClass Initialized");
   _navBtn = new NavBtn();
  }
 }
}


Now if you run the application you will see that our Output Window has the "NavigationButton Initilized" trace statement as well as the "DocumentClass Initialized"  Sweet huh?  But wait, where, you ask is the NavBtn on the Stage?

Well, it is not there yet because we have just instantitaed it and not actually added it to the Stage.  So let's do that now. 

Under the instantiation of NavBtn add the following code so that now your DocumentClass Constructor looks like this:

public function DocumentClass()
  {
   trace("DocumentClass Initialized");
   _navBtn = new NavBtn();
   addChild(_navBtn);
   _navBtn.x = 100;
   _navBtn.y =100;
  }


Notice I put in a x and y coord value of 100 because default would have been 0 and 0 and hard to see.  So if you run our app now you will see a new NavBtn at x of 100 and y of 100. (see Figure 5-1).


Figure 5-1: Our new NavBtn has been added to the Stage at x of 100 and y of 100

Now, the next and final thing I am going to do is to add an Event Listener for _navBtn in our DocumentClass and then create a Event Handler to handle the event.  Let's move on and do that now!