tags:

views:

13

answers:

1

I want to give the users the ability to set the background color or choose image to make it background (Tile, Center and Strentch). I tried couple of things with no luck such as trying to chaing a Skin object and assign it. and tried something like:

FlexGlobals.topLevelApplication.setStyle("backgroundColor",uint(chosenColor));

with no luck.

Any ideas?

+1  A: 

Are you using Flex 3 Halo or Flex 4 Spark components?

I thought to access the top level application object, you had to cast it as an application object. But, otherwise I would have used the exact same approach you use.

(FlexGlobals.topLevelApplication as Application).setStyle("backgroundColor",uint(chosenColor));

However, if you're using the Flex 4 approach, I would expect the background color to be in the Application skin class and am not sure if the style would affect that. I haven't worked through the styling differences between skin classes and styles yet. You may want to create a custom skin class that sets the background color based on the style in the component class.

www.Flextras.com
I'm using Flex 4. I tried your suggestion but it didn't work. I tried the skin approach but also I have to pass it as Class Application.setStyle("skinClass", mySkinClass); the problem here is that if I pass it as class I don't think I call pass attributes to it which is what I was as the color changes. Also, do you have a suggestion for setting background image?
Tam
I'm not sure which suggestion you were following, but I may have been unclear. You have to set "what" as a class? The "skinClass" attribute will always need to refer to a class. I suggested you create a skin class that refers to it's host component to get the backgroundColor style. Then just change the background style as you are.
www.Flextras.com