Walter She's Blog

flash,flex ,javascript原创教程,web设计,Flash RIA,其它与之相关的内容.

« Ariaware RIA Platform 范例将文本文件当作XML使用 »

使用代码画圆

当你使用直线工具画一条直线的时候,你会发现线的两端是圆形的(Flash 8出来后你可以设置线的两个端点的形状为方形或圆形,现在我也没有使用过Flash 8,所以下面的规则不一定在Flash 8以及以后的版本上有效),如果直线足够短,线足够粗,这条直线看起来就是一个圆。

新建一flash文档,把下面的代码放在第一帧,测试影片你就会看到一个漂亮的圆形。

var clip:MovieClip = this.createEmptyMovieClip("circle_mc", 

                     this.getNextHighestDepth( ));

circle_mc._x = circle_mc._y = 150;

circle_mc.lineStyle(200, 0x0, 100);

circle_mc.moveTo(0, 0);

circle_mc.lineTo(0.2, 0);

延伸阅读:
新建一flash文档,把下面的代码放在第一帧,测试影片看看更有趣的效果。

function createPoint(dynaPoint, depth, x, y) {

  clip = this.createEmptyMovieClip(dynaPoint, depth);

  clip.lineStyle(20, 0x0, 100);

  clip.moveTo(0, 0);

  clip.lineTo(0.2, 0);

  clip._x = x;

  clip._y = y;

}

function drag( ) {

  this.startDrag(true);

  paper.onMouseMove = drawLine;

  this.onPress = drop;

}

function drop( ) {

  this.stopDrag( );

  delete (paper.onMouseMove);

  this.onPress = drag;

}

function drawLine( ) {

  this.clear( );

  this.lineStyle(2, 0x0, 100);

  this.moveTo(point1._x, point1._y);

  this.lineTo(point2._x, point2._y);

  updateAfterEvent( );

}

// Example usage:

createPoint("point1", 1, 100, 100);

createPoint("point2", 2, 120, 100);

point1.onPress = drag;

point2.onPress = drag;

this.createEmptyMovieClip("paper", 0);

  • quote 1.Billows
  • http://Billows.blog.5d.cn
  • 试了成功了,但是怎么也想不通这样可以画圆
    circle_mc.moveTo(0, 0);
    circle_mc.lineTo(0.2, 0);
    我只能理解
    _root.createEmptyMovieClip( "triangle", 1 );
    with (_root.triangle){
    beginFill (0x0000FF, 50);
    lineStyle (5, 0xFF00FF, 100);
    moveTo (200, 200);
    lineTo (300, 300);
    lineTo (100, 300);
    lineTo (200, 200);
    endFill();
    }
    这样的画三角形的代码
  • 2006-1-17 12:43:18 回复该留言
  • quote 2.jackyshe
  • 如果直线足够短,线足够粗,这条直线看起来就是一个圆.
  • 2006-1-18 17:30:32 回复该留言

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

日历

最新评论及回复

最近发表