Skip to main content
Aaronius9er9er
Inspiring
October 22, 2010
Question

getBounds() returns incorrect rectangle

  • October 22, 2010
  • 1 reply
  • 796 views

Riddle me this.  Here's my Flex app:

<?xml version="1.0" encoding="utf-8"?>

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"

   xmlns:s="library://ns.adobe.com/flex/spark"

   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600"

   creationComplete="cc();">

<fx:Script>

<![CDATA[

import spark.core.SpriteVisualElement;

protected function cc():void

{

var outer:Sprite = new Sprite();

var inner:Sprite = new Sprite();

inner.graphics.beginFill(0);

inner.graphics.drawRect(-10, -10, 20, 20);

outer.addChild(inner);

inner.x = inner.y = 100;

var spriteVisual:SpriteVisualElement = new SpriteVisualElement();

spriteVisual.addChild(outer);

addElement(spriteVisual);

trace(inner.getBounds(outer));

}

]]>

</fx:Script>

</s:Application>

The cc() function traces (x=90, y=90, w=20, h=20).  Here's my AIR app with the same code:

<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx"
   creationComplete="cc();">
<fx:Script>
<![CDATA[
import spark.core.SpriteVisualElement;
protected function cc():void
{
var outer:Sprite = new Sprite();
var inner:Sprite = new Sprite();
inner.graphics.beginFill(0);
inner.graphics.drawRect(-10, -10, 20, 20);
outer.addChild(inner);
inner.x = inner.y = 100;
var spriteVisual:SpriteVisualElement = new SpriteVisualElement();
spriteVisual.addChild(outer);
addElement(spriteVisual);
trace(inner.getBounds(outer));
}
]]>
</fx:Script>
</s:WindowedApplication>

The cc() function traces (x=-10, y=-10, w=20, h=20).
Why the disparity?  Arrrrg!  Is there a suitable workaround?  Thanks.
This topic has been closed for replies.

1 reply

Aaronius9er9er
Inspiring
October 25, 2010

Looks like this has already been reported as a bug: http://bugs.adobe.com/jira/browse/FP-5143 I cannot believe this issue actually made it into any AIR release build.

chris.campbell
Legend
October 29, 2010

Hi Aaron,

This bug (internal bug #2667566) should be fixed with the AIR 2.5 SDK and runtime release.  Please let me know if you find that isn't the case.

Thanks,

Chris