Passing a function through data in a comboBox
I want a comboBox that will allow the user to select what colour palette they want the application to have.
I am using a comboBox to do this and want to have a function with arguments as the data in the comboBox item.
I’ve managed to do it and pass arguments but these are running when the comboBox is set up. I only want the function to run when the user presses the submit button. How can I prevent the function from running on set up?
Here is my code:
ActionScript Code:
package { import flash.display.*; import flash.events.*; import flash.text.*; import fl.controls.*; import fl.managers.StyleManager; import flash.text.TextFormat; public class CatProcess extends MovieClip { var headingTxt:Label; var headingFormat:TextFormat; var userLabel:Label; var paletteLabel:Label; var ageLabel:Label; var ageInputBox:TextInput; var standardFormat:TextFormat; var nameInputBox:TextInput; var userName:String; var paletteCombo:ComboBox; var submit_btn:Button; var rose:TextFormat; var aqua:TextFormat; public function CatProcess() { //Palette Label paletteLabel=new Label(); paletteLabel.text = "Please select a colour palette for this form"; paletteLabel.autoSize = TextFieldAutoSize.LEFT; paletteLabel.setStyle("textFormat",standardFormat); paletteLabel.move(89,157); addChild(paletteLabel); //Palette ComboBox paletteCombo=new ComboBox(); paletteCombo.addItem({data:setPalette("chose aqua via a function"),label:"aqua"}); paletteCombo.addItem({data:setPalette("chose rose via a function"),label:"rose"}); paletteCombo.move(360,157); addChild(paletteCombo); submit_btn=new Button(); submit_btn.move(255,258); submit_btn.label = "submit"; addChild(submit_btn); submit_btn.addEventListener(MouseEvent.CLICK,processData); function processData() { trace("working"); } function setPalette(hhh:String) { trace(hhh); } } } }
Plus, my movie is taking ages to submit, even though there is nothing on the stage. There are components in the library though. Would this cause it to take about 5 seconds to export to swf?
Original post by nicolanicola