Solved

Problems dragging overlapping buttons

Posted on 2002-04-09
5
152 Views
Last Modified: 2010-04-03
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();
}
0
Comment
Question by:GaryW021199
  • 4
5 Comments
 
LVL 6

Expert Comment

by:rootdir
ID: 6934625
Please send your movie to rotdir@hotmail.com I will take a look
0
 

Author Comment

by:GaryW021199
ID: 6934683
Is that rotdir@hotmail.com or rootdir@hotmail.com?
0
 
LVL 6

Expert Comment

by:rootdir
ID: 6934702
it is rotdir@hotmail.com
0
 
LVL 6

Expert Comment

by:rootdir
ID: 6934704
I am just waiting for your movie
0
 
LVL 6

Accepted Solution

by:
rootdir earned 100 total points
ID: 6934868
I found answer for your problem.

May be it is bug in micromedia flash.

The horizontal function looses functionlity if you try to lock the mouse pointer in center like this

startDrag(this, true, BoxMiddleX, BoxTop, BoxMiddleX, BoxBottom);


and if you make it 'false' it works

startDrag(this, false, BoxMiddleX, BoxTop, BoxMiddleX, BoxBottom);

So dont lock mouse pointer, I think this will solve your problem

Cheers
RootDir
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now