3 Replies Latest reply on Jan 8, 2010 7:43 AM by kglad

    Donut shape draw api found, but only works on the stage?

    chrisatflash Level 1

      Hello, I found a nice script for drawing a donut shape.
      I don't know why it only works with using 'this' or ' _root' . You should be able to apply this to a movieclip?
      Or am i missing something?

       

      This is the script:

      this.createEmptyMovieClip("emptymovie",2);

      emptymovie._x = 220;

      emptymovie._y = 150;

       

       

      function DrawCirclePart(mc, xPos, yPos, radius, angle, rotatie, dir) {

          if (dir == 1) {

              angle = 0-angle;

              rotatie = rotatie-angle;

          }

          accuracy = 10;

          var span = (Math.PI/(360/angle))/accuracy;

          var controlRadius = radius/Math.cos(span);

          var anchorAngle = Math.PI*((rotatie-90)/180), controlAngle = Math.PI*((rotatie-90)/180);

       

       

          for (var i = 0; i<accuracy; ++i) {

              controlAngle = anchorAngle+span;

              anchorAngle = controlAngle+span;

              mc.curveTo(xPos+Math.cos(controlAngle)*controlRadius, yPos+Math.sin(controlAngle)*controlRadius, xPos+Math.cos(anchorAngle)*radius, yPos+Math.sin(anchorAngle)*radius);

          }

       

      }

       

       

      function Wedge(mc, Wradius1, Wradius2, Wangle, Wrotatie) {

      //mc.lineStyle(1, 0, 100);

         mc.beginFill(0x0000FF);

          mc.moveTo(Math.cos(Math.PI*((Wrotatie-90)/180))*Wradius1, Math.sin(Math.PI*((Wrotatie-90)/180))*Wradius1);

          mc.DrawCirclePart(mc, 0, 0, Wradius1, Wangle, Wrotatie, 0);

          mc.lineTo(Math.cos(Math.PI*((Wrotatie-90+Wangle)/180))*Wradius2, Math.sin(Math.PI*((Wrotatie-90+Wangle)/180))*Wradius2);

          mc.DrawCirclePart(mc, 0, 0, Wradius2, Wangle, Wrotatie, 1);

          mc.lineTo(Math.cos(Math.PI*((Wrotatie-90)/180))*Wradius1, Math.sin(Math.PI*((Wrotatie-90)/180))*Wradius1);

      mc.endFill();

      }

       

      //This works

      //Wedge(this, 30, 50, 320, 180);

       

      //This does not work?

      //Wedge(emptymovie, 30, 50, 320, 180);