Modules and Panels issue

只谈情不闲聊 提交于 2019-12-25 04:55:26

问题


I have the following problem.

In my application I have several modules and each of them have components CollapsableTitleWindow (extends Panel). After opening the window it is added to the container which is in the main application (CollapsableTitleWindowContainer). In these windows you can open another window (and so on).

Now, what is the problem. When I change (reload) any module and I want to open a new window (sub window) with the already loaded window I get this error:

TypeError: Error #1009: Cannot access a property or method of a null object reference.
 at mx.containers::Panel/layoutChrome()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\containers\Panel.as:1405]
 at com::CollapsableTitleWindow/layoutChrome()[D:\Flex 3 Workspace\WesobCrm\src\com\CollapsableTitleWindow.as:216]
 at mx.core::Container/updateDisplayList()[C:\autobuild\3.2.0\frameworks\projects\framework\src\mx\core\Container.as:2867] (...)

Indicates that the main applications have object Panel

Please help.

P.S. I found a similar problem on http://www.nabble.com/Flex-Module-issue-with-Panel-td20168053.html

ADDED: I extendes the Panel class and do something like that:

override protected function layoutChrome(unscaledWidth:Number, unscaledHeight:Number):void
    {
        use namespace mx_internal;
        if(!(mx_internal::titleBarBackground is TitleBackground)) {
            mx_internal::titleBarBackground = new TitleBackground();
        }
        super.layoutChrome(unscaledWidth, unscaledHeight);          
    }

But now i had something like that: Before
(source: ak.bx.pl)
After
(source: ak.bx.pl)

You can see that it loos style declaration.


回答1:


I found a solution but it is bad pratice:

I add in my main application

public function getProductWindow():ProductWindow {
    return new ProductWindow();
}

And change in the module:

From

var productWindow:ProductWindow = new ProductWindow();

To

var productWindow:ProductWindow = Application.application.getProductWindow();

If anyone have a better solution ?



来源:https://stackoverflow.com/questions/1623705/modules-and-panels-issue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!