WEB开发网
开发学院图形图像Flash 积少成多Flash(2) - ActionScript 3.0 基础之包、... 阅读

积少成多Flash(2) - ActionScript 3.0 基础之包、类、包外类、命名空间、属性、方法、接口和继承

 2009-11-05 00:00:00 来源:WEB开发网   
核心提示: PropertyTest.aspackageactionScript{importflash.display.Sprite;publicclassPropertyTestextendsSprite{//属性publicvarnickname:String;publicvarage:int;pri

PropertyTest.as

package actionScript
{
    import flash.display.Sprite;
    
    public class PropertyTest extends Sprite
    {
        // 属性
        public var nickname:String;
        public var age:int;
        
        private var _salary:int;
        
        public function PropertyTest()
        {
            
        }
        
        // getter方法
        public function get salary():int
        {
            return this._salary;
        }
        
        // setter方法
        public function set salary(s:int):void
        {
            this._salary = s;
        }
    }
}

StaticTest.as

package actionScript
{
    import flash.display.Sprite;
    
    public class StaticTest extends Sprite
    {
        // 静态属性
        public static const nickname:String = "webabcd";
        public static var age:int;
        
        public function StaticTest()
        {
            
        }
        
        // 静态方法
        public static function hello(s:String):String
        {
            return "hello: " + s;
        }
    }
}

上一页  1 2 3 4 5  下一页

Tags:积少成多 Flash ActionScript

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接