Hey,
So I'm writing an application in Adobe Air (AJAX) and I've come upon a little problem.
I've created a function to set a minimum size for the window

var check_size = function() {
     if ( window.nativeWindow.width < 690 ) {
          window.nativeWindow.width = 690;
     }
     if ( window.nativeWindow.height < 400 ) {
          window.nativeWindow.height = 400;
     }
}
window.nativeWindow.addEventListener(air.NativeWindowBoundsEvent.resizing, check_size);

However when I run this I get the error

TypeError: Error #2007: Parameter Type Must Be Non-null

For refference this is the complete HTML/JS for the application so far (There isn't much of it yet)


main_app.html (The initial content of the app)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Application</title>
<script src="AIRAliases.js"></script>
<script type="application/javascript" language="javascript" src="media/js/main.js"></script>
<link type="text/css" rel="stylesheet" href="media/css/main.css" />
</head>

<body onload="init();">
</body>
</html>

And the contents of main.js

//Some initial settings
//Useful vars

//Get the usable size of the display
var  stat_screen_width = screen.width;
var stat_screen_height = screen.height;

//Resize and position the window top right
var stat_screen_x = stat_screen_width-690;
window.nativeWindow.x = stat_screen_x;
window.nativeWindow.y = 0;
window.nativeWindow.width = 690;
window.nativeWindow.height = stat_screen_height;

//We don't want the window to be thinner than 690px or shorter than 400px so this function sorts that
var check_size = function() {
     alert('OK');
     if ( window.nativeWindow.width < 690 ) {
          window.nativeWindow.width = 690;
     }
     if ( window.nativeWindow.height < 400 ) {
          window.nativeWindow.height = 400;
     }
}
window.nativeWindow.addEventListener(air.NativeWindowBoundsEvent.resizing, check_size);

function init() {//Startup script
/*


*/
}

Thanx,

Sam Rudge

Hi, since you are writting an AIR application you can specify the minimum and maximum width and height of your application in the application.xml file located in your root project folder.

Look for the <minSize> and the <maxSize> tags and change it for your own sizes.

HTH

.::AleX::.

commented: Did not answer the question +0

No!
I need to be able to change the max and min width dynamically based on the content

That's not what your code says. Your code says that you are resizing to an specific width on height if some boundaries are broken. With minSize and maxSize you are still able to resize your window but not thiner nor taller than the specified in those tags.

Now if you want to resize the window depending on the content is another thing. You should specify the height and width in your content container and use min-width and min-height to control it.

I don't know what else may be wrong, but the event you appear to want is NativeWindowBoundsEvent.RESIZING

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.