Movement with actionscript in flash

Ok, I recently got intrested in flash and now want to increase my flash ability with actionscript,

I have Flash MX and am wondering how with action script i can move a symbol or movieclip when clicking on a button with the use of actionscript. I want to be able to to move a symbol or movieclip to an exact location and with some animation like a motion tween but with the use of actionscript.

Can anyone shed any light on the subject , I really need help and am looking for any suggestions.

mikey,

check out this tutorial on Kirupa to find out more:

http://www.kirupa.com/developer/mx/ASmovement.htm

if that doesn’t help, post your questions on here and i’ll be sure to answer :slight_smile:

yes that was helpful but how can i make the symbol or movieclip stop and start at a specific location,
such as starting at x 50 y 50 and finishing at x 50 y 100 ?
please reply and
thankyou

put it at x50 and y50, then

onClipEvent(enterFrame) {
     speed = 5;
     if(this._y<100){
          this._y += speed;
     }
}

untested, see if that works

morse u rule !!!
if i need any more help ur the one to try
thanx
mike

:slight_smile: Thanks man. I’m nothing compaired to most of the people on this site.

Anyway, if you have any questions, feel free to PM me, or email me: himself@morsedesigns.com

ooh
one more question how can i make it start moving from where it was so it can move up and down with the use of a button? and when u click another button it starts from where it was and goes to a new location

thanx for your help
mike

On the stage make two buttons. One above the other. Call the top one (using instance names) “MCup” and the bottom one “MCdown” (both without quotes). On the stage name the thing you want to move (using instance names) “myMC”.

//Code for the top button - MCup
on(release){
     _root.myMC._y+=5
}
//Code for the bottom button - MCdown
on(release){
     _root.myMC._y-=5
}

untested, see if it works

ok thAT WAS ALMOST WHAT I WANTED BUTi wanted to be able to move the button continuously from point to point with only one click of the button and it move to a specific location like with the
previous example instead of stopping every 5 pixels
is this possible

thanx mike

I’v been meaning to try this… Here’s my chance :slight_smile:
Try this. In the first frame of the timeline put this:

MovieClip.prototype.move = function() {
	speed = 25;
	endX = 200;//Final X position you want
	endY = 200;//Final Y Position you want
	this._x += (endX-this._x)/speed;
	this._y += (endY-this._y)/speed;
};

on the movie clip that is to move (myMC) put this:

onClipEvent(enterFrame){
     move()
}

The cool thing is that you could change the endx and endy values to variables and then change them when a button is pushed, and the thing will automatically move.

I think.

HOW CAN I CHANGE THE endy and endx to VARIABLES and make them change when a button is pressed sorry im a bit new at this your help is much aprecated
thanx
mike