# Find x-intercepts & slide parabola?

**URL:** <https://forum.kirupa.com/t/find-x-intercepts-slide-parabola/224680>\
**Category:** Uncategorized\
**Created:** [May 4, 2007, 12:28pm UTC](https://forum.kirupa.com/t/find-x-intercepts-slide-parabola/224680 "2007-05-04T12:28:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![flashpipe](https://avatars.discourse-cdn.com/v4/letter/f/839c29/32.png) [@flashpipe](https://forum.kirupa.com/u/flashpipe)\
**Post date:** [May 4, 2007, 12:28pm UTC](https://forum.kirupa.com/t/find-x-intercepts-slide-parabola/224680/1 "2007-05-04T12:28:30Z")

</div>

Okay, I’ve given up on my previous attempt [here](http://board.flashkit.com/board/showthread.php?t=729793) and am trying a different tact.

I’m using the original parabola script from the parabola movie [here](http://www.flashkit.com/movies/Scripting/Maths/Graph_pl-Brave_Me-11568/index.php) . I’ve adjusted it so that the vertex is affected by the vertex slider (a), and adjusts itself when you slide the x-intercept sliders.

Here’s the new problem…any idea what the math would be to:  
a) identify the two x-intercepts so they display in their respective text box  
b) and this is the big one, what equation will keep one x-intercept stationary while the other one slides back & forth?

```auto

this.createEmptyMovieClip("mygraph2", 100);
mygraph2.onEnterFrame = function() {
    clear();
    var drawScale = 0;
    _global.var_a = (this._parent._parent.sliderPara_a.slide._x/5)+(this._parent._parent.sliderPara_p.slide._x/2)+(this._parent._parent.sliderPara_q.slide._x/2);
    //_global.var_p = this._parent._parent.sliderPara_p.slide._x*10;
    _global.var_p = 0;
    //_global.var_q = this._parent._parent.sliderPara_q.slide._x*10;
    _global.var_q = 0;
    _global.var_x1 = 0;
    _global.var_x2 = 0;
    //each slider sets a variable, depending on which one you are dragging...I think this 
    // will be the way to adjust this._parent._x based on which slider you're dragging, but
    // the math here is completely wrong...
    if (_global.x1) {
        this._parent._x = this._parent._parent.sliderPara_p.slide._x;
    } else if (_global.x2){
        this._parent._x = this._parent._parent.sliderPara_q.slide._x;
    }
    //trace(this._parent._parent.sliderPara_q.slide._x);
    //trace(this._parent._x);
    this._parent._parent.display_a = _global.var_a;
    //solve for x1
    this._parent._parent.display_p = -.6;
    //solve for x2
    this._parent._parent.display_q = .6;
    if (this._parent._parent.display_p>0) {
        temp_p = "- "+this._parent._parent.display_p;
    } else if (this._parent._parent.display_p<0) {
        temp_p = "+ "+(this._parent._parent.display_p*-1);
    } else if (this._parent._parent.display_p == 0) {
        temp_p = "- 0";
    }
    if (this._parent._parent.display_q>0) {
        temp_q = "- "+this._parent._parent.display_q;
    } else if (this._parent._parent.display_q<0) {
        temp_q = "+ "+(this._parent._parent.display_q*-1);
    } else if (this._parent._parent.display_q == 0) {
        temp_q = "- 0";
    }
    this._parent._parent.display_function = "y= "+this._parent._parent.display_a+"(x "+temp_p+")(x "+temp_q+")";
    lineStyle(1, 0x006600, 100);
    for (i=0; i<=250; i++) {
        _global.newX = i;
        _global.newY = ((((Math.pow(_global.newX, 2)*_global.var_a)+(_global.newX*_global.var_p))/50)+_global.var_q)+_global.var_a*-20;
        //_global.newY = _global.var_a(_global.newX-_global.var_p)(_global.newX-_global.var_q);
        if (_global.newY>250) {
            _global.newY = 251;
        }
        if (_global.newY<-250) {
            _global.newY = -251;
        }
        if (i == 0) {
            moveTo(_global.newX, _global.newY);
        } else {
            lineTo(_global.newX, _global.newY);
        }
    }
    for (i=0; i>=-250; i--) {
        _global.newX = i;
        _global.newY = ((((Math.pow(_global.newX, 2)*_global.var_a)+(_global.newX*_global.var_p))/50)+_global.var_q)+_global.var_a*-20;
        //_global.newY = _global.var_a(_global.newX-_global.var_p)(_global.newX-_global.var_q);
        if (_global.newY>250) {
            _global.newY = 251;
        }
        if (_global.newY<-250) {
            _global.newY = -251;
        }
        if (i == 0) {
            moveTo(_global.newX, _global.newY);
        } else {
            lineTo(_global.newX, _global.newY);
        }
    }
};

```

Any ideas or suggestions would be much appreciated! Here’s the fla so far…

Thanks!!!
