4 Replies Latest reply on Aug 22, 2007 4:48 PM by TOdd_23523523

    Errors with setting Scale9Grid at runtime

      I can't figure out why this code won't work. It keeps throwing
      ArgumentError: Error #2004: One of the parameters is invalid.
      at flash.display::DisplayObject/set scale9Grid()
      at ImageBorderTest/private::imageLoaded()

      I've searched Google, and these Adobe boards, but only find others with similar problems and unresolved answers. The inner Rectangle I'm trying to create is well within bounds of the image (which is 60x60). I've gotten scale9Grid to work when embedding the image, but have yet to get it to work when setting at runtime. Any suggestions?


      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="vertical"
      import mx.controls.Image;
      import mx.controls.Alert;

      private function init(e:Event):void
      image1.addEventListener(Event.COMPLETE, imageLoaded);
      image1.source ="./assets/default_border.gif";

      private function imageLoaded(e:Event):void
      //Alert.show("Image Loaded"); ;
      image1.width = 300;
      image1.height = 300;
      var rec:Rectangle = new Rectangle(10, 10,30,30);
      image1.scale9Grid = rec;
      <mx:Image id="image1" />