 |
TGixer
Young Devil

Registered: Mar 2002
Local time: 11:47 AM
Location: Albany, NY, USA
Posts: 133
|
| ComboBox Component setChangeHandler | Post #1 |
Has anyone played with this funtionality.
i want to use a combo box, so when a user selects a choice from the list, it then executes some code.
i dont really understand what they say in the help.
here is some example code;
code:
toyList.setChangeHandler("myHandler");
function myHandler(component){
trace(toyList.getSelectedItem().label);
}
however, where should i put this code. on the actual component, if i do then i need an OnClipEvent.
im lost on this.
Report this post to a moderator | IP: Logged
|
07-31-2002 06:48 AM |
|
|
|  |
 |
kristin
Young Devil

Registered: Jul 2002
Local time: 11:47 AM
Location: Toronto, ON
Posts: 166
|
it sounds like it should be within an if/else statement that is checking the value of what is selected and then changing the handler set in the parameters of the combo box based on what selection has been made.
do the users have to hit a button to confirm their selection? if so, this statement would go on the button. am i understanding your question correctly?
--K
__________________
--K
aka:K-dog
Report this post to a moderator | IP: Logged
|
07-31-2002 07:22 AM |
|
|
|  |
 |
TGixer
Young Devil

Registered: Mar 2002
Local time: 11:47 AM
Location: Albany, NY, USA
Posts: 133
|
well,
not really, i figured it out.....you have to write a function, and then in your component properties reference that function call.
i have it working, now im trying to make 2 boxes work dependently,
ie, select an album name, which in turn populates box 2 with the correct song names to select.....
im almost there..just NOT quite right.
thanks though
Report this post to a moderator | IP: Logged
|
07-31-2002 08:54 AM |
|
|
|  |
 |
kristin
Young Devil

Registered: Jul 2002
Local time: 11:47 AM
Location: Toronto, ON
Posts: 166
|
sounds very useful.. i'd love to see a quick and dirty .fla example if you're willing to post , i've used the list box and radio buttons components with changeHandlers a lot, but not the combo box yet.
--K
Report this post to a moderator | IP: Logged
|
07-31-2002 09:06 AM |
|
|
|  |
 |
TGixer
Young Devil

Registered: Mar 2002
Local time: 11:47 AM
Location: Albany, NY, USA
Posts: 133
|
actually, im updating my MP3 player.
ck it out.
its NOT 100% fixed yet. but it will be! 
here is the code i used:
2 combo boxes
Droppy and Song_Names (i know dumb names)
i created an action on frame 1 with this code. code:
song_names.setSelectedIndex(null);
song_names.setEnabled(false);
droppy.setStyleProperty("arrow", 0xFF0000);
// set up album selection
function onSelectAll(droppy) {
if (droppy.getSelectedIndex()>1) {
trace(droppy.getSelectedIndex());
song_names.setEnabled(true);
song_names.removeAll();
song_names.setSelectedIndex(0);
_root.outline.album = droppy.getValue();
// set up song titles
if (droppy.getSelectedIndex() == 2) {
// Buddah Album
song_names.removeAll();
song_names.addItem("Carosel", 1);
song_names.addItem("blah", 2);
song_names.addItem("blah2", 3);
song_names.addItem("blah3", 4);
song_names.addItem("blah4", 5);
song_names.addItem("blah5", 6);
song_names.addItem("blah6", 7);
song_names.addItem("blah7", 8);
song_names.addItem("blah8", 9);
}
if (droppy.getSelectedIndex() == 3) {
// Cheshire Album
song_names.removeAll();
song_names.addItem("Tony", 1);
song_names.addItem("blah", 2);
song_names.addItem("blah2", 3);
song_names.addItem("blah3", 4);
song_names.addItem("blah4", 5);
song_names.addItem("blah5", 6);
song_names.addItem("blah6", 7);
song_names.addItem("blah7", 8);
song_names.addItem("blah8", 9);
}
} else {
song_names.setSelectedIndex(null);
song_names.setEnabled(false);
}
}
// Play a song
function onPlaySong(song_names) {
if (song_names.getSelected()>=0) {
unloadMovieNum(1);
_root.outline.album = droppy.getSelectedItem().data;
trace(_root.outline.album);
_root.outline.songnum = (song_names.getSelectedIndex()+1);
trace(_root.outline.songnum);
_root.outline.totalsongs = int(13);
filename = (_root.outline.album+songnum);
if (_root.outline.pause.paused == false) {
loadMovieNum("http://www.kowalick.net/"+filename+".swf", 1);
_root.outline.spectrum.gotoAndPlay(2);
}
}
}
now on your component properites, there is a field called
"ChangeHandler"
for droppy i have 'OnSelectAll' (my first function)
for song_names i have 'OnSongPlay' ( my second function)
let me knowif you dont understand..
im posting my new swf now
www.kowalick.net/sony3.html
Report this post to a moderator | IP: Logged
|
07-31-2002 09:23 AM |
|
|
|  |
 |
kristin
Young Devil

Registered: Jul 2002
Local time: 11:47 AM
Location: Toronto, ON
Posts: 166
|
totally understood now that i see what you wanted to do.
(I was thinking in a different direction when you made your original post)
thank you for sharing. :-)
this could be applied to so many things
--K
__________________
--K
aka:K-dog
Report this post to a moderator | IP: Logged
|
07-31-2002 09:45 AM |
|
|
|  |
 |
Plankton
Little Devil

Registered: Dec 2002
Local time: 04:47 PM
Location:
Posts: 26
|
The best way to write a change Handler, that i have experienced so far is to write it similar to this:
testObj = new Object();
testObj.testHandler = function(){
//place code here
}
whateverObject.setChangeHandler("testHandler", testObj);
Just thought i would try and contribute. 
Plankton
Report this post to a moderator | IP: Logged
|
02-07-2003 01:44 AM |
|
|
|  |
 |
| All times are GMT. The time now is 04:47 PM. |
 |
|
 |
|
|
|  |
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
< FlashDevils - Terms of use
>
Copyright, FlashDevils Community, 2002 - Flash Archive
|
|