Hello,
I’m trying to figure out how this thing is working. I’m loading images with a script, I rescale them and then I want to change their position so they are spreading horizontally with let’s say 5 px space.
How is this to be done? I don’t know if this is right, but I’ve done this script, and it’s working as far as to the second picture. The first picture is placed at 0px as it should, but the others is placed right beside the first picture, all at the same place. What’s wrong and what’s the proper solution?
My script:
for (i = 1; i < 11; i++) {
duplicateMovieClip("tomt", "tomt"+i, i);
loadMovie(i+".jpg", "tomt"+i);
_root["tomt"+i]._width = 50;
_root["tomt"+i]._height = 50;
if (i == 1) {
_root["tomt"+i]._x = 0;
}
else {
_root["tomt"+i]._x = _root["tomt"+i-1]._x + 50;
}
}
I tried to use a while-loop, but I must have done wrong, because flash crashed… =)
I tried using this code:
for (i = 0; i < 11; i++) {
duplicateMovieClip("tomt", "tomt"+i, i);
_root["tomt"+i].loadMovie(i+".jpg");
_root["tomt"+i]._xscale = 15;
_root["tomt"+i]._yscale = 15;
_root["tomt"+i]._x = i*_root["tomt"+i]._width;
if (_root["tomt"+i]._x > 400 - _root["tomt"+i]._width) {
_root["tomt"+i]._y += _root["tomt"+i]._height;
_root["tomt"+i]._x = (i+1)*_root["tomt"+i]._width - 400;
}
}
Then it looks like this. Why is there whitespace between the images, and how should i do to set the first pictures _x value to the same as the one above and then continue with the others just like above?
Haven’t tested the script yet, but the thing about the spaces:
As you see in the previous script i used _width instead of 50 px to place the images… So I don’t think it’s that. Or could it be that anyway?
Yes that’s what I meant I think =)
The while loop runs smooth, thanks! =) But, I’ve still got the problem with the space. Can’t figure out why it looks like this!? I am using _xscale and _yscale. Watch the linkI also want the pictures to be placed at the same _x on all lines. Like if you set the first pic on the second row to pic0._x and then the rest of the pics follow the same pattern as before. Hope you get what I mean…
Just change the 50 in i*50 (from previous script) to a lower number to remove the space. Because using the _width takes the original _width of the image and not the _xscale width (I believe).
And the reason it isn’t aligning correctly is because of the width of the images. It isn’t divisible correctly into 400 so it throws it off so you have to figure that out too.
Yes I know that, but is there any way to bypass that? If I add pics with different widths it won’t look very nice if I use a exact value instead of _width (or whatever that could replace that).
So you don’t know any other solution to the thing about alignment? Well I must say that you’ve helped a lot already so I won’t bother you anymore =) Thanks
Well the only thing I can think of that MIGHT work (hard to test since I don’t hav ea working example of clips with different widths) would be to get the width of the previous clip.
Try something like i*_root[“tomt”+(i-1)]._xscale
In theory that should get the previous clips _xscale and space by that, but I have no clue really.