English 中文(简体)
Finding the correct scale value within a scaled object to maintain the aspect ratio of a video
原标题:

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.

最佳回答

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;
问题回答

暂无回答




相关问题
How are mobile service provider databases so fast?

i was wondering on how these databases which have over millions of records and millions of lookups per second soo fast. how are they optimised? are there any special servers hosting these databases? ...

C# Resized images have black borders

I have a problem with image scaling in .NET. I use the standard Graphics type to resize images like in this example: public static Image Scale(Image sourceImage, int destWidth, int destHeight) { ...

Performance tuning CakePHP application

I just got this quite large CakePHP app (about 20k lines of code), which isn t very clean and there is no documentation at all. The app is running in production, but it has really major problems with ...

AS3 按比例提升外部形象

目前,我正在利用一种 lo机,以动态方式载录XML图像,并将其放入一个grid网。 我有安排,所有数据都在顺利地装上,但现在我需要做......。

Using EC2 Load Balancing with Existing Wordpress Blog

I currently have a virtual dedicated server through Media Temple that I use to run several high traffic Wordpress blogs. Both tend to receive sudden StumbleUpon traffic surges that (I m assuming) ...

High-traffic, Highly-secure web API, what language? [closed]

If you were planning on building a high-traffic, very secure site what language would you use? For example, if you were planning on say building an authorize.net-scale site, that had to handle tons ...

热门标签