Skip to main content
June 22, 2007
Question

x and y coordinates

  • June 22, 2007
  • 4 replies
  • 337 views
Ok I posted up asking if anyone could help me with an interactive map tutorial but no replys so I tried my best (I am fairly new to actionscript) to create one out of some existing code.

I have got it to work but doesnt do exactly what I want the existing code was taken from an image gallery that basically change the y value of a movieclip so it would slide to the right image.

The problem I am having is changing both the x and y values of the movieclip to allow it to move to any point on the stage. i need to know how to make the target variables point to an x and y coordinates. or maybe this isnt the way to do it?

I am really stuck with this and I am sure it would be easy for someone who knows actionscript. Any help would be very much appreciated.

Thank you in advance.

Here is the code I am using and I have attached the fla

this.attachMovie("image_0", "image_0", 101);

target = 100;
target1 = 120;
target2 = 175;
target3 = 200;

images_0._y = -1000;

speed = 5;

for (var i = 0; i<4; i++)
{
var thumb = this["thumb_"+i];

thumb.pos = target;
thumb.pos1 = target1;
thumb.pos2 = target2;
thumb.pos3 = target3;

thumb_0.onPress = function() {
target = this.pos;
};
thumb_1.onPress = function() {
target = this.pos1;
};
thumb_2.onPress = function() {
target = this.pos2;
};
thumb_3.onPress = function() {
target = this.pos3;
};

thumb._alpha = 80;
thumb.onRollOver = function() {
this._alpha = 20;
};
thumb.onRollOut = function() {
this._alpha = 80;
};
}
this.onEnterFrame = function() {
image_0._y += (target-image_0._y)/speed;
image_0._x += (target-image_0._x)/speed;
};
This topic has been closed for replies.

4 replies

kglad
Community Expert
Community Expert
June 25, 2007
you're welcome.
June 25, 2007
Thank you for the reply I will try this when I have a moment. Once again thank you for the help much appreciated
June 25, 2007
I want to be able to change the x and y value. At the moment the value is stored under target, target1 etc. So when a thumb is pressed if the target says 50 the image_0 currently moves to x=50 y=50. I want to know if I can change the target variables so that image_0 will move to an x and y value that are different to each other eg x=50 y=100.
kglad
Community Expert
Community Expert
June 25, 2007
try:

kglad
Community Expert
Community Expert
June 22, 2007
that code doesn't make sense. to what x,y do you want your image_0 to move when thumb_0 is pressed, thumb_1 is pressed, etc?