Group not resizing correctly when contents are moved programmatically
Hi there,
My apologies in advance if this is a known issue. I searched the forums but I was unable to find a discussion about this topic. The issue we are running into is when we programmatically move the contents of a Group which is in turn enclosed within a Scroller beyond the Scroller's limits the position of the Group within the stage is incorrectly calculated. This will cause mouseEvents in the area beyond the Group's limits to be "ignored" among other problems.
I have created an application to illustrate the problem, we are in 4.1:
<?xml version="1.0" encoding="utf-8"?>
<s:Application
minWidth="955" minHeight="600"
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.controls.Alert;
private function onGroupClick(event:MouseEvent):void
{
Alert.show("It works");
}
private function onButtonClick(event:MouseEvent):void
{
rect.x += 500;
rect.y += 500;
}
]]>
</fx:Script>
<s:Scroller
width="100%" height="100%">
<s:Group id="myGroup"
width="100%" height="100%"
click="onGroupClick(event)">
<s:Rect id="rect"
x="0" y="0" width="10" height="10"/>
</s:Group>
</s:Scroller>
<s:Button
label="Move Rectangle"
click="onButtonClick(event)"/>
</s:Application>
Steps to reproduce:
- Click anywhere in the screen - notice that an alert that reads "It works" shows up.
- Click on the "Move Rectangle" button enough times for the coordinates of the Rectangle to exceed the limits of the Scroller, hence producing scroll bars.
- Scroll all the way to the right and to the bottom.
- Click right next to the right bottom corner - notice that no alert is displayed. The reason is the Group has not resized correctly hence we are actually clicking outside the Group. Resizing your browser window for example will cause the Group to resize and events will again "work". FlexSpy will make things pretty apparent as well.
Any pointers regarding where this bug lives in the source code or suggestions on how to fix this would be greatly appreciated, this issue is causing us a lot of pain.
Thanks in advance!!
~ TheMadPenguin
