Posts Tagged ‘flex’

For nowhere land

I guess nobody is still using flex, but I still have to debug legacy code and I run into this nice compiler error:

    [mxmlc] Error: null
    [mxmlc] 
    [mxmlc] java.lang.NullPointerException
    [mxmlc] 	at flex2.compiler.util.QName.hashCode(QName.java:131)
    [mxmlc] 	at java.util.HashMap.hash(HashMap.java:366)
    [mxmlc] 	at java.util.HashMap.getEntry(HashMap.java:466)
    [mxmlc] 	at java.util.HashMap.get(HashMap.java:421)
    [mxmlc] 	at flex2.compiler.util.QNameMap.get(QNameMap.java:46)
    [mxmlc] 	at flex2.compiler.as3.reflect.Class.getVariable(Class.java:194)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.findEvents(DataBindingFirstPassEvaluator.java:702)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.findEvents(DataBindingFirstPassEvaluator.java:662)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.watchExpression(DataBindingFirstPassEvaluator.java:959)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:635)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:85)
    [mxmlc] 	at macromedia.asc.parser.QualifiedExpressionNode.evaluate(QualifiedExpressionNode.java:43)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:436)
    [mxmlc] 	at macromedia.asc.parser.GetExpressionNode.evaluate(GetExpressionNode.java:55)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:613)
    [mxmlc] 	at macromedia.asc.parser.MemberExpressionNode.evaluate(MemberExpressionNode.java:57)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:316)
    [mxmlc] 	at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:224)
    [mxmlc] 	at macromedia.asc.parser.ArgumentListNode.evaluate(ArgumentListNode.java:45)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:651)
    [mxmlc] 	at macromedia.asc.parser.SetExpressionNode.evaluate(SetExpressionNode.java:58)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:613)
    [mxmlc] 	at macromedia.asc.parser.MemberExpressionNode.evaluate(MemberExpressionNode.java:57)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:316)
    [mxmlc] 	at macromedia.asc.parser.ListNode.evaluate(ListNode.java:44)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:359)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:405)
    [mxmlc] 	at macromedia.asc.parser.FunctionCommonNode.evaluate(FunctionCommonNode.java:104)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingFirstPassEvaluator.evaluate(DataBindingFirstPassEvaluator.java:325)
    [mxmlc] 	at macromedia.asc.parser.ClassDefinitionNode.evaluate(ClassDefinitionNode.java:106)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:338)
    [mxmlc] 	at macromedia.asc.parser.StatementListNode.evaluate(StatementListNode.java:60)
    [mxmlc] 	at flash.swf.tools.as3.EvaluatorAdapter.evaluate(EvaluatorAdapter.java:923)
    [mxmlc] 	at macromedia.asc.parser.ProgramNode.evaluate(ProgramNode.java:80)
    [mxmlc] 	at flex2.compiler.as3.binding.DataBindingExtension.generate(DataBindingExtension.java:87)
    [mxmlc] 	at flex2.compiler.as3.Compiler.generate(Compiler.java:696)
    [mxmlc] 	at flex2.compiler.mxml.ImplementationCompiler.generate(ImplementationCompiler.java:308)
    [mxmlc] 	at flex2.compiler.mxml.Compiler.generate(Compiler.java:159)
    [mxmlc] 	at flex2.compiler.API.generate(API.java:3514)
    [mxmlc] 	at flex2.compiler.API.generate(API.java:3477)
    [mxmlc] 	at flex2.compiler.API.batch2(API.java:416)
    [mxmlc] 	at flex2.compiler.API.batch(API.java:1117)
    [mxmlc] 	at flex2.compiler.API.compile(API.java:1290)
    [mxmlc] 	at flex2.compiler.API.compile(API.java:1210)
    [mxmlc] 	at flex2.tools.Compiler.mxmlc(Compiler.java:275)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at flex.ant.FlexTask.executeInProcess(FlexTask.java:283)
    [mxmlc] 	at flex.ant.FlexTask.execute(FlexTask.java:225)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [mxmlc] 	at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [mxmlc] 	at net.sf.antcontrib.logic.IfTask.execute(IfTask.java:197)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [mxmlc] 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.TaskAdapter.execute(TaskAdapter.java:154)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
    [mxmlc] 	at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
    [mxmlc] 	at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
    [mxmlc] 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    [mxmlc] 	at java.lang.reflect.Method.invoke(Method.java:606)
    [mxmlc] 	at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
    [mxmlc] 	at org.apache.tools.ant.Task.perform(Task.java:348)
    [mxmlc] 	at org.apache.tools.ant.Target.execute(Target.java:435)
    [mxmlc] 	at org.apache.tools.ant.Target.performTasks(Target.java:456)
    [mxmlc] 	at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
    [mxmlc] 	at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
    [mxmlc] 	at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
    [mxmlc] 	at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
    [mxmlc] 	at org.apache.tools.ant.Main.runBuild(Main.java:851)
    [mxmlc] 	at org.apache.tools.ant.Main.startAnt(Main.java:235)
    [mxmlc] 	at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
    [mxmlc] 	at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

Caused by this small modification in code:

<mx:TextInput id="motpPin"
text="{editedItem.@motpPin}"
change="{setValue(editedItem, '@motpPin' + selectedAuthNo, motpPin)}"/>
<mx:TextInput id="motpPin"
text="{editedItem.@['motpPin' + selectedAuthNo]}"
change="{setValue(editedItem, '@motpPin' + selectedAuthNo, motpPin)}"/>

RIA’s. Where to go from now?

I was a big fan of Flex. The code was clean, object-oriented, re-usable. We even had the bonus of E4X. We’ve wrote the interface of a huge project using it and I know there was no way we could have had such a rich client other than using native code. We developed multiplatform and the client ran multiplatform without a bit of change. The deployment was easy and the administration on the client side minimal. Everyone had flash.

(more…)

Betrayed by adobe

In the last few days I tried to find as much information as possible on the Adobe Flash decision to stop developing flash on mobile platforms. Some called it “the death of flash” even if the statement issued by Adobe is much unclear to me. After reading and reading posts and comments all over the net I got increasingly frustrated and decided to write down some of my thoughts on the subject.

(more…)

Air versus native Android applications

This weekend was cloudy and it rained so I decided to give some more time to play with my android phone. Even since I got the phone some time ago I tried on several occasions to do some fun development on it but it never seemed quite fun as expected so beside some play with the sensors, gps and camera I did not do much. However this time I was decided to do a different kind of test. I had in mind a simple application and I wanted to try how nice it is to develop it using the java android libraries from google and the air libraries from adobe.

The application

It is quite a simple application. In the first screen a login window is presented, the info is used to authenticate with a remote server, the response is evaluated and if the login is successful the JSESSION cookie is passed to a new view which connects to a service which returns a list of tasks which are displayed in a list. The server part existed and returned XML streams as response.

(more…)

My first Firefox workaround

This weekend, being stranded inside by the rain I tried to help a friend with a small flex (flash) application. The code looked very simple and I could not understand the problem. On a non-US keyboard flash seemed to ignore all special chars (like @, #) in a basic text field. After some research I found this very, very ugly and old bug laying around since FF 2. It seems it had been corrected sometime and then lost again and there is no solution for it other than setting the wmode parameter to window. This is not really a solution if using menus and the iframe hacks for making them draw above the flash part of the screen. Very, very ugly.

With the same occasion I found out that FF now ships on a 6 months basis and it has just released FF 5. Good work! :(

FB4 on linux

Since 01.01.2011 Adobe has stopped support for Flex Builder 3 alpha on Linux. After this date the plugin effectively stopped working even if you had a valid, payed license as it was my case. This was a very sad news since I do a lot of flex development. I don’t need much of the Builder since I use ant for the compilation but at least code completion in .as and .mxml files is a must. As such I will try to describe here how to install the fb4 on linux with some success. Even if this describes the setup for 32 bit java on a 64 bit machine you can skip the 32 bit libraries part and install 64bit java. (more…)

Searching for duplicate flex functions

After a day lost trying to find a bug caused while refactoring multiple versions of copy/paste code into a component I’ve decided to write a small application which searches for other code from my component still duplicated in other places.
Naturally a basic python script has emerged. It takes as argument a file and a folder and searches for files ending with .as recursively. Both the reference file and the found files are parsed and a basic function reference is created which is compared to the other files.
This method could be easily used for C, Java or other brace based language. The parsing is very basic and some obvious limitations exist such as comment handling. But it’s ok for 10 minutes of work and gave me enough information to simplify my work for the days ahead and also find some interesing informations about the copy-paste anti-pattern.

(more…)

Mixing generated with mxml code

The problem this example tries to solve is the following: you have a Container component (Accordion, TabNavigator, etc.) and you wish it’s content to be generated dynamically but inside this generated content to use some content which is defined in the mxml, inside the Container. For those with Tapestry experience this behaviour is similar to the @RenderBody component.

<my:CustomWrapper ...>
    <mx:VBox> ... </mx:VBox>
</my:CustomWrapper>

This is very similar to a Container definition but the VBox will not end as a child of CustomWrapper but further down in the hierarchy.

Actually the main trick is to rewrite the DefaultProperty to something else than: childDescriptors since the childDescriptors property is used to create the children of the component (look inside Container.as if curious).

Your component will look similar to:

<?xml version="1.0" encoding="utf-8"?>
<mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml">
 <mx:Metadata>
 [DefaultProperty("children")]
 </mx:Metadata>
 <mx:Script>
 <![CDATA[

 private var _children:VBox;

 public function set children( value:* ):void{
 _children = value as VBox;
 invalidateProperties();
 }

 public function get defaultSearch():VBox{
 return _children;
 }

 override protected function createChildren():void {
 super.createChildren();
 //add the _children somewhere else in the hierarchy
 }

 ]]>
 </mx:Script>
 <mx:HBox>
... other components here,
 </mx:HBox>
</mx:VBox>

Some other interesting links on this subject:

asdoc pain

Running asdoc should have been a breeze. Just create an ant task which calls the asdoc executable with the given parameters and voila! Well, it was not.

<target name="compile">
<exec executable="${asdoc}" failonerror="true">
<arg line="-doc-sources ${src.dir}"/>
<arg line="-window-title "My Application""/>
<arg line="-output ${asdoc.output}"/>
</exec>
</target>
 (more…)

Flex applications size optimization

After quite some time of development we realised that our application flex has grown quite large, both in functionality and size. I should have chosed to develop it in GWT since I think we could not have done even 30% of the functionality and it would have been simpler :). Joke aside the size of all the modules has grown over 50M. These are some steps I have found in order to reduce the size. Note that I am using ant files to compile everything so adapt this to your method. (more…)