We are attempting to build our project using Ant so that we can
include Flex in our continuous build process.  We are getting a
strange namespace error when attempting to build using the mxmlc
compiler.  We created a simple HelloWorld project to verify the error
was not in our project structure. Ant fails to build the project, but
FlexBuilder has no problems.   Here are the code snippets and error
message:

Error Message: 
compile-flex:
    [mxmlc] Loading configuration file
C:\flex_sdk\frameworks\flex-config.xml
    [mxmlc]
C:\eclipse_workspaces\RRS\HelloWorld\src\HelloWorld.mxml(8): Error:
Unknown namespace http://www.w3.org/2000/xmlns/ on attribute
http://www.adobe.com/2006/mxml (only default attribute namespaces are
supported).
    [mxmlc] >

BUILD FAILED
C:\eclipse_workspaces\RRS\HelloWorld\build-flex.xml:14: mxmlc task failed

Example code:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
    xmlns:mx="http://www.adobe.com/2006/mxml"; 
    horizontalAlign="center" verticalAlign="middle" 
    width="300" height="200"
    creationComplete="creationCompleteHandler(event);"

>
    <mx:Script>
        <![CDATA[
            import flash.events.MouseEvent;
            import mx.events.FlexEvent;

            private function creationCompleteHandler(event:FlexEvent):void

            {
                // Listen for the click event on the Button control
                myButton.addEventListener (MouseEvent.CLICK,
clickHandler);
            }

            private function clickHandler ( event:Event ):void

            {
                myLabel.text = "Hello, World!";
            }
        ]]>
    </mx:Script>


    <mx:Panel 
        title="My Application" horizontalAlign="center"
        paddingTop="10" paddingBottom="10" paddingLeft="10"
paddingRight="10"
    >

        <mx:Label id="myLabel" width="180" fontWeight="bold"
fontSize="24"/>
        <mx:Button id="myButton" label="Click Me!" />

    </mx:Panel>
</mx:Application>

Ant Build File:
<?xml version="1.0"?>

<project default="compile-flex" basedir="." name="Compile Flex Tasks">
      <property environment="env"/>
      <taskdef resource="flexTasks.tasks"
classpath="${env.FLEX_HOME}/ant/lib/flexTasks.jar" />
      <taskdef name="mxmlc" classname="flex.ant.MxmlcTask"
classpath="${env.FLEX_HOME}/ant/lib/flexTasks.jar" />
      
      <!-- Define Properties -->
      <property name="FLEX_HOME" value="${env.FLEX_HOME}"/>
      <property name="APP_ROOT" value="src"/>  
    
      
      <target name="compile-flex">
         <mxmlc file="${APP_ROOT}/HelloWorld.mxml"
output="${APP_ROOT}/HelloWorld.swf" keep-generated-actionscript="true">
            <load-config
filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
            <source-path path-element="${APP_ROOT}"/>

         </mxmlc>
     </target>  

</project>


Reply via email to