Flex - ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller when using added swc file

StackOverflow https://stackoverflow.com/questions/8259292

문제

I know already so many questions have been asked here on this error #2025 topic.

But, in my case, it is happening when trying to use a .swc file in a flex project.

I am trying to use one of my library project into another flex project by adding using "Add swc" file. I have successfully added it in my new project as a .swc file.

But, when I try to use it new project by clicking on the application in browser, it shows me this runtime error. Below is my new project's main file.

NewSample.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
                xmlns:swclib="*"
                layout="absolute">
    <swclib:Main width="100%" height="100%"/>
</mx:Application>

StackTrace:

ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller. at flash.display::DisplayObjectContainer/getChildIndex() at mx.managers::SystemManager/getChildIndex()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:1772] at mx.managers::SystemManager/mouseDownHandler()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:3615]

I am unable to identify what caused the error ?


EDIT : This is the main application file of the .swc library file.

Main.mxml

   <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 
                    xmlns:parsley="http://www.spicefactory.org/parsley"
                    minWidth="955" minHeight="600"
                    xmlns:custom="components.*"
                    horizontalScrollPolicy="off" 
                    layout="vertical" 
                    verticalScrollPolicy="off" xmlns:models="models.*" xmlns:views="views.*">
        <views:Header width="100%" height="50"/>
                <mx:HDividedBox id="hdv" width="100%" height="100%">
                    <views:ABC width="15%" height="100%"/>
                    <views:DEF width="65%" height="100%"/>
                    <views:XYZ width="20%" height="100%"/>
                </mx:HDividedBox>

        <parsley:ContextBuilder config="Conf"/>
    </mx:Application>
도움이 되었습니까?

해결책

Do you really need Application? Application should be only the upper one and main class. Possible solutions:

  1. Use another container (for example Canvas).
  2. Compile your Main.mxml application into swf and then load it with Loader class.

I'd prefer to use 1st variant.

다른 팁

I bet you are not checking if the (you think child) object is actually a child of the (you think parent) object

Put an if there like:

if(parentObj.getChildren().indexOf(childObj) >= 0) {
    parentObj.removeChild(childObj);
} else {
    //whatever error logging you do goes here
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top