0

我找到了一个关于如何制作动态未填充和填充圆的教程。这将从滑块获取输入来确定绘制了多少圆。我想将它用于预加载器。与作者不同,我想在文档类中使用它。我得到了 1061: Call to a possibly undefined method createEmptyMovieClip through a reference with static type document.1120: Access of undefined property circ1.第二个是由第一个引起的。我如何让它在我的文档类中工作?提前致谢!

//original code
// x: circles center x, y: circles center y
// a1: first angle, a2: angle to draw to, r: radius
// dir: direction; 1 for clockwise -1 for counter clockwise
MovieClip.prototype.CircleSegmentTo = function(x, y, a1, a2, r, dir) {
     var diff = Math.abs(a2-a1);
     var divs = Math.floor(diff/(Math.PI/4))+1;
     var span = dir * diff/(2*divs);
     var rc = r/Math.cos(span);
     this.moveTo(x+Math.cos(a1)*r, y+Math.sin(a1)*r);
     for (var i=0; i<divs; ++i) {
          a2 = a1+span; a1 = a2+span;
          this.curveTo(
               x+Math.cos(a2)*rc,
               y+Math.sin(a2)*rc,
               x+Math.cos(a1)*r,
               y+Math.sin(a1)*r
          );
     };
     return this;
};

// empty
this.createEmptyMovieClip("circ1",1);
circ1._x = 100;
circ1._y = 150;
circ1.radius = 35;

circ1.onEnterFrame = function(){
    this.clear();
    var endAngle = 2*Math.PI*percentLoaded;
    var startAngle = 0;
    if (endAngle != startAngle){
        this.lineStyle(2,0,100);
        this.CircleSegmentTo(0, 0, startAngle, endAngle, this.radius, -1);
    }
}

//filled
this.createEmptyMovieClip("circ2",2);
circ2._x = 220;
circ2._y = 150;
circ2.radius = 35;
/* code in tutorial i left out since its for a second filled in circle
circ2.onEnterFrame = function(){
    this.clear();
    var endAngle = 2*Math.PI*slider.value/100;
    var startAngle = 0;
    if (endAngle != startAngle){
        this.lineStyle(2,0,100);
        this.beginFill(0xFF9999,100);
        this.lineTo(this.radius,0);
        this.CircleSegmentTo(0, 0, startAngle, endAngle, this.radius, -1);
        this.lineTo(0,0);
        this.endFill();
    }
}
*/
4

1 回答 1

0

您获得的代码是使用 Actionscript 2 制作的,并且您正在为 Actionscript 3 构建它,因此您必须将其重新编码为 Actionscript 3 或为 AS2 编译它。

于 2011-10-31T18:04:07.247 回答