Function-Level Variables and Functions : Variable scope : Data Type Flash / Flex / ActionScript examples


Flash / Flex / ActionScript examples » Data Type » Variable scope »

 

Function-Level Variables and Functions


 

package{
  import flash.display.Sprite;
  
  public class Main extends Sprite{
    public function Main(){
        var myTest:ScopeTest = new ScopeTest();
        myTest.showGreeting()// Displays: Hello, world!
     //   trace(myTest.message); // undefined
    }
  }
}
class ScopeTest {
      public static var foo:String = "bar";

      public var answer:Number = 42;

      public function showGreeting():void {
         var message:String = "Hello, world!";
         trace(message);
      }

}

        



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


Flash / Flex / ActionScript examples

 Navioo Data Type
» Variable scope