# Button code problem

**URL:** https://forum.kirupa.com/t/button-code-problem/185308
**Category:** Uncategorized
**Created:** [April 12, 2006, 12:25pm UTC](https://forum.kirupa.com/t/button-code-problem/185308 "2006-04-12T12:25:38Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)
#### Post date: [April 12, 2006, 12:25pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/1 "2006-04-12T12:25:38Z")

</div>

Hi i have a problem with telling flash to look for my movie clip problem is that it has no instance name as the movie clip is added via action script but it has a linkage id called pane7, and within the movieclip has a button called one so how do i tell flash to look for this?

pane7.one.onRelease = function() {  
gotoAndPlay(10);  
}

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 12, 2006, 12:51pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/2 "2006-04-12T12:51:53Z")

</div>

If you attach it you have to give it a new (instance) name

```auto
this.attachMovie("pane7", "new_mc", 99)

```

and then you can refer to the new name

```auto
new_mc.one.onRelease = function() {
//if you want 'one' to gotoandplay 10
this.gotoAndPlay(10);
}

```

or if the path is more complicated

```auto
var new_mc = nav.top_mc.attachMovie("pane7", "new_mc", 99);
new_mc.one.onRelease = function() {
this.gotoAndPlay(10);
}

```

scotty(-:

---

<div class="post-metadata">

### Author: ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)
#### Post date: [April 12, 2006, 1:19pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/3 "2006-04-12T13:19:11Z")

</div>

\*EDIT

yes that works but not quite, it creates a new instance (sorry maybe i wasnt clear enough on what i wanted or what was happering the movie clip pane7 is already on the timeline moving spining around with other images and when you click on pane7 it jumps to frame 10 on the timeline

this link is the source file  
[http://www.funnycrew.co.uk/SpinningImages15.fla](http://www.funnycrew.co.uk/SpinningImages15.fla)

Many thanks for your help

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 12, 2006, 1:31pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/4 "2006-04-12T13:31:18Z")

</div>

Next time use [noparse]

```auto

```

[/noparse] tags for readibility  
If I look at your original question I think you want this

```auto
for (i=0; i<16; i++) {
	attachedObj = theScene.attachMovie(paneArray*, "pane"+i, i);
	attachedObj.angle = angleStep*i;
	attachedObj.radius = 170;
	attachedObj.x = Math.cos(attachedObj.angle)*attachedObj.radius;
	attachedObj.z = Math.sin(attachedObj.angle)*attachedObj.radius;
	attachedObj.y = 30;
	attachedObj.display = displayPane;
	objectsInScene.push(attachedObj);
	attachedObj.one.onRelease = function() {
		this.gotoAndPlay(10);
	};
}

```

scotty(-:

---

<div class="post-metadata">

### Author: ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)
#### Post date: [April 12, 2006, 1:55pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/5 "2006-04-12T13:55:34Z")

</div>

[quote=scotty]Next time use [noparse]

```auto

```

[/noparse] tags for readibility

ill rember that for next time,

sorry but did you read my edit imade which should be alot clearer thanks

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 12, 2006, 1:59pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/6 "2006-04-12T13:59:48Z")

</div>

LOL, no where do think I got your code from:)  
You want every pane to goto frame 10?

scotty(-:

---

<div class="post-metadata">

### Author: ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)
#### Post date: [April 12, 2006, 2:02pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/7 "2006-04-12T14:02:15Z")

</div>

> [@scotty](#):
>
> LOL, no where do think I got your code from:)  
> You want every pane to goto frame 10?
> 
> scotty(-:

🙂 no different frames if possible but i only really need pane7 to go to frame 10 thanks

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 12, 2006, 2:15pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/8 "2006-04-12T14:15:36Z")

</div>

Here you go, I’ve left some panes out of the code, you can add these.  
Important is that you give the button (in all the panes) an instancename ‘one’

```auto
stop();
this.createEmptyMovieClip("theScene", 1);
theScene._x = 290;
theScene._y = 220;
objectsInScene = new Array();
//twodimensional array the number is the frame you want goto
var paneArray:Array = [["pane", 10], ["pane1", 20], ["pane2", 30], ["pane3", 40], ["pane4", 50], ["pane5", 60], ["pane6", 70], ["pane7", 10]];
spin = 0;
focalLength = 250;
displayPane = function () {
	var angle = this.angle-spin;
	var x = Math.cos(angle)*this.radius;
	var z = Math.sin(angle)*this.radius;
	var y = this.y;
	var scaleRatio = focalLength/(focalLength+z);
	this._x = x*scaleRatio;
	this._y = y*scaleRatio;
	this._xscale = this._yscale=40*scaleRatio;
	this.swapDepths(Math.round(-z));
};
angleStep = 2*Math.PI/15;
for (i=0; i<15; i++) {
	//get the first element of each array item
	attachedObj = theScene.attachMovie(paneArray*[0], "pane"+i, i);
	attachedObj.angle = angleStep*i;
	attachedObj.radius = 160;
	attachedObj.x = Math.cos(attachedObj.angle)*attachedObj.radius;
	attachedObj.z = Math.sin(attachedObj.angle)*attachedObj.radius;
	attachedObj.y = 30;
	attachedObj.display = displayPane;
	//give each pane its id
	attachedObj.id = i;
	//inside the panes give all the buttons an instancename one
	attachedObj.one.onRelease = function() {
		_root.gotoAndStop(paneArray[this._parent.id][1]);
	};
	objectsInScene.push(attachedObj);
}
panCamera = function () {
	spin += this._xmouse/4000;
	for (var i = 0; i<objectsInScene.length; i++) {
		objectsInScene*.display();
	}
};

```

scotty(-:

---

<div class="post-metadata">

### Author: ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)
#### Post date: [April 12, 2006, 2:29pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/9 "2006-04-12T14:29:30Z")

</div>

THANKS thats perfect i bow down to the Flash Guru 🙂

---

<div class="post-metadata">

### Author: ![martinb18](https://avatars.discourse-cdn.com/v4/letter/m/3ab097/32.png) [@martinb18](https://forum.kirupa.com/u/martinb18)
#### Post date: [April 12, 2006, 3:24pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/10 "2006-04-12T15:24:39Z")

</div>

sorry to ask for you help again scotty but, for some reason when you click on pane7 and it gotos frame 10 the carosuel is still there even though inthe time line the action script isnt placed at frame 10 so how can i get the carasouel to stop and disapear when u click on a pane and if i add a back button to say frame 10 the carasouel reapears? thanks here my new sourse file

[http://www.funnycrew.co.uk/web2.fla](http://www.funnycrew.co.uk/web2.fla)

to view the effect click link below (but dont worrie about the gap that appear in the caroseul effect because pane13 and 14 for some reason where playing up when i created that swf)

[http://www.nwmsltd.com/shared2.html](http://www.nwmsltd.com/shared2.html)

thanks again martin

---

<div class="post-metadata">

### Author: ![scotty](https://avatars.discourse-cdn.com/v4/letter/s/91b2a8/32.png) [@scotty](https://forum.kirupa.com/u/scotty)
#### Post date: [April 12, 2006, 3:40pm UTC](https://forum.kirupa.com/t/button-code-problem/185308/11 "2006-04-12T15:40:14Z")

</div>

Here you go:

```auto
displayPane = function () {
	var angle = this.angle-spin;
	var x = Math.cos(angle)*this.radius;
	var z = Math.sin(angle)*this.radius;
	var y = this.y;
	var scaleRatio = focalLength/(focalLength+z);
	this._x = x*scaleRatio;
	this._y = y*scaleRatio;
	this._xscale = this._yscale=40*scaleRatio;
	//changed next line so all panes are on a removable depth
	this.swapDepths(8000+Math.round(-z));
};
angleStep = 2*Math.PI/15;
for (var i = 0; i<15; i++) {
	//get the first element of each array item
	attachedObj = theScene.attachMovie(paneArray*[0], "pane"+i, i);
	attachedObj.angle = angleStep*i;
	attachedObj.radius = 160;
	attachedObj.x = Math.cos(attachedObj.angle)*attachedObj.radius;
	attachedObj.z = Math.sin(attachedObj.angle)*attachedObj.radius;
	attachedObj.y = 30;
	attachedObj.display = displayPane;
	//give each pane its id
	attachedObj.id = i;
	//inside the panes give all the buttons an instancename one
	attachedObj.one.onRelease = function() {
		_root.gotoAndStop(paneArray[this._parent.id][1]);
		//remove the panes
		removePanes();
	};
	objectsInScene.push(attachedObj);
}
function removePanes() {
	for (var i = 0; i<15; i++) {
		theScene["pane"+i].removeMovieClip();
	}
}

```

In the target frames have a back button that with gotoAndStop(1) action

scotty(-:
