1 Reply Latest reply on May 11, 2010 7:56 AM by reidabel

    css within FB4 - colors in variables?

    reidabel Level 1

      How can I specify my colors once and use them throughout the application? I have tried defining color-value variables in an ActionScript file, like so:

       

      Colors.as

      -------------

      /* main color with brightness variations */

       

      public

       

       

      var color1:int = new int(0xA1D190);

      public

       

       

      var color2:int = new int(0x6EC84E);

       

      Skin file - yes

      ------------

      If I include the colors.as file in a skin file, I can use data binding to do things like:

      color.down="

      {color1}"

       

      mxml file - no

      ---------------

      However, if I do this in my main mxml file, it kills design view (nothing but blank white space, no components showing) BUT - the application runs just fine with the right colors. Run-time availability vs. design-time unavailability, I assume.

       

      css file - no

      -------------

      I can't use the data-binding {color1} in the css file, I have to hardcode the values and can't find a way to use variables.

       

      So, what IS the best way to do this? My friend says that I can do css variables within FB4, I just have to use the IDE somehow. However, he believes I should have a Design tab when I've got a css file open in FB4, and I don't have one and can't seem to get it.

       

      How can I specify my colors in variables and use them throughout the application's files?

       

      Thanks

       

       

        • 1. Re: css within FB4 - colors in variables?
          reidabel Level 1

          Okay, so after getting almost no views and getting zero replies here, I've found the answer. The answer is NO, this can't be done. Well, at least the part about being able to use variables within the css file. See details at:

           

          http://forums.adobe.com/message/2645929#2645929

           

          I found some discussion of people hoping that it will be possible in the future to have variables within css, but that would still not provide what I was looking for in Flash Builder. Perhaps a pre-processing program could be written that would inject colors into the mxml, skin, and css files, but I'm not sure how well that would play with the FB IDE. And even with such a thing, going back and forth with changes could be a problem.

           

          So I guess we're stuck doing it the hard way.