Hi Ben,

Well you know what, people have called me extreme, can you believe that?! ;-)

Anyway, I am totally an advocate of callLater(), just not using callLater() with the framework template methods.

IE

- commitProperties()
- measure()
- updateDisplayList()

Think about it this way, the LayoutManager that is the scheduler for the whole framework uses callLater(), but it schedules all calls to the above methods in a very methodical, sequential order.

Order, the is what is beautiful about the template method pattern, you can always count on the order of things happening.

When you add a call like callLater(measure) that messes things up.

Example, you always run the chance of calling measure() in a component and it could call another invalidation method.

Essentially calling callLater(measure) is the equivalent of the framework calling invalidateSize().

The difference is the invalidateSize() schedules the measure() call based on nets level and other invalidation factors.

The last statement is my rationale for not doing it. :)

Peace, Mike

On 9/7/06, ben.clinkinbeard < [EMAIL PROTECTED]> wrote:

Thanks Darron! That works beautifully. Although I can't believe you
don't think SuperCheckBox is an accurate name :)

Michael, I would be interested in hearing your rationale, because so
far it seems like a perfectly valid way of dealing with the underlying
processes of Flash/Flex.

Thanks all,
Ben



--- In flexcoders@yahoogroups.com, "Darron J. Schall" <[EMAIL PROTECTED]> wrote:
>
> It's not actually the events that are giving you a problem, but rather
> it's the tricky nature of dealing with auto-sizing text measurement.
> Add this statement to your measure function:
>
> trace( "textHeight = " + textField.textHeight );
> trace( "height = " + textField.height );
>
> When the components are first added into your VBox, you'll see that
> their textHeight is actually 0 and the textField height is 4. Now,
when
> you roll over the checkboxes and measure is called again, you'll see
> those numbers change to be the "actual" values, and that's when they're
> drawn correctly.
>
> Here's what I changed your code to to get something that works. It's a
> bit of a hack in that it just calls measure again in the constructor
> after things have had time to measure, and I cleaned it up a bit to not
> rely on those events (you should override createChildren, as I've done
> below). Note I've also re-named the class to describe its purpose
better:
>
> package
> {
> import mx.controls.CheckBox;
> import flash.text.TextFieldAutoSize;
>
> public class MultiLineCheckBox extends CheckBox
> {
> public function MultiLineCheckBox()
> {
> super();
>
> callLater( measure );
> }
>
> override protected function createChildren():void
> {
> super.createChildren();
> textField.wordWrap = true;
> textField.autoSize = TextFieldAutoSize.LEFT;
> textField.border = true;
> }
>
> override protected function measure():void
> {
> super.measure();
> // Make sure the text field has measured itself
> if ( textField.height > 4 )
> {
> measuredMinHeight = minHeight = textField.height;
> }
> }
> }
> }
>
>
> I hope this helps!
>
> -d
>
>
> ben.clinkinbeard wrote:
> >
> > Thanks for the reply Abdul. However, if I remove the
> > FlexEvent.CREATION_COMPLETE listener, the checkboxes overlap each
> > other. Until I roll over them that is... once I roll over them they
> > each pop into the correct, non-overlapping position. I believe the
> > problem is that the textbox has not yet resized when INITIALIZE is
> > called. The behavior is virtually identical if I remove the INITIALIZE
> > listener, leaving only CREATION_COMPLETE; the items overlap until they
> > are rolled over. Very strange.
> >
> > Any ideas?
> >
>




--
What goes up, does come down. __._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





SPONSORED LINKS
Software development tool Software development Software development services
Home design software Software development company


YAHOO! GROUPS LINKS




__,_._,___

Reply via email to