Actionscript 3 - First Steps IV

      FLASH 2005-10-19 23:0
//第一个可以看到图形效果的代码
If you have seen our first examples, you may have wondered, if we can do more with a MovieClip than just trace. And yes indeed, the good old drawing api is still intact. It was just pushed down to the member MovieClip.graphics.
//使用MovieClip同trace一样需要导入相应的文件
package {
        import flash.display.MovieClip;
        
        public class Test extends MovieClip {
                public function Test() {
                        
                        var bgColor:int = 0xff0000;
                        var size:int = 400;
                        var count:int = 300;
                        graphics.beginFill(bgColor);
                        for( var i:int=0; i<count; i++){
                                graphics.lineTo(
                                       Math.floor(size*Math.random()), 
                                       Math.floor(size*Math.random()));
                        }
                        graphics.endFill();
                }
        }
}


Additionally there are new methods like drawRect and drawCircle, which make drawing a lot more convenient these days.

Cheers,
Ralf.

/////////////////
因为是个人读书的笔记,所以没有进行翻译,只是对其中关键地方进行注释。如有错误欢迎指出。
原文转载自: www.he
lpqlodhelp.com/blog/
标签集:TAGS:
回复Comments() 点击Count()

回复Comments

{commenttime}{commentauthor}

{CommentUrl}
{commentcontent}