新的as3 ..类结构和精灵

时间:2011-01-28 11:03:52

标签: actionscript-3

我是as3的新手,我正在尝试编写一个必须绘制内容的类...我无法弄清楚你是如何设置代码的?

播放器/ Player.as:

package player {
    import flash.display.Sprite;

    public class Player extends Sprite {
        public var loader = null;

        public function Player(){
            this.cnstr_loader();
        }

        private function cnstr_loader(){
            this.loader = new Sprite();
            addChild(this.loader);
            this.loader.graphics.lineStyle(1,0x000000);
            this.loader.graphics.beginFill(0x0000FF);
            this.loader.graphics.drawRect(0,0,10,10);
            this.loader.graphics.endFill();
            this.loader.x = 10;
            this.loader.y = 10;
            trace('e');
        }
    }
}

main.as:

import player.Player;
var _Player = new Player();

如何在自己的movieclip或sprite或其名称中绘制整个Player类?

1 个答案:

答案 0 :(得分:0)

addChild正是您要找的。您还应该阅读DisplayList