Motion tutorial

how do I get a MC to continue to loop thru?

I have this:

onClipEvent(enterFrame) {
speed = 2;
this._x += speed;
}

I just want the MC to continue back onto the screen

u want it to move across the screen, and then appear on the other side and move across again?

let’s say the movie is 400 wide.

add:

if(_x>410 ){
_x=-10;
}

just an example…

That work going one way but going to the left it does not work.

Here is what i have now:

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

try:

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

Ahh yes and I actually understood that=)

Thanks.

i guess you just overlooked that tiny detail huh? :stuck_out_tongue:

actually, if you have no intention of changing the speed, you can get rid of ( speed=-3; ) and just write:

_x+=-3

then you get rid of 1 line of code…

how would you do a random speed?

onClipEvent(load){
speed=random(9)+1;
}

onClipEvent(enterframe){
_x+=speed;
}

that’s how i’d do it…

i was reading this tut to, i have a question tho, that action script only works for an object moving from right the left. but not left to right or up to down or down to up, i tried changing the script around but nothin worked i need help

It works. Just increment the value of _y by 1.
That is something like.

this._y += 1;

That would make your object move down by 1.

If you want it to move up, you’d code it as

this._y -= 1;

I was reading these post and I was wondering how would I modify the code to make a movie clip slide out and stop at a certain spot. What I have is two menus that I’m trying to make slide out and stop, one on the right and one on the left. I’m new to actionscripting any help would be appreciated, thanks in advance.

let’s say that the movie is 400x400
Put 1. menu on the left side of the movie and the second to the right side

  1. menu

onClipEvent(enterFrame) {
_x += 1;
if(_x >= 100) {
_x = 100;
}
}

  1. menu

onClipEvent(enterFrame) {
x -= 1
if(_x <= 300) {
_x = 300;
}
}

if(_x <= 300)
checks if the movie is in the right position (in this case 300)
_x = 300
assigns the position of it 300 so it won’t be moving to the left forever
Put the first actions on the 1. menu and the second ones on the second.

took me a few minutes to figure out what those lil yellow balls with the plus sign in them meant, but the codes worked! thanks a lot syko! I’ll show you what I made once I’m finished! =)

OOPS! Stupid smilies! Didn’t notice those! :slight_smile: lol

Ok syko, here’s another one for you… I have a button sitting inside a movie clip. I want it to play a section on my main timeline which I gave a label name of “data”. This is what I tried, but obviously I was wrong so here I am asking for help.

on(release) {
gotoAndPlay(root.data);
}

make it
_root.gotoAndPlay(“data”);
_root. refers to the main timeline (make sure you include the underscore _)
and data should be in “” :slight_smile:

thanks again syko! Everything works the way how I want it to work now. If you want to see what I have so far, here’s the link to the project I’m currently working on.

www15.brinkster.com/ozzo481/main.htm

I’ve only been working with flash for about 2 months so there’s still a lot I need to learn so maybe you could give me some pointers and maybe point out some problems I might have right now. Once again thanks for the help!! =)

omg! That site is so cool! And from where did get those backgrounds? :stuck_out_tongue:
This is so cool!
I’ve tried making a flash homepage many times but none of them were cool enough to be finished …

wow electrongeek, your site is awesome! did you create the graphics and backgrounds yourself? they look very professional.

Yup I made everything from scratch, the backgrounds were made in Cinema 4D and then I gave it the monochrome look in Photoshop. I’m glad you guys like my site, I’ve spent a lot of time on it the past 2 months ever since I opened up MX. But I don’t think I could of done it without the help of tutorials and forums like this one. Thanks again you guys! =)