0

这是我的代码。

<?xml version="1.0" encoding="utf-8"?>

<fx:Script>
    <![CDATA[
        import comps.sampleTextArea;

        import mx.managers.PopUpManager;



        protected function button1_clickHandler(event:MouseEvent):void
        {
            var pop:sampleTextArea = new sampleTextArea();
            PopUpManager.createPopUp(this, sampleTextArea, false);
            PopUpManager.centerPopUp(pop);
        }
    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>

<s:Button click="button1_clickHandler(event)" label="open popup"/>

这是弹出代码

<?xml version="1.0" encoding="utf-8"?>

<fx:Script>
    <![CDATA[
        import mx.managers.PopUpManager;
        protected function button1_clickHandler(event:MouseEvent):void
        {
            ta.text = '';
            PopUpManager.removePopUp(this);
        }
    ]]>
</fx:Script>

<fx:Declarations>
    <!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:layout>
    <s:VerticalLayout horizontalAlign="center" verticalAlign="top" />
</s:layout>
<s:TextArea id="ta" width="100%" height="90%">

</s:TextArea>
<s:Button label="Submit" click="button1_clickHandler(event)" />

当我点击应用程序错误后的文本区域时。

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at spark.components::Scroller/focusInHandler()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Scroller.as:2139]
at flash.display::Stage/set focus()
at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::setFocus()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\ContainerController.as:2265]
at flashx.textLayout.container::ContainerController/mouseDownHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\ContainerController.as:2067]
at flashx.textLayout.container::TextContainerManager/mouseDownHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\TextContainerManager.as:1939]
at spark.components.supportClasses::RichEditableTextContainerManager/mouseDownHandler()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\supportClasses\RichEditableTextContainerManager.as:666]
at flashx.textLayout.container::ContainerController/http://ns.adobe.com/textLayout/internal/2008::requiredMouseDownHandler()[C:\Vellum\branches\v2\2.0\dev\output\openSource\textLayout\src\flashx\textLayout\container\ContainerController.as:2088]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()[E:\dev\4.y\frameworks\projects\framework\src\mx\core\UIComponent.as:13152]
at mx.managers::SystemManager/mouseEventHandler()[E:\dev\4.y\frameworks\projects\framework\src\mx\managers\SystemManager.as:2918]

我如何处理这个问题

4

4 回答 4

1

试试看,因为this参考阶段没有点击的元素:

PopUpManager.removePopUp(event.target);
于 2012-06-08T10:16:17.623 回答
0

在做了许多实验/方法后,我得出结论,问题是由于弹出组件父容器造成的。

我使用 Spark 的 Group/VGroup/HGroup,那么这个问题仍然存在,但是如果我用 spark Panel/SkinnableContainer 更改父容器,那么问题就解决了。

尝试自己并享受。

于 2012-06-08T11:00:56.107 回答
0

您可能无法在非 IFocusManagerContainer 中弹出可聚焦组件。如果你的 Group 容器实现了 IFocusManagerContainer 类,你可以使用 PopUpManager。

<s:Group implements="mx.managers.IFocusManagerContainer"/>
于 2012-06-08T15:25:38.983 回答
0

我遇到了同样的问题,根本原因是如果弹出的组件没有实现IFocusManagerContainer接口,PopUpManager/PopUpAnchor 将无法正确设置 focusManager。实现这样的接口后,问题就消失了。

您可以阅读启发解决方案的这篇博文。

于 2012-09-10T11:53:29.793 回答