# Using array.slice

**URL:** https://forum.kirupa.com/t/using-array-slice/177261
**Category:** Uncategorized
**Created:** [January 31, 2006, 4:41pm UTC](https://forum.kirupa.com/t/using-array-slice/177261 "2006-01-31T16:41:51Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Mrrufus](https://avatars.discourse-cdn.com/v4/letter/m/b2d939/32.png) [@Mrrufus](https://forum.kirupa.com/u/Mrrufus)
#### Post date: [January 31, 2006, 4:41pm UTC](https://forum.kirupa.com/t/using-array-slice/177261/1 "2006-01-31T16:41:51Z")

</div>

Hi there,

I made an swf that displays 8 thumbnails at a time. The locations of the content for the thumbs comes from an external text file, that contains a string of folder names that hold the images.  
I now feed this string into an array, by splitting the string up using:  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#0000FF]stop[/COLOR]COLOR=#000000[/COLOR];  
theArray = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]Array[/COLOR]COLOR=#000000[/COLOR];  
pr\_var = [COLOR=#000000] **new** [/COLOR] [COLOR=#0000FF]LoadVars[/COLOR]COLOR=#000000[/COLOR];  
pr\_var.[COLOR=#0000FF]onLoad[/COLOR] = [COLOR=#000000] **function** [/COLOR]COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]if[/COLOR] COLOR=#000000[/COLOR] [COLOR=#000000]{[/COLOR]  
projArray = [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]projArray[/COLOR].[COLOR=#0000FF]split[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#0000FF]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#0000FF]trace[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR] [COLOR=#0000FF]else[/COLOR] [COLOR=#000000]{[/COLOR]  
[COLOR=#0000FF]trace[/COLOR][COLOR=#000000]([/COLOR][COLOR=#FF0000]“can’t get the txt file”[/COLOR][COLOR=#000000])[/COLOR];  
[COLOR=#0000FF]gotoAndPlay[/COLOR]COLOR=#000000[/COLOR];  
[COLOR=#000000]}[/COLOR]  
[COLOR=#000000]}[/COLOR];  
pr\_var.[COLOR=#0000FF]load[/COLOR]COLOR=#000000[/COLOR];  
[/LEFT]  
[/FONT]

Then I used the following code to load only the first 8 items:  
ActionScript Code:  
[FONT=Courier New][LEFT][COLOR=#000000] **var** [/COLOR] startIndex:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]0[/COLOR];  
[COLOR=#000000] **var** [/COLOR] endIndex:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000080]8[/COLOR];  
[COLOR=#000000] **var** [/COLOR] projRange = [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]projArray[/COLOR].[COLOR=#0000FF]slice[/COLOR][COLOR=#000000]([/COLOR]startIndex, endIndex[COLOR=#000000])[/COLOR];  
[/LEFT]  
[/FONT]

Now, my original array contains 22 items for now, how would I add a “next” Button to load items the next 8 items (8 to 16 and after that 16 to 22)?

Thanks for any help,

Rufus
