I'm trying to compile a AIR library project to SWC using compc and it's not including any of my libraries files. Here is my ANT task:
<!-- Compile the FCLibrary swc -->
<target name="compileFCLibrary" >
<compc output="${FC_DEPLOY_DIR}" directory="true" locale="en_US" >
<!-- FCLibrary has Air classes and requires air-config to be loaded -->
<load-config filename="${FLEX_HOME}/frameworks/air-config.xml" />
<source-path path-element="${FCLIB_SRC}"/>
<include-sources dir="${BASE_DIR}/FClibrary/src" includes="*" />
</compc>
</target>
It looks like it includes some files. The directory it creates is as such:
/catalog.xml
/library.swf
/local
/en_US
/... (*.properties)
/spark
/components
/... (*.png)
Actually, I don't know if the classes are not including my files. The catalog.xml mentions them.
The error I'm getting on the project that is compiling based on this is:
Type was not found or was not a compile-time constant:
Error: Type was not found or was not a compile-time constant: LoadFile.
Solved. The problem was two fold.
The name of the library referenced in ANT was miscased. It was referenced FClibrary.swc when the actual file was FCLibrary.swc
mxmlc was not including the library and was failing silently (should have thrown an error).
Didn't work:
<include-libraries file="FClibrary.swc" />
Worked:
<include-libraries file="FCLibrary.swc" />
Related
Ok, I need some help on this one. I upgraded from Flash Builder 4 to Flash Builder 4.5 and have switched my project to the 4.5.1 sdk. I use an ant script to build my project, so I modified it to use the appropriate flexTasks.jar, mxmlc, etc...
Now, if I start out with a blank bin-debug folder, then build and run the app everything works fine. However, if I then make a code change and build (without deleting the bin-debug) then run the app I get a runtime error:
ReferenceError: Error #1065: Variable ... is not defined.
at flash.display::MovieClip/nextFrame()
at mx.managers::SystemManager/deferredNextFrame()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\SystemManager.as:284]
at mx.managers::SystemManager/preloader_preloaderDocFrameReadyHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\managers\SystemManager.as:2633]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.preloaders::Preloader/timerHandler()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\preloaders\Preloader.as:515]
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()
Again, if I delete the bin-debug folder and compile again it runs with no problems.
The variable it complains about is always a Class variable that points to an image file used as an icon. The code I use to create the var:
[Embed(source="/assets/icons/close-32x32.png")]
public var closeIcon:Class;
The file exists, and I verified that when it gives that error the file is in the bin-debug/assets/icons folder and the src/assets/icons/ folder.
After the error is thrown, if I hit the continue button in Flash Builder it then throws the same error again on the next Class variable pointing to an image file.
Any ideas? The delete/recompile takes several minutes, so obviously this is driving me mad.
Edit: Ant task that compiles in debug mode:
<target name="compile-debug">
<echo>Compile MXML</echo>
<mxmlc
file="${SRC_DIR}/${MAIN_SOURCE_FILE}"
debug="true"
optimize="false"
output="${DEBUG_DIR}/${APP_ROOT_FILE}"
append="true"
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="false"
link-report="MyReport.xml"
maxmemory="2048m"
incremental="true">
<!-- Get default compiler options. -->
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<load-config filename="${FLEX_HOME}/frameworks/air-config.xml"/>
<!-- List of path elements that form the roots of ActionScript class hierarchies. -->
<source-path path-element="${FLEX_HOME}/frameworks"/>
<!-- Include Themes -->
<!-- NOTE: Spark theme required -->
<theme dir="${FLEX_HOME}/frameworks/themes/Spark/">
<include name="spark.css" />
</theme>
<theme dir="${FLEX_HOME}/samples/themes/spark_graphite/">
<include name="spark_graphite.css" />
</theme>
<!-- List of SWC files or directories that contain SWC files. -->
<compiler.library-path dir="${FLEX_HOME}/frameworks" append="true">
<include name="libs" />
<include name="../bundles/{locale}" />
</compiler.library-path>
<!-- uncomment if you have external libs (swc files) -->
<library-path dir="${LIB_DIR}/riaspace/" append="true">
<include name="*.swc" />
</library-path>
<library-path dir="${LIB_DIR}/AlivePDF/" append="true">
<include name="*.swc" />
</library-path>
<library-path dir="${LIB_DIR}/coltware/" append="true">
<include name="*.swc" />
</library-path>
</mxmlc>
</target>
Where FLEX_HOME = < path to flash builder >/sdks/4.5.1
The answer is buried in the middle of Maxim's post that he referenced in a comment above:
--> Try turning off incremental compilation.
I had the same issue here with a simple mimeType='application/octet-stream' embed, and when reading Maxim's text this jumped out because I'd recently changed my custom build tools to use inremental compilation: "Embed sometimes fails during incremental compilation"
The result of this failure is that the .swf contains something like this:
<DefineBinaryData id='1' length='1024' />
which looks like it's empty, instead of this (from the working file):
<DefineBitsLossless2 id='1' encoding='base64'>
(.. in my case, 1024 bytes of base64-encoded data)
</DefineBitsLossless2>
(This solved it for me, so a big thank-you to Maxim. I hope it solves it for you too.)
I had the same problem, so I "Clean"ed the project and then re ran. It worked.
I have Flash Builder 4.7 and am using sdk 4.5.1A.
I was using Flash Player debugger version 15 before Christmas of 2014 and everything was working. I had Firefox set up as the default browser. However, in 2015, Adobe has a new player so I upgraded to version 16 and that's when I got the same problem. After much struggle, I found that the problem had to do with the new version of Firefox Flash player debugger. I had to switch the default browser to Internet Explorer and installed the Internet Explorer Flash player debugger. Prior to debugging, I had to clean and update first. Then everything worked again!
According to the Adobe asdocs, Flex framework files are supposed to be able to be loaded at runtime. These localized framework files, the ones that exist at (on windows) C:\Program Files (x86)\Adobe\Adobe Flash Builder 4.5\sdks\4.5.0\frameworks\locale, are responsible for items such as button text on Alert Dialogs, and a host of other controls. My expectation is that once these framework files are loaded I would see these resources available in my Flex app.
I've set up my project as follows:
MyProject
-src
-Flex4.5
-Referenced Libraries
-bin-debug
-bin-release
-libs
-locale (I've copied all of the directories(da_DK,en_US,es_ES,etc) of framework files for the locales I want to support inside of this dir)
Now the asdocs state that in order to do this, you have to set the compiler settings to read
-locale=en_US,da_DK,de_DE,es_ES,fi_FI,fr_FR,it_IT,ja_JP,ko_KR,nb_NO,nl_NL,pt_BR,ru_RU,sv_SE,zh_CN,zh_TW -allow-source-path-overlap=true -source-path=locale/{locale}
which I have done.
My Build Path Libraries for Flex 4.5 - C:Program Files (x86)\Adobe\Adobe Flash Builder 4.5\sdks\4.5.0 are set to be Runtime Shared library (of note, the {locale} subfolder says "Merged into code")
But when I change the language in the browser, I'm not seeing any of the framework resources.
Also, when I build my project, I don't see any indication of the locale-oriented resource files in the bin-release. Since we only deploy the contents of the bin-release folder (and not the entire project), how is this supposed to work?
I am also seeing .swz files in my bin-release (and I know these arent the localized framework resources).
Does anyone have any experience with Runtime Framework Localization?? What am I doing wrong? My expectation is that once I build my project (with the framework resources externalized) that the app would be able to load those resources, but this isn't happening and I am not interested in compiling a different version of my app for all of the locales I support.
Thanks in advance
I use the following ANT task which works for me:
<mxmlc file="${build.dir.src}/${mxml.file}" keep-generated-actionscript="false" output="${build.dir.stage}/${project.app.name}.swf"
actionscript-file-encoding="UTF-8" incremental="false" context-root="${project.app.name}" optimize="${app.optimize}"
debug="${app.debug}" configname="air" locale="en_US,ja_JP,fr_FR">
<jvmarg value="-Xmx1024m" />
<jvmarg value="-Xms512m" />
<compiler.theme append="true" file="${FLEX_HOME}/frameworks/projects/spark/MXFTEText.css" />
<source-path path-element="${FLEX_HOME}/frameworks" />
<source-path path-element="${build.dir.locale.src}/{locale}" />
<library-path dir="${FLEX_HOME}/frameworks/libs" append="true">
<include name="*.swc" />
</library-path>
<library-path dir="${FLEX_HOME}/frameworks/libs/air" append="true">
<include name="*.swc" />
</library-path>
<library-path dir="${FLEX_HOME}/frameworks/locale" append="true">
<include name="{locale}" />
</library-path>
<library-path dir="${build.dir.lib}" append="true">
<include name="*.swc" />
</library-path>
Add the following tag to the classes that use resources and read the strings in the way:
[ResourceBundle('application')]
// set up the locale chain
ResourceManager.getInstance().localeChain = [ 'en_US', 'ja_JP', 'fr_FR' ];
// load resources
ResourceManager.getInstance().getString('application', 'some.string.code');
An observation: One does not need to copy the framework files into one's project folder. They will be picked up the compiler when compiling.
Let me know if it works, else we can debug more!
I can compile the main application but am having an issue with compiling a nested module.
I have the following application structure:
src
MyApp.mxml
view
MyView.mxml
module
MyModule.mxml
view
AnotherView.mxml
When using the following command
<mxmlc file="${SRC_DIR}/${MODULE_DIR}/MyModule.mxml"
debug="false"
output="${OUTPUT_DIR}/${MODULE_DIR}/MyModule.swf"
locale=""
actionscript-file-encoding="UTF-8"
keep-generated-actionscript="false"
optimize="true"
fork="true"
load-externs="LinkReport.xml"
incremental="false">
<load-config filename="${FLEX_HOME}/frameworks/flex-config.xml"/>
<source-path path-element="${FLEX_HOME}/frameworks"/>
<compiler.library-path dir="libs" append="true">
<include name="*.swc"/>
</compiler.library-path>
</mxmlc>
I get the following error:
Error: Could not resolve "view:AnotherView" to a component implementation.
I think the compiler might be having an issue with determining which "view" directory has the right mxml file ..
Any Thoughts? A detailed explaination with an example would be most appreciated.
You need to add your src directory as part of the source-path as well. You basically haven't told the compiler where to find your code.
Does anyone know of a way to use the mxmlc Flex Ant task with a user-defined list of source or library paths?
The user should be able to define an arbitrary list of source and/or library (.swc) paths in an Ant properties file and the build file can use these values in the mxmlc task.
Are there any tricks (maybe use filtering/string replacing) to get this working?
Don't know if this helps, but you can include an external XML in your Ant build file:
<?xml version="1.0" ?>
<project name="test" default="test" basedir=".">
<target name="setup">
...
</target>
<import file="./common.xml" />
</project>
I ran across your question, looking for a way to define the library (and source path) definitions in external files. Looping through a list of defined properties seems somewhat problematic to me, since you would possibly have to define a list of library paths as well as sub-lists of files in each defined path in the list.
Seems that including external files defining the library and various source paths might be a better and just as extensible way to go.
They way I do it is list my source paths, library paths etc. in an external mxmlc configuration file (e.g. flex-config.xml), my more-or-less universal build.xml file just does
<mxmlc file="${app.mainClass}" output="${swf}">
<load-config filename="${air.sdk.config}" />
<load-config filename="${app.config}" />
</mxmlc>
Where air.sdk.config points to the SDK's default config xml and app.config is the app's custom config xml.
I don't know if it is possible to do it from a properties file.
You can use this in your Ant script:
<source-path>
<source-path path-element="my/src/dir" />
</source-path>
<library-path dir="my/libs/dir" append="true">
<include name="*.swc" />
</library-path>
Or maybe develop some Ant module to simulate this from your properties file.
I can't understand why you want to make your properties file dynamic, it is the role of your build.xml normally, but hey :)
I would like to build a flex library project automatically instead of the current process, which involves one of our developers compiling it on his machine and then us checking in the resulting .swc file. It's gross.
I am coming at this from the perspective of a java developer, so I'm having a hard time getting the hang of the compilation tools provided in the Flex Builder 3 application, but here's what I already have:
I have created an ant file that loads the ant task library correctly, and can therefore execute <mxmlc/> and <compc/> tasks.
I have located the source code that I need to build, and know what sort of .swc I want to end up with.
What I want is an ant script that will do the equivalent of these steps:
We build all sources (actionscript and MXML) and assets in the project into an swc file.
The library.swf file is extracted and optimized
So far I have this:
<target name="compile-component" depends="init">
<compc output="${DEPLOY_DIR}/${SWC_NAME}.swc">
<source-path path-element="${FLEX_HOME}/frameworks"/>
<source-path path-element="${SRC_DIR}"/>
</compc>
</target>
However, it's not including any content:
[compc] Loading configuration file /Applications/Adobe Flex Builder 3/sdks/3.2.0/frameworks/flex-config.xml
[compc] Adobe Compc (Flex Component Compiler)
[compc] Version 3.2.0 build 3958
[compc] Copyright (c) 2004-2007 Adobe Systems, Inc. All rights reserved.
[compc]
[compc] Error: nothing was specified to be included in the library
[compc]
[compc] Use 'compc -help' for information about using the command line.
It looks like I need to enumerate every class that I want to include in the library, which is... ludicrous. There must be a better way. How do I do this?
You can do the following... it takes all the files from the source path and converts it to a format that the compc task can then use.
<fileset id="project.test.dir.fileset" dir="${project.test.dir}">
<include name="**/*.as" />
<include name="**/*.mxml" />
</fileset>
<property name="project.test.dir.fileset" refid="project.test.dir.fileset" />
<!-- Convert the test files into a compiler friendly format. -->
<pathconvert property="project.test.dir.path" pathsep=" " refid="project.test.dir.fileset">
<compositemapper>
<chainedmapper>
<globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
<mapper type="package" from="*.as" to="*" />
</chainedmapper>
<chainedmapper>
<globmapper from="${project.test.dir}/*" to="*" handledirsep="true" />
<mapper type="package" from="*.mxml" to="*" />
</chainedmapper>
</compositemapper>
</pathconvert>
<compc headless-server="true" default-frame-rate="${flex.default-frame-rate}" debug="${flex.compiler.debug.mode}" output="${build.swc.dir}/${test.component.name}.swc" include-classes="${project.test.dir.path}" directory="false">
<source-path path-element="${project.test.dir}" />
&dependencies;
</compc>
We use it to produce swcs for testing purposes.
Lucky for you I JUST solved this problem and was looking for the answer to another problem!
<compc output="${basedir}/mySwc.swc" locale="en_US">
<source-path path-element="${basedir}/src/main/flex"/>
<include-sources dir="${basedir}/src/main/flex" includes="*" />
<load-config filename="${basedir}/fb3config.xml" />
</compc>
The source-path is necessary to tell it what to look at when trying to resolve various references. The include-sources tells it which sources to include (obviously in this case all of them). The load-config is just the -dump-config output from Flex Builder.
Hope this helps!!
You can use Maven. It's a configuration management tool rather than just a build tool. It does rely on your project having a manifest file.