# Tracking what button has been clicked... Need some help

**URL:** https://forum.kirupa.com/t/tracking-what-button-has-been-clicked-need-some-help/277383
**Category:** Uncategorized
**Created:** [December 11, 2008, 12:45pm UTC](https://forum.kirupa.com/t/tracking-what-button-has-been-clicked-need-some-help/277383 "2008-12-11T12:45:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![n1ckyb0y](https://avatars.discourse-cdn.com/v4/letter/n/3e96dc/32.png) [@n1ckyb0y](https://forum.kirupa.com/u/n1ckyb0y)
#### Post date: [December 11, 2008, 12:45pm UTC](https://forum.kirupa.com/t/tracking-what-button-has-been-clicked-need-some-help/277383/1 "2008-12-11T12:45:09Z")

</div>

Hi All

I have a script to do partially what I need to do… basically control some buttons but I need to track which button has been clicked and then assign a numerical value to a variable called buttonclicked so I can refer to this variable and pull info from an XML document on frame 5. Here’s the short script…

```auto
stop();

this.button1.textBTN_txt.text = "ABOUT US";
this.button2.textBTN_txt.text = "SERVICE";
this.button3.textBTN_txt.text = "PORTFOLIO";
this.button4.textBTN_txt.text = "CONTACT";

var buttonNum:Number = 4;

for (i=1; i<=buttonNum; i++) {
	this["button"+i].onRollOver = function() {
		if (this.clicked != "yes") {
			this.gotoAndPlay("over");
			
		}
	};
	this["button"+i].onRollOut = function() {
		if (this.clicked != "yes") {
			this.gotoAndPlay("out");
		}
	};
	this["button"+i].onRelease = function() {
		gotoAndPlay(5);
		_global.buttonclicked=[COLOR="Red"]?what do I need to put here?[/COLOR];
		this.gotoAndStop("out");
		this._parent[_root.clickedButton].gotoAndPlay("out");
		this._parent[_root.clickedButton].clicked = false;
		this._parent[_root.clickedButton].enabled = true;
		_root.clickedButton = this._name;
		this.clicked = "yes";
		this.enabled = false;
		_root.on_txt.text=this._name +" in "+this.textBTN_txt.text;
	};
}

```

Can anyone help?

Regards

Nick
