views:

40

answers:

1

Hello, I have a video inside of another movieclip. When I go full screen, I scale up the outer movieclip to fit the screen. So that OuterMovieClip.width is equal to screenWidth etc. How do I maintain the aspect ratio on my video so it does not get distorted? Whats the proper math for that?

Thank you.

+2  A: 

I believe you'd need something (code below untested) along the lines of...

var screen_aspect_ratio = Screen.Width / Screen.Height;
var outer_aspect_ratio = OuterMovieClip.Width / OuterMovieClip.Height;
var new_outer_width;
var new_outer_height;

if (screen_aspect_ratio > outer_aspect_ratio) {
  new_outer_height = Screen.Height;
  new_outer_width = (Screen.Height * OuterMovieClip.Width) / OuterMovieClip.Height;
} else {
  new_outer_width = Screen.Width;
  new_outer_height = (Screen.Width * OuterMovieClip.Height) / OuterMovieClip.Width;
}

OuterMovieClip.Width = new_outer_width;
OuterMovieClip.Height = new_outer_height;
theraccoonbear
Thank you. It's not exactly working, but I think that puts me in the right direction.Can you briefly explain what mutiplying the Screen.Height by the OuterMovieClip.Width is doing exactly? Thanks.
Guest
Take a look at this wikipedia article...http://en.wikipedia.org/wiki/Cross_multiplication#Use
theraccoonbear