# Same movieclips, different layouts

**URL:** <https://forum.kirupa.com/t/same-movieclips-different-layouts/21180>\
**Category:** Uncategorized\
**Created:** [May 18, 2003, 4:09pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180 "2003-05-18T16:09:43Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![subquark](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@subquark](https://forum.kirupa.com/u/subquark)\
**Post date:** [May 18, 2003, 4:09pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/1 "2003-05-18T16:09:43Z")

</div>

arghh! This has to be so easy but I don’t know how to approach it. Arrays!?! Function?!? There is an efficient way to do this but . . .

Okay I want to use the same movieclips (some are button movieclips) but be able to have a function lay them out at runtime in two (or more) layouts. Just the \_x and \_y position like in this example:

![](http://www.subquark.com/footer/layout.gif)

I’d like to layout the mcs with just actionscript. So it can be hardwired into the movie’s script with parameters A yielding layout A, et cetera.

something like this:

```auto
boxOne_mc._x = 100;
boxOne_mc._y = 100;

boxTwo_mc._x = 200;
boxTwo_mc._y = 100;

boxOne_mc._x = 300;
boxOne_mc._y = 100;

btnOne_mc.x = 5;
btnOne_mc.y = 100;

```

but all wrapped up in one function. Gee this is hard for me to explain and maybe I’m making this more difficult than it needs to be. ☹

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 9:17pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/2 "2003-05-18T21:17:29Z")

</div>

allright, i dont know if its this what you mean, but ill give it a shot… here we go…

```auto

function changeLayout(x){
if(x==1){
boxOne_mc._x = 100;
boxOne_mc._y = 100;
boxTwo_mx._x = 200;
boxTwo_mx._y = 100;
} else if (x==2){
boxOne_mc._x = 300;
boxOne_mc._y = 100;
boxTwo_mx._x = 5;
boxTwo_mx._y = 100;
}
}
// if you want to change the layout on the fly, just use this code:
// the parameter givin (in this case 1) will determine the layout
changeLayout(1)

```

i hope this is what you ment

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 10:30pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/3 "2003-05-18T22:30:53Z")

</div>

that is it! yes, yes, yes!!! thank you so much!!!

RvGaTe, you RULE!!!

thanks!!! :thumb:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 10:31pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/4 "2003-05-18T22:31:42Z")

</div>

np dude 🙂 (btw, did it really took 5 minutes to type that all? :P, i love Who’s Online)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 10:55pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/5 "2003-05-18T22:55:05Z")

</div>

almost 5 minutres, I also have two windows open on [actionscript.org](http://actionscript.org) :geek:

thanks again!

23 seconds later . . .

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 11:23pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/6 "2003-05-18T23:23:38Z")

</div>

it would be neat, and possible, to have this function and have a button to control the x variable, so they could change the layout on the button, but have each MC move with inertia so they slide into place when you change it…

that would be a neat extra to a site

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 18, 2003, 11:28pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/7 "2003-05-18T23:28:26Z")

</div>

that would kick \*\*\*\*\* and you could use a localSharedObject to place a cookie so that the site would look the same to that user, hmm, this sounds pretty interesting!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 1:43pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/8 "2003-05-19T13:43:51Z")

</div>

i goin to figure out the xtra you want, just hold on, could take 15min 🙂

ill post it when im done…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 1:54pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/9 "2003-05-19T13:54:43Z")

</div>

this will check for a cookie:

```auto
// Get the cookie
so = sharedobject.getlocal("cookie");
// Get the user of the kookie and go to the frame number saved for this user.
if (so.data.user != undefined)
{
        this.user = so.data.user;
        trace("cookie exists!!!");
}
else
{
        trace("cookie does not exist!!!");
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 2:11pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/10 "2003-05-19T14:11:28Z")

</div>

alright, i figured it out, worked out pretty good and cool 🙂

```auto

// this prototype function is for making it all go smooth
// put the protytype and the changeLayout function on the main
// timeline, frame 1.... 
MovieClip.prototype.ease = function(x, y) {
	speed = 5;
	this.onEnterFrame = function() {
		this._x += (x-this._x)/speed;
		this._y += (y-this._y)/speed;
	};
};
// here you determine the templates, just use:
// mc.ease(newx, newy)
function changeLayout(x) {
	if (x == 1) {
		number1.ease(300, 5);
		number2.ease(50, 5);
		number3.ease(500, 10);
	} else if (x == 2) {
		number1.ease(5, 300);
		number2.ease(5, 50);
		number3.ease(0, 0);
	}
}
// to change the layout on a button, just use this actionscript on the button
// with X being the template
on(release){
	changeLayout(X)
}

```

about the cookies… you need to do that on ur own, i never worked with cookies b4… sorry

i hope i been allot of help 😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 2:25pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/11 "2003-05-19T14:25:35Z")

</div>

kewl code!! thanks! I’ll try it out.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 3:18pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/12 "2003-05-19T15:18:47Z")

</div>

here’s a live preview:

[swf=“[http://vdschee.nl/~RvGate/rvgate/kirupaSIG.swf](http://vdschee.nl/~RvGate/rvgate/kirupaSIG.swf) height=60 width=300”][/swf]

goin to be my sig to 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 3:40pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/13 "2003-05-19T15:40:04Z")

</div>

i like it!! but what does it mean?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 3:59pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/14 "2003-05-19T15:59:13Z")

</div>

RvGaTe is a mix of my own name, and my previeus nickname (GaTeKeePeR)

R = René  
v = van  
GaTe = GaTeKeePeR

translated to english,  
René from GaTeKeePeR

🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 5:49pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/15 "2003-05-19T17:49:36Z")

</div>

ha! my name is David Rene Miller (and my step dad is dutch: VandenBerg)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 8:50pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/16 "2003-05-19T20:50:33Z")

</div>

nice to meet you david :), my full name is René van Aerle (dutch :P)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [May 19, 2003, 9:05pm UTC](https://forum.kirupa.com/t/same-movieclips-different-layouts/21180/17 "2003-05-19T21:05:32Z")

</div>

when I am done with the project I’m working on, I’ll post it for you to see why I was asking these questions. although what you will see will not use your code at this point. it is a dummy layout for a prospective fulltime job.

i’ll post it in a few hours . . .
