views:

2240

answers:

1

Hi,

I need to make my application height dynamic based on the size of a data grid which changes after a user does a search for specific items. Can someone help me with this.

Also when im embedding in my html is there a javascript function i can call which can access applicatin height so i can set page accordingly?

the javascript needs to be called from inside my html page so that i can get the dynamaic height

+1  A: 

If your SWF embedding object has an ID (or any other means of unique identification, for that matter), then it is rather simple to change its size. Using jQuery, for example:

$("#swf").height(500);

This sets the height of the SWF to 500 pixels. It is fairly simple even without jQuery:

document.getElementById("swf").style.height = "500px";

To call javascript from inside Flash, use the ExternalInterface class, it has a static method for this purpose. (Alternatively, you may use the navigateToURL() static function with "javascript:" protocol.)

David Hanak
the size of my application is actually dynamic so is there a way that i can render the swf object and then retrieve the height via javascript and tell the html page what height to expect?
combi001
i dont want to be tied down to having to hard code the height when generating the swf
combi001
Of course you don't. You need to add a resize listener in your flash code, and call the external javascript function from the listener with the appropriate size parameters.
David Hanak
can you direct me to some examples of this - just to clarify, my browser already handles resize events, my senario is i need to retrieve the height so i can set the height of a portlet container it sits in
combi001
I'd need to know more about your code to give samples. But if you look at the DataGrid class, I'm sure you'll find the events that are fired as elements are added/removed to it, and the methods that can be used to determine its current size.
David Hanak