OOP - basic test

Hiya - Itd be great if someone could help me out here … I want to use OOP as a test, to put an MC on the Stage.
Here goes - be patient - im trying to also keep it as clean as poss for peeps to actually get in here and help…

I have the following:
my FLA with doc class Main.as,
Main.as (calls Task)
Task.as (calls Ball)
Ball.as (Draws a circle)

[1] Main just tells Task to do what ever he’s meant to do.
[2] Task gets the Ball class, and puts an instance of Ball on the Stage.

Simple … &I know I could just put Ball on the Stage in my doc class - but thats not the aim.

Ill just show my simplified packages - because this is where I can learn how to make this work… (Thanks in advance :wink:
Main.as

public class Main extends MovieClip      {  
        public function Main()  
        {  
  	initiate();
        }  
        public function initiate()
        {
        var ball:Task = new Task();
	addChild(ball);
        }
    }  

Task.as

public class Task extends Sprite      {  
        private var b1:Ball;  
  
        public function Task() 
	{  
            b1 = new Ball(20);  
            addChild(b1);  
        }  
    }

Ball.as

import flash.display.Sprite;	
	public class Ball extends Sprite
	{
		private var radius:Number;
		private var color:uint;
		
		public function Ball(radius:Number = 40)
		{
			this.radius = radius;
			this.color = Math.random()*color;
			init();	
		}
		public function init():void
		{
			graphics.beginFill(color);
			graphics.drawCircle(0,0,radius);
			graphics.endFill();		
		}
	}	

OK - so that works … BUT I dont know why! Thats not my stupid question - but rather about why it does - Because if you noticed - for it to work - I have to ‘addChild(ball)’ in Main.as to get it to go on the stage… But I want Task.as to do that when I ask ‘addChild(b1)’ to do so … And also just by calling Task - it does what I want it to - without having to declare what in the Main class…

ANY TIPS or ADVICE would be GREATLY APPRECIATED!
:slight_smile: