# \[beginner\] reference object and stage

**URL:** <https://forum.kirupa.com/t/beginner-reference-object-and-stage/264667>\
**Category:** flash\
**Created:** [June 28, 2008, 11:02am UTC](https://forum.kirupa.com/t/beginner-reference-object-and-stage/264667 "2008-06-28T11:02:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![samroni](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@samroni](https://forum.kirupa.com/u/samroni)\
**Post date:** [June 28, 2008, 11:02am UTC](https://forum.kirupa.com/t/beginner-reference-object-and-stage/264667/1 "2008-06-28T11:02:59Z")

</div>

Hi all,

its me again with simple questions if you don’t mind answering.

- i have 1 fla and 1 class file.

- inside fla, i’ put one instance called “main” on the stage. And i put this code in frame 1:

[AS]var obj:StageHandler = new StageHandler(main);[/AS]

- inside class file, i put this code:

[AS]package {

```
import flash.display.MovieClip;
import flash.display.Stage;

public class StageHandler {
    
    var _stage;
    var _main;
    
    public function StageHandler(main_obj) {
        _stage = main_obj.stage;
        _main = main_obj;
        
        trace(_stage.stageHeight); // output: 400 
        trace(_main.height); // output: 200
    }
}

```

}  
[/AS]

it works perfectly. However i’m still confused with the as3 concept. in this class file, i successfully trace stage’s height and main’s height.

but, if i change the code in fla to:

[AS]var obj:StageHandler = new StageHandler(stage);[/AS]

and in class file to:  
[AS]package {

```
import flash.display.MovieClip;
import flash.display.Stage;

public class StageHandler {
    
    var _stage;
    var _main;
    
    public function StageHandler(thisStage) {
        _stage = thisStage;
        _main = thisStage.main;
        
        trace(_stage.stageHeight);  
        trace(_main.height); //1120: Access of undefined property main.
    }
}

```

}  
[/AS]

i cannot trace any main’s properties. why is that? isn’t “main” inside stage?

How do i access “main” via \_stage?

Thankyou all.

attached is the source.

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [June 28, 2008, 11:32am UTC](https://forum.kirupa.com/t/beginner-reference-object-and-stage/264667/2 "2008-06-28T11:32:24Z")

</div>

```auto
package {
	
	import flash.display.MovieClip;
	import flash.display.Stage;
	
	public class StageHandler {
		
		var _stage;
		var _main;
		
		public function StageHandler(thisStage) {
			_stage = thisStage;
			_main = thisStage.getChildAt(0).main;
			
			trace(_stage.stageHeight); // output: 400 
			trace(_main.height); // output: 200
		}
	}
}

```

[How stage, root, and MainTimeline Fit Together](http://www.kirupa.com/forum/showthread.php?p=2129548#post2129548) - by Senocular

---

<div class="post-metadata">

**Author:** ![samroni](https://avatars.discourse-cdn.com/v4/letter/s/2acd7d/32.png) [@samroni](https://forum.kirupa.com/u/samroni)\
**Post date:** [June 28, 2008, 12:30pm UTC](https://forum.kirupa.com/t/beginner-reference-object-and-stage/264667/3 "2008-06-28T12:30:26Z")

</div>

believe me i’ve read those article. but still i don’t get it.

can you explain why, in details?

---

<div class="post-metadata">

**Author:** ![Felixz](https://avatars.discourse-cdn.com/v4/letter/f/ecb155/32.png) [@Felixz](https://forum.kirupa.com/u/Felixz)\
**Post date:** [June 28, 2008, 12:54pm UTC](https://forum.kirupa.com/t/beginner-reference-object-and-stage/264667/4 "2008-06-28T12:54:58Z")

</div>

stage is an instance of Stage class and it’s Top DisplayObject (all starts here).  
Then the only child of stage is root (Document Class/Main Timeline).  
Ex. stage -\> root -\> someContainer -\> myClip
