# Making a movie clip appear again and again

**URL:** <https://forum.kirupa.com/t/making-a-movie-clip-appear-again-and-again/291301>\
**Category:** Uncategorized\
**Created:** [June 27, 2009, 5:28pm UTC](https://forum.kirupa.com/t/making-a-movie-clip-appear-again-and-again/291301 "2009-06-27T17:28:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jxmckenzie](https://avatars.discourse-cdn.com/v4/letter/j/977dab/32.png) [@jxmckenzie](https://forum.kirupa.com/u/jxmckenzie)\
**Post date:** [June 27, 2009, 5:28pm UTC](https://forum.kirupa.com/t/making-a-movie-clip-appear-again-and-again/291301/1 "2009-06-27T17:28:58Z")

</div>

I created a simple slideshow type thing that involves two buttons that allow a user to go left or right to view additional pictures. All of the pictures are stored in a single movieclip.

When the buttons are clicked it just changes the x value of the movie clip. Everything works perfectly.

Currently when it reaches the last picture (the very end of the movie clip) it scrolls back to the beginning. But I have to change it so that it appears to loop… Basically creating another instance of the movie clip on the fly.

Any ideas on how to do it?

**Here’s a link to see it in action:**

[http://www.mindfully21.com/about\_test.php](http://www.mindfully21.com/about_test.php)

**And here’s a snippet of the code to give you an idea:**  
_[SIZE=1]A few notes… photo\_mc is the movie clip that moves around (and stores all the pics)  
All the actionscript is in the first frame.  
btn\_left & btn\_right are the buttons[/SIZE]_

```auto
final_x=225 ;
speed =3.5;
photo_width = 296;
photo_mc.onEnterFrame = function() {
    photo_mc._x += (final_x - photo_mc._x)/speed;
}

btn_right.onRelease = function() {
    if(final_x==225){
        final_x =-72;
    }
    else if(final_x==-72){
        final_x =-368;
    }
    else if(final_x==-368){
        final_x =-665;
    }
    else if(final_x==-665){
        final_x =-990;
    }
    else if(final_x==-990){
        final_x =-1290;
    }
    else if(final_x==-1290){
        final_x =-1610;
    }
    else if(final_x==-1610){
        final_x =-1881;
    }
    else if(final_x==-1881){
        final_x =225;
    }
    photo_mc.onEnterFrame = function(){
        photo_mc._x += (final_x - photo_mc._x)/speed;
    }
}

btn_left.onRelease = function() {
    if(final_x==225){
        final_x =225;
    }
    else if(final_x==-72){
        final_x =225;
    }
    else if(final_x==-368){
        final_x =-72;
    }
    else if(final_x==-665){
        final_x =-368;
    }
    else if(final_x==-990){
        final_x =-665;
    }
    else if(final_x==-1290){
        final_x =-990;
    }
    else if(final_x==-1610){
        final_x =-1290;
    }
    else if(final_x==-1881){
        final_x =-1610;
    }
    photo_mc.onEnterFrame = function(){
        photo_mc._x += (final_x - photo_mc._x)/speed;
    }

}

```

Any help would be greatly appreciated!! :hr:
