Flex Example: simple slide out menu using effects

A lot of Flex developers resort to Flex ‘states’ when adding interactivity and transitions to their applications. I built the sample below to show a colleague that using Flex ‘effects’ are some times easier and involve less code than ‘states’. This simple example (very beginner) shows how you could build a slide out menu bar without the use of states, which I consider a bit difficult to maintain and skin. The code is available for you just below the working sample.

Click the button on the yellow panel to see it slide out like a shelf.

You can cut and paste this code into your FlexBuilder project and test it out. Feel free to use this in any project or app you are working on.



	
		

	
		
	
	
	
	
	
		

If you know or a more simple way to do this, please feel free to post it on your blog and comment the URL here. If you’ve got other examples of using transitions without states, feel free to post those as well.

chuckstar

6 Comments

Tejas

Use of states and transitions vs effects seems to be a personal choice. I prefer states and transitions because it involves far lesser code, but another developer on our team whom I regard highly uses states sparingly. Definitely it is a good point of debate. Would love more information and views on this.

Rodrigo

Any ideas on how to implement absolute positioning layer in Flex without using absolute positioning for everything?

João Saleiro

The “right” way (without states) is:

You should never allow effects to define the way the view will look. Effects should happen between the changes of the view aspect. This is where states makes sense. You define a view that looks like A, and B. And then you define that for going from A to B, some kind of animations will occur. You should never say that “for the view to look like B, the effect needs to happen”. This creates a dependency on the effect (and a lot of code) (and problems refactoring).

Comments are closed.