Skip to main content

Dynamically changing the background color in Adobe Flex Builder

Recently I have been messing around a bit with Flex 3.0. In one particular occasion I was wondering what would be the easiest way to let a user change the background of a Flex based website. The project consisted of just a standard color picker component (just to illustrate the point). Basically what you want to do is capture the selected color when a particular event is being fired, and use this information to dynamically change the background color of the Flex application.

So, in your main MXML document you can add a standard ColorPicker component, give it an x, y coordinate to put it someplace near the center, and on the "close" event of this component you would use the setStyle() method of the UIComponent class. The code to do this is listed here below:

<mx:ColorPicker id="color" x="380" y="338" 
close="{this.setStyle('backgroundGradientColors', 
[color.selectedColor,color.selectedColor])}" />

Can it be done more easily? I guess not.

Comments

Popular posts from this blog

But Google what about mobile phones that do not support Javascript?

In the global device market, there are still between 0.2% and 5.4% of phones that do not support Javascript, at least in these set of countries according to this site. In case your mobile website falls within this set than what do you do when you want to optimize CSS delivery by deferring the loading of some CSS but still serving the complete CSS to non-Javascript websites?

Algorithm to sort edge list of simple polygon for 2D and 3D

Sometimes it is handy to sort an edge list. In this case I needed an algorithm to test for concavity of a simple 3D polygon with just one face. You can also apply the procedure on 2D because it just sorts an edge list that could contain either 2D or 3D vertices. The polygons were made in Blender v.2.67 , so the script had to be written in Python and executed via the Run Script button in the text editor. I didn't want to use fancy algorithms to sort edges because we're dealing with simple polygons, so I ended up writing my own. As a side note, the edge-angle checkbox in Blender, which can be used to see if a polygon is convex or concave didn't work for me, so I had no other choice but to first sort edges before I can apply angle calculations on consecutive vertices. Suggestions for improvements are welcome and hopefully it helps someone else who had to deal with the same (or similar) issues in Blender!

A scalable geometrical model for muscle and tendon units: An algorithmic solution on how to fit a template muscle on a high resolution muscle mesh

The reason for this blog post is to share a bit on a particular hard problem that I've encountered during my Master's thesis with a broader audience. I will try my best to write it in plain English, but as the problem is complex expect this to be a lengthy post with domain specific terminology.