Same movieclips, different layouts

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:

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:

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. :frowning:

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


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

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

RvGaTe, you RULE!!!

thanks!!! :thumb:

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

almost 5 minutres, I also have two windows open on actionscript.org :geek:

thanks again!

23 seconds later . . .

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

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!

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

ill post it when im done…

this will check for a cookie:

// 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!!!");
}

alright, i figured it out, worked out pretty good and cool :slight_smile:


// 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 :smiley:

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

here’s a live preview:

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

goin to be my sig to :slight_smile:

i like it!! but what does it mean?

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

:slight_smile:

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

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

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 . . .