Quick cheat notes for Flex's MXML and State.

MXML is basically a quick way to describe the View component to Flex. It can define pages, components, containers etc. So it mixes in quite a bit in the same haphazard way the JSP, PHP, ASPs, Visual Studio components etc allow. It looks like it can get messy quickly Additionally ActionScript can be embedded in MXML documents under CDATA which is a recipe for spaghetti code and difficult to debug behavior. MXML can define visual components such as containers (mx:VBox and mx:HBox) as well as UI interface controls (mx:Button and mx:ComboBox). There are also non-visual components such as Data binding and Utils code. They are probably best not done in MXML (see spaghetti code pattern). The model/controller patterns should use ActionScript even though MXML is compiled down to ActionScript and is an XML representation of ActionScript classes and packages. Flex provides a client/desktop paradigm in a web environment. So it is bad to think of Flex/Flash in web page terms. It is a client-based application. As a result the interactions between components, state and data is done through events rather than http requests and tacked on publish/subscribe mechanisms.

There are two types of events, User Events and System Events. The user events are in response to a user performing an action with a component, such as clicking a button. The user events can be attached to a MXML declaration directly and inlines (same as javascript), or a handler can be registered in the MXML declaration and the event handling code be done in ActionScript either in an mx:Script tag and under a CDATA or through ActionScript in an included file mx:Script and source="name_of_actionscript_file.as"

Flex includes the ability to manage State directly to over-ride views. The state functionality is defined in the UIComponent object. States can be defined in MXML or ActionScript but since it is a view technology, it is best performed and defined in MXML. States are defined with mx:States and the children mx:State where the State tag can add/remove components, set properties of components/objects, set styles of components, set event handlers and perform custom overrides where new events can be defined. Adding and removing components with state changes is like doing a display:none on a div in html. The component remains in memory but is not visible.The properties of component can be modified when state is changed via the mx:SetProperty tag. Style is modified with mx:SetStyle, and handlers added with mx:SetEventHandler.

Rounded Corners and Drop Shadow with Flex

This is a vbox component with a canvas and label inside it. Setting the component's properties is similar to VB or other Visual Studio happy languages. There is none of the mess that CSS and HTML would require to achieve this same effect.

This is the code that creates the screenshot above.

Quite simple. Flex becomes more difficult once MXML and Actionscript are mixed which simple examples such as this don't require.

Most Popular on South Sea Republic

The articles that have been viewed the most:

Most Popular Restaurants in Phoenix

Phoenix Eats Out is the restaurant review site for Phoenix, Scottsdale and Old Town Scottsdale which lists the modernist and contemporary restaurants, taverns and bars in the greater Phoenix area. This is the list of the most popular restaurants pages from phoenixeatsout.com that have been viewed the most; My personal favourite restaurants in Phoenix are AZ88, Postinos, Bomberos with Grazie, Humble Pie, Orange Table, The Vig, Fez and others coming close behind. View the complete list with the photo-journalistic style images on phoenixeatsout.com

Most Popular Hikes in Arizona

Arizona is an outdoor state and has lots of hiking in the city and around the state. Phoenix is unusual for most cities in having several large mountains in the center of the city with great hiking. Anyone who comes to Phoenix has to do the Echo Canyon trail on Camelback and the Summit Hike on Squaw Peak or Piesta Peak. The views of the city, suburbs and surrounding mountains are wonderful from Camelback and Piesta Peak. For more experienced hikers there is the McDowell Mountains in North Scottsdale that has several difficult and strenuous hikes in Tom's Thumb and Bell Pass. Alternatively, you can hike the highest mountain in Arizona. At 12,600 feet Humphrey's Peak is a long and difficult hike.

Alternate Australian Constitutions

Between 2004 and 2009 this site, southsearepublic.org, was a constitutional blog based on scoop which focused on Australian and global constitutional issues. One of the strongest aspects of it was the development of constitutions by those involved in the blog. These constitutions are the outcome: The constitutions were built using principles from Montesquieu's separation of powers, the enlightnment's universal political rights and the ancient Athenian technology of sortition and choice by lot.

Archives For South Sea Republic

South Sea Republic started in 2004 as an Australian constitutional blog in 2004 based on scoop software. It was an immigrative outgrowth of Kuro5hin. The archives for each year since then; The articles are ordered by views.

Who Is Cam Riley

Cam Riley I am an Australian living in the United States as a permanent resident. I am a software developer by trade and mostly work in Java and jump between middleware and front end. I originally worked in the New York area of the United States in telecommunications before moving to Washington DC and working in a mix of telecommunications, energy and ITS. I started my own software company before heading out to Arizona and working with Shutterfly. Since then I have joined a startup in the Phoenix area and am thoroughly enjoying myself.

I do a lot of photography which I post on this website, but also on flickr. I have a photo-journalistic website which lists the modernist and contemporary restaurants in phoenix. I have a site on the Australian Flying Corps [AFC] which has been around since the 1990s and which I unfortunately lost the .org URL to during a life event; however, it is under the www.australianflyingcorps.com URL now. The AFC website has gone through several iterations since the 90s and the two most recent are Australian Flying Corps Archives(2004-2002) and Australian Flying Corps Archives(2002-1999) which are good places to start.

Websites Worth Reading

Websites of friends, colleagues and of interest;