- package
{
import flash.display.Sprite;- public class Test extends Sprite
{
private var a : Boolean;
public var b : Boolean;
internal var c:Boolean;- private function test1() : void
{- }
- public function test2() : void
{- }
internal function test3():void
{
}- public function Test()
{
super();
trace( this.hasOwnProperty( "a" ));//false
trace( this.hasOwnProperty( "b" ));//true
trace( this.hasOwnProperty( "c" ));//false
trace( this.hasOwnProperty( "test1" ));//false
trace( this.hasOwnProperty( "test2" ));//true
trace( this.hasOwnProperty( "test3" ));//false
}
}
}
hasOwnProperty只能判断public权限的属性和方法是否存在,非public的属性和方法一律都为false,如果没注意这点,很容易导致动态获取属性或方法时程序出现所谓的bug