Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1691
  • Last Modified:

Actionscript 2 List Box help

I have built a simple application that uses a list box and a window component to display external SWFs.  Using code that calls a setInterval inside of a function every 7 seconds, the list box index will go to the next item and also change the content of the window compenent to the corresponding information.

Here is my problem...  the list box has room for 4 items to be shown before you must scroll, and when the function (with the setInterval) advances to the 5 item, you cannot see it...

I tried placing a "setScrollPosition" inside the function that builds everything, but I don't think that works properly in version 7 and actionscript 2.0

here is the code that is in the function:

windowSwitch = function(evt){
     if (evt == "click"){
      myIndex = listBox1.getSelectedItem().data;
      titleFix();
      windowBuild(myIndex);
      _root.n = listBox1.getSelectedIndex();
      listBox1.setScrollPosition(_root.n);        //////  area in question
     } else {
      _root.n = _root.n + 1;
      if(listBox1.getSelectedIndex() == _root.menuMax){
            listBox1.setSelectedIndex(0);
            myIndex = listBox1.getSelectedItem().data;
            _root.n = 0;
      } else {
            var gsi = listBox1.setSelectedIndex(_root.n);
            myIndex = listBox1.getSelectedItem().data;
      }
      listBox1.setScrollPosition(_root.n);        //////  area in question
      titleFix();
      windowBuild(myIndex);
     }
}


again, everything is working fine, except for the "auto scroll"  when this function is called...  

what type of code should I be using instead of setScrollPosition() to automatically scroll the list box when this function is called...

this is fairly urgent, so I will give an extra 500 points to anyone who can point me in the right direction...


rp
0
rascalpants
Asked:
rascalpants
  • 2
1 Solution
 
rascalpantsAuthor Commented:
here is a link to what I am talking about:

http://www.rascalpants.com   <--delete this space-->     /flash/menu_sys/index.asp


when the menu advances down to the 5th item, I want the list box to auto scroll so that is it seen...  and when it goes back to the top item, I need it to scroll back up again...

thanks in advance...


rp
0
 
hansblixCommented:
//A basic example
function blah()
{
      test_lb.vPosition = vpos;
      test_lb.selectedIndex = vpos++;
}
vpos = 0;
test_lb.selectedIndex = vpos++;
interval = setInterval(blah, 2000);

//////////////////////////////////////////
The effect you want (where it starts scrolling from the last item) can be achieved with some tinkering :)

hth
-h
------------
http://www.quillem.com
0
 
rascalpantsAuthor Commented:
I was able to implement your code...  thanks...

rp

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now