Okay, I want to make a timeline.
You slide an arrow from left to right and if you drop the arrow on one of the two dropboxes (those transparant squares), a text appears above the timeline.
Pretty basic stuff and as you can see I managed with that (I attached the example .fla for your convenience ).
However, it needs that final touch, and with this I need your help
Basically I want to add two other functionalities to it, but I don’t know how.
1. when you slide the arrow now, you can drop it on any place. But that I don’t want that. What I want is that the arrow snaps to the dropbox nearest to the position of the arrow.
or if not possible, at least snap back to the last dropbox (seen from left to right) that was passed or dropped on.
So on default I guess it should snap back to the start.
I guess I would need the getproperty function for that, but quite frankly I haven’t got a clue how to use that in this particular case.
the second thing I would like is this:
now the text only appears when the arrow is dropped on the dropbox. But I want that also when the arrow is slided over the dropbox, the text appears… and on rollOut the text disappears again.
Ofcourse I could put a rollOver script on that dropbox, but in this case it doesn’t work, since as you can see with defining the space the arrow can slide in, it is very well possible that the cursor is far below the arrow and therefore also dropbox, so that doesn’t work.
So how could I do this?
If someone could help me out, or perhaps point me to a tutorial which covers this, I would be most grateful
I keep forgeting that you´re a flash 5 user(the fla is in mx).
But here is the code for the button inside the mc to be dragged:
on (press) {
startDrag (this, false, 19, 103, 350, 103);
_root.text.gotoAndStop(1);
}
on (release) {
stopDrag ();
// snaps back if it´s not on the right position
if (this._x < 230) {
this._x = 40;
}
if (this._x > 244) {
this._x = 40;
}
//
if (this._droptarget == "/dropbox1") {
_root.text.gotoAndStop(2);
}
else if (this._droptarget == "/dropbox2") {
_root.text.gotoAndStop(3);
}
}
You´ll have to change the registration point of the mc and the button to the left. Do you know how to do that?
you mean that I should make sure that the top left corner is the part with what I align the mc and button???
> and with these if statements I can also fix that if the arrow is near the dropbox, it also snaps to the dropbox (so exactly positioned over the dropbox?).
you mean that I should make sure that the top left corner is the part with what I align the mc and button???
No. Go to the mc´s timeline align the button to the left, then go to the button´s timeline do the same to the fill.
and with these if statements I can also fix that if the arrow is near the dropbox, it also snaps to the dropbox (so exactly positioned over the dropbox?).
> now the text only appears when the arrow is dropped on the dropbox. But I want that also when the arrow is slided over the dropbox, the text appears… and on rollOut the text disappears again.
**>**and apart from that, when the arrow snaps to the dropbox, the text isn’t displayed, only when you drop it on it with the cursor.
How can I change that it shows the text also when the arrow snaps on the dropbox???
else if this._x > 244 && this._x < 270
_root.text.gotoAndStop(4);
these numbers are wrong: this._x > 244 && this._x < 270
on this code:
onClipEvent (enterFrame) {
// shows the message if pointer is on the spot
if (this._x > 230 && this._x < 244) {
_root.text.gotoAndStop(3);
}
}
the this._x > 230 && this._x < 244 tell us that if the pointer (that has a width of 14px) is exactly between 230px and 244px in the x axis the condition is met. note that 244px - 230px = 14px(width of the pointer). So, if you will gonna add more message spots you will have to calculate the exactly location were the pointer should be to a message appear, just as I did in the code above.
add a trace command to the enter frame code on the mc like this:
trace (this._x);
and then test the movie, drag the pointer around the screen and write down the values in the output window, where you want the pointer to be (from beginning to end).
onClipEvent (enterFrame) {
// shows the message if pointer is on the spot
if (this._x > 40&& this._x < 54) {
_root.text.gotoAndStop(2);
}else if (this._x > 230&& this._x < 244) {
_root.text.gotoAndStop(3);
// hides the message if pointer is not on the spot
}else if (_root.pointer.spot == 0) {
_root.text.gotoAndStop(1);
}
}
code for the button inside the mc:
on (press) {
startDrag (this, false, 5, 103, 350, 103);
_root.pointer.spot = 0;
}
on (release, releaseOutside) {
stopDrag ();
// snaps to position one
if (this._x > 40&& this._x < 54) {
this._x = 40;
_root.pointer.spot = 1;
// snaps to position two
}else if (this._x > 230 && this._x < 244) {
this._x = 230;
_root.pointer.spot = 2;
// snaps back if it´s not on the right position
} else {
this._x = 6;
_root.pointer.spot = 0;
}
//
if (this._droptarget == "/dropbox1") {
_root.text.gotoAndStop(2);
}
else if (this._droptarget == "/dropbox2") {
_root.text.gotoAndStop(3);
}
}