Flex/Actionscript assistance

odoe

[H]F Junkie
Joined
Oct 10, 2001
Messages
9,796
Not sure how many Flex/Actionscript guys are on this board, but I'm not sure where else to look.

Ok, so I a version of a panel in Flex that is a modified from this Super Panel component, not that it matters, but I am basically just created a panel extender.
I didn't like some of it's behavior, so I tweaked it bit.

So, I have a close/min(max) button on the right of my titlebar. What I am trying to do is make it so that if the width of the panel changes, it will fire off this function of the code in the component that controls positioning of these buttons.

Code:
[SIZE=2]
[LEFT][/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].minButton.buttonMode = [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]true[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].minButton.useHandCursor = [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]true[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].minButton.x = [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].unscaledWidth - [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].normalMaxButton.width - 24;
[/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].minButton.y = 8;
[/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].closeButton.buttonMode = [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]true[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].closeButton.useHandCursor = [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]true[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].closeButton.x = [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].unscaledWidth - [/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].closeButton.width - 8;[/LEFT]
[/SIZE][B][SIZE=2][COLOR=#0033ff][SIZE=2][COLOR=#0033ff]this[/B][/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2].closeButton.y = 8;
[/SIZE]

So I am trying to find the right event to add an eventlistener, but the only events I can get to work are mouse events. This won't work as it requires a user to actually click on the panel to change button positions.

To give you an idea of the panel
Application
- Panel
- Box
-Datagrid1
-Datagrid2 (gets added dynamically)

When I add or remove datagrid 2, I resize the panel to fit, so I don't have extra space and it won't look odd. Anyone have any ideas? The only thing I can think of really, would be to add a timer with a mouse event, but that just seems cumbersome. The ResizeEvent.Resize doesn't seem to fire when the width changes and I'm not sure.
 
Ok, I got it. I must have just been not paying attention or something, but I was able to add an event listener on the Event.RENDER and bam, it moves my buttons for me.
In the component script I add
this.addEventListener(Event.RENDER, pnlResizeHandler); when it initializes

The handler points to the code I posted above.

See, sometimes, I just need to write out my problems.
 
Back
Top