Ok I have another drag question. I am getting sick of asking questions so frustrating at times! if only I was a guru like Pom :asian:
Ok I have been playing with dragging. I wanted to have a picture that you could load in dynamically and drag around, and when you released it would go back to its original position.
If anybody knows a tutorial of this PLEASE post it and out me out of my misery.
Anyway, as I am newbie, I though it may be best to make it do that when you pressed a “reset” button to start with because I think I will have to mess about with functions and things otherwise.
I can drag it about, and have created a the “reset” which sends the pic back to its start position 0,0.
The code in frame one to load it in is:
loadMovie("photo.jpg", "location");
location._x = 0;
location._y = 0;
_root.onMouseDown = function() {
startDrag("location", false, 0, 0, 500, 500);
};
_root.onMouseUp = function() {
stopDrag();
};
“location” is a movie clip symbol on the main timeline.
My button has the following code=
on (release) {
tellTarget ("location") {
trip = 1;
}
}
Basically “trip” is just a variable.
Attached to this movie clip instance “location” I have the following code
onClipEvent (load) {
_x = 0;
_y = 0;
rateOfChange = 5;
}
onClipEvent (enterFrame) {
if (trip == 1 && _root.location._x>0) {
_root.location._x -= rateOfChange;
}
if (trip == 1 && _root.location._y>0) {
_root.location._y -= rateOfChange;
}
}
onClipEvent (enterFrame) {
if (_root.location._x == 0 && _root.location_y == 0) {
_root.location.trip = 0;
}
}
The problem is this - it DOESN’T set trip to 0.
After its reset and you drag it out again it keeps trying to go back to 0 before you even press the button.
The irony of this is that this is kind of what I wanted to do originally…
How do I stop it from doing this? (how do I Unset trip = 1?)