Category Archives: Java

Flex Icon

Packaging a Flex Mobile Project using Ant for Android, BlackBerry or iOs

Flex IconIf you want to package a Flex Mobile Project using Ant, you’ll first need to compile your project to get a swf. ADT is the tool need to package your application. First of all, if you want lots of information, I recommend installing the Adobe Community Help.

Remember you can also do this by creating a Release Build (right click project –> Export… –> Flash Builder –> Release Build) of your Flex Mobile Project.

Continue reading

Flex Project in IntelliJ with Charts

This year, my brother, Jef Monballieu, graduates as Civil Engineer. For his thesis, he needed a program that calculated the different criteria for building roads. Charts were ideal to show why certain materials were better and how they compared to each other. Starting from an Excel file, we first created the model, then implemented all the calculations and finished with creating tables and charts. Thanks to the help of my brother, we were able to create this application on short notice.

Normally I work with FlexBuilder, but for this project I wanted to experiment with IntelliJ. I already had experimented with BlazeDs in IntelliJ, but I had never really created a project. IntelliJ is great, but it’s really hard to compare it with FlexBuilder because the project I’m doing in FlexBuilder is way bigger. I would need to check FlashBuilder to be able to compare the features and import the big project in IntelliJ to see how compiling compares to each other.

The new Spark architecture was strange in the beginning, especially because now you have all these namespaces mixing together. Mx, s, fx, … I really should check some online resources and videos because now I just experimented while doing the project. Not a lot of time to go and search for things, best practices, …

No backend was used, but setting BlazeDs (or GraniteDs) up in IntelliJ is really a piece of cake. Coming from .NET world, it does feel strange and it’s a totally new world.

The project can be found here, but I think not a lot of people will understand it. There are three states: in the first general parameters need to be entered, in the second some specific parameters need to be entered and in the third all tables and charts are shown.

I still have one big problem and that’s loading the application. Apparently a couple of swf files are downloaded before the application is shown. I guess that these swf files should be included when compiling, but I haven’t managed to do this. If one of you knows how to resolve this, please let me know. Now the application is loading toooo slow. Maybe it’s a configuration in IntelliJ? I have searched online but haven’t found anything, so I guess it’s not a bug in Flex SDK 4.

Eclipse Web Tools Platform

Lately I’ve been reading a book called ‘Eclipse Web Tools Platform’. I had read two books on ‘Servlets & JSP’ and ‘EJB’ from Head First and I really wanted to know more about the Eclipse plugins that make it easy to develop for the Web. The book is very good written and easy to understnad. The only thing that got me frustrated in the beginning is that you really need to download the exact versions of eclipse, WTP, Derby, Tomcat, … in order to do the examples in the book. Ok, if you are experienced with these things, there wouldn’t be a problem, but I’m not that experienced. It amazes me that the Java story is unbelievable strong with dozends of open source projects, but it’s far from being user friendly if you’ve worked for two years with Microsoft technologies. I’m a senior Flex Developer, so I know that Eclipse can drive a man crazy, but still, they should do something about that. I have the feeling that after reading the book (and trying out the examples) I will be able to develop web applications with those versions of the tools. If I will install the latest versions, I’ll have to go and look on the internet to get things started.

Ok, part of it will be me being not experienced, but for instance opening a solution file in Microsoft is so easy a little child could do it. Opening projects in Eclipse is somehting else…

Anyway, I love working with Eclipse and WTP, because in Microsoft technology a lot is done for the user without knowing it is done. As a result you often don’t know what’s under the hood. When developing with Eclipse, WTP, Java, … you get to know everything. It helps me be a better programmer in .NET. It’s like playing 10 years of guitar and then learning some piano. It’s amazing how often you suddenly understand things about the guitar that you didn’t understand before.

Next chapter in the books becomes interesting. Until now it was just a quick tour, but now we’re getting into Architecture.

Ciao!

BlazeDS Ubuntu Eclipse FlexBuilder

Man, the last couple of days were trying to survive from the flew and trying to get Eclipse, FlexBuilder and BlazeDS working on Ubuntu. Not an easy task if you never worked in Ubuntu. At the university we did see some Linux scripting, but that’s a long time ago.

Anyway, I got it starting, but probably not the way it should. For instance I need to start Eclipse as root because apperently I installed it as root (sudo?).

The latest FlexBuilder Linux build doesn’t work with the latest Eclipse 3.3. On Vista we had the same problem but a new FlexBuilder release solved the problem. Guess Linux has to wait a while. With Eclipse 3.3 you get an assertion error. With Eclipse 3.2 everything works like a charm.

The instructions to install BlazeDS were not that simple but with the little things I remembered from HighSchool I managed. Now I’m off to play a little bit with BlazeDS. I want to know if it’s capable of replacing WebORB for .NET. The thing I’m curious about is the easy way objects can be saved, offline modus, messaging, sub/prod, …

If I’m right, BlazeDS is free and opensource. FMS is not. FMS seems to have Video streaming and a lot of other things not included with BlazeDS. FMS is also a lot of money… But if a lot of time can be saved with it, why not do the investment.

Johlero aka Lieven Cardoen

Building Adobe Air Flex Project With Ant

Compiling an Adobe Air Flex Project is almost the same as compiling a Flex project. However, after the project is compiled to a swf, you will need adl.exe to run/test your Adobe Air application and/or adt.bat to package the swf.

First compiling your Adobe Air project goes like this…

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<target name="Build For Apollo">
        <mxmlc 
        	file="eva.mxml" 
        	output="${DEPLOY_DIR}/evaApollo.swf"
    		keep-generated-actionscript="true"
    		locale="nl_BE"
    	 >
            <load-config filename="${FLEX3_SDK}/frameworks/air-config.xml"/>
            <!-- Default Configuration File For Air
                 If you are using apollo, you will need apollo-config.xml
                 (Talk about these configuration files in another post) -->
            <source-path path-element="${FLEX3_SDK}/frameworks"/>
            <sp path-element="../locale/{locale}"/>
            <!-- List of SWC files or directories that contain SWC files. -->
            <compiler.library-path dir="${FLEX3_SDK}/frameworks/libs" append="true">
                <include name="*" />
            </compiler.library-path>
            <!-- Adobe Air Libraries -->
            <compiler.library-path dir="${FLEX3_SDK}/frameworks/libs/air" append="true"> 
                <include name="*" />
            </compiler.library-path>
            <!-- A framework library for my project -->
            <compiler.library-path dir="${EVAFRAMEWORKSWC}" append="true">
                <include name="EvaFrameWork.swc" />
            </compiler.library-path>
        </mxmlc> 
        <antcall target="Run EvaApollo"/>
    </target>

You’ll notice that you will have to copy some localization files from air to your locale folders of your project.

Running an Adobe Air Application (swf)…

1
2
3
4
5
	<target name="Run EvaApollo">
		<exec dir="${basedir}\..\flexBin" executable="${APOLLO_SDK}\bin\adl.exe" spawn="false">
			<arg value="application.xml"/>
		</exec>
	</target>

The application.xml is a configuration file you will need to edit for your application.

To package your Adobe Air Project, you’ll first need to create a certificate…

1
2
3
4
5
6
7
8
9
10
<target name="Create certificate EvaApollo">
		<exec dir="${basedir}\..\flexBin" executable="${APOLLO_SDK}\bin\adt.bat" spawn="false">
			<arg value="-certificate"/>
			<arg value="-cn"/>
			<arg value="eva"/>
			<arg value="2048-RSA"/>
			<arg value="eva.pfx"/>
			<arg value="johlero"/>
		</exec>
	</target>

Packaging…

1
2
3
4
5
6
7
8
9
10
11
12
	<target name="Package EvaApollo">
		<exec dir="${basedir}\..\flexBin" executable="${APOLLO_SDK}\bin\adt.bat" spawn="false">
			<arg value="-package"/>
			<arg value="-certificate"/>
			<arg value="eva.pfx"/>
			<arg value="-password"/>
			<arg value="johlero"/>
			<arg value="Eva.air"/>
			<arg value="application.xml"/>
			<arg value="evaApollo.swf"/>
		</exec>
	</target>

More info at :
http://labs.adobe.com/wiki/index.php/Flex_Ant_Tasks
http://livedocs.adobe.com/labs/air/1/devappsflex/CommandLineTools_1.html

Adios!

Building Flex With Ant

I will not go and explain too much in this post because an example sometimes is worth more than a thousand lines of explanation.

Currently I’m working on an application to manage restuts from several applications. It’s being developed in FlexBuilder3Beta (eclipse plugin) together with Zinc. Adobe Air was also an option, but the applications are still being developed in AS2, so we could not use Adobe Air there. Most of the times I create a loader swf that loads the main application swf. Like that, I can put the loader swf in my Zinc exe which loads the main swf. If you compile your main application swf, you don’t need to package it again in a Zinc exe. With ant, I compile the Flex project and then start the Zinc exe.

Compiling my Flex project with ant goes like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<target name="Build Swf And Start Zinc">
        <mxmlc 
        	file="eva.mxml" 
        	output="${DEPLOY_DIR}/evaZinc.swf"
    		keep-generated-actionscript="true"
    		locale="nl_BE"
    	 >
            <load-config filename="${FLEX3_SDK}/frameworks/flex-config.xml"/>
            <!-- Default Configuration File (Talk about that in another post) -->
            <source-path path-element="${FLEX3_SDK}/frameworks"/><!-- Path to Flex SDK you are using -->
            <sp path-element="../locale/{locale}"/><!-- Path to the locales -->
        	<!-- List of SWC files or directories that contain SWC files. -->
        	<compiler.library-path dir="${FLEX3_SDK}/frameworks/libs" append="true">
                <include name="*" />
            </compiler.library-path>
        	<compiler.library-path dir="${EVAFRAMEWORKSWC}" append="true"><!-- A framework library for my project -->
                <include name="EvaFrameWork.swc" />
            </compiler.library-path>
            <compiler.library-path dir="${MDMSWC}" append="true"><!-- If you are using MDM Zinc -->
                <include name="mdm.swc" />
            </compiler.library-path>
        </mxmlc> 
        <antcall target="zinc.start.exe"/><!-- Calling target to start Zinc exe -->
    </target>

Starting the Zinc Exe

1
2
3
<target name="zinc.start.exe">
        <exec executable="${DEPLOY_DIR}/evaZincLoader.exe" dir="${DEPLOY_DIR}\"/>
    </target>

The main disadvantage here is that debugging is quite harder when launching your application from the Zinc exe. I haven’t been able to put a debug version of the swf in an Zinc exe and having the FlexBuilder listening to the debug-swf. If I find some time, I’ll have a look at this. Now if an error occurs, the application just stops and you get absolutely no info on what’s happening. Now I just create an SOSLogger in my application and look in the SOSWindow to the traces to find out what’s happening. If I run it on Mac, I also get my logs on my pc.

My EvaZincLoader.mxml looks like this

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
	xmlns:mx="http://www.adobe.com/2006/mxml" 
 
	creationComplete="creationCompleteHandler()"
 
	layout="absolute"
 
	width="100%"
	height="100%"
>
	<mx:Script>
		<![CDATA[
			import mdm.Application;
 
			private function creationCompleteHandler():void
			{
				mdm.Application.init(this);
				this.mySWFLoader.source = mdm.Application.path + "evaZinc.swf";
			}
 
		]]>
	</mx:Script>
 
	<mx:SWFLoader 
		id="mySWFLoader"
		width="100%" 
		height="100%" 
		scaleContent="true" 
		autoLoad="true"
	/>
</mx:Application>