View Full Version : detect if movement has reached goal???
loaded
03-29-2003, 08:45 AM
Hello there I've got some actionscripted movement.
I want to detect when the movement has finished, but how???
var xStart = 800;
function pInit(xStart){
setDir(_root.follow["pointer"],xStart); //initial y,x,movement pointer function....
if(_root.follow["pointer"]._x >= xStart){
trace("home sweet home");
}
}
So when the "pointer" reaches xStart I want to get some action, started with a simple trace....
The above unfortunaely isn't working
Thnx
CyanBlue
03-29-2003, 12:18 PM
Howdy...
Basically what you need is a constant loop that checks the condition... Try this...var xStart = 800;
function pInit(xStart)
{
setDir(_root.follow["pointer"], xStart);
//initial y,x,movement pointer function....
this.onEnterFrame = function()
{
if (_root.follow["pointer"]._x >= xStart)
{
delete this.onEnterFrame;
trace("home sweet home");
}
else
{
trace("Condition has not met yet...");
}
}
}
loaded
03-31-2003, 08:42 AM
Well thnx,
Don't have my pc for a couple of days, so I''l test it a soon as possible.
loaded
04-02-2003, 08:10 PM
Sorry, took me some time to get my pc back....
However your function doesn't seem to work correct?
It loop indeed, but keeps tracing
"Condition has not met yet..."
forever???
Maybe the problem is in the line:
if (_root.follow["pointer"]._x >= xStart){
or maybe it has to with the setDir function????
function gotoXPos() {
difX = this._x-this.p_topT;
(Math.abs(difX)<.1) ? this.onEnterFrame = undefined : this._x -= (difX/8);
}
function setDir(clip,xPos) {
clip.p_topT = xPos;
clip.onEnterFrame = gotoXPos;
}
more solutions???? I think your close!
CyanBlue
04-02-2003, 08:18 PM
Well... Be honest with you, I don't know... You will have to go over the sets of numbers that this will show you on the output window and see what actual value is and figure out what's causing it... ;)var xStart = 800;
function pInit(xStart)
{
setDir(_root.follow["pointer"], xStart);
//initial y,x,movement pointer function....
this.onEnterFrame = function()
{
trace("_root.follow[pointer]._x = " + _root.follow["pointer"]._x + "\txStart = " + xStart)
if (_root.follow["pointer"]._x >= xStart)
{
delete this.onEnterFrame;
trace("home sweet home");
}
else
{
trace("Condition has not met yet...");
}
};
}You can also show me the copy from the output window if you need me more... ;)
loaded
04-02-2003, 08:48 PM
damned that I didn't think of that!
the trace you gave provided the answer.
the value increased to 799.65 or something.
So the next makes it work:
if (math.round(_root.follow["pointer"]._x) >= xStart){
CyanBlue
04-02-2003, 08:54 PM
Yup... TRACE is your best friend... Not TRACY though... :D
loaded
04-03-2003, 04:54 PM
Hahaha back again!
Damned can't figure this one out???
I've got a for loop from an xml file.
In this loop I attach buttons, make them move like the pointer to a starting position.
trace(_root.menu[mcName+n]._x);
If I place the first code in the loop, I only get the starting position...
So I'm trying to loop it again, however it doesn't seem to work...
onEnterFrame = function() {
trace(_root.menu[mcName+n]._x);
}
The above only gives me undifined's for ever....
this.onEnterframe = .... doesn't work
Sugestions????
If you need more code please let me know
loaded
04-03-2003, 05:20 PM
_root.menu[mcName+n].n = n;
_root.menu[mcName+n].onEnterFrame = function(){ //init move:
startPos += xOffset;
setDir(_root.menu[mcName+this.n], startPos);
this.n.onEnterFrame = function() {
trace(this.n._x);
}
}
However can get our friend Trace to work????
(What the f*ck is the problem with Tracey anyway, hahaha.
I know 2 tracey's, which are believe me not even close to being f*ckable, so no probs there!)
CyanBlue
04-04-2003, 02:30 AM
this.n.onEnterFrame = function() {
trace(this.n._x);
}What is this 'n'??? It does look like a variable to me... ;)
onEnterFrame handler goes with the movieclip, not the variable... Know what I mean???
I think 'this.n.onEnterFrame' should be 'this.onEnterFrame'... Try it and let me know...I know 2 tracey's, which are believe me not even close to being f*ckableUm... What are you trying to say??? I am not quite getting it... :(
loaded
04-04-2003, 11:06 AM
Hmmmm.... I tried it al Ithink as far as I know:
_root.menu[mcName+n].n = n;
that is where the n came from.
Maybe it's better to post you the entire code or something???
Or the fla, however I rather not stick it up on this board...
Your help is appreciated!
concerning Tracey's:
I thought you encountered some horrible trauma with a TRACY or something....
CyanBlue
04-04-2003, 02:57 PM
Um... Put the file somewhere and let me know the link... I don't know how much I can do, but I'll do what I can do...
Concering Tracy... Nope... I was just joking not to be confused with Trace with Tracy... But no need to use four letter words... Know what I mean??? :(
loaded
04-04-2003, 03:43 PM
Sorry bout the f words there, no harm ment!
Included the fla, Tell me when you have it, cause I'll remove it after that!
CyanBlue
04-04-2003, 05:02 PM
Um... I am kinda lost where I was at...
Anyways... This shows you the correct _x value... this.onEnterFrame = function() {
trace("this = " + this._x);
And let me know what I have missed so far... ;)
Oh, I got the file...
loaded
04-04-2003, 10:08 PM
thanx for the help so for the help so far, appreciated!!!
however this doesn't solve the problem.
Did it work for you???
T ._x keep streaming, however the buttons don't move any more???
Damned this is a stupid peace of code! I'll bet you it's something real easy! However the problem remains unsolved!
Let me know if you can figure it out.
I need to get the button action to start when items have reached destination, else it's to buggy!
However I personally like the menu...
Please let me know if you can help! Thanx again,
Lode
CyanBlue
04-05-2003, 01:35 AM
Obviously I am not getting what you want...
What about this??? this.onEnterFrame = function()
{
trace("this = " + this._x + " : " + this._name);
// /*
trace("\tmath.round(this._x) = " + math.round(this._x) + " xStart = " + xStart);
if (math.round(this._x) >= xStart){
delete this.onEnterFrame;
trace("item " + this._name + " @ home");
}
else{
trace("Condition has not met yet...");
}
// */
};
loaded
04-07-2003, 08:40 AM
Thnx for the reply.
How luck is not on my side lately.
My Mother board got fried this weekend when I was upgrading RAM mem. Still clueless how this could happen, however I'll test it as soon as possible.
CyanBlue
04-08-2003, 01:01 AM
Oops... Sorry to hear that... :(
loaded
04-08-2003, 11:26 AM
Mobo burned to a crisp, sucks!
But Got a new one so tonight pc will be runnig again....
I tried your code, however it doesn't seem to work, did you test it in the fla??? I'm getting a little desperate to finish this however it doesn't seem to go, darn
We'll let me know If you want to proceed / find a solution.
Let me know speak to you soon....
CyanBlue
04-09-2003, 01:12 AM
Well... If I remember correctly, I think I got it working on my side with your sample file... and probably the code that I have post up there is the one that I have fixed to correct the problem...
I'll check out the file again if you want me to... You gotta let me know the file name though... um... better yet, post the file again... I don't think I have left the file on my computer... I probably have deleted it... That's what I usually do... :D
loaded
04-15-2003, 12:15 AM
Let me know if you can figure it out!
CyanBlue
04-15-2003, 07:18 AM
Um... I guess you will have to tell me what the problem is again... I don't see any problem... It was working just fine... or I was looking at the wrong place... :D
loaded
04-15-2003, 09:57 AM
I want to do some actions when the menu items reach are finished moving to there starting point...
but I can't get this to trace or work in any way!
CyanBlue
04-15-2003, 10:13 AM
Um... I see this one on the output window...trace("pointer @ home");Doesn't this mean that the icons are moving to the right position and ready for whatever you want???
You have this...pInterVal = setInterval(pInit(800), 500);
//<-- not workingand I think this works just fine... That's why those icons are moving, isn't it???
loaded
04-15-2003, 04:18 PM
the pointer we figured out, but now I want to get the same for the dynamic menu items....
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.