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?