last year, at the end of February
Learning Flex
Posted by pbirnie under technology
No Comments
I have spent the past month working with flex - and thought I would blog all the things I have learnt
I am used to object orientated languages such as java (and nowdays even php). All languages have started to look very similar with object orientated dot notation etc. Actionscript (as3) also falls into this category.
I have worked with spring ad java - and am used to xml that can be used to wire java objects together.
Lesson 1) The first difficult part about flex is to get used to the concept that the ActivityPopup.mxml actually creates a new class called ActivityPopup which can be referenced as a normal class in your code. You have a totally new class - but there is <code>no public class ActivityPopup {</code> anywhere to be found.
(You can use the compiler option "-keep-generated-actionscript" to keep the actionscript that is generated from the .mxml files if you want to see what is happening)
Lesson 2) When using flash builder, you may receive a message that the application is already running but the application is not visible. Use task manager to kill adl.exe (adobe debugger) . This will resolve the issue.
Lesson 3) If you are working with a new project - make certain you use the newer sdks (4.1 + ) - as older sdks have many issues (for example: licensing hassels with the visualisation libraries).
Lesson 4) Learning by create a fresh project and using examples from a recent book. The quality of examples found via google can be poor. Some do not work, many encourge poor programming. If you are new to flex, its difficult to know what is good technique. You have to get used to the basics before you can start adding advanced features.
Lesson 5) The [Binding] parameter allows components to listen (and respond) to changes on a data source. The datasource needs to have [Binding] keyword over the definition of the parameter to make it bindable.
Lesson 6) I just expect the component to data binding to work for both reads(component reads datasource and presents data) and writes(changes by user in component, automatically writes to the data source it is bound it). This is not the case. Writes to not write back to the data model.
Lesson 7) Its better to have a central model singleton which contains all the data context the user is in. Then bind the components to this model. You can use
[Bindable]
private var model:ModelLocator = ModelLocator.getInstance();
Lesson
Use some form of hungarian notation to help you seperate objects that are created by flex(magically in the background) eg. checkBox_IncludeMasterEntityName
Lesson 9) For you first project avoid one of the frameworks. I added parsely ioc framework to the code I was working on. These frameworks come with significant learning overhead if you are new to flex. I ended removing parsley from the code - because it actually made it harder understand the code. I would like to try robot legs framework as I think it will make more sence to me - its more OO inheritance based rather than special [tags] in your code.
Lesson 10) Write use OO classes to model your problem domain and use flexunit tests to test business logic - so you dont have to keep on testing it though the UI
Lesson 11) Assuming you are accessing a database directly - Get your relational database model right. Having a bad relational model and refusing to fix that can result in lots of hacks in your code.
Lesson 12) When you see references to @name - this is short hand for referencing properties in a xml node.
Lesson 13) you can use spark and mx components together by
<?xml version="1.0" encoding="utf-8"?>
<s:Panel
xmlns:fx="http://ns.adobe.com/mxml/2009
" xmlns:s="
library://ns.adobe.com/flex/spark"
xmlns:sf="http://www.spicefactory.org/parsley
"title="
Receive Panel" >










I found this
Came across 


