um.. not sure exactly what you are trying to do, but :

300/400 = 0.75

400/300= 1.33

BUT, if you just want to make a smaller window with the same proportions, try multiplying both width and height by a constant.. ie

var calculatedWidth:Number = width*0.75
var calculatedHeight:Number = height*0.75

OR, if you want to make the window smaller AND want to specify one side length, you have to find the correct constant first.


On Aug 16, 2006, at 1:58 PM, Matthew Ganz wrote:

hi.

i have a viewport for my application and i want to create another smaller viewport whose width and height is in the same ratio as the original viewport. i'm having trouble calculating it correctly.

// here's the call to the method that creates the 2nd, smaller viewport setSubWindowSize(viewportWidth,viewportHeight); // the params are the width and height of the original viewport.

public function setSubWindowSize(width:Number,height:Number):Void {

  // calculate ratio of width to height
  var ratio:Number = viewportHeight/viewportWidth;

  var calculatedWidth:Number = ratio*height;
  var calculatedHeight:Number = height;
 }

so, if my original viewport is 300 x 400, then the ratio will be 1.33 but the new ratio(calculatedHeight/calculatedWidth) gives 0.75. can anyone see what is wrong with my calculations?

any help is very much appreciated. thanks.

matt.
_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

_______________________________________________
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to