homepage Welcome to WebmasterWorld Guest from 54.196.62.23
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
loop movie clip?
mightymid

10+ Year Member



 
Msg#: 3602912 posted 2:23 pm on Mar 17, 2008 (gmt 0)

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

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3602912 posted 3:03 pm on Mar 17, 2008 (gmt 0)

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

10+ Year Member



 
Msg#: 3602912 posted 3:52 pm on Mar 17, 2008 (gmt 0)

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

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3602912 posted 7:17 pm on Mar 21, 2008 (gmt 0)

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

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 5+ Year Member



 
Msg#: 3602912 posted 7:46 pm on Mar 21, 2008 (gmt 0)

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;
}

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved