Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-31-2007, 05:30 PM   #1
xacttech
Member
 
Join Date: Oct 2006
Posts: 69
Default ComboBox function, selection runs function

Hey guys I've got another comboBox one for you...

I'm having a comboBox selection run a function of the same name.

ie:
PHP Code:
comboBox.addItem({data:"NAME"label:"Item number 1"});
comboBox.addItem({data:"NAME_2"label:"Item number 2"}); 
So two items on a comboBox... I need to execute a function after a section is made. here's what I've been doing

PHP Code:
var modelListener:Object = new Object();
this.comboBox.addEventListener("change"comboChange);
comboChange.change = function(model_evtObj:Object) {
    if (
comboBox.selectedItem.data == "NAME") {
        
NAME();
}
if (
comboBox.selectedItem.data == "NAME_2") {
        
NAME_2();

If I could create a listener that automatically executed a function of the same string held in the comboBox data, I'd be set.

Here's my Dummy Logic:
if combo box selected data = something, run something();

No matter what the data is, run a function of the same name.

Thanks Guys!!
xacttech is offline   Reply With Quote
Old 08-01-2007, 01:11 AM   #2
xacttech
Member
 
Join Date: Oct 2006
Posts: 69
Default

Out of curiosity how come this was moved?
xacttech is offline   Reply With Quote
Old 08-01-2007, 06:17 PM   #3
CyanBlue
Super Moderator
 
CyanBlue's Avatar
 
Join Date: Jan 2002
Location: Centreville, VA
Posts: 26,666
Default

I moved your thread because I thought that the Component forum best fits your question...
__________________
CyanBlue / Jason Je / Macromedia Certified Flash Developer & Designer
http://CyanBlue.FlashVacuum.com
http://www.FlashVacuum.com
http://tutorials.FlashVacuum.com

Do NOT PM, Email or Call me... Your question belongs right in this forum...
CyanBlue is offline   Reply With Quote
Old 08-01-2007, 06:59 PM   #4
tg
done
 
Join Date: Jun 2001
Location: portland, or
Posts: 8,106
Default

try:
Code:
//as 2 code
import mx.utils.Delegate;

comboBox.addEventListener("change",Delegate.create(this,comboChange));
comboChange=function(){
     this[comboBox.selectedItem.data]();
}
so. should work. basically the [] will evaluate teh data value of the combobox selection.
__________________
tg
---
what the hell was i thinking?
tg is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
onMouseDown_outside_my_multiple_mc = function() jsonchiu Components 0 04-29-2007 09:14 PM
Reusable class ... ? xxlm ActionScript 2.0 3 01-18-2006 03:29 AM
repositioning controller bar endortrails ActionScript 2.0 1 08-04-2005 07:03 PM
I can't resart my streaming sounds after they've been paused! athomas ActionScript 1.0 (and below) 2 07-01-2004 03:18 PM
Jumping to scenes from ComboBox selection pwdoncaster Components 1 03-31-2004 03:00 AM


All times are GMT. The time now is 10:32 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.