|
-
anyone else hear that?
Redraw/clear line??
I've got a movie where a user drags points and a line needs to be drawn between the minimum and maximum point. I've got everything working fine unless I make the line shorter...If I drag the points farther from each other, the line redraws fine, but, if I drag the points closer, the line doesn't redraw shorter...I tried using the clear function, but it just makes the line disappear entirely...
HELP!!
Here's the code, and I attached the fla:
Code:
var ptAry = [{x:105}, {x:130}, {x:200}];
var numPts = ptAry.length;
var minPt = 0;
var midPt = Math.floor(numPts/2);
var maxPt = numPts-1;
minRangeInd_mc._x = 105;
maxRangeInd_mc._x = 200;
for (var i = 0; i<numPts; i++) {
var myPt = attachMovie("pointMC", "p"+i, i, {_x:ptAry[i].x, _y:100});
ptAry[i].ID = myPt;
if (i == midPt) {
myPt.gotoAndStop(2);
}
this.createEmptyMovieClip("line_mc", this.getNextHighestDepth());
this.line_mc.lineStyle(2, 0x000000, 100);
this.line_mc.moveTo(ptAry[minPt].ID._x, minRangeInd_mc._y);
this.line_mc.lineTo(ptAry[maxPt].ID._x, maxRangeInd_mc._y);
myPt.onPress = startDragging;
myPt.onRelease = stopDragging;
myPt.onReleaseOutside = stopDragging;
}
function startDragging() {
this.startDrag(false, 0, 100, 300, 100);
this.onEnterFrame = function() {
for (var i = 0; i<numPts; i++) {
if (ptAry[i].ID == this) {
ptAry[i].x = this._x;
}
}
ptAry.sortOn("x", 16);
this._parent.minRangeInd_mc._x = ptAry[minPt].ID._x;
this._parent.maxRangeInd_mc._x = ptAry[maxPt].ID._x;
//this._parent.line_mc.clear();
this.line_mc.lineStyle(2, 0x000000, 100);
this._parent.line_mc.moveTo(ptAry[minPt].ID._x, minRangeInd_mc._y);
this._parent.line_mc.lineTo(ptAry[maxPt].ID._x, maxRangeInd_mc._y);
updateAfterEvent();
};
}
function stopDragging() {
delete this.onEnterFrame;
stopDrag();
}
stop();
Last edited by flashpipe1; 09-10-2007 at 01:37 PM.
Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|