Welcome to WebmasterWorld Guest from 54.234.129.215

Forum Moderators: open

Message Too Old, No Replies

loop movie clip?

     

mightymid

2:23 pm on Mar 17, 2008 (gmt 0)

10+ Year Member



I'm creating a small swf in Flash MX 2004. I have a horizontal filmstrip of thumbnails with control buttons to allow users to scroll left and right.

However when you scroll all the way in either direction, you reach the end of the filmstrip and see the blank space where the strip ends. Is there a way to make the strip appear continuous?

Here is the actionscript I'm using:

goleft.onPress = function() {
filmstrip.onEnterFrame = function() {
filmstrip._x += 10;
}
}
goleft.onRelease = function() {
delete filmstrip.onEnterFrame;
}

goright.onPress = function() {
filmstrip.onEnterFrame = function() {
filmstrip._x -= 10;
}
}
goright.onRelease = function() {
delete filmstrip.onEnterFrame;
}

Thanks,
Mid.

rocknbil

3:03 pm on Mar 17, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Create your filmstrip as a symbol.

When either edge of the filmstrip reaches the edge of the viewport, attach a new copy of the strip and set that edge next to the one currently on stage. Be sure to remove movie clips that have completely moved off the stage.

mightymid

3:52 pm on Mar 17, 2008 (gmt 0)

10+ Year Member



Thanks. On further thought, maybe what I really want to do is force the filmstrip to stop scrolling when the end enters the viewport.

Is there a way to achieve THAT by modifying the script posted above?

rocknbil

7:17 pm on Mar 21, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



Well, think of the logic. If you're moving left, and the right edge meets the right edge of the viewport, stop scrolling.

goleft.onPress = function() {
filmstrip.onEnterFrame = function() {
if ((filmstrip._x+filmstrip._width) <= yourmovie._width) {
delete filmstrip.onEnterFrame;
}
else { filmstrip._x += 10; }
}
}

For left, it's easier.

goright.onPress = function() {
filmstrip.onEnterFrame = function() {
if (filmstrip._x >= 0) { delete filmstrip.onEnterFrame; }
else { filmstrip._x -= 10; }
}
}

Untested, but something like that should do it. :-) Looks to me like you have go left and go right backwards though, don't you?

+x ----------> makes it go right
-x <---------- makes it go left

rocknbil

7:46 pm on Mar 21, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I was right, your buttons are backwards. Here's one that is tested in a movie of 550 px width. Make sure you set the orientation of the symbol filmstrip to 0 and 0, or you'll have to do more complex math.

goleft.onPress = function() { 
filmstrip.onEnterFrame = function() {
if (filmstrip._x <= 0) {
delete filmstrip.onEnterFrame;
}
else { filmstrip._x -= 10; }
}
}
goleft.onRelease = function() {
delete filmstrip.onEnterFrame;
}
goright.onPress = function() {
filmstrip.onEnterFrame = function() {
if ((filmstrip._x+filmstrip._width) >= 550) {
delete filmstrip.onEnterFrame;
}
else { filmstrip._x += 10; }
}
}
goright.onRelease = function() {
delete filmstrip.onEnterFrame;
}
 

Featured Threads

Hot Threads This Week

Hot Threads This Month