Reputation: 165
I have been given the seemingly simply task of resizing a Group container by setting width and height explicitly in response to user interaction. However, changing these values have no effect on the size of the container at all. Changing scaleX and/or scaleY will change the size of the container just fine, but this is not the behavior I am after.
I have tried overriding updateDisplayList() to set a specific width and height, but this has not yielded the desired results.
If anyone has a link to a good tutorial or can contribute in any other way to a solution, then I would greatly appreciate it. Google does not seem to be my friend on this one.
Edit
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="ns.adobe.com/mxml/2009" ;
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
width="400" height="300"
click="resize()">
<fx:Script>
<![CDATA[
private function resize():void
{
width = 500;
height = 300;
}
]]>
</fx:Script>
</s:Group>
Upvotes: 1
Views: 1802
Reputation: 19220
Actually your approach works just fine, but you need to have some content inside that group, or use a BorderContainer
instead:
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
click="doResize();">
<fx:Script>
<![CDATA[
public function doResize():void
{
this.width = 300;
this.height = 200;
}
]]>
</fx:Script>
</s:Group>
To stick to your problem, I've put a TextArea
into this Group instance from the main application, and it gets resized.
Upvotes: 1
Reputation: 3022
Your group is visually empty and click
handler is never called. Try using a BorderContainer
with backgroundColor
.
Upvotes: 0