In this tutorial we modify our swipe code so that, a left swipe on our last frame will loop to the first frame and a right swipe on our first frame will loop to the last frame.
I’m using the hideLogo_completeC.fla file from the previous tutorial sample files and have added a conditional statement inside our swipe code, in which we use the “currentFrame” and “totalFrames” properties to loop through the frames.
Note: Directions are reversed on a mobile device, so a swipe left would go to the next page and a swipe right would go to the previous page.
I have added the following conditional statement to our swipe right code.
if(currentFrame == 1)
Above we are asking Flash to check if the play head is on the first frame, if so, then move the play head to the very last frame, otherwise move to the previous frame.”
Here’s the code snippet for swipe left:
if(currentFrame == totalFrames)
Here we are asking flash to check if the play head is on the last frame, if so then go to the first frame, otherwise go to the next frame.
Note: Because we used the “currentFrame” and “totalFrames” properties, and not specific frame numbers, we can add as many frames as we like to our test app, and the code will always work, check out the sample code for more info.
To access code samples, Click Here.
Tutorial files were created using Flash CS5 Professional version 126.96.36.1999.
Contents of Archive (2 Files)
loopFramesC.fla (fully commented test app)
Copyright © Shane Hogan
Do not copy this article.