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.
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)
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 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!
// 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
// 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
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.