Side scrolling objects

I’m trying to create an effect similar to the one on this site:\ (click on Portfolio, then Digital)\r\rI want to have horizontally scrolling objects that go in a loop. The scroll doesn’t have to halt on mouseover or have any speed/rate effects–constant is fine.\r\rI can do the scroll using standard tweening, but I figure it has to be a lot smoother and smaller (file size) to use action script. How is this done? Is there a tutorial or sample .fla that I can look at? Thanks!

scryber,\r\rthis was discussed in an earlier post, you might find this approch useful:\r\…=421.topic\r\rfood for thought anyways.

Thanks, that was very helpful. I still have a little tweaking to do, though.\r\rI modified the script in the action layer, removing the part that affects the scroll speed, and extending it to make it longer:\rMovieClip.prototype.scrollx = function(){\r&nbsp &nbsp &nbsp &nbsp var spd = 1\r&nbsp &nbsp &nbsp &nbsp x += spd;\r&nbsp &nbsp &nbsp &nbsp if(x > 700){ x -= 650; nextFrame(); }\r&nbsp &nbsp &nbsp &nbsp _x=x;\r}\r\rThe question now is, how do I set the distance between the objects? I have 5 objects that are 107px wide, and they bunch over each other using the current script. I believe it has something to do with this portion of the code:\r\rfor(i=0;i<7;i++){\r&nbsp &nbsp &nbsp &nbsp _root.clip.attachMovie(“menuitem”,“m”+i,i);\r&nbsp &nbsp &nbsp &nbsp var mc = _root.clip[“m”+i];\r&nbsp &nbsp &nbsp &nbsp mc.frame = i+1;\r&nbsp &nbsp &nbsp &nbsp mc.x = 50+i*60;\r&nbsp &nbsp &nbsp &nbsp mc._y = 25;\r}\r\r…but I can’t figure it out. Note that I change i<5 to i<7 because I added two objects to Symbol1. This was a guess on my part, I don’t know if that really helps or hurts. One other thing, I’d like about 30px between the objects.

you’re right on the money, it has everything to do with that script, especially this line:\r\rmc.x = 50+i*60;\r\r50 is the initial offset ( i don’t remember why it was 50, it may be important for the spacing on the wrap around) and 60 represents the space each object will occupy. to get 30 px between them, make 60 equal their width, plus 30.\r\ryou could code that dynamically like:\r\rmc.x = 50 + mc._width + 30;\r\rthen you’ll get 30 between, even if the menu items are different sizes.

Getting closer…\r\rIf I use this line:\rmc.x = mc._width + 30;\rone image goes across by itself, and the next one doesn’t show up until the first one has left.\r\rIf I use this line:\rmc.x = i*107 + 30;\r7 images go across, no space between them, then there’s a wide space (100px or so), then 7 more images. The images are not in the same order twice, nor are they in the frame order of Symbol1.\r\r(Note that I removed the 50 offset)

have you changed the thresholds for moving to the other side? if your movies are larger, and your scroll area is larger, you’ll need to adjust when the movies wrap around to the other side. that might be causing some mayhem.

The movie width is 760. I have a mask that covers the right exit point (x=690). Right now I have the code removing the object just as it disappears behind the mask:\r if(x > 690){ x -= 690; nextFrame(); }\r\rThe example fla has the objects continue behind the mask for a short period before starting over. Should I be doing it this way?\r\rAlso in the example there are always 5 squares, even if only 3 are shown (non-masked). Since the left entry point for mine is x=0, it occurs to me that the masking functionality isn’t quite the same.\r\rGetting confused again…

since you’re only scrolling in one direction, it’s like you said, there’s no need for the small overlap, and yes, the masking functionality is quite different. \r\ryou’ll only need one extra movie, not two. in fact, if you don’t need the movies to appear on the left as they’re disappearing on the right, you don’t need any extra movies, and you can do away with the frame changing too.\r\rthe challenge in that example was to make the movies appear on one side while they disappeared off the other, in both directions. without needing that functionality, the movie can be greatly simplified.\r\roh, and that spacing code i gave you was totally bogus, sorry about that.\r\rif you do want dynamic spacing between differently sized movies, you’ll need to either store the total y assignments or reference the _y of the movie previous. something like this:\r\rmc._y = _root.clip[“m”+(i-1)]._y + * space*;\r\rwhere * space* is the space between clips. if your movies are the same width, the original code is a little simpler (and thus better, imho. lovin’ the simple stuff).

OK, I follow (somewhat). My movie symbols are all the same size (107x55) so no problem there. Still though, I am back to the same issue of spacing. For starters, I assume I can change the For loop to this:\rfor(i=0;i<6;i++){\r…since I have 5 movies and it goes in one direction.\r\rThat leaves the mc.x spacing line. What would that be if \rmc.x = 50 + mc._width + 30; \ris bogus? :slight_smile:

the way it was to begin with will still work fine:\r\rmc.x = [offset] + ([space]*i);\r\rwhere [space] is the total amount of space alotted to each movie. so if you’re movie was 50px wide and you wanted a 10px margin [space] would be 60. the brackets are not strictly necessary, they’re just showing order of operations.

the offsets look great…\r\rNow there just remains the correct order of the movies. There is still some weird ordering going on. Some are being repeated sooner than they should be.\r\rI don’t know if this is the right approach or not, but I am thinking that it might be the gotoAndStop(2);/gotoAndStop(6); actions in Symbol1. I don’t need a Previous Frame because it is only going in one direction, so doesn’t that mean I can take out one of those actions?\r\rAnd if I remove one of those actions, how does that affect the for(i=0;i<7;i++){ loop?\r\r(keep in mind I have 5 movie objects)

do you need your movies to appear on the left as they disappear off the left?\r\rif not, you can do away with the extra movie, the frame changing, and the extra frames at the beginning and end of each movie.\r\rif you do want it, you can still get rid of the extra frame at the beginning. change the empty frame at the end to read gotoAndStop(1);\r\rthe for loop should be ok.