View Full Version : MX attachMovie problem
blah-de-blah
August 19th, 2003, 01:14 AM
ok so i have this code:
for (i=1; i<=20; i++) {
var holder = attachMovie("box", "box+n", ++n)
holder._x = 15*i
}
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!
thoriphes
August 19th, 2003, 01:21 AM
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.
Voetsjoeba
August 19th, 2003, 01:23 AM
for (i=1; i<=20; i++) {
var holder = attachMovie("box", "box"+n, ++n)
holder._x = 15*i
}
for (i=1; i<=20; i++) {
var holder = attachMovie("box", "box"+n, ++n)
holder._x = 20*i
}
blah-de-blah
August 19th, 2003, 01:29 AM
thanks ithuriel, didn't manage to spot that, but i don' think thats the problem :-\
Even with the new code:
for (i=1; i<=20; i++) {
var holder = attachMovie("box", "box"+n, ++n);
holder._x = 15*i+5;
}
...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!
Voetsjoeba
August 19th, 2003, 01:33 AM
Because they are more spread when you set it to 20 ;) Look at the code:
for (i=1; i<=20; i++) {
var holder = attachMovie("box", "box"+n, ++n);
holder._x = 15*i; //So 15*1, 15*2, 15*3, ...
}
for (i=1; i<=20; i++) {
var holder = attachMovie("box", "box"+n, ++n);
holder._x = 20*i; //So 20*1, 20*2, 20*3, ...
}
blah-de-blah
August 19th, 2003, 01:54 AM
oh i see :P 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 :-\
kode
August 19th, 2003, 02:15 AM
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 15*i.
holder._x = 15*i+5*i;
That would do.
Although I'd do what Voetsjoeba said, it's simpler. :P
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.