|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
||||
|
||||
|
Changing _y of each element in array with loop...
I have this code:
karate.onRelease = function() { karateOpen(); } function karateOpen() { array = new Array("elem","karate","jh","hs","duke"); for (var i=0;i<array.length;i++) { if (array[i] != "karate") { with(array[i]) { _y += 40; } } } } What I want is for each button to move down 40 when the karate button is pressed. The problem is the instead of each moving down individually, they are all moving down together...like all the buttons are one button and it's moving it. Thanks |
|
#2
|
|||
|
|||
|
Hi, sounds like you want a pause. This might do what you want:
Code:
karate.onRelease = function()
{
karateOpen();
}
function karateOpen()
{
if(count < maxCount)
{
if (array[count] != "karate")
{
array[count]._y += 40;
}
count++;
}
else
{
clearInterval(pauser);
}
}
function init()
{
array = new Array("elem","karate","jh","hs","duke");
maxCount = array.length;
count = 0;
pauser = setInterval(karateOpen, 100);
}
init();
It probably needs some tweaking but it should be enough to give you the general idea. lower the second value for setInterval to reduce the time between function calls. |
|
#3
|
||||
|
||||
|
whenever I try something like this:
array[i]._y It tells me it is undefined. ![]() |
|
#4
|
|||
|
|||
|
Hi, oh...well a couple of things pop to mind. Its never really a good idea to call things the same as functions/methods i.e. array. try enclosing it in an eval statement i.e.:
eval(array[count])._y = whatever; If that doesnt work switch back to using your with() clause. |
![]() |
| Viewing: Dev Shed Forums > Web Design > Flash Help > Changing _y of each element in array with loop... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|