Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drawing multiple lines - only last line survives

Status
Not open for further replies.

Roel018

Programmer
Jun 12, 2002
30
NL
Drawing multiple lines - only last line survives
================================================


Dear folks,
I'm doing a simple program where I have an MC which I can drag across screen. A line is then drawn from the last point (where I started to drag) to the new point (where I ended the drag). All works fine... so far. The problem is that when I start to drag the MC again to a new point, it does again create the right line but it deletes the old one !!.. Or at least it looks like it does.....

Now, I know it has to do with getNexHighestDepth() because when I change it into 100 for example it works fine.. However, for my real project i'm having this problem with (code below is just a simple sample I have setup beceause the orinal has 1000+ lines of code.. to much !) i MUST use getNexHighestDepth()..... But it doesn't work....

Here's the code (on the draggable MC):


on(press){
xnow = this._x;
ynow = this._y;
this.startDrag();
}

on(release){
this.stopDrag();
_root.createEmptyMovieClip ("triangle", getNextHeigestDepth());
with(_root.triangle){
lineStyle (4, 0xFF0000, 100);
moveTo (xnow, ynow);
lineTo (this._x, this._y);
}
}

P.s. This MC is in the _root.
Thnx a million !!!
 
Code:
var i = 1;
drag_mc.onPress= function(){
xnow = this._x;
ynow = this._y;
this.startDrag();
}

drag_mc.onRelease = function(){
this.stopDrag();
_root.createEmptyMovieClip ("triangle", i);
    with(_root.triangle){
         lineStyle (4, 0xFF0000, 100);
         moveTo (xnow, ynow);
         lineTo (this._x, this._y);
        }
		i++
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top