0

Here is my code.

<?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"/>

and here is code of 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)" />

when i click on text area following error through by the application.

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]

How i handle this issue

4 Answers 4

1

try, because this refer to stage no the clicked element:

PopUpManager.removePopUp(event.target);
2
  • but i want to add something in textarea and then remove popup.
    – Tahir Alvi
    Jun 8, 2012 at 10:28
  • @mgraph the problem is in clicking the text not the close button. As the error shows, the problem comes from the setFocus() method. And btw.. the PopUpManager.removePopUp(this); looks ok for me. Jun 8, 2012 at 10:41
0

You may not be able to popup a focusable component inside a non-IFocusManagerContainer. If your Group container implements IFocusManagerContainer class, you may use PopUpManager.

<s:Group implements="mx.managers.IFocusManagerContainer"/>
0

I ran into the same issue, and the root cause was that PopUpManager/PopUpAnchor would not properly set the focusManager if the component being popped up does not implement the IFocusManagerContainer interface. After implementing such interface, the problem goes away.

You may read this blog post that inspired the solution.

0

After doing many experiments/ways i conclude that problem is due to the popup component parent container.

I use Group/VGroup/HGroup of spark then this issue remains but if i change the parent container with spark Panel/SkinnableContainer then issue solved.

Try yourself and enjoy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.