如何解决此错误“未知项被声明为 MXML 文档的根”。 切换到源模式来纠正它。”?

发布于 2024-07-09 06:58:02 字数 492 浏览 6 评论 0原文

我的 mxml 源代码中只有这个:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
            xmlns:comp="components.*"
            width="770" height="330">
    <mx:Label x="185.5" y="150" 
text="Placeholder for Future UI." fontSize="30" color="#93A8AD"/>

</mx:Canvas>

当我尝试使用 Flex 构建器的设计模式时,我收到错误“未知项目被声明为 MXML 文档的根。切换到源模式以更正它。” 那里有人知道如何解决这个问题吗?

这里需要注意的一件事是我最近升级到了 Flash Player 10 调试器。

I have only this in my mxml source code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
            xmlns:comp="components.*"
            width="770" height="330">
    <mx:Label x="185.5" y="150" 
text="Placeholder for Future UI." fontSize="30" color="#93A8AD"/>

</mx:Canvas>

And when I try to use the flex builder's design mode, I get the error "An unknown item is declared as the root of your MXML document. Switch to source mode to correct it." Anyone out there knows how to resolve this issue?

One thing to note here that I've recently upgraded to flash player 10 debugger.

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

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

发布评论

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

评论(8

仄言 2024-07-16 06:58:02

我正在使用 MyEclipse for Spring 版本:8.6,并使用配置中心安装了 Flex Builder 3 插件。 当我在工作区之间切换并安装/卸载 MyEclipse 和 Flex Builder 以找出安装它们的正确方法时破坏了 Flex 3 配置时,我遇到了这个问题。 我通过更正指向不存在文件夹的损坏的 Flex SDK 路径来解决此问题。

您可以通过查看Flex->安装的Flex SDKs->库路径来验证它,如果错误,请将其修复为正确的路径。

I am using MyEclipse for Spring Version: 8.6 with Flex Builder 3 plug-in installed using configuration center. I had this issue when i broke the Flex 3 configuration while swithing between workspaces and installing/uninstalling MyEclipse and Flex Builder to figure out the correct way to install them. I fix the issueby correcting the broken Flex SDK path pointing to a non-existing folder.

You can verify it by looking under Flex->installed Flex SDKs->libraries path, and fix it to correct path if wrong.

梦魇绽荼蘼 2024-07-16 06:58:02

我已经解决了这个问题。 问题是我使用 Maven 创建了多模块项目并将项目导入到 Eclipse 中。 因此默认情况下 Eclipse 不会将 Flex 项目识别为 Flex 项目。 我所做的是删除了 flex 项目,然后重新创建了它
'文件-> 新-> Flex Project'选项,然后问题就解决了。

I solved this problem already. The problem was I created my multi module project with maven and imported the projects to eclipse. So by default the flex project wasn't recognized by eclipse as a flex project. What I did was I deleted the flex project, and recreated it with
'File -> New -> Flex Project' option, and then the problem was resolved.

七婞 2024-07-16 06:58:02

Flex Builder 不是一个整体...一般来说,Eclipse 和 Maven 不能很好地协同工作。 它变得好多了。 如何正确解决这个问题呢? 在项目 .project 文件中,删除所有与 Flex 构建器有关的 buildSpec、Natures 和链接资源。 这将从项目中删除所有 Flex 内容。 然后在 Eclipse 中,确保它看起来不像 Flex 项目,重新添加 Flex 性质。 (在项目上单击鼠标右键,您应该看到“Flex Project Nature”并选择“Add Flex Project Nature”这将解决 gui 构建器问题。如果您使用 maven 构建 Flex 项目,则必须更新更多设置.IE。您需要将其设置为 src/main/flex,然后更新您的 main.flexProperties 文件和 .actionScrioptProperties 文件。有一天 eclipse:eclipse maven 插件将支持 flex builder :)

谢谢!

Flex Builder is not a piece... Eclipse in general and maven don't play well together. Its getting a lot better. How to properly resolve this issue? In the projects .project file remove all the buildSpec's, Natures, and linked Resources that have anything to do with flex builder. This will remove any flex stuff from the project. Then in eclipse, make sure it does not look like a flex project, add back in the flex natures. (right mouse clik on the project and you should see "Flex Project Nature" and select "Add Flex Project Nature" This will resolve the gui builder issues. If you are using maven to build your flex project you will have to update some more settings. IE. the build path. You will need to set it to src/main/flex and then update your main. You will get to know the other really to important files for flex builder. The .flexProperties file and the .actionScrioptProperties file. One day the eclipse:eclipse maven plugin will support flex builder :)

Thanks!

习ぎ惯性依靠 2024-07-16 06:58:02

在Flex Builder 3上右键单击项目->属性->Flex编译器,在“Flex SDK版本”上我选择“使用默认SDK”(当前是flex3)

On Flex Builder 3 right click on the project->properties->Flex compiler, and on the "Flex SDK version" I choose "Use default SDK" (currently flex3)

音盲 2024-07-16 06:58:02

我在 Flash Builder v. 4.0.1 中遇到了同样的问题。 build 277662。提到的解决方案都没有任何帮助,但我找到了其他解决方法(对我有用)。

我在 Flash 构建器中安装了以下附加插件:

  • 来自 Sonatype 的 Maven 2.0 集成插件。
  • Eclipse J2EE 标准工具,版本:3.0.4.v200811190840-7U1959LJIHM6ogLbhvbrAnWtxuyM
    构建 ID:20090212194735

我的项目是一个多模块 Maven 项目,我们称之为“todolist”,其中有一个使用 Flexmojos maven 插件构建的 todolist/todolist-ria 子项目。
实际上它基于:此参考应用程序
它使用 Flex 版本 4.1.0.16248。

在Flash Builder中导入maven项目后,添加Flex项目类型并将主源路径设置为src/main/flex(右键单击项目|属性|Flex构建路径|主源文件夹:src/main/flex)我看到在设计模式下打开任何 .mxml 文件时的错误消息。 在源模式下,代码补全也不起作用。

解决方法:

  1. 让 Flash Builder 创建一个全新的 Flex 项目,为您的项目选择适当的 Flex 版本(3 或 4)。 确保该项目的位置位于您的 Maven 项目之外。
  2. 右键单击新项目 | 属性 | Flex 构建路径 | 源路径
  3. 添加文件夹... | 浏览...
  4. 选择您的Flex代码所在的文件夹(例如.../todolist/todolist-ria/src/main/flex)

Flash Builder将在项目。

现在,您可以在设计模式下打开此源文件夹中的任何 .mxml 文件,并且代码完成也可以在源模式下使用。

警告:到目前为止,我的项目中不依赖任何第三方 Flex 库(.swc 文件),因此我不确定此解决方法在这种情况下是否仍然有帮助。

I experienced the same problem in Flash Builder v. 4.0.1. build 277662. None of the solutions mentioned were of any help but I found an other workaround (that works for me).

I have the the following additional plugins installed in Flash builder:

  • Maven 2.0 integration plugin from Sonatype.
  • Eclipse J2EE Standard Tools, Version: 3.0.4.v200811190840-7U1959LJIHM6ogLbhvbrAnWtxuyM
    Build id: 20090212194735

My project is a multi module maven project, let's call it 'todolist', with a todolist/todolist-ria subproject that is build using the Flexmojos maven plugin.
Actually it is based on: this reference application
It uses Flex version 4.1.0.16248.

After importing the maven project in Flash Builder, adding the Flex Project Type and setting the main source path to src/main/flex (right-click project | Properties | Flex Build Path | Main source folder: src/main/flex) I see the error message when opening any .mxml file in design mode. In source mode code completion does not work either.

The workaround:

  1. Let Flash Builder create a brand new Flex project, choose the appropriate Flex version for your project (3 or 4). Make sure this project's location is outside your maven project.
  2. right-click the new project | Properties | Flex Build Path | Source path
  3. Add folder... | Browse ...
  4. choose the folder where your flex code is (e.g. .../todolist/todolist-ria/src/main/flex)

Flash Builder will add a link to the source folder (e.g. [source path] flex) in the project.

Now you can open any .mxml file in this source folder in Design mode, and code completion also works in Source mode.

Caveat: I don't have dependencies on any third party Flex libraries (.swc files) in my project so far, so I don't know for sure if this workaround still helps in that situation.

独木成林 2024-07-16 06:58:02

检查您的项目属性是否正确。 通过浏览文件夹并选择它们来找到 swc 文件,而不仅仅是输入正确的路径。

这对我有用。

Check that your project properties are correct. Locate the swc files by browsing through the folders and selecting them, not just entering the correct path.

This worked for me.

金兰素衣 2024-07-16 06:58:02

听起来它不喜欢“Canvas”元素。 我从未使用过 Flex,但在 Visual Studio 中执行 WPF 应用程序的示例中,只有某些元素不属于根元素,具体取决于文件的使用方式。 如果它是主 MXML 文件,则可能需要其他内容,例如“Application”元素。 如果它以其他方式使用,例如数据文件或自定义控件,那么它应该不重要。

这是 MXML 文件的示例(向下滚动页面),其中在使用控件之前,文件的根元素确实是“Application”元素...

示例 MXML 文件

It sounds like it's not liking the "Canvas" element. I've never used Flex, but in the example of doing an WPF application in Visual Studio, there are only certain elements that are excepted for the root element depending on how the file is being used. If it's the main MXML file, it's probably expecting something else, like the "Application" element. If it's being used in another manner, such as a data file or a custom control, then it shouldn't matter.

Here's an example of an MXML file (scroll down the page) where the file's root element is indeed an 'Application' element before the controls are used...

Sample MXML file

只想待在家 2024-07-16 06:58:02

只需将类型光标 (blik |) 放在 .mxml 文件第一行,代码之前:

|

按回车键,然后退格键删除此回车键,项目会自动重新加载,就可以了。

Just place your type cursor (blik |) in first line your .mxml file, before your code:

| <?xml...

Hit enter and then backspace to delete this enter, project automaticly reloads and will be fine.

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