Motion using actionscript

ok if :

onClipEvent(enterFrame) {
speed = -3;
this._x += speed;
if(_x<-10 ){
_x=810;
}
}

makes an object going from right to left loop over and keep goign and going, then what do i change in the script to make an object going from left to right to keep looping over and going and going, and also for down to up and up to down, sorry ima flash newbie rofl:(

Well I am not sure I 100% understand what you are trying to do, but I will give it a whirl.

First off, you can change your code above to say this…

onClipEvent (enterFrame) {
	speed = 3;
	this._x -= speed;
	if (_x<-10) {
		_x = 810;
	}
}

And to make it go the other way, add this…

onClipEvent (enterFrame) {
	speed = 3;
	this._x += speed;
	if (_x>810) {
		_x = -10;
	}
}

ok ill explain, i have an object moving across the screen ( right to left) but when it gets to the end i want it to loop, you know what im saying? well i got it to loop but i can’t do do the same for an object moving left to right

The second example I gave you above does just that. It moves your object from -10 _x all the way to 810 _x, once it reaches 810, it sends the clip back to -10 and the process starts over.

thank you very much, sorry for all the comotion im a flash newbie lol

No problem. I am the one that stated I wasn’t exactly sure if that was what you wanted.

I am glad I could help you out.

wow never mind that thing u gave me didn’t work, my image width is 300 pixels and the height is 100 pixels, i have an object starting on the left side, i want it to start on the left and move to the right and when it hit’s the end i want it to go back to where it started and move to the right again, like loop

All you have to do is change the numbers around to make them bigger or smaller.

It does what you are saying, you just need to adjust the numbers so it loops at the right time.

thats where im having trouble lol ill try things then if i have problems ill ask u :slight_smile:

Here, check my example .fla (for flash MX, Flash 5 can not open MX files)

Just view the attachment on this post and I think it does what you wanted.

hmm nothin seems to work even when i look at your example
thats what im making, i want all the boxes to move then loop but i can only get the right box to do it

Here, try the new .fla I posted.

thanks so much man, i see whati wasn’t changing and why it didn’t work, not only did u help me alot, but u tought me some stuff thanks man :slight_smile: i owe you one lol

No problem man. I am glad I could help you out. AS motion rules! Much better than tweening :stuck_out_tongue:

ya i’d have to say, now time for me to learn new techniques using action script, i just don’t know where to start or what to try rofl

Experimentation is the best way to actually learn what things do :slight_smile:

Just try things out and experiment some. Be as evil as you would like :evil:

hehe ya, i guess i better get learning AS before i start trying new stuff tho

This site is the best place to learn :stuck_out_tongue: