[flexcoders] Re: Custom Component Styles
Hi Stephen, The link you posted was what I was attempted to point people to in my first post. What I posted is indeed similar to what the Live Docs suggest but with a fairly vital twist. That suggested by the Live Docs means if a user defines only one of the component's style attributes using a css file then none of the defaults will be set (if you look at the code with that in mind it's quite clear why), thereby forcing the user to define all style attributes in the css file. Where as the code I posted (picked up from the charting code) allows the component to behave as those created for the framework, i.e. use the default value for any style attribute not specified by the user's css file. Hope that clears things up. Graham --- In flexcoders@yahoogroups.com, "Stephen Gilson" <[EMAIL PROTECTED]> wrote: > > Hi Graham, > > Isn't that similar to the example in the docs here: > http://livedocs.adobe.com/flex/201/html/skinstyle_149_7.html > > Stephen > > > > > From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On > Behalf Of g_odds > Sent: Monday, February 26, 2007 11:55 AM > To: flexcoders@yahoogroups.com > Subject: [flexcoders] Re: Custom Component Styles > > > > It would appear the link I gave is broken. But nevermind, I have > found the solution by delving through the framework source code, where > the developers do it differently from what is documented in the Live > Docs. > > The solution is to use something along the lines of: > > private static var stylesInitialised:Boolean = initStyles(); > > private static function initStyles():Boolean { > var sd:CSSStyleDeclaration = > StyleManager.getStyleDeclaration("AreaZoom"); > > if (!sd) > { > sd = new CSSStyleDeclaration(); > StyleManager.setStyleDeclaration("AreaZoom", sd, false); > } > > sd.defaultFactory = function():void > { > this.borderColour = 0x017C98; > this.borderAlpha = 1; > this.fillColour = 0x96CEFD; > this.fillAlpha = 0.2; > } > > return true; > } > > Graham > > --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> > , "g_odds" wrote: > > > > I have been looking through the Adobe documentation for a few hours > > now and have no suggestion of how to achieve what I want to do. I > > have a custom component that has some custom style attributes. I > > would like these style attributes to have default values. So, I > > followed what is described in the Live Docs > > > (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.h > tm?href=Part2_DevApps_048_1.html > <http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.h > tm?href=Part2_DevApps_048_1.html> ). > > > > All is fine and dandy, except for a (rather major?) problem. This > > method of setting defaults forces someone using the component to set > > all the style values or none, because if they set a single style > > attribute the default values are not set for any of the other > > attributes. Am I missing something or is this styling malarky > > complicated? > > > > Cheers, > > > > Graham > > >
RE: [flexcoders] Re: Custom Component Styles
Hi Graham, Isn't that similar to the example in the docs here: http://livedocs.adobe.com/flex/201/html/skinstyle_149_7.html Stephen From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of g_odds Sent: Monday, February 26, 2007 11:55 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: Custom Component Styles It would appear the link I gave is broken. But nevermind, I have found the solution by delving through the framework source code, where the developers do it differently from what is documented in the Live Docs. The solution is to use something along the lines of: private static var stylesInitialised:Boolean = initStyles(); private static function initStyles():Boolean { var sd:CSSStyleDeclaration = StyleManager.getStyleDeclaration("AreaZoom"); if (!sd) { sd = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration("AreaZoom", sd, false); } sd.defaultFactory = function():void { this.borderColour = 0x017C98; this.borderAlpha = 1; this.fillColour = 0x96CEFD; this.fillAlpha = 0.2; } return true; } Graham --- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com> , "g_odds" <[EMAIL PROTECTED]> wrote: > > I have been looking through the Adobe documentation for a few hours > now and have no suggestion of how to achieve what I want to do. I > have a custom component that has some custom style attributes. I > would like these style attributes to have default values. So, I > followed what is described in the Live Docs > (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.h tm?href=Part2_DevApps_048_1.html <http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.h tm?href=Part2_DevApps_048_1.html> ). > > All is fine and dandy, except for a (rather major?) problem. This > method of setting defaults forces someone using the component to set > all the style values or none, because if they set a single style > attribute the default values are not set for any of the other > attributes. Am I missing something or is this styling malarky > complicated? > > Cheers, > > Graham >
Re: [flexcoders] Re: Custom Component Styles
Graham, You may also want to take a look at this: http://www.scalenine.com/ You'll need the Flex 2.1 update to use it. hth, Mike Britton
[flexcoders] Re: Custom Component Styles
It would appear the link I gave is broken. But nevermind, I have found the solution by delving through the framework source code, where the developers do it differently from what is documented in the Live Docs. The solution is to use something along the lines of: private static var stylesInitialised:Boolean = initStyles(); private static function initStyles():Boolean { var sd:CSSStyleDeclaration = StyleManager.getStyleDeclaration("AreaZoom"); if (!sd) { sd = new CSSStyleDeclaration(); StyleManager.setStyleDeclaration("AreaZoom", sd, false); } sd.defaultFactory = function():void { this.borderColour = 0x017C98; this.borderAlpha = 1; this.fillColour = 0x96CEFD; this.fillAlpha = 0.2; } return true; } Graham --- In flexcoders@yahoogroups.com, "g_odds" <[EMAIL PROTECTED]> wrote: > > I have been looking through the Adobe documentation for a few hours > now and have no suggestion of how to achieve what I want to do. I > have a custom component that has some custom style attributes. I > would like these style attributes to have default values. So, I > followed what is described in the Live Docs > (http://livedocs.adobe.com/flex/201/html/wwhelp/wwhimpl/js/html/wwhelp.htm?href=Part2_DevApps_048_1.html). > > All is fine and dandy, except for a (rather major?) problem. This > method of setting defaults forces someone using the component to set > all the style values or none, because if they set a single style > attribute the default values are not set for any of the other > attributes. Am I missing something or is this styling malarky > complicated? > > Cheers, > > Graham >