Pay for Hesitation: Scope summary

Pages

2010年3月5日 星期五

Scope summary


package{

 //Global scope
 
 public class A {

  //Class scope

  public static function b():void
  {
    //Static method scope
  }

  public function c():void
  {
    //Class method scope

    function d():void{
      // Nested method scope
    }
  }

 }

}

// Global scope


注意:global scope有兩處


add at 2010/4/8
Conditionals and loops do not have their own scope in ActionScript3.
(p.335 in Chapter 17: Namespaces)

That's why the complier always issues a warning message "Duplicate variable definition" when I put following codes in a function.

for(var i:int = 1; i < 10; i++)
 doSomething();
}

for(var i:int = 1; i < 10; i++)
 doSomething();
}

this thread also talked about same issue.

沒有留言: