Periodic Table of Elements

Well, this is a day late and a dollar short . . . When I read a February 1st deadline in the rules I thought that meant you could submit something on Feb. 1st and since I didn’t see the “this is that last day” thread yesterday I didn’t know.

Anyhow, the rules are the rules, but I figured I might as well post what I was working on to get some feedback on it.

It’s the periodic table of elements. The array contains the Atomic Number, Atomic Mass, and Chemical symbol of each element. The script draws a simple periodic table and when you click on an element, it draws the atom with appropriate number of protons, neutrons, and electrons (which are placed in their proper electron shells).

I wanted to animate the electrons when I was done, but I used up my 25 lines just getting them drawn, so here it is:
[AS]pTable = new Array([[1, “H”, 1.01], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [2, “He”, 4]], [[3, “Li”, 6.94], [4, “Be”, 9.01], [], [], [], [], [], [], [], [], [], [], [5, “B”, 10.81], [6, “C”, 12.01], [7, “N”, 14.01], [8, “O”, 15.99], [9, “F”, 19], [10, “Ne”, 20.18]], [[11, “Na”, 22.99], [12, “Mg”, 25.31], [], [], [], [], [], [], [], [], [], [], [13, “Al”, 26.98], [14, “Si”, 28.09], [15, “P”, 30.97], [16, “S”, 32, 07], [17, “Cl”, 35.45], [18, “Ar”, 39.95]], [[19, “K”, 39.10], [20, “Ca”, 40.08], [21, “Sc”, 44.96], [22, “Ti”, 47.87], [23, “V”, 50.94], [24, “Cr”, 52], [25, “Mn”, 59.94], [26, “Fe”, 55.85], [27, “Co”, 58.93], [28, “Ni”, 58.69], [29, “Cu”, 63.55], [30, “Zn”, 65.41], [31, “Ga”, 69.72], [32, “Ge”, 72.64], [33, “As”, 74.92], [34, “Se”, 78.96], [35, “Br”, 79.9], [36, “Kr”, 83.8]], [[37, “Rb”, 85.47], [38, “Sr”, 87.62], [39, “Y”, 88.91], [40, “Zr”, 91.22], [41, “Nb”, 92.91], [42, “Mo”, 95.94], [43, “Tc”, 98], [44, “Ru”, 101.07], [45, “Rh”, 102.91], [46, “Pd”, 106.42], [47, “Ag”, 107.87], [48, “Cd”, 112.41], [49, “In”, 114.82], [50, “Sn”, 118.71], [51, “Sb”, 118.71], [52, “Te”, 127.76], [53, “I”, 126.9], [54, “Xe”, 131.29]], [[55, “Cs”, 132.91], [56, “Ba”, 137.33], [57, “La”, 138.91], [72, “Hf”, 178.49], [73, “Ta”, 180.95], [74, “W”, 183.49], [75, “Re”, 186.21], [76, “Os”, 190.23], [77, “Ir”, 192.22], [78, “Pt”, 195.08], [79, “Au”, 196.97], [80, “Hg”, 200.59], [81, “Tl”, 204.38], [82, “Pb”, 207.2], [83, “Bi”, 208.98], [84, “Po”, 209], [85, “At”, 210], [86, “Rn”, 222]], [[87, “Fr”, 223], [88, “Ra”, 226], [89, “Ac”, 227], [104, “Rf”, 261], [105, “Db”, 262], [106, “Sg”, 266], [107, “Bh”, 264], [108, “Hs”, 270], [109, “Mt”, 268], [110, “Ds”, 281], [111, “Rg”, 272], [], [], [], [], [], [], []], [[], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], [], []], [[], [], [], [58, “Ce”, 140.12], [59, “Pr”, 140.91], [60, “Nd”, 144.24], [61, “Pm”, 145], [62, “Sm”, 150.36], [63, “Eu”, 151.97], [64, “Gd”, 157.25], [65, “Tb”, 158.93], [66, “Dy”, 162.5], [67, “Ho”, 164.93], [68, “Er”, 167.26], [69, “Tm”, 168.93], [70, “Yb”, 173.04], [71, “Lu”, 174.97], []], [[], [], [], [90, “Th”, 232.04], [91, “Pa”, 231.04], [92, “U”, 238.03], [93, “Np”, 237], [94, “Pu”, 244], [95, “Am”, 243], [96, “Cm”, 247], [97, “Cm”, 247], [98, “Cf”, 251], [99, “Es”, 252], [100, “Fm”, 257], [101, “Md”, 258], [102, “No”, 259], [103, “Lr”, 262], []]);
for (i=0; i<10; i++) {
for (j=0; j<18; j++) {
pTable*[j].length>1 ? createCell(i, j, 22, 10) : null;
}
}
function createCell(i, j, grid, margin) {
clip = _root.createEmptyMovieClip(“cell”+i+j, (i100)+j);
clip.createTextField(“atomic”, 1, (j
grid)+margin, (igrid)+margin, grid-1, grid-1);
clip.atomic.background = true;
clip.atomic.text = pTable
[j][1];
clip.onRelease = function() {
buildAtom(pTable[(this.atomic._y-margin)/grid][(this.atomic._x-margin)/grid][0], pTable[(this.atomic._y-margin)/grid][(this.atomic._x-margin)/grid][0], Math.round(pTable[(this.atomic._y-margin)/grid][(this.atomic._x-margin)/grid][2])-pTable[(this.atomic._y-margin)/grid][(this.atomic._x-margin)/grid][0]);
};
}
function buildAtom(electrons, protons, neutrons) {
_root.clear();
nucleusArray = new Array();
for (p=0; p<neutrons+protons; p++) {
p<neutrons ? nucleusArray[p]=Math.floor(Math.random()999)+“n” : nucleusArray[p]=Math.floor(Math.random()999)+“p”;
}
nucleusArray.sort();
for (k=0; k<neutrons+protons; k++) {
r = 5 + Math.random()
(neutrons+protons)/10;
nucleusArray.pop().substr(-1, 1) == “p” ? drawParticle(660+(r
Math.cos(.75k((Math.PI4)/(neutrons+protons)))), 185+(rMath.sin(.75k((Math.PI4)/(neutrons+protons)))), 10, 0xFF0000) : drawParticle(660+(rMath.cos(.75k((Math.PI4)/(neutrons+protons)))), 185+(rMath.sin(.75k((Math.PI4)/(neutrons+protons)))), 10, 0x0000FF);
}
for (i=1; i<=electrons; i++) {
i<=2 ? n=1 : i<=10 ? n=2 : i<=28 ? n=3 : i<=60 ? n=4 : i<=110 ? n=5 : n=6;
n == 1 ? br=0 : n == 2 ? br=2 : n == 3 ? br=10 : n == 4 ? br=28 : n == 5 ? br=60 : br=110;
electrons-br>=2
nn ? drawParticle(660+(n50)Math.cos(i(360/(2nn))(Math.PI/180)), 185+(n50)Math.sin(i(360/(2nn))(Math.PI/180)), 5, 0x00CC00) : drawParticle(660+(n50)Math.cos(i(360/(electrons-br))(Math.PI/180)), 185+(n50)Math.sin(i(360/(electrons-br))*(Math.PI/180)), 5, 0x00CC00);
}
}
function drawParticle(x, y, radius, hex) {
_root.lineStyle(radius, hex);
_root.moveTo(x, y);
_root.lineTo(x+.3, y);
}
[/AS]