hello,
our teacher asked us to do a class project with Flash and I decide to do a demonstration for the different kinds of sorts and for that I need to show this procedure step by step:
1 - compare two elements of the table
2 - exchange their location in case of verification of the condition
yet I managed to create a table and fill it with random number i alos did the exchange of the two first elements
here is the code :
var tab:Array = new Array(); var min = 0; var max = 10; function remplir(tab) { for (i=0; i<5; i++) { tab[i] = Math.floor(Math.random()*(max-min+1))+min; } } t0 = tab[0]; t1 = tab[1]; t2 = tab[2]; t3 = tab[3]; t4 = tab[4]; var speed = 5; function deplacer(a, b, c, d, p) { if (a>b) { c._x += speed; d._x -= speed; if (d._x == p) { speed = 0; } } } onEnterFrame = function () { deplacer(t0, t1, to0, to1, 54); };//t0,t1,t2,t4 are the dynamic text variable
//to0 and to1 are the Instance Name of the Dynamic Texts
my problem is how to do this for the other Table elements (they are 5 elements)
i mean i can't just create a for loop and replace to0 by to[i]
(i don't know if that possible or not but i try it and it didn't work)
Thank you
okay but the thing is that i have no experience in "object" programmint i mean
i can do this and it's working :
for (i=1; i<5; i++) {
if(t[i]>[i-1]{
aux=t[i];
t[i]=t[i-1]
t[i-1]=aux;
}
}
but i don't know any way to use a counter on objects (movieClip,text,etc..) so if you have any tips i'll be very happy and gratefull
thank you
North America
Europe, Middle East and Africa
Asia Pacific