2 Replies Latest reply on Jul 21, 2006 8:10 PM by doug777

    Can't set global Styles

    doug777 Level 1
      StyleManager.getStyleDeclaration("Tile").setStyle("borderStyle", "solid");

      This was working correctly in Beta3, but now it and any other similar style declaration, fails with the error:

      Cannot access a property or method of a null object reference.

      Anyone have any ideas why this has stopped working?

      Doug
        • 1. Re: Can't set global Styles
          doug777 Level 1
          Can anyone see why this doesn't work. Uncomment line 16 to see the error.

          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete = "initApp()">

          <mx:Script>
          <![CDATA[
          import mx.controls.Text;
          import mx.styles.StyleManager;
          import mx.containers.Tile;

          public function initApp():void{
          var ti:Tile = new Tile();
          var txt:Text = new Text();
          txt.text = "Hope this is red too";
          ti.addChild(txt);
          pan.addChild(ti);
          //StyleManager.getStyleDeclaration("Tile").setStyle("color","red");
          StyleManager.getStyleDeclaration("TextArea").setStyle("color","red");
          }
          ]]>
          </mx:Script>

          <mx:HBox id="pan" width="450" height="150">
          <mx:TextArea height="100" width="200">
          <mx:text>Hope this is red</mx:text>
          </mx:TextArea>
          </mx:HBox>
          </mx:Application>
          • 2. Re: Can't set global Styles
            doug777 Level 1
            Can anyone confirm that they see the error when the commented out line is reinstated?

            It looks as though you can set global styles for components created with mxml, but not those created directly in ActionScript, though I realize this must be nonsense.

            But why doesn't it work (and exactly the same code did work in Beta3) ??

            Doug