View Full Version : simple listbox/goto problem
Halabar
08-30-2004, 06:37 AM
Howdy,
I using the following....
function menu() {
gotoAndPlay(listBox.getSelectedItem().data);
}
to direct a listbox-menu that goes to a the frame specified in the listbox data.
This works, the user clicks on a item, and it jumps to the right frame.
The problem: IF the user clicks again on the "current" item, it jumps to the next frame. If the user clicks again on the same item, it jumps back to the correct frame.
Why?.....
Halabar
08-30-2004, 06:40 AM
it also can get out-of-synch, and go to the next frame, instead of the correct one, and continue that way.
do I need to define the frame better?...
the values I am using are simple numeric. (1,2,4,6,8...etc.) do I need to indentify the frame differently?...
madgett
08-30-2004, 07:37 AM
Not sure why it's doing that...you could try using a listener object that fires events based on the "change" within a list. Something like this:
stop();
myList.addItem({label:"Frame2",data:2});
myList.addItem({label:"Frame3",data:3});
myList.addItem({label:"Frame4",data:4});
var listListener:Object = new Object();
listListener.change = function() {
_root.gotoAndStop(myList.selectedItem.data);
trace(myList.selectedItem.data);
}
myList.addEventListener("change", listListener);
That works efficiently. Give it a shot.
Halabar
08-31-2004, 02:29 AM
Ok, I'm not getting it, but I'm a designer, not a programmer....
I tried modifying the code you provided in a few ways, but I don't know enough to make it work...
In addition, with the original problem. What you click on the current item in the list, it jumps to the next item. If you click again, it goes back to the correct item. It does this consistently througout the project.
Here's my mangling of the code...
stop();
listBox.addItem({label:"Introduction",data:1});
listBox.addItem({label:"The Copper Serpent",data:2});
listBox.addItem({label:"The Fourth Commandment",data:4});
var listListener:Object = new Object();
listListener.menu = function() {
_root.gotoAndStop(listBox.selectedItem.data);
trace(listBox.selectedItem.data);
}
myList.addEventListener("menu", listListener);
function menu() {
gotoAndPlay(listBox.getSelectedItem().data);
}
the component ID is "listBox", the changehandler is "menu"
can someone tell me what I am missing?....
(a recent poster in another thread sure was right, they're moving Flash away from designers to programmers.... someone who spends most of the day in PS is never gonna remember all this AS)
Halabar
08-31-2004, 05:42 AM
OK, this is strange, it's even happening if I use a frame-name, and set that as the data instead of using numeric values.
ideas?.....
Halabar
08-31-2004, 05:46 AM
OK, I fixed it. used a gotoandStop instead.
Now, if someone could answer my other button question.... :-)
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.