This content has been marked as final. Show 4 replies
To scale the picture and center it when it's loaded, you can use simple percent calculation:
box.pic._yscale = box._height * 100 / box.pic._height;
box.pic._x = box._width / 2 - box.pic._width / 2;
This assumes the picture is loaded in an MC 'pic' inside the 'box' MC, and it scales just one dimension, which could lead to distortion. To keep the original ratio, just scale the y dimension with the same factor.
This would be the portrait scaling, landscape would be similar, just with the _width properties. You would have to know which type of picture was loaded before.
Thanks very much for your reply - is there any way Flash can sense what kind of picture it is when it's loaded?
It can't 'sense' it, you would have to indicate it somehow. Maybe through special names of the files, e.g. "pic1_P.jpg" vs. "pic2_L.jpg" (P for portrait, L for landscape), so Flash could check what's between _ and . and react accordingly. Maybe it would also be possible to know it from the image dimensions, if there are big differences between portrait and landscape pictures.
How do you load these pictures? If you have an external file (xml) with the filenames, you could store this info along the names, that should be the simplest way.
Many thanks for that... we'll probably be using a combination of PHP and XML so between those I'm sure we'll find a solution.