-
Firing an Event with ComboBox Component
Hi,
I have a simple ComboBox onstage, with 5 options in it.
Each one has a textual label, and is assigned a numeral "data" in the Component Inspector (1,2,3,4,5).
I'm trying to get the playhead to move to a specific frame, according to which option is selected, and can't make it work. The trace turns out fine, but the playhead stays in place.
Could someone maybe help with this code?
(The ComboBox is called my_cb).
PHP Code:
var cbListener:Object = new Object(); cbListener.change = function(evt_obj:Object) { trace("Value changed to: "+evt_obj.target.selectedItem.label); };
my_cb.addEventListener("change", cbListener.change); cbListener.change = function(evt_obj:Object) { var itemName:Number = new Number(); itemName = evt_obj.target.selectedItem.data; if(itemName == 1) { gotoAndStop(10); }
Thank you...
-
Senior Member
Which AS version are you using AS2 or 3?
- The right of the People to create Flash movies shall not be infringed. -
-
Moderator
Here is what I do:
Code:
//Assign values to the comboBox
cb.rowCount = 6;
cb.addItem({data:0, label:"Please Choose One"});
cb.addItem({data:"2", label:"Frame 1"});
cb.addItem({data:"3", label:"Frame 2"});
cb.addItem({data:"4", label:"Frame 3"});
cb.addItem({data:"5", label:"Frame 4"});
cb.addItem({data:"6", label:"Frame 5"});
//Make sthe comboBox listen for any change to itself
cb.addEventListener(Event.CHANGE, changeHandler);
//This function handles the change
function changeHandler(event:Event):void
{
var comboBoxData:Number = event.target.selectedItem.data;
var comboBoxLabel:String = event.target.selectedItem.label;
trace(comboBoxData);
trace(comboBoxLabel);
Content_mc.gotoAndStop(comboBoxData);
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|