2 Replies Latest reply on Jul 9, 2009 7:12 AM by Gregory Lafrance

    Can't change style at runtime

    Benoitcn

      I try to change the backgroundImage of a canvas

       

       

           private function butClickHandler(event:MouseEvent):void
           {
                          /* invalidly */
                styleCanvas.setStyle("backgroundImage", "@Embed('bird.png')");
                    //  styleCanvas.setStyle("backgroundImage", "Embed('bird.png')");
                    //  styleCanvas.setStyle("background-Image", "@Embed('bird.png')");
                     //  styleCanvas.setStyle("background-Image", "@Embed(source='bird.png')");
      
                          /* normally */
                styleCanvas.setStyle("backgroundColor", "#777777");
                Button(event.target).setStyle("fontSize", 22);
           }
      
              <mx:Button x="38" y="44" label="为中国喝彩" click="butClickHandler(event)"/>
           <mx:Canvas id="styleCanvas" width="80" height="80">
                <mx:Label text="I'm Label"/>
           </mx:Canvas>