# Passing function as DATA n a comboBox

**URL:** <https://forum.kirupa.com/t/passing-function-as-data-n-a-combobox/300018>\
**Category:** flash\
**Created:** [November 14, 2009, 2:50pm UTC](https://forum.kirupa.com/t/passing-function-as-data-n-a-combobox/300018 "2009-11-14T14:50:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolanicola](https://avatars.discourse-cdn.com/v4/letter/n/c89c15/32.png) [@nicolanicola](https://forum.kirupa.com/u/nicolanicola)\
**Post date:** [November 14, 2009, 2:50pm UTC](https://forum.kirupa.com/t/passing-function-as-data-n-a-combobox/300018/1 "2009-11-14T14:50:30Z")

</div>

Using Flash CS4.

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:

```auto

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?
