views:

3376

answers:

7

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.

A: 

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

invenetix
+2  A: 

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.

Mozammel
You should add a "maven" tag to this post. (I don't have enough rep to edit it.)
erikprice
+2  A: 

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!

A: 

it ain't working for me...

Flex en Español
A: 

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.

pablo
A: 

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.

Jeroen Pielage
A: 

Check you project properties to be correct. Do not locate the swc files by just entering the correct path but browse through the folders and select. It worked at my end.

ashwyn