ActiveDen

Z dimension 3d width and height

15 posts
  • Has been a member for 0-1 years
  • Exclusive Author
MaximusCript says

I have this small problem. I have mysite, where i have 5 oferts, with 5 huge images, that fits to width and height of browser. Now to do that i use z attribute in as3.

My code looks like this: var hei:int = stage.stageHeight; while(pi1c.width > wid){ pic1.z++; } while(pi1c.height > hei){ pic1.z++; } while(pic1.width < wid){ pic1.z—; } while(pic1.height < hei){ pic1.z—; } while(pi2c.width > wid){ pic2.z++; } while(pi2c.height > hei){ pic2.z++; } while(pic2.width < wid){ pic2.z—; } while(pic2.height < hei){ pic2.z—; }[/code]

wid:int = stage.stageWidth;

This works perfect, but all these pic have diffrent sizes, and it makes a nice pile of code, and lots more work for cpu. All this pictures are displayed at once, and code is run at resize event. Now, does anybody know,s how to calculate how much width/height increase and decrease while playing with z attribute?

Please, any tips.

PS: Also, could someone tell me how i make my code, look like a code i mean how i put it in a border.

5 months ago
1945 posts
  • Has been a member for 4-5 years
  • Exclusive Author
  • Sold between 5 000 and 10 000 dollars
  • Bought between 10 and 49 items
  • Netherlands
  • Referred between 10 and 49 users
Emroni says
Not the best way to handle image resizing. Try this instead:
function resizePic(pic){
     pic.width = stage.stageWidth; // Set to stage width
     pic.scaleY = pic.scaleX; // Resizes height and keeps the ratio

     if(pic.height > stage.stageHeight){ // Still larger than stage height?
          pic.height = stage.stageHeight; // Set to stage height
          pic.scaleX = pic.scaleY; // Resizes widthand keeps the ratio
     }
}

resizePic(pi1c);
resizePic(pi2c);

And you can use the < pre > tag to display code

5 months ago
15 posts
  • Has been a member for 0-1 years
  • Exclusive Author
MaximusCript says

I couldn’t get better idea, but your way is is so simple, and so genius.

Thanks alot! Max

5 months ago
by
by
by
by
by