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:
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
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
package com.tolgainam {
public class Console {
public function Console(){
trace('Console Started');
}
public function log(traceInput) {
trace(traceInput);
}
}
}