Monday, November 10, 2008

Flex setup and workspace

Its been a little while since i tried to do any flexing. I came across a neat little project that caught my eye, because of what it was building, a task list. Maybe i could replace some of my stickies. Anyway, ive been working on the example this am for a little bit. Here are a couple of "oh yas" that i encountered so far. http://www.ddj.com/web-development/209900484?pgno=1

Briefly, the reason we want to use flex is:
It builds better interfaces that HTML - look better, and have built in features that HTML does not.
It allows remote access to data without needing to reload the entire HTTP request. This is more responsive when there is alot of data. Remember, FLEX is an IDE that builds SWFs that play in flash player. 99% of all browers have flash player installed. Flashplayer is still a plugin and needs to be installed into a new browser, that is a one time cost, and many many sites across the web deplay swfs, so its a no brainer. SWFs allow us to get to the data layer without needing to reload the entire HTTP request. Swfs have been doing this for years, in the past couple years, swf development has become available to the programmers via FLEX.

Recall that flex uses a markup language called MXML, similar to HTML to build its UI components. There are lots of them available. It uses actionScript to build the event model that allows the UI to communicate with the user via clicks and the data layer, generally using ROing, but also can use web services and XML file consumption to speak with the data layer.

Think too about OO design, as you build UI components via MXML and ActionScript to speak to the data layer, the UI components should speak to a service. The service component speaks to an object in the model domain.

While i was playing with my little example this am, i was greatful for my previous documentation, http://jira.accelerateu.org/confluence/display/WebTeam/Flex. Very useful to remind me of some basic techniques. One of the first things i wanted to do was connect my UI component to the database via an RO call. I was able to borrow from my documentation quickly to cut to the chase. I created a new cfc with a function set to remote access and queried a random table. Then i set the applicationComplete property in the mxml file to call the function via the remote object defined in the file. The i created a function in the mxml file, via ActionScript to handle the results, binding them to a data grid control in the mxml file.

I had to perform a Project Clean workspace to get my swf to recompile, even though i was not getting any errors. Im not sure what the trigger is here, only that at some point, it stoped recomiling the swf. I could see this by looking at the compile date on the swf. I would then deploy the swf into my webroot and view it via the browser. Typically, when there are problems with the mxml or ActionScript that prevent a recompile, there is an indication in the source file.

Overall, i was able to quickly get back into the guts of Flex development. Keywords:

  • Flex - IDE for building swfs
  • Swfs - movie renderable in flashplayer
  • Flashplayer - plugin used in browser
  • MXML - mark up language used by Flex to build swfs
  • ActionScript - scripting language used to program events and attach UI to domain
  • Compilation - process of turning MXML file into swf.
  • Deploying - process of moving swf into the web server root
  • Embedding - placing swf within a CFM or HTML file

No comments: