Instance Level Variables and Methods are independent for each instance of the class : Variable scope « Data Type « Flash / Flex / ActionScript






Instance Level Variables and Methods are independent for each instance of the class

 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){

        var myTest:ScopeTest = new ScopeTest();
        trace(myTest.answer) //Displays: 42

    }
  }
}
class ScopeTest {
      public static var foo:String = "bar";

      public var answer:Number = 42;
}

        








Related examples in the same category

1.Static Method Scope
2.Instance Method Scope
3.ActionScript available scopes:
4.Class Level (Static) Variables and Methods are accessed by using the class name followed by the object name
5.Function-Level Variables and Functions