Just moved my Flex app onto Ant with a basic ant script and I am getting this stupid error: mxmlc doesn't support the "file" attribute. I looked through docos and it seems that my code is right, so hows it going.
<!-- load previously defined configuration properties file -->
<property file="build.properties" />
<!-- points to our flexTasks.jar we copied to the libs folder to distribute with the project -->
<taskdef resource="flexTasks.tasks" classpath="${basedir}/libs/flexTasks.jar"/>
<!-- delete and recreate the DEPLOY dir -->
<target name="init">
<delete dir="${DEPLOY_DIR}" />
<mkdir dir="${DEPLOY_DIR}" />
</target>
<!-- Build and output the Main.swf-->
<target name="compile flex project" depends="init">
<mxmlc file="${SRC_DIR}/DNASupport.mxml"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="false"
incremental="true"
optimize="true"
output="${DEPLOY_DIR}/Main.swf">
<license product="flexbuilder3" serial-number="137740016118223699076222" />
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${app_root_dir}/src" />
<source-path path-element="${FLEX_HOME}/frameworks" />
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.debug>false</compiler.debug>
</mxmlc>
</target>
are you using the flex ant tasks?
This is a part of my "typical" build file
<taskdef resource="flexTasks.tasks" />
...
<target name="compile">
<mxmlc file="Main.mxml" debug="true" output="main.swf">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${FLEX_HOME}/frameworks" />
<source-path path-element="${src}" />
</mxmlc>
</target>
Hope this helps
Related
I have created a flex mobile as3 project that exports to air, to ipa and apk.
This project does not use any specific to mobile or air calls (camera, files. .)
my question is : how do I create a swf ?
Regards
Since your project doesn't use any AIR-specific APIs, you can use an Ant build to create a SWF from your mobile project. The following build file will do the trick if your project is self-contained as a single Flash Builder project.
<?xml version="1.0" ?>
<project name="Build" default="build">
<property name="FLEX_HOME" value="C:/Program Files/Adobe/Adobe Flash Builder 4.7/sdks/4.6.0" />
<taskdef resource="flexTasks.tasks" classpath="${FLEX_HOME}/ant/lib/flexTasks.jar" />
<property name="PROJECT_NAME" value="MyMobileProject" />
<property name="PROJECT_BASE_DIR" value="C:/FlexProjects/${PROJECT_NAME}" />
<property name="PATH_TO_SRC_FOLDER" value="${PROJECT_BASE_DIR}/src" />
<property name="OUTPUT_DIR" value="${PROJECT_BASE_DIR}/bin" />
<target name="build">
<mxmlc file="${PATH_TO_SRC_FOLDER}/${PROJECT_NAME}.mxml"
output="${OUTPUT_DIR}/${PROJECT_NAME}.swf"
show-actionscript-warnings="false" show-binding-warnings="false"
locale="en_US" incremental="true">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${PATH_TO_SRC_FOLDER}" />
<external-library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
<include name="*.swc" />
</external-library-path>
<compiler.library-path dir="${PROJECT_BASE_DIR}/libs" append="true" includes="*"/>
</mxmlc>
</target>
</project>
I am using compc in an ant to task to compile a theme swc. This theme swc depends on some asset swcs and in the defaults.css style sheet I refer to some of the classes in these asset swcs.
The linkage I use for the asset swcs is compiler.library-path but it seems that the referred to classes and not compiled into the theme swc.
I include my stylesheet using include-file and with defaults-css-url.
When I build my application that uses this theme swc I get a class not found error for the class in the asset swc.
The easy solution is of course to have my application depend on the asset swc but I don't wnat to do that. All of the assets that the theme requires should be included in the theme swc. I also don't want to bloat my theme swc by including all the classes in the asset swc by using compiler.include-libraries.
ant example code:
<target name="compile" description="Builds the SWC">
<mkdir dir="${dist}" />
<compc output="${dist}/${library.name}.swc"
fork="true" debug="false" warn-no-constructor="false">
<source-path path-element="${src.dir}" />
<external-library-path dir="${FLEX_HOME}/frameworks/libs">
<include name="player/9/playerglobal.swc" />
<include name="datavisualization.swc" />
<include name="framework.swc" />
<include name="rpc.swc" />
<include name="utilities.swc" />
</external-library-path>
<compiler.library-path dir="${basedir}/libs" append="true">
<include name="*.swc" />
</compiler.library-path>
<include-file name="defaults.css" path="${src.dir}/defaults.css" />
<keep-as3-metadata name="Bindable" />
<keep-as3-metadata name="Managed" />
<keep-as3-metadata name="ChangeEvent" />
<keep-as3-metadata name="NonCommittingChangeEvent" />
<keep-as3-metadata name="Transient" />
<jvmarg line="${compc.jvm.args}" />
</compc>
</target>
hope help for you
I'm trying to speed up my builds by using the ANT <updtodate/> task to check for changes and compile only if necessary. This is for a Flex project. Here is the relevant part of my build.xml:
<target name="framework-clean"
description="Clean the Framework library">
<echo>Clean: Deleting dist directory in framework</echo>
<delete dir="${flex.framework.dir}/dist"/>
</target>
<target name="check-framework-changes">
<uptodate property="framework-no-changes" targetfile="${flex.framework.dir}/dist/imanager-framework.swc">
<srcfiles dir="${flex.framework.dir}/src" />
<srcfiles dir="${flex.framework.dir}/libs" />
</uptodate>
</target>
<target name="framework-compile"
depends="check-framework-changes"
unless="framework-no-changes"
description="Compile the Framework library">
<mkdir dir="${flex.framework.dir}/dist"/>
<echo>Compile: Compiling iManager Framework</echo>
<compc output="${flex.framework.dir}/dist/imanager-framework.swc"
debug="${debug}"
incremental="${incremental}">
<keep-as3-metadata name="Master"/>
<keep-as3-metadata name="Component"/>
<keep-as3-metadata name="Key"/>
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${flex.framework.dir}/src" />
<library-path dir="${flex.framework.dir}/libs" includes="*.swc" append="true"/>
<include-sources dir="${flex.framework.dir}/src" includes="*" />
</compc>
</target>
The problem:
Suppose I add a file called Foo.as in my project, the script will detect the change and recompile the swc. But if I delete this Foo.as without changing any other files, the script does not compile the project. The change is ignored even though the last modified timestamp of Foo's parent folder is updated.
Is there any way to fix this?
My ANT version is 1.8.4 and I'm using Flex SDK 4.6
I modified the check-framework-changes target to include directories along with files.
<target name="check-framework-changes">
<uptodate property="framework-no-changes" targetfile="${flex.framework.dir}/dist/imanager-framework.swc">
<srcresources>
<fileset dir="${flex.framework.dir}/src" />
<fileset dir="${flex.framework.dir}/libs" />
<dirset dir="${flex.framework.dir}/src" />
<dirset dir="${flex.framework.dir}/libs" />
</srcresources>
</uptodate>
</target>
This has solved the problem
I am using ant to build my web application. I have a target in my ant script which takes approximately 8 minutes to compile. Since mxmlc compiles everything from scratch and loads up the JVM each time, it is taking a lot of time. Is there a way to optimize this task?
I am using Flex SDK 3.0. Here is my ant target:
<target name="compile.organic.flash" depends="setup">
<property name="WelcomeBack.swf" value="${www.dir}/swf/as3/apps/welcome/WelcomeBack.swf" />
<mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/WelcomeBack.as"
output="${WelcomeBack.swf}"
incremental="${mxmlc.inc}"
default-frame-rate="30"
accessible="true"
default-background-color="${swf.backgrond.color}"
allow-source-path-overlap="true"
compiler.strict="true">
<default-size width="940" height="528" />
<source-path path-element="${Welcome.path}"/>
<source-path path-element="${AS3.classpath}"/>
</mxmlc>
<property name="Welcome.swf" value="${www.dir}/swf/as3/apps/welcome/Welcome.swf" />
<mxmlc file="${AS3.classpath}/com/organic/app/fthb/welcome/src/Welcome.as"
output="${Welcome.swf}"
incremental="${mxmlc.inc}"
default-frame-rate="30"
accessible="true"
default-background-color="${swf.backgrond.color}"
allow-source-path-overlap="true"
compiler.strict="true">
<default-size width="940" height="528" />
<source-path path-element="${Welcome.path}"/>
<source-path path-element="${AS3.classpath}"/>
<compiler.include-libraries dir="${AS3.component}/" >
</compiler.include-libraries>
</mxmlc>
<property name="App.swf" value="${www.dir}/swf/as3/apps/App-${svnVersion}.swf" />
<mxmlc file="${AS3.classpath}/com/organic/app/fthb/App.as"
output="${App.swf}"
incremental="${mxmlc.inc}"
default-frame-rate="30"
default-background-color="${swf.backgrond.color}"
compiler.strict="true">
<default-size width="300" height="300" />
<source-path path-element="${AS3.classpath}"/>
<compiler.include-libraries dir="${AS3.component}/" >
</compiler.include-libraries>
</mxmlc>
<property name="LSOApp.swf" value="${www.dir}/swf/as3/apps/LSOApp-${svnVersion}.swf" />
<mxmlc file="${AS3.classpath}/com/organic/boa/fthb/LSOApp.as"
output="${LSOApp.swf}"
incremental="${mxmlc.inc}"
default-frame-rate="30"
default-background-color="${swf.backgrond.color}"
compiler.strict="true">
<default-size width="300" height="300" />
<source-path path-element="${AS3.classpath}"/>
<compiler.include-libraries dir="${AS3.component}/" >
</compiler.include-libraries>
</mxmlc>
<property name="CheckRates.swf" value="${www.dir}/swf/as3/apps/CheckRates-${svnVersion}.swf" />
<mxmlc file="${CheckRates.path}/CheckRates.as"
output="${CheckRates.swf}"
incremental="${mxmlc.inc}"
default-frame-rate="40"
accessible="true"
default-background-color="${swf.backgrond.color}"
compiler.strict="true" compiler.allow-source-path-overlap="true" >
<default-size width="940" height="528" />
<compiler.source-path path-element="${AS3.classpath}"/>
<compiler.source-path path-element="${CheckRates.path}"/>
<!-- <source-path path-element="${AS3.classpath}"/> -->
<compiler.include-libraries dir="${AS3.classpath}">
<include name="fl/fl.swc" />
</compiler.include-libraries>
</mxmlc>
<copy file="${AS3.classpath}/com/organic/app/fthb/checkRates/js/config/check_rates_config.js" tofile="${www.dir}/swf/as3/apps/config/check_rates_config.js"/>
<property name="PointsCalculator.swf" value="${www.dir}/swf/as3/apps/PointsCalculator-${svnVersion}.swf" />
<property name="flash.apps.build.dir" value="${www.dir}/swf/as3/apps" />
<compile-flash basename="PointsCalculator" srcdir="${flash.apps.src.dir}/pointsCalculator">
</compile-flash>
<copy todir="${flash.apps.build.dir}/config">
<fileset dir="${flash.apps.src.dir}/pointsCalculator/config" includes="*.js"/>
</copy>
<copy todir="${build.dir}/www/css">
<fileset dir="${flash.apps.src.dir}/pointsCalculator/css" includes="*.css"/>
</copy>
<copy todir="${build.dir}/www/swf/as3/apps/welcome/assets/swfs">
<fileset dir="${flash.apps.src.dir}/welcome/assets/swfs" includes="*.swf"/>
</copy>
<copy file="${videoplayer.dir}/videoplayer.swf" tofile="${www.dir}/swf/as3/apps/videoplayer.swf" />
</target>
Use fcsh. From the first paragraph of that link
The fcsh (Flex Compiler Shell) utility provides a shell environment
that you use to compile Flex applications, modules, and component
libraries. It works very similarly to the mxmlc and compc command line
compilers, but it compiles faster than the mxmlc and compc
command-line compilers. One reason is that by keeping everything in
memory, fcsh eliminates the overhead of launching the JVM and loading
the compiler classes. Another reason is that compilation results (for
example, type information) can be kept in memory for subsequent
compilations.
We found that what was slowing down the compiler was mostly linking assets. We made a library project swf that is just used for assets (images, swfs, etc.) except fonts, and it works a treat.
We have a massive project building under 2 mins from maven.
I'm trying to compile a component using ant and keep getting this error message throughout the component . . .
ButtonSkin.mxml(179): Error: Could not resolve <s:SolidColorStroke> to a component implementation.
ButtonSkin.mxml(210): Error: Could not resolve <s:GradientEntry> to a component implementation.
It compiles fine in FlashBuilder 4. Here is the contents of the build.xml:
<project name="Flex Ant Tasks Build Script" default="compile flex project">
<property name="FLEX_HOME" value="c:/build/flex_sdk" />
<property name="SDK_VERSION" value="4.1.0.16076" />
<taskdef resource="flexTasks.tasks" classpath="c:/build/flex_sdk/lib/flexTasks.jar"/>
<echo message="File: ${FLEX_HOME}"/>
<!-- Build and output the Main.swf-->
<target name="compile flex project">
<compc output="${basedir}/../FlexSI/libs/MyLibrary.swc" locale="en_US">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml" />
<source-path path-element="${basedir}/src"/>
<include-sources dir="${basedir}/src" includes="*" />
<library-path dir="${basedir}/libs" includes="*" append="true"/>
<namespace uri="http://testapp.com/siLibrary" manifest="${basedir}/src/xml/manifest.xml" />
</compc>
</target>
</project>
SolidColorStroke doesn't belong to Spark theme. Try to use mx:SolidColorStroke instead of s:SolidColorStroke. Same with GradientEntry.
Discussion on the related issue at forums.adobe.com.
Suggested workaround or solution is to explicitly specify all Spark (Flex4) and Halo (Flex3) related class namespaces, e.g.
<namespace uri="library://ns.adobe.com/flex/spark" manifest="${FLEX_HOME}/frameworks/spark-manifest.xml"/>
<namespace uri="http://ns.adobe.com/mxml/2009" manifest="${FLEX_HOME}/frameworks/mxml-2009-manifest.xml"/>
<namespace uri="http://www.adobe.com/2006/mxml" manifest="${FLEX_HOME}/frameworks/mxml-manifest.xml"/>