AS1 OOP: Object Scope
by senocular
Introduction
Probably one of the more difficult concepts to understand in
Actionscript, especially when first learning it, is
correctly referencing variable or object scope. A scope
refers to the referenceable place where variables and
objects exist. The scope itself refers to the containing
object, of where variables can be defined. The way you would
differentiate between a num property contained within 2
different objects is through each objects own unique scope.
The property is num in both objects, but since there are 2
different objects, there are 2 different num properties (2
different scopes).
- firstObject = {num: 1};
- secondObject = {num: 10};
- trace(firstObject.num); // traces 1
- trace(secondObject.num); // traces 10
So scope, for the most part, refers to which object.