_x and _y coordinate question
by giyggugpupg » Mon, 06 Jun 2005 00:55:01 GMT
Hello:
I have a movieclip that is navigated by buttons to various _x and _y
coordinates. When the user clicks on "button 1" is takes them to a specified
area, then when the user clicks "button2" is takes them to another area.
However, the pathway is a straight line between the two.
I would like the "path" to negotiate a determined route, (such as a curved or
"S" shaped route). Is it possible to put a series of _x and _y coordinates into
the onClipEvent then the final _x and _y coordinate for a final destination,
(Similar to waypoints in a GPS).
If so, is there a simple way that "people that know what they are doing"
calculate _x and _y coordinates within a movieclip?
Regards,
Stephen
Re: _x and _y coordinate question
by the fleece » Mon, 06 Jun 2005 04:47:14 GMT
mmm sounds to me like what you need is a bit of maths - maybe a sine equation
to descibe the sort of path you want.
actually, i'm making the assumption that you are doing this throu
actionscript, when you are possibly doing it allong the timeline...
if so, you could use a motion path.
Re: _x and _y coordinate question
by giyggugpupg » Mon, 06 Jun 2005 05:18:57 GMT
Hello:
Well, I cannot disagree that I could always use a math lesson, but apart from
that I was hoping of an easier method within flash to pull from the properties
panel the various _x _y coordinates.
I am using actionscript but not to navigate a timeline, but to access "pages"
within a movieclip. I am using the following:
onClipEvent (load) {
_x = -149.0;
_y = -94.0;
spd = 8;
}
onClipEvent (enterFrame) {
_x += (endX-_x)/spd;
_y += (endY-_y)/spd;
_root.page1.onRelease = function() {
endX = -149.0;
endY = -94.0;
};
_root.page2.onRelease = function() {
endX = -449.0;
endY = -94.0;
};
_root.page3.onRelease = function() {
endX = +151.0;
endY = -94.0;
};
_root.page4.onRelease = function() {
endX = -149.0;
endY = +94.0;
};
_root.page5.onRelease = function() {
endX = -149.0;
endY = -294.0;
};
}
I was just hoping instead of a straight path to have a different route. No
necessarily the direct route.
Regards,
Stephen
Re: _x and _y coordinate question
by the fleece » Mon, 06 Jun 2005 05:26:10 GMT
no, maths is the only way.
and my mine aint good enough either, however there's loads of tutorials on that sort of thing. Not that I know of any - not very helpful, sorry
Re: _x and _y coordinate question
by Der Zlmeister » Mon, 06 Jun 2005 21:01:26 GMT
let's say you want to move from (x0, y0) to (x1, y1) in 9 steps.
the following piece of code will move the movie clip mcObject
from the source to the destination as jStep goes from 0 to 9.
// at beginning of script
nSteps = 9;
// event handler or loop
var t = jStep / nSteps;
mcObject._x = (1 - t) * x0 + t * x1;
mcObject._y = (1 - t) * y0 + t * y1;
-----
that's for two points. now if you have a series of way-points,
then you'd probably store the coordinates in arrays e.g. xCoords,
yCoords (for consistency, the arrays should include the start and
the end point). let's have an index jWayPoint that goes from 0
to jLastPoint (= the number of intermediate points + 1).
at first you have
jWayPoint = 1;
nSteps = 9;
x1 = xCoords[0]; y1 = yCoords[0];
x2 = xCoords[1]; y2 = yCoords[1];
your onClipEvent handler would look something like this:-
onClipEvent = function() {
var t = jStep / nSteps;
mcObject._x = (1 - t) * x0 + t * x1;
mcObject._y = (1 - t) * y0 + t * y1;
jStep++;
if (jStep > nSteps) {
jWayPoint++;
if (jWayPoint > jLastPoint) {
// destination reached. disable the handler
} else {
// set new line segment
jStep = 0;
x1 = x2;
y1 = y2;
x2 = xCoords[jWayPoint];
y2 = yCoords[jWayPoint];
}
}
}
Similar Threads:
1.Finding _x and _y coordinates of a word within a string
Is this possible? I have a dynamic text within a TextField. I want the
user to be able to select a word within the text they've inputted and
for me to place a gap (a TextInput component) where this word is. I've
messed around with getTextExtent but that only allows me to find the
hieght or width of the entire text and not a specific word.
2.AlertBox Component _x and _y coordinates
Hi,
In using the Alert Box component how do you control where the AlertBox is displayed?
Thanks for any help!
3.absolute or relative _x/_y coordinates
Hello friends,
allrite here it goes.
I have three clips.
Lets call'em: clip0,clip1 and clip2
clip1 is INSIDE clip0
clip2 and clip0 are on the same level. How do allign clip2 to clip1?
So what I do need to find out I guess, is how I do retrieve the _x and _y coordinates of clip1 relative to the _root stage?
did this make sense? I sure hope so
thanks a lot, any help or pointers are wastly appreciated
V
4.display _x and _y
i've created a movieclip (ball) that bounces and a dynamic text fields to
display the _x and _y position of my ball as it bounces. the thing is the
position remains static as the balls bounces, how can i make them change in
relation to the position of the ball.
5._x and _y wrong
hi all
i have this in a movieclip called map
on (release) {
_root.map._x = 138.1;
_root.map._y = 80.4;
}
but when i press it it goes to about ._x = 75.8 ._y = 26.1
how can i stop it
6. attachMovie and _x, _y position in Flash Player5
7. flash _X and _y properties
8. buttons/movieclip on a path - how to get _x and _y