Help a brother out (Actionscript)
- Started
- Last post
- 6 Responses
- jackfoley
If you visit the following portfolio site http://www.iso50.com and click on the different examples of work the brown box behind the work changes size to fit the work? Can anyone show me how this is done? Do you know of any tutorials on how to do this? Thanks!
- unfittoprint0
//stretch function
changeSize= function(targetW,targetH){
bg._width=movieW;
movieW += (targetW-movieW)/4;
movieW=bg._width;
bg._height=movieH;
movieH += (targetW-movieH)/4;
movieH=bg._width;
}//stretch loop
stretch = function (targetW, targetH){
clearInterval(stretchLoop);
stretchLoop = setInterval( this,
"changeSize", 30, targetW, targetH);
}paste something like this intoyour image loader:
if(image.getBytesTotal() == image.getBytesLoaded() && image.getBytesTotal>0){
stretch (image._width+10, image._height+10);
}good luck...
- jackfoley0
could you maybe explain a little of what each section does so I know how the code works rather than just throwing it in there? Thanks a ton for your help!
- unfittoprint0
changeSize is the function to change the size of the background...
stretch is the loop to animata that change...
when the image is finally loaded, the stretch function uses the image's width and height to stretch the background...
- jackfoley0
where in that code does it take in the different size of each image (for example if i had 10 different images, that all had different dimensions)?
- unfittoprint0
if(image.getBytesTotal() == image.getBytesLoaded() && image.getBytesTotal>0){
stretch (image._width+10, image._height+10);
}image is the MC where the jpeg is loaded.
- shant0
hey unfit, i see you use "setInterval" a lot. Is this from habit, or are there benefits to using setInterval. I've never used it, but it seems to be your favorite, so I'm just curious.