I’m new to this forum and fairly new Flash and just now getting a crasp on ActionScript.
What I would like to do is a menu based on the principles of the attached file, although my overall design would be quite different.
How should I go about doing this using ActionScript…I would appreciate any help anyone could give thanks…!!!
BTW, from my first impressions here at Kirupaville, I think I may have found a new home.
Wonderful site…!!!
I don’t know why the attachment didn’t work…Let’s try this…Expanding Menu
All right, I don’t have Flash, so I’m just spitting out code off the top of my head, but I hope you’ll get the idea. Let’s imagine that all your clips are called section0, section1, section2…
// first, the function that will make the clips move
MovieClip.prototype.easeTo = function(x,y){
// We ease to the target position (x,y)
var dx = x - this._x;
var dy = y - this._y;
this._x += dx;
this._y += dy;
// if we're really close, we cancel the onEnterFrame
if (Math.abs(dx)+Math.abs(dy) < 1){
this._x = x;
this._y = y;
delete this.onEnterFrame;
}
}
// Array containing the target positions (only 4 in this example)
positionTarg_arr = [[0,0],[20,0],[40,0],[60,0]];
// Array containing the original positions
positionStart_arr = [[200,0],[220,0],[240,0],[260,0]];
// n is the number of clips we have
n = position_arr.length;
// What happens when we click on a clip?
for (var i=0 ; i < n ; i++){
var clip = this["section"+i]; //section0, then section1...
clip._x = positionStart_arr*[0];
clip._y = positionStart_arr*[1];
clip.num = i;
clip.onPress = function(){
// when we click on a button...
for (var p=0 ; p <= this.num ; p++){
// all the clips that are before that clip move to their targets
eval("section"+p).onEnterFrame = function(){
this.easeTo(positionTarg_arr[p][0],positionTarg_arr[p][1]);
}
}
for (var p=this.num+1 ; p < n ; p++){
// all the clips that are after that clip move to their original positions
eval("section"+p).onEnterFrame = function(){
this.easeTo(positionStart_arr[p][0],positionStart_arr[p][1]);
}
}
}
}