I need some help here please, I pretty much a math-tard in general that why I am posting here, hoping someone more mathematically inclined than I can help out.
I want to create a sort of circular menu, that dynamically places MC's to form a circle or on a curved path. I could easily do it the non programmers way, but I would like to be able to easily update it in the future. Anyone got a .fla siiting around like this they are willing to share?
My vision is that I can define a variable like num_menus = 16 for example, and the function(makeMenu) or whatever will place them in the correct x, y coordinates..... thats about as far as i can get before my head starts hurting.
var origin = {x: 250, y: 200}; // object representing the centre of the circle
var radius = 100; // pixels radius
var numItems = 16; // how many items round the circle
var spacing = 2 * Math.PI / numItems; // how far to space them apart
var depth = 0;
for (var i = 0; i < 2 * Math.PI; i += spacing) {
var mc = this.attachMovie("obj", "obj" + ++depth, depth); // attach a clip from the library, with linkage name obj
mc._x = origin.x + Math.cos(i) * radius; // position the new clip
mc._y = origin.y + Math.sin(i) * radius;
}
thanks for that. I tried it using an onClipEvent(load) and it worked fine...next question I have is...how do I show 16 different graphics in the duplicated clip?
Should i build an array with the dup names and assign each a graphic?
You could either create separate movie clips for each menu item or have a single movie clip containing multiple frames with the different images in different frames.
for example you could create 16 clips and give each a different linkage identifier, then store each linkage id in an array,
code:
ids = ["someClip", "anotherClip", "andSoOn"];
then when you run the loop you could use the depth counter to pick the next clip to be displayed,
code:
var mc = this.attachMovie(ids[depth], "obj" + depth, depth);
depth++;
or you could have all the different images in the same clip and when the clip is attached send it to the desired frame (if the images each occupied a single frame you could use,
code:
var mc = this.attachMovie("obj", "obj" + depth, depth);
mc.gotoAndStop(++depth);