# Swiping movie clips from array

**URL:** https://forum.kirupa.com/t/swiping-movie-clips-from-array/323963
**Category:** flash
**Created:** [July 26, 2011, 10:55am UTC](https://forum.kirupa.com/t/swiping-movie-clips-from-array/323963 "2011-07-26T10:55:39Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Betamax](https://avatars.discourse-cdn.com/v4/letter/b/ccd318/32.png) [@Betamax](https://forum.kirupa.com/u/Betamax)
#### Post date: [July 26, 2011, 10:55am UTC](https://forum.kirupa.com/t/swiping-movie-clips-from-array/323963/1 "2011-07-26T10:55:39Z")

</div>

Hello good people,

I’m a complete AS3 novice trying to create a flash card app where the user can swipe through a series of animated fullscreen movie clips. I want to get as close as I can to the responsiveness of native iOS photo-swiping.

Here’s the relevant code I have so far – with mouse clicking instead of swiping so I can test it without having to put it on the device. It works OK with placeholder clips, but I have a feeling I’m doing it in a slightly over-complex way and that it may struggle with either a succession of rapid swipe interactions or more asset-heavy clips.

Any suggestions for streamlining the code would be most appreciated.

```auto
import flash.display.MovieClip;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import fl.transitions.easing.*;
import flash.events.MouseEvent;

// SETS UP ARRAY
var clipArray:Array=new Array(StartClip,aClip,bClip,cClip,dClip,eClip,fClip,gClip,hClip,iClip,jClip,kClip,lClip,mClip,nClip,oClip,pClip,qClip,rClip,sClip,tClip,uClip,vClip,wClip,xClip,yClip,zClip);

// SPAWNS START CLIP
var nowShowing:int = 1;
var rightClipIndex:int = nowShowing + 1;
var leftClipIndex:int = nowShowing - 1;
var currentClip:MovieClip = new clipArray[nowShowing];
addChild(currentClip);

// SPAWNS RIGHT BUTTON
var right_btn:RightButton = new RightButton;
addChild(right_btn);
right_btn.x = 800;
right_btn.y = 460;

function rightClip()
{
	return new clipArray[rightClipIndex];
	}

function leftClip()
{
	return new clipArray[leftClipIndex];
	}

// Click Listeners
right_btn.addEventListener(MouseEvent.CLICK, clickRight);
function clickRight (e:MouseEvent):void{

	var moveOffStage:Tween = new Tween(currentClip, "x", Strong.easeOut, 0, -960, 0.5, true);
	var rightHander
	rightHander = rightClip();
	addChildAt(rightHander,0);
	rightHander.x = 960
	var moveOnStage:Tween = new Tween(rightHander, "x", Strong.easeOut, 960, 0, 0.5, true);
	
	moveOnStage.addEventListener(TweenEvent.MOTION_FINISH, afterMotionFinished);
	function afterMotionFinished(e:TweenEvent):void
	{
	removeChild(currentClip);
	removeChild(rightHander);
	currentClip = rightClip()
	addChildAt(currentClip,0);
	nowShowing++;
	rightClipIndex++;
	leftClipIndex++;
	}

```
