Solved

Actionscript 2 List Box help

Posted on 2004-04-09
3
1,679 Views
Last Modified: 2012-05-04
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
Comment
Question by:rascalpants
  • 2
3 Comments
 
LVL 22

Author Comment

by:rascalpants
ID: 10792820
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
 
LVL 2

Accepted Solution

by:
hansblix earned 500 total points
ID: 10796087
//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
 
LVL 22

Author Comment

by:rascalpants
ID: 10805434
I was able to implement your code...  thanks...

rp

0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
Introduction This article is primarily concerned with ActionScript 3 and generally specific to AVM2.  Most suggestions would apply to ActionScript 2 as well, and I've noted those tips that differ between AS2 and AS3. With the advent of ActionS…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question