If/then question

I am trying limit the scroll length of a movie clip. I’m sure it’s a simple if/then statement, but I am lost. Does anyone know how to limit the length of the scroll depending on the width of the clip?

on(press, release, keyPress “<left>”)
{
thumbnails._x += 30;
}

Any help would be greatly appreciated, thanks.

Adam

Can you provide more of the code? It’s hard to understand what sort of scroll you mean, and how it is to be dependent on width. Do you want the scroll width to be equal to the movie clip width? If so, you might not need if / else statement at all, you could just set something like

 thumbnails._width = Stage.width; 

Uploading the FLA would be helpful.

I’ve attached the fla, what I’m trying to do is limit how far the mc will scroll based on the size of the mc so it won’t just keep scrolling to infinity, or at least of the page.

Thanks for the help.

Adam

I’ll write up what I did in a few min, but let me know if this is NOT what you meant…

Edit:

Okay, so, the first thing I did was convert the mask into a movieclip, and give it the instance name ‘mask’ so that I could use it in the code.

Then on the left button, I inserted this code


on(press, release, keyPress "<left>")
{
if (thumbnails._x < mask._x){

thumbnails._x = (thumbnails._x +10);
}
}

so what you’re saying here is that if the position of the thumbnails is further to the left than the position of the mask, move the thumbnails to the right.

For the right button:



on(press, release, keyPress "<right>")
{
if (thumbnails._x > (mask._width - thumbnails._width)){

thumbnails._x = (thumbnails._x -10);
}
}

Hope that helps and was what you were looking for. You had the buttons aligned differently than I do, so maybe I didn’t help at all.

thank you BlueEyedMonster, it did help, a lot. It works perfect.