> 1. If the same code produces different character bounds in AIR than in
> the Flash Player, that's a bug and you should file it.

It produces the same bounds, you just can't access the function at the
same time, that is upon setting the text property. You have to do it
later at some point in time.


> 2. A constructor should not call createChildren(). The framework
> automatically calls createChildren() at the appropriate time, which is
> when the component is added to the display list.


If I don't call createChildren() I get null object exception. 


> 3. If you find yourself having to use callLater(), you're probably doing
> something the wrong way. In general, you should use events rather than
> just waiting awhile. If the framework doesn't provide the event you
> need, please file an enhancement request.

Or it might be that Adobe is doing something the wrong way and we're
just forced to use all sorts of hacks to work with half baked
products. (no access to TextField, no documentation on mx_internal,
AIR bounds vs. FP bounds, etc, etc...)


Cheers










> Gordon Smith
> Adobe Flex SDK Team
> 
> ________________________________
> 
> From: [email protected] [mailto:[EMAIL PROTECTED] On
> Behalf Of b_alen
> Sent: Wednesday, February 20, 2008 8:48 AM
> To: [email protected]
> Subject: [flexcoders] Re: getCharBounds not working on AIR?
> 
> 
> 
> Great, it seems like callLater saved my butt. Luckily i also found the
> blog which explains in short the WHY's and HOW's of the callLater.
> Title of the blog is callLater() - The Function That Saved My Butt.
> It's here:
> 
> http://www.kylehayes.info/blog/index.cfm/2007/5/31/callLater--The-Functi
> on-That-Saved-My-Butt
> <http://www.kylehayes.info/blog/index.cfm/2007/5/31/callLater--The-Funct
> ion-That-Saved-My-Butt> 
> 
> The function actually broke because I had to use it within the for
> loop. The solution was to to get rid of the for loop and instead split
> the iteration into several functions that were calling each other upon
> completion.
> 
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com>
> , "Daniel Freiman" <FreimanCQ@> wrote:
> >
> > If you want a simple wait, you can use uicomponent.callLater(). 
> (See the
> > docs). The other alternative is to listen for an event but which
> even to
> > listen for depends on your use case. (for example if this is
> happening when
> > the application is loaded applicationComplete would probably be the
> correct
> > event.) Check out the events thrown by the components involved to
> see if one
> > jumps out at you.
> > 
> > - Dan Freiman
> > 
> > On Wed, Feb 20, 2008 at 10:53 AM, b_alen <alen.balja@> wrote:
> > 
> > > Wow, that was fast, I didn't even manage to finish the cigarette :)
> > >
> > > And it works. Now, should I use the interval or is there a more
> > > elegant way to know that the component is ready? You were mentioning
> > > "refresh".
> > >
> > > Thanks a ton buddy
> > >
> > >
> > > --- In [email protected]
> <mailto:flexcoders%40yahoogroups.com>  <flexcoders%40yahoogroups.com>,
> "Daniel
> > > Freiman" <FreimanCQ@> wrote:
> > > >
> > > > Try getting the rect later (Put a button somewhere and click it
> after
> > > > everything is finished loading) to make sure the UITextField
> doesn't
> > > just
> > > > need to be refreshed first. If that doesn't work, I'd file a bug
> if
> > > I were
> > > > you.
> > > >
> > > > - Dan Freiman
> > > >
> > > > On Wed, Feb 20, 2008 at 10:20 AM, b_alen <alen.balja@> wrote:
> > > >
> > > > > It seems a bit ridiculous but it's true. Not just that you have
> > > to use
> > > > > all sorts of hacks to get access to good old TextField
> (IUITextField)
> > > > > in Flex in order to even think of accessing characters'
> Rectangles.
> > > > > Once you do manage to cut your way through, you get a very nasty
> > > > > disappointment that IUITextField.getCharBounds() works
> perfectly in
> > > > > Flex Web apps, but returns some bizarre incorrect values when
> running
> > > > > on AIR.
> > > > >
> > > > > If anyone has any suggestion, I'd really appreciate it very
> much.
> > > > > We're in terrible deadline and this is one of the crucial
> > > functionalities.
> > > > >
> > > > > var tf:TextAreaExtended = new TextAreaExtended();
> > > > > tf._textField.text = "dsfsdf sfd sf dsf sfdsd fdsfdsfdsfdsfdsf
> fds";
> > > > > addChild(tf);
> > > > > var rect:Rectangle = tf._textField.getCharBoundaries(20);
> > > > >
> > > > > // I get values for rect.left something like 0.58888888888888888
> > > > > // same goes for other rect properties, very weird.
> > > > >
> > > > > // extended TextArea which gives access to TextField
> > > > > package
> > > > > {
> > > > > import mx.controls.TextArea;
> > > > > import mx.core.IUITextField;
> > > > >
> > > > > public class TextAreaExtended extends TextArea
> > > > > {
> > > > > public function TextAreaExtended()
> > > > > {
> > > > > createChildren();
> > > > >
> > > > > }
> > > > >
> > > > > public function get _textField():IUITextField{
> > > > > return textField;
> > > > > }
> > > > > }
> > > > > }
> > > > >
> > > > >
> > > > >
> > > >
> > >
> > > 
> > >
> >
>


Reply via email to