Link to home
Start Free TrialLog in
Avatar of GaryW021199
GaryW021199

asked on

Problems dragging overlapping buttons

Flash 5:

I've got a vertical line overlapping a horizontal line.  The user can click and drag either one, but they always intersect.  I can do this easily by making each line a movie clip ("HorzClip" and "VertClip") and scripting them appropriately.  

The problem I had with this is that the cursor doesn't change when over the lines.  So I made the lines into buttons ("HorzButton" and "VertButton") within each corresponding movie clip.  For example, VertClip>VertButton>vertical_line.  An additional advantage of using buttons here is that I can automatically change the color of the line as the user drags it by changing the "down" state of the button.

Now here's the weird part.  The vertical line works perfectly.  But I have several problems with the horizontal line, even though the code is almost identical.

Problem 1:  If I click and hold the mouse over the horizontal line FIRST, the color of the line flickers -- it flashes to the "down" color and immediately returns to the normal color, even though I'm still holding the mouse button down.  I can drag the line and move it around but it has the wrong color.  If I click the vertical line FIRST, release it and then click the horizontal line, the color behaves and stays the "down" color (for a while, anyway... see below) until I release it.

Problem 2: If I click and drag the horizontal line for a while (several seconds), eventually the color will revert to the "up" color, even though I'm still dragging the line.

Problem 3: If I continue to drag the horizontal line, eventually it will not stop dragging even after I release the mouse button.

None of these problems occur with the vertical line.

All my code is in the button action for each line, as follows.  This is the only scripting in the whole project.  BoundsBoxVert and BoundsBoxHorz are hidden movie clips that identify the dragging constraints for each line.

VertButton:

on (press) {
  var Bounds = _parent.BoundsBoxVert.getBounds(_parent);
  var BoxLeft = Bounds.xMin;
  var BoxRight = Bounds.xMax;
  var BoxTop = Bounds.yMin;
  var BoxBottom = Bounds.yMax;
  var HalfHeight = Math.floor((BoxBottom-BoxTop)/2);
  var BoxMiddleY = BoxTop+HalfHeight;
  startDrag (this, true, BoxLeft, BoxMiddleY, BoxRight, BoxMiddleY);
}

on (release, releaseOutside) {
  stopDrag ();
}

HorzButton:

on (press) {
  var Bounds = _parent.BoundsBoxHorz.getBounds(_parent);
  var BoxLeft = Bounds.xMin;
  var BoxRight = Bounds.xMax;
  var BoxTop = Bounds.yMin;
  var BoxBottom = Bounds.yMax;
  var HalfWidth = Math.floor((BoxRight-BoxLeft)/2);
  var BoxMiddleX = BoxLeft+HalfWidth;
  startDrag(this, true, BoxMiddleX, BoxTop, BoxMiddleX, BoxBottom);
}

on (release, releaseOutside) {
  stopDrag();
}
Avatar of rootdir
rootdir

Please send your movie to rotdir@hotmail.com I will take a look
Avatar of GaryW021199

ASKER

Is that rotdir@hotmail.com or rootdir@hotmail.com?
it is rotdir@hotmail.com
I am just waiting for your movie
ASKER CERTIFIED SOLUTION
Avatar of rootdir
rootdir

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial