# gotoAndPlay problem

**URL:** https://forum.kirupa.com/t/gotoandplay-problem/183367
**Category:** Uncategorized
**Created:** [March 26, 2006, 11:37am UTC](https://forum.kirupa.com/t/gotoandplay-problem/183367 "2006-03-26T11:37:59Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![DrunkenMajestic](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drunkenmajestic/32/237_2.png) [@DrunkenMajestic](https://forum.kirupa.com/u/DrunkenMajestic)
#### Post date: [March 26, 2006, 11:37am UTC](https://forum.kirupa.com/t/gotoandplay-problem/183367/1 "2006-03-26T11:37:59Z")

</div>

Hey all, having a little problem with the following actionscript…

```auto
import mx.transitions.Tween;
import mx.transitions.easing.*;

var moving;

init = function() {
	_root['but_' + 0].origX = 9.1;
	_root['but_' + 0].origY = 332.2;
	_root['but_' + 0].openX = _root['but_' + 0]._x;
	_root['but_' + 0].openY = _root['but_' + 0]._y;
	_root['but_' + 0].origW = 79.3;
	_root['but_' + 0].origH = 75;
	_root['but_' + 0].openW = _root['but_' + 0]._width;
	_root['but_' + 0].openH = _root['but_' + 0]._height;
	_root['but_' + 0].opened = true;
	
	for (i = 1; i < 10; i++) {
		_root['but_' + i].origX = _root['but_' + i]._x;
		_root['but_' + i].origY = _root['but_' + i]._y;
		_root['but_' + i].openX = _root._width/2;
		_root['but_' + i].openY = 21;
		_root['but_' + i].origW = _root['but_' + i]._width;
		_root['but_' + i].origH = _root['but_' + i]._height;
		_root['but_' + i].openW = _root['but_' + i]._width*4;
		_root['but_' + i].openH = _root['but_' + i]._height*4;
		_root['but_' + i].opened = false;
	}
	_root['but_' + 1].openX -= _root['but_' + 1]._width*4;
	_root['but_' + 2].openX -= _root['but_' + 2]._width*4;
	_root['but_' + 7].openX -= _root['but_' + 7]._width*4;
	_root['but_' + 8].openX -= _root['but_' + 8]._width*4;
	_root['but_' + 9].openX -= _root['but_' + 9]._width*4;
	
	for (i=0; i<10; i++) {
		_root['but_'+i].onRollOver = _root['but_'+i].onDragOver = function() {
			if (this.opened == false && _root['moving'] == false) {
				this.gotoAndStop(2);
			}
		}
		_root['but_'+i].onRollOut = _root['but_'+i].onDragOut = function() {
			if (this.opened == false && _root['moving'] == false) {
				this.gotoAndStop(1);
			}
		}
		_root['but_'+i].onRelease = function() {
			if (this.opened == false && _root['moving'] == false) {
				for (j = 0; j < 10; j++) {
					if (_root['but_'+j].opened == true) {
						_root['but_'+j].closeMenu(this);
					}
				}
			}
		}
		
		_root['but_'+i].openMenu = function () {
			_root['moving'] = true;
			var moveX:Tween = new Tween(this, "_x", Regular.easeInOut, this.origX, this.openX, 0.5, true);
			var moveY:Tween = new Tween(this, "_y", Regular.easeInOut, this.origY, this.openY, 0.5, true);			
			var growW:Tween = new Tween(this, "_width", Regular.easeInOut, this.origW, this.openW, 0.5, true);
			var growH:Tween = new Tween(this, "_height", Regular.easeInOut, this.origH, this.openH, 0.5, true);
			but = this;
			growH.onMotionFinished = function () {
				but.opened = true;
				_root['moving'] = false;
				but.gotoAndPlay(3);
			}
		}
		
		_root['but_'+i].closeMenu = function(but_in) {
			_root['moving'] = true;
			this.gotoAndStop(1);
			var closeX:Tween = new Tween(this, "_x", Regular.easeInOut, this.openX, this.origX, 0.5, true);
			var closeY:Tween = new Tween(this, "_y", Regular.easeInOut, this.openY, this.origY, 0.5, true);			
			var shrinkW:Tween = new Tween(this, "_width", Regular.easeInOut, this.openW, this.origW, 0.5, true);
			var shrinkH:Tween = new Tween(this, "_height", Regular.easeInOut, this.openH, this.origH, 0.5, true);
			this.opened = false;
			shrinkH.onMotionFinished = function () {
				_root['moving'] = false;
				but_in.openMenu();
			}
		}
	}
	_root['but_' + 0].gotoAndPlay(3);
}

moving = false;
init();

```

The problem is that the final _root['but_’ + 0].gotoAndPlay(3); part isnt working, it is behaving as if it was a gotoAndStop();. I have also tried putting this further up in the init function (after other but\_0 values are set), and have also tried it outsie of the init function, being called before and after it, all with no luck…everything else seems to be working ok, although i did notice through a few traces that my init function was being called twice, however when i commented the final call of init() down the bottom out, it was not called at all…im thinking this is symptomatic of my gotoAndPlay problem…

cheers for your help

---

<div class="post-metadata">

### Author: ![DrunkenMajestic](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drunkenmajestic/32/237_2.png) [@DrunkenMajestic](https://forum.kirupa.com/u/DrunkenMajestic)
#### Post date: [March 26, 2006, 11:28pm UTC](https://forum.kirupa.com/t/gotoandplay-problem/183367/2 "2006-03-26T23:28:56Z")

</div>

one other thing…the gotoAndPlay in the “openMenu()” and “closeMenu()” functions do work…any thoughts?

---

<div class="post-metadata">

### Author: ![DrunkenMajestic](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/drunkenmajestic/32/237_2.png) [@DrunkenMajestic](https://forum.kirupa.com/u/DrunkenMajestic)
#### Post date: [March 27, 2006, 8:40am UTC](https://forum.kirupa.com/t/gotoandplay-problem/183367/3 "2006-03-27T08:40:07Z")

</div>

still having issues…the code has changed a bit, however i still havent had any luck figuring out the inherent flaw in it…im thinking my logic has gone wrong somewhere, but i cant figure out where…any help would be great…
