# Noob: add child to main stage from within a method

**URL:** <https://forum.kirupa.com/t/noob-add-child-to-main-stage-from-within-a-method/309305>\
**Category:** Uncategorized\
**Created:** [May 11, 2010, 10:17pm UTC](https://forum.kirupa.com/t/noob-add-child-to-main-stage-from-within-a-method/309305 "2010-05-11T22:17:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![NeoDreamer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@NeoDreamer](https://forum.kirupa.com/u/NeoDreamer)\
**Post date:** [May 11, 2010, 10:17pm UTC](https://forum.kirupa.com/t/noob-add-child-to-main-stage-from-within-a-method/309305/1 "2010-05-11T22:17:06Z")

</div>

I just began learning AS3. I’m simply trying to play an FLV video. How do you attach the video object to the main stage? I tried but it said that “stage” was undefined.

```php

package {
	import flash.media.*;
	import flash.net.*;
	import flash.display.*;
	
	public class Player {
		private var vid:Video;
		private var vidConnection:NetConnection;
		private var vidStream:NetStream;
		private var monitor:Object;
		
		public function Player() {
			this.vid = new Video();
			stage.addChild(this.vid);
			this.vidConnection = new NetConnection();
			this.vidConnection.connect(null);
			this.vidStream = new NetStream(this.vidConnection);
			
			this.monitor = new Object();
			this.monitor.onMetaData = this.onMetaData;
			this.monitor.onCuePoint = this.onCuePoint;
			this.vidStream.client = this.monitor;
			
			this.vid.attachNetStream(this.vidStream);
			this.vidStream.play("video.flv");
		}
		
		private function onMetaData(info:Object):void {
			trace("duration:", info.duration);
		}
		
		private function onCuePoint(info:Object):void {
			trace("cuepoint:", info.parameters.text);
		}
		
		private function init():void {
			
		}
	}
}

```
