User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Graphics and Multimedia section within the Web Development category of DaniWeb, a massive community of 391,929 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,715 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Graphics and Multimedia advertiser:
Views: 354 | Replies: 1
Reply
Join Date: Feb 2006
Location: Leeds innit
Posts: 29
Reputation: punkrockbboy is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
punkrockbboy punkrockbboy is offline Offline
Light Poster

[FLASH 8] image aspect ratio resize problem

  #1  
27 Days Ago
Hi, i've been trying to figure this out all morning with no luck, i'm trying to create a site that can dynamically resize elements depending on the size of the browser, or if someone drags and resizes the window displaying the page.

The problem i'm having right now though is getting a background image to resize while keeping it's aspect ratio, here is my code:

Stage.align = "TL";
Stage.scaleMode = "noScale";

//Site content
stretch_bar._width = Stage.width;


//Define the role of the listener
sizeListener = new Object();
sizeListener.onResize = function(){
	//Get the new dimensions of the stage:
	var stageWidth:Number = Math.round(Stage.width);
	var stageHeight:Number = Math.round(Stage.height);
		trace ("stage size is now " + Stage.width + " px by " + Stage.height + " px");

	//This is what is giving me the trouble, but i don't know what i'm doing wrong
	var aspectratio = Stage.width/Stage.height;
	photo_01._yscale = aspectratio * photo_01._xscale;
	
	stretch_bar._width = Stage.width;	
}

Stage.addListener(sizeListener);

I've used google to try find an answer and got pretty close, however all that happens is that when the window is dragged down the photo squashes upwards and when the window is dragged up the photo stretches down past the end of the window

Does anyone know what i am doing wrong?
bboykrillin[DOT]com always under construction!!!

krillin art: cause i like to draws and stuff
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jan 2007
Posts: 2,510
Reputation: MidiMagic is on a distinguished road 
Rep Power: 7
Solved Threads: 104
MidiMagic's Avatar
MidiMagic MidiMagic is offline Offline
Posting Maven

Re: [FLASH 8] image aspect ratio resize problem

  #2  
27 Days Ago
You need to calculate the aspect ratio from the original image sizes, not the sizes of the strechable container.
Daylight-saving time uses more gasoline
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb Graphics and Multimedia Marketplace
Thread Tools Display Modes

Other Threads in the Graphics and Multimedia Forum

All times are GMT -4. The time now is 8:26 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC