Okay, I’ve given up on my previous attempt here and am trying a different tact.
I’m using the original parabola script from the parabola movie here . 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?
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!!!