To register for an Internet.com membership to receive newsletters and white papers, use the Register button ABOVE.
To participate in the message forums BELOW, click here


A Flash Developer Resource Site

Go Back   Flash Kit Community Forums > General Help > Scripting & Backend

Reply
 
Thread Tools Search this Thread Display Modes
Old 08-15-2002, 08:40 AM   #1
EoinMD
Member
 
Join Date: Aug 2002
Posts: 42
Hi, the animation that I'm trying to build is probaly very simple, but I can't quite work it out?
What I'm trying to make is a basic drag and drop where the object ('dragt') slowly returns to it's starting point by following the target ('targett') in order to get there.

The problem is that the function I'm using to move it there ('movet' = pasted in below) keeps going. So that when you try to click on it again, it's still working and it causes a flickering between the movement it's trying to accomplish and the drag action.

I tried including a variable ('ton') to build in a basic on/off state into the function, so that it won't work until 'ton == 0', ton is made equal to 0 as part of the start drag action. However, as said, this only works once as the function is still going when you go back to click again. So the hitest (seen below) registers again and puts 'ton == 1' before the drag can even begin.

So... what I need is some way to tell the function to stop doing what it's doing when the movieclip returns to it's original co-ordinates?

Hopefully I'm explaining this in some way that makes a degree of sense and somebody can solve this, or has encountered something similar before,

thanks loads,

-Eoin McD


Here's the function:

setInterval(movet, 5);
// call the catchase function every 5 ms
function movet() {
// set x, y for cat closer to x, y of mouse
if (_root.ton == 0) {
_root.dragt._x = _root.dragt._x+(_root.targett._x-_root.dragt._x)/20;
_root.dragt._y = _root.dragt._y+(_root.targett._y-_root.dragt._y)/20;
}
if (_root.dragt.hitTest(_root.targett)) {
_root.ton = 1;
}
if (_root.ton == 1) {
gotoAndStop(1);
}
}
updateAfterEvent();

EoinMD is offline   Reply With Quote
Old 08-15-2002, 08:52 AM   #2
raven69
nobody
 
Join Date: Aug 2002
Posts: 269
You can put a function inside an empty movie clip (then it does not need to be a function anymore), that loops when you play it. When you dont want it, you just stop playing that movie.
raven69 is offline   Reply With Quote
Old 08-15-2002, 09:25 AM   #3
EoinMD
Member
 
Join Date: Aug 2002
Posts: 42
thanks

Thanks loads, I was trying to make life far too complicated.

That works a charm.
EoinMD is offline   Reply With Quote
Old 08-15-2002, 04:16 PM   #4
Wheels
Flash Video Moderator
 
Wheels's Avatar
 
Join Date: Dec 2000
Location: Minneapolis
Posts: 1,589
I've had a hard time getting this to work dynamically (using onEnterFrame) but the one sure fire way I've had success with is:

An empty MC inside the object you want to return.

Frame 1:

xHome=_parent._x;
yHome=_parent._y;

Frame 2:

if(_parent.snapBack) {
x = _parent._x;
y = _parent._y;
if (Math.abs(x-xHome)>1) {
x = x+((xHome-x)/8);
_parent._x = x;
}
if (Math.abs(y-yHome)>1) {
y = y+((yHome-y)/8);
_parent._y = y;
}
}

Frame 3:

gotoAndPlay(2);

Then in the parent set the snapBack variable with onPress/onRelease.

You could add a if(_parent._x == this.x && _parent._y==this.y){
this.stop();
} (not tested)

- to end the loop.

5G
Wheels is offline   Reply With Quote
Old 08-16-2002, 11:40 AM   #5
ZandoMan
Junior Member
 
Join Date: Aug 2002
Posts: 5
To Stop a function from working

In the beginning of the function, insert an if statement that checks a flag variable( ex. if (allowFunction==TRUE)...put code in here and end the if statement. Then all you have to do is set the flag to false in the frame you want it to stop running on. Remember, onClipEvent(load) to set the variable to true if you want the function to initialize to run.
ZandoMan is offline   Reply With Quote
Reply

Go Back   Flash Kit Community Forums > General Help > Scripting & Backend

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 07:27 PM.


internet.commerce
Be a Commerce Partner
 »  »  »  »  »  »  »
 »  »  »  »  »  »
 

    

Acceptable Use Policy


The Network for Technology Professionals

Search:

About Internet.com

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | E-mail Offers


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.