ok so i have this code:
[AS]
for (i=1; i<=20; i++) {
var holder = attachMovie(“box”, “box+n”, ++n)
holder._x = 15*i
}
[/AS]
That works fine, but the problem is i want the boxes to spread out more, so i tried:
holder._x = 15*i+5
But theres no difference? i tried bigger numbers too with no luck :-\ Anyone know whats wrong? thanks!
system
August 19, 2003, 5:21am
2
oh…you’re naming all the boxes the same name. and in flash you can’t do that. at the end of this code, you have one box called “box+n”, literally. I think you meant this:
for (i=1; i<=20; i++) {
var holder = attachMovie("box", "box"+n, ++n)
holder._x = 15*i
}
those tiny mistakes will really get you.
system
August 19, 2003, 5:23am
3
[AS]for (i=1; i<=20; i++) {
var holder = attachMovie(“box”, “box”+n, ++n)
holder._x = 15i
}
[/AS]
[AS]for (i=1; i<=20; i++) {
var holder = attachMovie(“box”, “box”+n, ++n)
holder._x = 20 i
}
[/AS]
system
August 19, 2003, 5:29am
4
thanks ithuriel, didn’t manage to spot that, but i don’ think thats the problem :-\
Even with the new code:
[AS]
for (i=1; i<=20; i++) {
var holder = attachMovie(“box”, “box”+n, ++n);
holder._x = 15*i+5;
}
[/AS]
…the boxes still don’t seem to spread apart :-\
I’ll attach an fla…
And to voetajoeba, why did you just change it to 20*i?? thanks!
system
August 19, 2003, 5:33am
5
Because they are more spread when you set it to 20 Look at the code:
[AS]
for (i=1; i<=20; i++) {
var holder = attachMovie(“box”, “box”+n, ++n);
holder._x = 15i; //So 15 1, 152, 15 3, …
}
[/AS]
[AS]
for (i=1; i<=20; i++) {
var holder = attachMovie(“box”, “box”+n, ++n);
holder._x = 20i; //So 20 1, 202, 20 3, …
}
[/AS]
system
August 19, 2003, 5:54am
6
oh i see But doesn’t it work if you do it just like:
(15*1)+5
anyways thanks i guess i’ll do it your way since my way doesn’t seem to be workin :-\
system
August 19, 2003, 6:15am
7
I know why it doesn’t work, but I can’t really explain it. This might help:
15*1 = 15 + 5 = 20
15*2 = 30 + 5 = 35
15*3 = 45 + 5 = 50
15*4 = 60 + 5 = 65
15*5 = 75 + 5 = 80
15*6 = 90 + 5 = 95
15*7 = 105 + 5 = 110
15*8 = 120 + 5 = 125
15*9 = 135 + 5 = 140
15*10 = 150 + 5 = 155
15*11 = 165 + 5 = 170
15*12 = 180 + 5 = 185
15*13 = 195 + 5 = 200
15*14 = 210 + 5 = 215
15*15 = 225 + 5 = 230
15*16 = 240 + 5 = 245
15*17 = 255 + 5 = 260
15*18 = 270 + 5 = 275
15*19 = 285 + 5 = 290
15*20 = 300 + 5 = 305
See? You’re adding 5 to the value returned by 15i.
[AS]holder._x = 15 i+5*i;[/AS]
That would do.
Although I’d do what Voetsjoeba said, it’s simpler.