Hello,
I have decompiled a flash movie and exracted the actionscript from it. The flash movie has a form and based on the values, the actionscript computes a result and displays it.
I need to convert this structure into a HTML form collecting values and a Javascript computing and displaying the result.
I know that Actionscript is based on JS but I don't know where the differences are. For instance AS has the switch function like php, but I am not sure if that will work with JS.
Anyway, here is the AS:
How can this script be converted to JS?
I have decompiled a flash movie and exracted the actionscript from it. The flash movie has a form and based on the values, the actionscript computes a result and displays it.
I need to convert this structure into a HTML form collecting values and a Javascript computing and displaying the result.
I know that Actionscript is based on JS but I don't know where the differences are. For instance AS has the switch function like php, but I am not sure if that will work with JS.
Anyway, here is the AS:
Code:
function importContent() { loadVariables("content_" + lingo + ".txt", "_root"); initAll(); } function parseContent() { test = "bcdef"; initAll(); } function initAll() { grossessesSelector._visible = 0; sexe = 0; taille = ""; poids_actuel = ""; poids_croisiere = ""; poids_minimum = ""; ossatureSelector.setSelectedIndex(0); poids_souhaite = ""; poids_maximum = ""; poids_actuel = ""; age = ""; regimesSelector.setSelectedIndex(0); sexeSelector.setSelectedIndex(0); grossessesSelector.setSelectedIndex(0); herediteSelector.setSelectedIndex(0); details = ""; result = ""; } function changeSexe() { if (sexeSelector.getSelectedItem().data == 2) { grossessesSelector._visible = 1; wife_1._visible = 1; wife_2._visible = 1; } else { grossessesSelector._visible = 0; wife_1._visible = 0; wife_2._visible = 0; } // end else if } function computeWeidth() { isOk = 1; systemBase = systemSelector.getSelectedItem().data; sexe = sexeSelector.getSelectedItem().data; ossature = ossatureSelector.getSelectedItem().data; regimes = regimesSelector.getSelectedItem().data; if (regimes == 0 || age == "" || taille == "" || poids_minimum == "" || poids_maximum == "" || poids_croisiere == "" || poids_souhaite == "" || ossature == 0) { details = "ERROR! #1"; isOk = 0; } // end if if (isOk == 1) { taille = Number(taille); age = Number(age); poids_minimum = Number(poids_minimum); poids_maximum = Number(poids_maximum); poids_croisiere = Number(poids_croisiere); poids_souhaite = Number(poids_souhaite); if (test_taille.Number.NaN) { details = "ERROR! #2_1"; isOk = 0; } // end if if (test_poids_minimum.Number.NaN) { details = "ERROR! #2_2"; isOk = 0; } // end if if (test_poids_maximum.Number.NaN) { details = "ERROR! #2_3"; isOk = 0; } // end if if (test_poids_croisiere.Number.NaN) { details = "ERROR! #2_4"; isOk = 0; } // end if if (test_poids_souhaite.Number.NaN) { details = "ERROR! #2_5"; isOk = 0; } // end if } // end if if (isOk == 1) { tailleMetters = taille / 100; compute = (poids_minimum + poids_maximum) / 2; details = "(poids_minimum + poids_maximum) / 2 : " + compute + "\n"; thisComputing = poids_croisiere + poids_souhaite * 2; compute = compute + thisComputing; details = details + ("poids_croisiere + (poids_souhaite * 2) : " + thisComputing + "\n"); details = details + (compute + "\n"); if (sexe == 2 || sexe == 4) { imc = tailleMetters * tailleMetters * 21; details = details + ("imc : (tailleMetters * tailleMetters) * 21 : " + imc + "\n"); } else if (sexe == 1 || sexe == 3) { imc = tailleMetters * tailleMetters * 24; details = details + ("imc : (tailleMetters * tailleMetters) * 24 : " + imc + "\n"); } // end else if thisComputing = imc * 2; compute = compute + thisComputing; details = details + ("imc * 2 : " + thisComputing + "\n"); details = details + (compute + "\n"); thisComputing = compute / 6; compute = thisComputing; details = details + ("result / 6 : " + thisComputing + "\n"); if (ossature == 1) { compute = compute + 1; details = details + "Ossature : +1"; } else if (ossature == 3) { compute = compute - 1; details = details + "Ossature : -1"; } else if (ossature == 2) { details = details + "Ossature : 0"; } // end else if details = details + (" : " + compute + "\n"); if (sexe == 2 || sexe == 4) { nombreDeGrossesses = grossessesSelector.getSelectedItem().data; compute = compute + 5.000000E-001 * nombreDeGrossesses; details = details + ("grossesses : " + nombreDeGrossesses + " : " + 5.000000E-001 * nombreDeGrossesses + " : " + compute + "\n"); } // end if if ((sexe == 1 || sexe == 2) && age >= 30) { plusYears = age - 30; if (sexe == 1) { thisComputing = plusYears * 8.000000E-002; compute = compute + thisComputing; } else { thisComputing = plusYears * 1.200000E-001; compute = compute + thisComputing; } // end else if details = details + ("Correctif age : " + thisComputing + " : " + compute); } // end if switch (systemBase) { case 1: { systemExtension = "kg"; break; } case 2: { compute = compute * 2.200000E+000; systemExtension = "lbs"; break; } } // End of switch result = compute + " " + systemExtension; } // end if } stop (); if (lingo == undefined) { lingo = "fr"; } // end if System.useCodePage = true; importContent();
Comment