tigra
Administrator
Posts: 1907
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 1/3/2006 at 07:09 PM |
|
|
Randomizing the order of the scrolling items
Below function will shuffle the scroller items:
| Code: |
function random_items (a_source) {
var n_index, a_items = [];
while (a_source.length) {
n_index = Math.ceil(Math.random() * a_source.length) - 1;
a_items[a_items.length] = a_source[n_index];
a_source[n_index] = a_source[a_source.length - 1];
a_source.length = a_source.length - 1;
}
return a_items;
}
|
It can be used like this:
| Code: |
new TScroll_init (Tscr_LOOK, Tscr_BEHAVE, random_items(Tscr_ITEMS));
|
|
|
|
yaya20
Junior Member
Posts: 2
Registered: 3/16/2006
Member Is Offline
|
| posted on 3/16/2006 at 05:38 PM |
|
|
I've been trying to find a way to do this and what you pose is much simpler than what I was trying to do...
In what file do I need to put the random function? And where/how do I call it correctly?
|
|
|
tigra
Administrator
Posts: 1907
Registered: 6/17/2002
Location: US, CO
Member Is Offline
|
| posted on 3/16/2006 at 10:49 PM |
|
|
The function can be inserted in .js file or inside the <script> tag anywhere obove the place where it is first called. See the call example in
the initial post.
|
|
|
yaya20
Junior Member
Posts: 2
Registered: 3/16/2006
Member Is Offline
|
| posted on 3/17/2006 at 03:09 AM |
|
|
Thanks. After some work I got it functioning.
|
|
|