7 Replies Latest reply on Apr 17, 2010 6:43 AM by Ned Murphy

    Where's the Square?

    beno12345 Level 1

      One more question, if you don't mind. I have the following code:

       

              function Navigation(navName:String, navURL:String, myX:int, myBackgroundColor:uint):void
              {
                  myFont2 = 'Arial';
                  mySize = 15;
                  myTextColor = 0x000000;
                  myBorder = true;
                  myBorderColor = 0xFF0000;
                  myY = 240;
                  myGraphicsFill = 0xffffff;
                  var myNavigation:TextField = new TextField();
                  var format:TextFormat = new TextFormat();
                  format.font = myFont2;
                  format.size = mySize;
                  myNavigation.htmlText = '<a href="' + navURL + '">' + navName + '</a>';
                  myNavigation.textColor = myTextColor;
                  myNavigation.border = myBorder;
                  myNavigation.borderColor = myBorderColor;
                  myNavigation.background=true;
                  myNavigation.backgroundColor = myBackgroundColor;
                  myNavigation.autoSize = TextFieldAutoSize.LEFT;
                  myNavigation.x = myX;
                  myNavigation.y = myY;
                  myNavigation.setTextFormat(format);
                  var navDropShadow:DropShadowFilter = new DropShadowFilter();
                  navDropShadow.color = 0x000000;
                  navDropShadow.blurX = 10;
                  navDropShadow.blurY = 10;
                  navDropShadow.angle = 135;
                  navDropShadow.alpha = 0.5;
                  navDropShadow.distance = 10;
                  var navFiltersArray:Array = new Array(navDropShadow);
                  myNavigation.filters = navFiltersArray;
                  var myURL:TextField = new TextField();
                  myURL.text = navURL;
                  myURL.x = -100;
                  myURL.y = -100;
                  var navSprite:URLClip = new URLClip();
                  navSprite.url = navURL;
                  navSprite.name = navName;
                  navSprite.addChild(myNavigation);
                  navSprite.addChild(myURL);
                  /*
                  var len:int = myNavigation.numLines;
                  for (var i:int = 0; i < len; i++)
                  {
                      var metrics:TextLineMetrics = myNavigation.getLineMetrics(i);
                      with(navSprite.graphics)
                      {
                          beginFill(myGraphicsFill, 1);
                          drawRect(myNavigation.x, myNavigation.y, metrics.width + 4, metrics.height + metrics.descent + 1);
                          endFill();
                      }
                  }
                  */
                  addChild(navSprite);
                  navSprite.addEventListener(MouseEvent.MOUSE_OVER, onMouseOverHandler);
                  navSprite.addEventListener(MouseEvent.MOUSE_OUT, onMouseOutHandler);
                  navSprite.addEventListener(MouseEvent.MOUSE_DOWN, onPressHandler);
                  navSprite.addEventListener(MouseEvent.MOUSE_UP, onReleaseHandler);
                  navSprite.mouseChildren = false;
                  navSprite.buttonMode = true;
              }

       

      This works and makes nice little nav widget boxes with appropriate text inside linked to Web pages when clicked (left out all the handlers code). The strange thing is I don't know how it makes the boxes that get filled in with the bgcolor! I commented out the code above thinking it was responsible for the creation of those boxes but it works fine without it! I want to tweak the boxes. Please advise.

      TIA,

      beno