Vishwas
Vishwas

Reputation: 1541

Adding Child to Document Class Vs Adding Child to Stage

The name of my DocumentClass is Main. So, what's the difference between :

var myClass:Main = new Main(); 
var mcInLibrary:MovieClip ; 

/////////////////////////////////////////

myClass.addChild(mcInLibrary) ;

////////  - VS - /////////////////////

myClass.stage.addChild(mcInLibrary) ;

/////////////////////////////////////////

Upvotes: 1

Views: 76

Answers (1)

Sr.Richie
Sr.Richie

Reputation: 5740

With

 myClass.addChild(mcInLibrary) ;

you're adding the mcInLibrary to the DisplayList of myClass.

With

 myClass.stage.addChild(mcInLibrary) ;

you're adding it to the stage in which myClass is instantiated. Every instance which is derived from DisplayObject has the property stage, which refers to the stage instance to which it is added (essentially the root of the Display list).

Upvotes: 1

Related Questions