1 Reply Latest reply on Oct 17, 2006 11:07 AM by Newsgroup_User

    Graphing y=bx+a

    creativkook
      So I have a graph that I need to make that is graphed from y=bx+a. I've looked through the forums, and the only graphing equations I can find involve sin and cosin, which this does not. Does anyone have any ideas?
        • 1. Re: Graphing y=bx+a
          Level 7

          "creativkook" <webforumsuser@macromedia.com> wrote in message
          news:eh323v$ov1$1@forums.macromedia.com...
          > So I have a graph that I need to make that is graphed from y=bx+a. I've
          > looked
          > through the forums, and the only graphing equations I can find involve sin
          > and
          > cosin, which this does not. Does anyone have any ideas?
          >



          Here is something that will work, or at least give you an idea.


          Try this code:

          var mc = _root.createEmptyMovieClip("mc", 1);

          with (mc) {
          moveTo(Stage.width/2, 0);
          lineStyle(1, 0x666, 100);
          lineTo(Stage.width/2, Stage.height);
          moveTo(0, Stage.height/2);
          lineTo(Stage.width, Stage.height/2);
          }

          var penIsDown:Boolean = false;

          function createGraph(slope:Number, yintercept:Number, color:Number):Void {
          for (var i:Number = -Stage.width/2; i<Stage.width/2; i += 10) {
          xPos = i;
          yPos = (slope*xPos+yintercept);
          with (_root.mc) {
          if (! penIsDown) {
          penIsDown = true;
          lineStyle(2, color, 100);
          moveTo(xPos+Stage.width/2, (Stage.height/2 - yPos));
          }
          lineTo(xPos+Stage.width/2, (Stage.height/2 - yPos));
          }
          }
          penIsDown = false;
          }
          createGraph(1, 4, 0xff0000);
          createGraph(1.5, -10, 0xffff00);
          createGraph(-2, 4, 0x00ff66);