简体   繁体   中英

How to dynamically set Flex Background (Color and Image)

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM