# Accessing an object from an another one

**URL:** https://forum.kirupa.com/t/accessing-an-object-from-an-another-one/317446
**Category:** flash
**Created:** [December 20, 2010, 11:41pm UTC](https://forum.kirupa.com/t/accessing-an-object-from-an-another-one/317446 "2010-12-20T23:41:23Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![tolgainam](https://avatars.discourse-cdn.com/v4/letter/t/bbe5ce/32.png) [@tolgainam](https://forum.kirupa.com/u/tolgainam)
#### Post date: [December 20, 2010, 11:41pm UTC](https://forum.kirupa.com/t/accessing-an-object-from-an-another-one/317446/1 "2010-12-20T23:41:23Z")

</div>

Hello,  
I am trying to access an object I created from an another object.

I have the document class main.as and two other classes player.as and console.as

circle.as is draws a circle on the stage and logger.as is a simple class that I will use to trace stuff and record data.

In main.as I created both two objects and I want to be able to access the console class methods from player class (and all the future classes that I will write)

Main.as:

```php

package com.tolgainam
{

	import com.tolgainam.Console;
	import flash.display.MovieClip;

	public class main extends MovieClip
	{
		private var oConsole:Object;
		private var oPlayer:Object;
		function main()
		{
			//Instaniate Console, Player
			oConsole = new Console();
			oConsole.log(123);
			
			oPlayer = new Player();
			

		}
	}
}

```

Player.as

```php

package com.tolgainam {
	
	import flash.display.MovieClip;
	
	public class Player extends MovieClip {
		
		private var bIsUp:Boolean = false;
		private var bIsDown:Boolean = false;
		private var bIsLeft:Boolean = false;
		private var bIsRight:Boolean = false;
		private var iPlayerHp:uint = 100;
		private var iPlayerSpeed = 7;
		
		
		function Player() {
			
			oConsole.log('A new creature has born');
[COLOR="Red"]Outputs Error:
/Users/tolgainam/AS3/UGHH/com/tolgainam/Player.as, Line 24	1120: Access of undefined property oConsole.

[/COLOR]
			
			

		}

		
	}
	
}

```

Console.as

```php

package com.tolgainam {
	
public class Console {
	public function Console(){
		trace('Console Started');
	}
	
	public function log(traceInput) {
		trace(traceInput);
		
	}
}
}

```
