PDA

View Full Version : Autosize window according to its content movie clip


macsym
07-12-2004, 06:36 PM
Hi everybody,

I am trying to dynamically attach a window component and autosize it according to its content path. I had no problem to attach a window but how to automatically set its size?

I tried:
myWindow.setSize(myWindow.contentPath._width, myWindow.contentPath ._height);

Unfortunately,
trace (myWindow.contentPath._width);
trace (myWindow.contentPath._height);

returns “undefined” for both values.

Do you have an idea of how I could get a window autosized according to its content movie clip?

petefs
07-12-2004, 07:48 PM
window.content will return undefined immediately after you instantiate the window component.

You need to capture the window's 'complete' event to set it's size based upon the content's width and height. Look in the component dictionary in the help docs, there's an example of the 'complete' event in there under the window component.

macsym
07-13-2004, 12:29 AM
Hi Petefs,

Thanks for your answer! I didn't see that part in the manual (sorry about that).

For those who might be interested, here is the code I use:


attach_window = function (instance_name, content_path, window_title) {
instance_name = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true, {title:window_title, contentPath:content_path, closeButton:true});
windowListener = new Object();
windowListener.handleEvent = function(evt) {
if (evt.type == "click") {
instance_name.deletePopUp();
}
if (evt.type == "complete") {
instance_name.setSize(instance_name.content._width +8, instance_name.content._height+35);
}
};
instance_name.addEventListener("click", windowListener);
instance_name.addEventListener("complete", windowListener);
};


Thanks again,

MAX

petefs
07-13-2004, 04:03 AM
no problem ^_^

Had to dig into all the fmx2004 components in preparation for a big app, so it's all fresh in the mind : )