Accessing the Icon for a Button Programmatically in Flex 3

flex_logo

The other day, I was trying to get the icon for a button in flex programmatically for a FlexUnit test. The code I was testing set the icon of a button using setStyle('icon', ICON). I attempted the obvious button.getStyle('icon') in the test, but was surprised that this always returned null.

A little bit of digging revealed that the I needed to go through the style declaration for the button. When changing my test to assert on button.styleDeclaration.getStyle('icon'), I was able to successfully access the icon.

I found this a bit non-intuitive, but fortunately it only involved some investigation and minimal code changes.

Related posts:

  1. Using Flex Code Generator (FCG) with Flex & PureMVC
  2. Can your Selenium do that? Testing flash/flex and silverlight in web apps with iMacros
  3. Ajax and the “Back” button II
  4. Ajax & the “Back” button III. To boldly go where they have just come from.
  5. Skinning Flex with Illustrator CS3

Topics:

Leave a comment

Powered by WP Hashcash

Launch: Pathfinder Newsletter

    Get a monthly update on best practices for delivering successful software.

    Subscribe via email


    Subscribe via RSS      RSS icon

Topics

Search

WordPress

Comments about this site: info@pathf.com