语录提交--登陆--注册--论坛交流--站长博客

AS3图形对象和绘图API

[作者:zrong][日期:2008-01-16][导航:Flash教程 >> ActionScript3 >> AS3图形对象和绘图API]
  

图形对象和绘图API

就像ActionScript1和2一样,ActionScript3也有绘图API,你可以使用它们在影片剪辑和sprite对象中绘制矢量线条或图形。使用ActionScript3,绘图API总是在显示对象(例如影片剪辑、sprite等等)的graphics属性(flash.display.Graphics)中使用。graphics属性表现为绘图API绘制出的一个动态层。就像以前一样,这个动态层位于绘图目标对象的所有的子对象之下。在ActionScript3中,提供了一些新的方法让你绘制矩形、圆形以及圆角矩形变得更加容易。它们包括:

范例:

// draw a blue rounded rectangle:
var square:Sprite = new Sprite();
square.graphics.beginFill(0xFF);
square.graphics.drawRoundRect(0, 0, 100, 50, 10, 10);
square.graphics.endFill();
addChild(square);

===========================================================

原文如下:

Graphics Object and the Drawing API

Like ActionScript 1 and 2, ActionScript 3 also has a drawing API that allows you to draw vector lines and shapes dynamically in movie clips and sprites. With ActionScript 3, however, the drawing API is now used off of an object within display objects (movie clips, sprites, etc.) defined as graphics (flash.display.Graphics). This graphics property represents the dynamic drawing layer where drawing API drawings exist. Like before, it is placed below all children of the target object. Also, in ActionScript 3, you have new methods that help you more easily create rectangles, circles, and even rounded rectangles. These include:

* drawCircle(x:Number, y:Number, radius:Number):void
* drawEllipse(x:Number, y:Number, width:Number, height:Number):void
* drawRect(x:Number, y:Number, width:Number, height:Number):void
* drawRoundRect(x:Number, y:Number, width:Number, height:Number, ellipseWidth:Number, ellipseHeight:Number):void

Example:
ActionScript Code:(同上)

这里是原文地址

[文章热度:]


上一页:AS3 中This的引用

下一页:AS3 新的变量类型

最新话题

网站导航

搜索

网站公告


Copyright 2007 51as.com. Some Rights Reserved.
鄂ICP备07003189号

Powered by: KingCMS 5.0.1.0217