Flex - ArgumentError:错误 #2025:使用添加的 swc 文件时提供的 DisplayObject 必须是调用者的子级

发布于 2024-12-18 00:50:24 字数 2125 浏览 5 评论 0原文

我知道已经有人就这个错误 #2025 主题提出了很多问题。

但是,就我而言,当尝试在 Flex 项目中使用 .swc 文件时,就会发生这种情况。

我正在尝试通过添加“Add swc”文件来将我的一个库项目使用到另一个 Flex 项目中。 我已成功将其作为 .swc 文件添加到我的新项目中。

但是,当我尝试通过单击浏览器中的应用程序来使用它的新项目时,它会向我显示此运行时错误。下面是我的新项目的主文件。

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:错误#2025:提供的 DisplayObject 必须是子对象 来电者的。在 flash.display::DisplayObjectContainer/getChildIndex() 位于 mx.managers::SystemManager/getChildIndex()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:1772] 在 mx.managers::SystemManager/mouseDownHandler()[C:\autobuild\3.x\frameworks\projects\framework\src\mx\managers\SystemManager.as:3615]

我无法确定导致错误的原因?


编辑:这是.swc库文件的主要应用程序文件。

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>

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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狼亦尘 2024-12-25 00:50:24

您真的需要Application吗? Application 应该只是上层和主类。
可能的解决方案:

  1. 使用另一个容器(例如 Canvas)。
  2. 将 Main.mxml 应用程序编译为 swf,然后使用

我更喜欢使用第一个变体。

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.

浅唱ヾ落雨殇 2024-12-25 00:50:24

我敢打赌,您不会检查(您认为的子)对象实际上是否是(您认为的父)对象的子对象,

在那里放置一个 if ,如下所示:

if(parentObj.getChildren().indexOf(childObj) >= 0) {
    parentObj.removeChild(childObj);
} else {
    //whatever error logging you do goes here
}

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
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文