I like the slightly different approach of using XML for the CSS. You don't have 
to write the stylesheet parsing code since xml parsers do the job for you.

Not sure if you all are really that interested in the xml based approach, but 
here is a link to that...

http://flexcomponents.net/buildingslideshow/

Even though the title says slideshow, it is really about xmlizing the CSS so 
that it can be applies to the slides at runtime without the need to recompile 
the app.

Web Manager
FlexDownloads.com

--- In [email protected], "vipinck" <vipi...@...> wrote:
>
> Hi Valdhor,
> 
> I was doing the same thing for dynamic styling using an xml style file.  I am 
> successful except applying skin files to components. I was trying to keep an 
> image inside an FLA and give linkage properties (which extends BitmapData 
> class) and load it at runtime. And based on the linkage name specified in the 
> XML file, tried getDefinition(name). Got an error which said 'Argument count 
> mismatch on TickMark(). Expected 2, got 0.'
> 
> Can we load a dynamic image or swf like this, so that I can skin components 
> too with XML and resource file instead of pre-compiled skin swfs. I have 
> specific need for this, and cant do the CSS/compiled CSS skinning.
> 
> Thanks for any help you can offer.
> 
> Best regards,
> Vipin 
> 
> --- In [email protected], "valdhor" <valdhorlists@> wrote:
> >
> > parseCSS only works for text fields (See
> > http://livedocs.adobe.com/flex/3/langref/flash/text/StyleSheet.html)
> > 
> > You will need to parse the string yourself and apply styles as required.
> > 
> > One of the bigger problems are that some styles require strings, others
> > require numbers and some even require arrays.
> > 
> > I came up with the following code to demonstrate (You can extend it to
> > do whatever you want):
> > 
> > <?xml version="1.0" encoding="utf-8"?>
> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml";
> > layout="absolute"
> >      creationComplete="onCreationComplete()">
> >      <mx:Script>
> >          <![CDATA[
> >              import mx.styles.StyleManager;
> > 
> >              private var styleString:String = "Button {cornerRadius: 9;
> > highlightAlphas: 0, 0; fillAlphas: 1, 1, 1, 1; fillColors: #6699ff,
> > #6699ff, #6699ff, #6699ff; color: #0033cc; textRollOverColor: #000000;
> > textSelectedColor: #000000; borderColor: #6699ff; themeColor: #ffffff;
> > fontSize: 12; fontWeight: normal; }";
> > 
> >              private function onCreationComplete():void
> >              {
> >                  var CSSArray:Array = styleString.split("{");
> >                  var CSSStyleDeclarationName:String =
> > CSSArray[0].replace(" ", "");
> > 
> >                  var stylesArray:Array = CSSArray[1].split(";");
> >                  for each(var currentStyle:String in stylesArray)
> >                  {
> >                      currentStyle = currentStyle.replace("}",
> > "").replace(" ", "");
> >                      if(currentStyle != null && currentStyle.length > 0)
> >                      {
> >                          var currentStyleName:String =
> > currentStyle.split(":")[0];
> >                          var currentStyleValue:String =
> > currentStyle.split(":")[1].replace(" ", "");
> >                          if(currentStyleName != null && currentStyleValue
> > != null)
> >                          {
> >                              switch(currentStyleName)
> >                              {
> >                                  case "fillColors":
> >                                  case "fillAlphas":
> >                                  case "highlightAlphas":
> >                                     
> > StyleManager.getStyleDeclaration(CSSStyleDeclarationName).setStyle(curre\
> > ntStyleName, currentStyleValue.split(","));
> >                                  break;
> >                                  case "cornerRadius":
> >                                  case "fontSize":
> >                                     
> > StyleManager.getStyleDeclaration(CSSStyleDeclarationName).setStyle(curre\
> > ntStyleName, new Number(currentStyleValue));
> >                                  break;
> >                                  default:
> >                                     
> > StyleManager.getStyleDeclaration(CSSStyleDeclarationName).setStyle(curre\
> > ntStyleName, currentStyleValue);
> >                                  break;
> >                              }
> >                          }
> >                      }
> >                  }
> >              }
> >          ]]>
> >      </mx:Script>
> >      <mx:Button label="Test Button"/>
> > </mx:Application>
> > 
> > 
> > 
> > --- In [email protected], "MicC" <chigwell23@> wrote:
> > >
> > > I am loading cssStyle text from server with a stored procedure and
> > > loading into a string:
> > >
> > > Button {
> > >     cornerRadius: 9;
> > >     highlightAlphas: 0, 0;
> > >     fillAlphas: 1, 1, 1, 1;
> > >     fillColors: #6699ff, #6699ff, #6699ff, #6699ff;
> > >     color: #0033cc;
> > >     textRollOverColor: #000000;
> > >     textSelectedColor: #000000;
> > >     borderColor: #6699ff;
> > >     themeColor: #ffffff;
> > >     fontSize: 12;
> > >     fontWeight: normal;
> > > }
> > >
> > > into cssString. I want to use this as the Application's StyleSheet
> > i.e.
> > >
> > >       <mx:Style source="contents of cssString"/>
> > >
> > > I tried
> > >
> > > this.styleName = cssString;
> > >
> > > and played with
> > >
> > > appStyle = new StyleSheet;
> > > appStyle.parseCSS(cssString);
> > >
> > > but a little knowledge is a dangerous thing :-) How do I get the style
> > > text to become the Application StyleSheet? TIA,
> > >
> > > Mic.
> > >
> >
>


Reply via email to