Currently Reading

Image of Derivatives Demystified: A Step-by-Step Guide to Forwards, Futures, Swaps and Options (The Wiley Finance Series)

Image of Working Effectively with Legacy Code (Robert C Martin)

Image of Coders at Work: Reflections on the Craft of Programming

Image of Succeeding with Agile: Software Development Using Scrum (Addison-Wesley Signature)

Recently Read

Image of Advanced Actionscript 3 with Design Patterns

Image of Refactoring: Improving the Design of Existing Code (Object Technology Series)

Image of iPhone Advanced Projects (Books for Professionals by Professionals)

Image of Cloud Atlas

Image of UML 2 for Dummies

Image of The Secrets of Consulting: A Guide to Giving and Getting Advice Successfully

Image of Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)

Image of Test Driven: TDD and Acceptance TDD for Java Developers

Image of Test Driven Development (The Addison-Wesley Signature Series)

Image of Beginning iPhone 3 Development: Exploring the iPhone SDK


May 18, 2008

Static Code

Filed under: Flex — Anthony @ 2:37 pm

I have recently seen some interesting posts regarding the topic of Static code blocks especially over at InsideRIA I posted my own two cents over there but I will also post it here for future reference:

I often use static variables for creating default styles for my components, these styles then can be overwritten by someone using the component however there will always be my initial stying applied if they arent overwritten.

/***** DEFAULT STYLE DECLARATIONS GO BELOW ***/
 
private static var STYLES : Boolean = defaultStyles( );
 
private static function defaultStyles( ) : Boolean
{
   //NO CSS DECLARATIONS
   var newStyle : CSSStyleDeclaration = new CSSStyleDeclaration( );
   if( !StyleManager.getStyleDeclaration( 'yOffSet' ) )
   {
      newStyle.setStyle( 'yOffSet', 30 );
   }
   StyleManager.setStyleDeclaration(
                                     'CustomComponentName',
                                      newStyle,
                                      true
                                    );
 
   return true;
}

1 Comment »

  1. http://www.tink.ws/blog/styleutilgetdefaultstylename/

    might be of interest

    Comment by Tink — June 6, 2008 @ 2:34 pm

RSS feed for comments on this post. | TrackBack URI

Leave a comment

XHTML ( You can use these tags): <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> .