It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Flash Forum

Graph parabola in flash?

Moderator: Phate

Graph parabola in flash?

Postby flashpipe on Tue May 08, 2007 2:14 pm

I need to create a parabola between 3 points which are controlled by a slider:
the two points where the parabola crosses the x plane
the y location of the vertex of the parabola

I've tried adapting the code in:
http://www.flashkit.com/movies/Scriptin ... /index.php
but that doesn't let you set the x points.

I've got the code to set the location of the 3 points, but not sure what formula/convention I can use to draw the parabola between the points and have the ends extend across the grid?

Anyone have any idea what formula I might use?

See the code below to see what I'm talking about...or you can grab the fla at http://www.brianwpiper.com/gridParabola.fla

Code: Select all
para_mc.onEnterFrame = function() {
   this.p0._y = this._parent.sliderPara_p0.slide._x*5;
   this.p1._x = this._parent.sliderPara_p1.slide._x*5;
   this.p2._x = this._parent.sliderPara_p2.slide._x*5;
   if ((this.p1._x)<(this.p2._x)) {
      this.p0._x = (this.p2._x/2)-(this.p1._x/-2);
   } else {
      this.p0._x = (this.p1._x/2)-(this.p2._x/-2);
   }
   
   clear();
   lineStyle(1, 0, 100);
   moveTo(this.p1._x+this._x, this.p1._y+this._y);
   curveTo(this.p0._x+this._x, (this.p0._y*2)+this._y, this.p2._x+this._x, this.p2._y+this._y);
   /**/
   //text
   this._parent.display_a = (this.p0._y*2)/100;
   this._parent.display_p = (this.p1._x*2)/100;
   this._parent.display_q = (this.p2._x*2)/100;
};


Thanks!!
flashpipe
 
Posts: 2
Joined: Tue May 08, 2007 1:58 pm

Who is online

Users browsing this forum: No registered users and 0 guests

cron