Accessing object on stage from class

I’m creating a game and I want to test if an object (created by a class)
hit the main character (created on the stage)
I tried referencing the main character in the class (parent.main_character),
but it states that it doesn’t recognize that instance name.

How can I reference an object on the main stage through a class?


Have you tried:


I think you should better make a function to reference the object which created on the stage and assign it to a variable.

var myOwnObj:Object = new Object();
public function getMyOnwObj():Object
return myOwnObj;

when you want the myOwnObj then you can call this function,if you put this function in a public class then it can be called every where,
if you want to disable the object then you just change the function only.

Anogar, it doesn’t work.
I tried:

if(this.hitTestObject(parent.getChildByName("square"))) trace("yeah");


if(this.hitTestObject(parentObject.getChildByName("square"))) trace("yeah");


if(this.hitTestObject(stage.getChildByName("square"))) trace("yeah");


if(this.hitTestObject(Stage.getChildByName("square"))) trace("yeah");

(square is the name of the object on the stage)
They all give me this error:
1119: Access of possibly undefined property square through a reference with static type Class.

any other suggestions?