# Gettting access to instances

**URL:** <https://forum.kirupa.com/t/gettting-access-to-instances/309384>\
**Category:** flash\
**Created:** [May 13, 2010, 4:40pm UTC](https://forum.kirupa.com/t/gettting-access-to-instances/309384 "2010-05-13T16:40:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![RossKidd](https://avatars.discourse-cdn.com/v4/letter/r/53a042/32.png) [@RossKidd](https://forum.kirupa.com/u/RossKidd)\
**Post date:** [May 13, 2010, 4:40pm UTC](https://forum.kirupa.com/t/gettting-access-to-instances/309384/1 "2010-05-13T16:40:28Z")

</div>

so I have been declaring my instances inside the package

public var projectDetail:ProjectDetail = new ProjectDetail();

which is fine but I don’t really want to create the instance automatically when the class is created and I do not need to make them public but the problem is if I create in in a function

public function createDetail() {

var projectDetail:ProjectDetail = new ProjectDetail();  
stage.addChild(projectDetail);

}

public function deleteDetail() {

stage.removeChild(projectDetail);

}

I get his error, 1120: Access of undefined property projectDetail.

because the variable only exists in its own scope, it there an alternative technique rather than use public variables all the time?
