Monday, 19 January 2015

ARRAY SORT OUT AND MOVIE POSITION CHANGE IN AS2

function init(){
myItemArray = new Array("move01", "move02", "move03", "move04", "move05", "move06", "move07", "move08", "move09", "move10", "move11", "move12", "move13", "move14", "move15", "move16", "move17", "move18", "move19", "move20", "move21", "move22", "move23", "move24", "move25", "move26", "move27", "move28", "move29", "move30", "move31", "move32", "move33", "move34", "move35", "move36", "move37", "move38", "move39", "move40", "move41", "move42", "move43", "move44", "move45", "move46");
var x = 0;
while (x < kCount){
myItemArray[x] = parseInt(Math.random() * 9) + myItemArray[x];
++x;
}
myItemArray.sort();
var x = 0;
while (x < kCount){
myItemArray[x] = myItemArray[x].substr(1, myItemArray[x].length);
++x;
}
myXArray = new Array(_root.move01x, _root.move02x, _root.move03x, _root.move04x, _root.move05x, _root.move06x, _root.move07x, _root.move08x, _root.move09x, _root.move10x, _root.move11x, _root.move12x, _root.move13x, _root.move14x, _root.move15x, _root.move16x, _root.move17x, _root.move18x, _root.move19x, _root.move20x, _root.move21x, _root.move22x, _root.move23x, _root.move24x, _root.move25x, _root.move26x, _root.move27x, _root.move28x, _root.move29x, _root.move30x, _root.move31x, _root.move32x, _root.move33x, _root.move34x, _root.move35x, _root.move36x, _root.move37x, _root.move38x, _root.move39x, _root.move40x, _root.move41x, _root.move42x, _root.move43x, _root.move44x, _root.move45x, _root.move46x);
myYArray = new Array(_root.move01y, _root.move02y, _root.move03y, _root.move04y, _root.move05y, _root.move06y, _root.move07y, _root.move08y, _root.move09y, _root.move10y, _root.move11y, _root.move12y, _root.move13y, _root.move14y, _root.move15y, _root.move16y, _root.move17y, _root.move18y, _root.move19y, _root.move20y, _root.move21y, _root.move22y, _root.move23y, _root.move24y, _root.move25y, _root.move26y, _root.move27y, _root.move28y, _root.move29y, _root.move30y, _root.move31y, _root.move32y, _root.move33y, _root.move34y, _root.move35y, _root.move36y, _root.move37y, _root.move38y, _root.move39y, _root.move40y, _root.move41y, _root.move42y, _root.move43y, _root.move44y, _root.move45y, _root.move46y);
var t = 0;
while (t < kCount){
myElement = eval("_root." + myItemArray[t]);
myElement._x = myXArray[t];
myElement._y = myYArray[t];
myElement._visible = true;
myElement.found = false;
++t;
}
move01x = _root.move01._x;
move01y = _root.move01._y;
move02x = _root.move02._x;
move02y = _root.move02._y;
move03x = _root.move03._x;
move03y = _root.move03._y;
move04x = _root.move04._x;
move04y = _root.move04._y;
move05x = _root.move05._x;
move05y = _root.move05._y;
move06x = _root.move06._x;
move06y = _root.move06._y;
move07x = _root.move07._x;
move07y = _root.move07._y;
move08x = _root.move08._x;
move08y = _root.move08._y;
move09x = _root.move09._x;
move09y = _root.move09._y;
move10x = _root.move10._x;
move10y = _root.move10._y;
move11x = _root.move11._x;
move11y = _root.move11._y;
move12x = _root.move12._x;
move12y = _root.move12._y;
move13x = _root.move13._x;
move13y = _root.move13._y;
move14x = _root.move14._x;
move14y = _root.move14._y;
move15x = _root.move15._x;
move15y = _root.move15._y;
move16x = _root.move16._x;
move16y = _root.move16._y;
move17x = _root.move17._x;
move17y = _root.move17._y;
move18x = _root.move18._x;
move18y = _root.move18._y;
move19x = _root.move19._x;
move19y = _root.move19._y;
move20x = _root.move20._x;
move20y = _root.move20._y;
move21x = _root.move21._x;
move21y = _root.move21._y;
move22x = _root.move22._x;
move22y = _root.move22._y;
move23x = _root.move23._x;
move23y = _root.move23._y;
move24x = _root.move24._x;
move24y = _root.move24._y;
move25x = _root.move25._x;
move25y = _root.move25._y;
move26x = _root.move26._x;
move26y = _root.move26._y;
move27x = _root.move27._x;
move27y = _root.move27._y;
move28x = _root.move28._x;
move28y = _root.move28._y;
move29x = _root.move29._x;
move29y = _root.move29._y;
move30x = _root.move30._x;
move30y = _root.move30._y;
move31x = _root.move31._x;
move31y = _root.move31._y;
move32x = _root.move32._x;
move32y = _root.move32._y;
move33x = _root.move33._x;
move33y = _root.move33._y;
move34x = _root.move34._x;
move34y = _root.move34._y;
move35x = _root.move35._x;
move35y = _root.move35._y;
move36x = _root.move36._x;
move36y = _root.move36._y;
move37x = _root.move37._x;
move37y = _root.move37._y;
move38x = _root.move38._x;
move38y = _root.move38._y;
move39x = _root.move39._x;
move39y = _root.move39._y;
move40x = _root.move40._x;
move40y = _root.move40._y;
move41x = _root.move41._x;
move41y = _root.move41._y;
move42x = _root.move42._x;
move42y = _root.move42._y;
move43x = _root.move43._x;
move43y = _root.move43._y;
move44x = _root.move44._x;
move44y = _root.move44._y;
move45x = _root.move45._x;
move45y = _root.move45._y;
move46x = _root.move46._x;
move46y = _root.move46._y;
}


function restartTimer(){
hours = "00";
minutes = "00";
seconds = "00";
milli = "00";
buttonPressTime = getTimer() / 1000 - pauseLength;
pause();
}
function pause(){
pauseTime = getTimer() / 1000;
timing = false;
}
function unpause(){
unpauseTime = getTimer() / 1000;
pauseLength = unpauseTime - pauseTime + pauseLength;
timing = true;
}
function char_press(char){
if (!char.found){
origX = char._x;
origY = char._y;
startDrag (char, true)}}
function char_release(char){
if (!char.found){
stopDrag ();
myString = String(char._name);
myString2 = myString.substr(length(myString) - 2, 2);
if (eval(char._droptarget) == eval("_root.dest" + myString2)){
char._x = eval("_root.dest" + myString2 + "._x");
char._y = eval("_root.dest" + myString2 + "._y");
++_root.gNumCorrect;
char.found = true;
if (_root.gNumCorrect == _root.kCount){
_root.reward._visible = true;
_root.pause();}}
else{
char._x = origX;
char._y = origY;
}}}
kCount = 46;
init();
init();
stop ();



========================================================================
EXTRA PART

========================================================================
_root.onEnterFrame = function (){
totalTime = getTimer() / 1000 - pauseLength;
goTime = totalTime - buttonPressTime;
if (timing)
{
hours = Math.floor(goTime / 3600);
minutes = Math.floor((goTime / 3600 - hours) * 60);
seconds = Math.floor(((goTime / 3600 - hours) * 60 - minutes) * 60);
milli = Math.floor((gotime - (seconds + minutes * 60 + hours * 3600)) * 100);
if (seconds < 10){
seconds = "0" + seconds;

if (minutes < 10){
minutes = "0" + minutes;

if (hours < 10){
hours = "0" + hours;
}
if (milli < 10){
milli = "0" + milli;
}}}

------------------------------------------------------------------------------------------------------------------
SHORT CODE 1
-------------------------------------------------------------------------------------------------------------------

function init(){
myItemArray = new Array("move01", "move02", "move03", "move04", "move05", "move06", "move07", "move08", "move09", "move10", "move11", "move12", "move13", "move14", "move15", "move16", "move17", "move18", "move19", "move20", "move21", "move22", "move23", "move24", "move25", "move26", "move27", "move28", "move29", "move30", "move31", "move32", "move33", "move34", "move35", "move36", "move37", "move38", "move39", "move40", "move41", "move42", "move43", "move44", "move45", "move46");
var x = 0;
while (x < kCount){
myItemArray[x] = parseInt(Math.random() * 9) + myItemArray[x];
++x;
}
myItemArray.sort();
var x = 0;
while (x < kCount){
myItemArray[x] = myItemArray[x].substr(1, myItemArray[x].length);
++x;
}
myXArray = new Array(_root.move01x, _root.move02x, _root.move03x, _root.move04x, _root.move05x, _root.move06x, _root.move07x, _root.move08x, _root.move09x, _root.move10x, _root.move11x, _root.move12x, _root.move13x, _root.move14x, _root.move15x, _root.move16x, _root.move17x, _root.move18x, _root.move19x, _root.move20x, _root.move21x, _root.move22x, _root.move23x, _root.move24x, _root.move25x, _root.move26x, _root.move27x, _root.move28x, _root.move29x, _root.move30x, _root.move31x, _root.move32x, _root.move33x, _root.move34x, _root.move35x, _root.move36x, _root.move37x, _root.move38x, _root.move39x, _root.move40x, _root.move41x, _root.move42x, _root.move43x, _root.move44x, _root.move45x, _root.move46x);
myYArray = new Array(_root.move01y, _root.move02y, _root.move03y, _root.move04y, _root.move05y, _root.move06y, _root.move07y, _root.move08y, _root.move09y, _root.move10y, _root.move11y, _root.move12y, _root.move13y, _root.move14y, _root.move15y, _root.move16y, _root.move17y, _root.move18y, _root.move19y, _root.move20y, _root.move21y, _root.move22y, _root.move23y, _root.move24y, _root.move25y, _root.move26y, _root.move27y, _root.move28y, _root.move29y, _root.move30y, _root.move31y, _root.move32y, _root.move33y, _root.move34y, _root.move35y, _root.move36y, _root.move37y, _root.move38y, _root.move39y, _root.move40y, _root.move41y, _root.move42y, _root.move43y, _root.move44y, _root.move45y, _root.move46y);
var t = 0;
while (t < kCount){
myElement = eval("_root." + myItemArray[t]);
myElement._x = myXArray[t];
myElement._y = myYArray[t];
myElement._visible = true;
myElement.found = false;
++t;
}
move01x = _root.move01._x;
move01y = _root.move01._y;
move02x = _root.move02._x;
move02y = _root.move02._y;
move03x = _root.move03._x;
move03y = _root.move03._y;
move04x = _root.move04._x;
move04y = _root.move04._y;
move05x = _root.move05._x;
move05y = _root.move05._y;
move06x = _root.move06._x;
move06y = _root.move06._y;
move07x = _root.move07._x;
move07y = _root.move07._y;
move08x = _root.move08._x;
move08y = _root.move08._y;
move09x = _root.move09._x;
move09y = _root.move09._y;
move10x = _root.move10._x;
move10y = _root.move10._y;
move11x = _root.move11._x;
move11y = _root.move11._y;
move12x = _root.move12._x;
move12y = _root.move12._y;
move13x = _root.move13._x;
move13y = _root.move13._y;
move14x = _root.move14._x;
move14y = _root.move14._y;
move15x = _root.move15._x;
move15y = _root.move15._y;
move16x = _root.move16._x;
move16y = _root.move16._y;
move17x = _root.move17._x;
move17y = _root.move17._y;
move18x = _root.move18._x;
move18y = _root.move18._y;
move19x = _root.move19._x;
move19y = _root.move19._y;
move20x = _root.move20._x;
move20y = _root.move20._y;
move21x = _root.move21._x;
move21y = _root.move21._y;
move22x = _root.move22._x;
move22y = _root.move22._y;
move23x = _root.move23._x;
move23y = _root.move23._y;
move24x = _root.move24._x;
move24y = _root.move24._y;
move25x = _root.move25._x;
move25y = _root.move25._y;
move26x = _root.move26._x;
move26y = _root.move26._y;
move27x = _root.move27._x;
move27y = _root.move27._y;
move28x = _root.move28._x;
move28y = _root.move28._y;
move29x = _root.move29._x;
move29y = _root.move29._y;
move30x = _root.move30._x;
move30y = _root.move30._y;
move31x = _root.move31._x;
move31y = _root.move31._y;
move32x = _root.move32._x;
move32y = _root.move32._y;
move33x = _root.move33._x;
move33y = _root.move33._y;
move34x = _root.move34._x;
move34y = _root.move34._y;
move35x = _root.move35._x;
move35y = _root.move35._y;
move36x = _root.move36._x;
move36y = _root.move36._y;
move37x = _root.move37._x;
move37y = _root.move37._y;
move38x = _root.move38._x;
move38y = _root.move38._y;
move39x = _root.move39._x;
move39y = _root.move39._y;
move40x = _root.move40._x;
move40y = _root.move40._y;
move41x = _root.move41._x;
move41y = _root.move41._y;
move42x = _root.move42._x;
move42y = _root.move42._y;
move43x = _root.move43._x;
move43y = _root.move43._y;
move44x = _root.move44._x;
move44y = _root.move44._y;
move45x = _root.move45._x;
move45y = _root.move45._y;
move46x = _root.move46._x;
move46y = _root.move46._y;
}

function char_release(char){
if (!char.found){
stopDrag ();
myString = String(char._name);
myString2 = myString.substr(length(myString) - 2, 2);
if (eval(char._droptarget) == eval("_root.dest" + myString2)){
char._x = eval("_root.dest" + myString2 + "._x");
char._y = eval("_root.dest" + myString2 + "._y");
++_root.gNumCorrect;
char.found = true;
if (_root.gNumCorrect == _root.kCount){
_root.reward._visible = true;
_root.pause();}}
else{
char._x = origX;
char._y = origY;
}}}
kCount = 46;
init();
init();
stop ();


------------------------------------------------------------------------------------------------------------------
SHORT CODE 2
-------------------------------------------------------------------------------------------------------------------


function init(){
myItemArray = new Array("move01", "move02", "move03", "move04", "move05", "move06", "move07", "move08", "move09", "move10", "move11", "move12", "move13", "move14", "move15", "move16", "move17", "move18", "move19", "move20", "move21", "move22", "move23", "move24", "move25", "move26", "move27", "move28", "move29", "move30", "move31", "move32", "move33", "move34", "move35", "move36", "move37", "move38", "move39", "move40", "move41", "move42", "move43", "move44", "move45", "move46");
var x = 0;
while (x < kCount){
myItemArray[x] = parseInt(Math.random() * 9) + myItemArray[x];
++x;
}
myItemArray.sort();
var x = 0;
while (x < kCount){
myItemArray[x] = myItemArray[x].substr(1, myItemArray[x].length);
++x;
}
myXArray = new Array(_root.move01x, _root.move02x, _root.move03x, _root.move04x, _root.move05x, _root.move06x, _root.move07x, _root.move08x, _root.move09x, _root.move10x, _root.move11x, _root.move12x, _root.move13x, _root.move14x, _root.move15x, _root.move16x, _root.move17x, _root.move18x, _root.move19x, _root.move20x, _root.move21x, _root.move22x, _root.move23x, _root.move24x, _root.move25x, _root.move26x, _root.move27x, _root.move28x, _root.move29x, _root.move30x, _root.move31x, _root.move32x, _root.move33x, _root.move34x, _root.move35x, _root.move36x, _root.move37x, _root.move38x, _root.move39x, _root.move40x, _root.move41x, _root.move42x, _root.move43x, _root.move44x, _root.move45x, _root.move46x);
myYArray = new Array(_root.move01y, _root.move02y, _root.move03y, _root.move04y, _root.move05y, _root.move06y, _root.move07y, _root.move08y, _root.move09y, _root.move10y, _root.move11y, _root.move12y, _root.move13y, _root.move14y, _root.move15y, _root.move16y, _root.move17y, _root.move18y, _root.move19y, _root.move20y, _root.move21y, _root.move22y, _root.move23y, _root.move24y, _root.move25y, _root.move26y, _root.move27y, _root.move28y, _root.move29y, _root.move30y, _root.move31y, _root.move32y, _root.move33y, _root.move34y, _root.move35y, _root.move36y, _root.move37y, _root.move38y, _root.move39y, _root.move40y, _root.move41y, _root.move42y, _root.move43y, _root.move44y, _root.move45y, _root.move46y);
var t = 0;
while (t < kCount){
myElement = eval("_root." + myItemArray[t]);
myElement._x = myXArray[t];
myElement._y = myYArray[t];
myElement._visible = true;
myElement.found = false;
++t;
}
move01x = _root.move01._x;
move01y = _root.move01._y;
move02x = _root.move02._x;
move02y = _root.move02._y;
move03x = _root.move03._x;
move03y = _root.move03._y;
move04x = _root.move04._x;
move04y = _root.move04._y;
move05x = _root.move05._x;
move05y = _root.move05._y;
move06x = _root.move06._x;
move06y = _root.move06._y;
move07x = _root.move07._x;
move07y = _root.move07._y;
move08x = _root.move08._x;
move08y = _root.move08._y;
move09x = _root.move09._x;
move09y = _root.move09._y;
move10x = _root.move10._x;
move10y = _root.move10._y;
move11x = _root.move11._x;
move11y = _root.move11._y;
move12x = _root.move12._x;
move12y = _root.move12._y;
move13x = _root.move13._x;
move13y = _root.move13._y;
move14x = _root.move14._x;
move14y = _root.move14._y;
move15x = _root.move15._x;
move15y = _root.move15._y;
move16x = _root.move16._x;
move16y = _root.move16._y;
move17x = _root.move17._x;
move17y = _root.move17._y;
move18x = _root.move18._x;
move18y = _root.move18._y;
move19x = _root.move19._x;
move19y = _root.move19._y;
move20x = _root.move20._x;
move20y = _root.move20._y;
move21x = _root.move21._x;
move21y = _root.move21._y;
move22x = _root.move22._x;
move22y = _root.move22._y;
move23x = _root.move23._x;
move23y = _root.move23._y;
move24x = _root.move24._x;
move24y = _root.move24._y;
move25x = _root.move25._x;
move25y = _root.move25._y;
move26x = _root.move26._x;
move26y = _root.move26._y;
move27x = _root.move27._x;
move27y = _root.move27._y;
move28x = _root.move28._x;
move28y = _root.move28._y;
move29x = _root.move29._x;
move29y = _root.move29._y;
move30x = _root.move30._x;
move30y = _root.move30._y;
move31x = _root.move31._x;
move31y = _root.move31._y;
move32x = _root.move32._x;
move32y = _root.move32._y;
move33x = _root.move33._x;
move33y = _root.move33._y;
move34x = _root.move34._x;
move34y = _root.move34._y;
move35x = _root.move35._x;
move35y = _root.move35._y;
move36x = _root.move36._x;
move36y = _root.move36._y;
move37x = _root.move37._x;
move37y = _root.move37._y;
move38x = _root.move38._x;
move38y = _root.move38._y;
move39x = _root.move39._x;
move39y = _root.move39._y;
move40x = _root.move40._x;
move40y = _root.move40._y;
move41x = _root.move41._x;
move41y = _root.move41._y;
move42x = _root.move42._x;
move42y = _root.move42._y;
move43x = _root.move43._x;
move43y = _root.move43._y;
move44x = _root.move44._x;
move44y = _root.move44._y;
move45x = _root.move45._x;
move45y = _root.move45._y;
move46x = _root.move46._x;
move46y = _root.move46._y;
}

function char_release(char){
if (!char.found){

}
else{
char._x = origX;
char._y = origY;
}}
kCount = 46;
init();
init();
stop ();







EmoticonEmoticon