MXML 复合容器初始化错误

发布于 2024-08-28 19:50:29 字数 1108 浏览 6 评论 0原文

我从复合画布组件中收到一个奇怪的错误:

 An ActionScript error has occurred:
  Error: null
at mx.core::Container/initialize()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Container.as:2560]
at -REMOVED THIS FOR STACK OVERFLOW-.view::EditableCanvas/initialize()[.../view/EditableCanvas
    ....

这似乎与我的复合组件有一个子组件这一事实有关,并且我试图在使用该组件的地方添加一个。那么我怎样才能正确地做到这一点呢?

组件代码如下所示(EditableCanvas.mxml):

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<mx:Image id="editTextImage"
            source="@Embed('/../assets/icons/small/edit.png')"/>
</mx:Canvas>

使用该代码的代码如下所示:

<view:EditableCanvas
            width="290" 
            height="120" 
            backgroundColor="#FFFFFF" 
            horizontalScrollPolicy="off" 
            borderStyle="solid" 
            cornerRadius="3">
            <mx:Text id="textContentBox" width="270" fontFamily="nautics" fontSize="12" text="{_text}"/>
</view:EditableCanvas>

I'm getting an odd error from my composite canvas component:

 An ActionScript error has occurred:
  Error: null
at mx.core::Container/initialize()[C:\autobuild\galaga\frameworks\projects\framework\src\mx\core\Container.as:2560]
at -REMOVED THIS FOR STACK OVERFLOW-.view::EditableCanvas/initialize()[.../view/EditableCanvas
    ....

It seems to be related to the fact that my composite component has a child and I'm trying to add one in the place I'm using the component. So how can I do this correctly?

Component code looks like this (EditableCanvas.mxml):

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<mx:Image id="editTextImage"
            source="@Embed('/../assets/icons/small/edit.png')"/>
</mx:Canvas>

The code that is using the code looks like this:

<view:EditableCanvas
            width="290" 
            height="120" 
            backgroundColor="#FFFFFF" 
            horizontalScrollPolicy="off" 
            borderStyle="solid" 
            cornerRadius="3">
            <mx:Text id="textContentBox" width="270" fontFamily="nautics" fontSize="12" text="{_text}"/>
</view:EditableCanvas>

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

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

发布评论

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

评论(2

梦情居士 2024-09-04 19:50:29

所以我自己从 Adobe Flex 找到了解决方案3 帮助

如果您在 MXML 组件文件中包含根容器标记的子标记,则当您在另一个 MXML 文件中将该组件用作自定义标记时,您将无法添加子标记。如果您在 MXML 文件中定义空容器,则可以在将该组件用作自定义标签时添加子标签。

在复合组件中拥有子元素的方法(也接受来自自定义标记的子元素)是在 as3 中的creationComplete之后添加它们。

So I found the solution all by my own from Adobe Flex 3 Help:

If you include child tags of the root container tag in an MXML component file, you cannot add child tags when you use the component as a custom tag in another MXML file. If you define an empty container in an MXML file, you can add child tags when you use the component as a custom tag.

The way to have child elements in a composite component (that also accepts childs from custom tag) is to add them after creationComplete in as3.

绝不放开 2024-09-04 19:50:29

您是否尝试过不绑定到 init() 函数,而只是使用creationComplete="init()" ?

Have you tried not binding to the init() function, and instead just having creationComplete="init()" ?

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