1 Reply Latest reply on May 24, 2010 5:27 PM by Flex harUI

    embedding images without explicit style definitions

    jsd99

      I'm designing an app with a big row of buttons.  They are all identical except for the label and icon.  Ideally I would like to be able to define them via ActionScript using a for loop.  I'm stuck on how to embed the icon images though without doing a separate style entry for each button.

       

      example code:

       

      var labels:Array = ["hello", "interior", "exterior", "photos", "videos", "accessories", "games"];
                  for each (var s:String in labels) {
                      var b:Button = new Button();
                      b.label = s;
                      buttonBox.addChild(b);
                  }


      For each button I've got graphics called name.png and name-b.png.  So how would I set the skin and over-skin properties of each button programmatically, as if I had made a separate style for each button ala:

       

      .hello {

         skin: Embed(source="assets/hello.png");

         over-skin: Embed(source="assets/hello-b.png");

      }