[flexcoders] Re: getCharBounds not working on AIR?
Sorry I couldn't answer before but for some strange reason Flex stopped compiling and started crashing. I reinstalled it but it's still the same. When I run a debug, it totally crashes and I have to manually shut down the machine. Will definitely revert once I solve this. --- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote: 1. I'll forward your complaints to the QA manager and the relevant QA engineer who marked SDK-10800 as UTR. 2. No, I wasn't saying that you have to add any children into the TextArea. I was trying to explain that you have to add the TextArea to the display list before the TextArea will create its TextField. Simply new-ing a component doesn't create its descendants. Yes, this is unintuitive, but a UIComponent delays the creation of any descendants until their inherited styles can be determined. In general, the framework often has good reasons for the way it does things, but these reasons sometimes aren't obvious or properly explained. 3a. I don't understand what isn't clear and straightforward about the ASDoc for TextArea listing 'textField' as a protected property. 3b. Yes, it's documented what mx_internal represents, and that mx_internal APIs are undocumented and unsupported. What exactly is your complaint about this? 3c. As with any software project, we could undoubtedly have done a better job if we had taken more time. But there are many Flex developers developing compelling Flex applications despite our shortcomings, and most probably wouldn't want longer release cycles. 4. Generally, the updateComplete event tells you that a UIComponent has finished reacting to changes in its properties. I'm unclear on why you said who could resist? about using the betas of Flex 3. It sounds like you've had nothing but frustration with Flex, and I apologize for that. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of b_alen Sent: Thursday, February 21, 2008 2:26 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: getCharBounds not working on AIR? 1. It seems a little bit odd, having to help you identify such obvious bugs, who knows what else we can expect then. I have an issue with your bug report system, where people are just marking everything as Cannot Reproduce. See this page: http://bugs.adobe.com/jira/secure/IssueNavigator.jspa?reset=truecustomf ield_10100=Beta%20App http://bugs.adobe.com/jira/secure/IssueNavigator.jspa?reset=truecustom field_10100=Beta%20App And if you take a look at issue SDK-10800, you'll find the boundaries bug there. I don't know if it applies to AIR but I'm pretty sure nobody took a good look into any bugs on that page. 2. I'm sorry I don't understand. All I wanted is to extend TextArea in order to get access to TextField. I don't want to add any children, I just want a subclass of TextArea. You're saying it's not possible to subclass a component without adding something to it? Isn't that a bit bizarre? I'm posting the class at the bottom. 3a. OK, there obviously is access to the TextField since I am using it and writing about it in the current thread. What I meant was there is no clear, straightforward and documented way of accessing it. You have to hack your way through by relying on information found on blogs and forums. I mean it's just a TextField for god's sake :) 3b. So it's documented that it's undocumented. Perfect documentation, lol. 3c. I appreciate and support this kind of product development where user community is involved. But I seriously think that you haven't done exactly a great job designing it internally, maybe relying to much on the community. It's also our fault we started using it while in beta, but hey, who could resist :) The only sad thing is that in the real world you have to deliver to get paid. 4. Back to the callLater. I don't think it's such a bad idea. In the docs and on the blogs it says that it gets called once all the properties are set. So I figure, it's the same as capturing the nonexistent ALL_PROPERTIES_SET event. package { import mx.controls.TextArea; import mx.core.IUITextField; public class TextAreaExtended extends TextArea { public function TextAreaExtended() { createChildren(); // doesn't work without this } public function get _textField():IUITextField{ return textField; } } } then I'm just using it like this and it works: var actualyUsefulTextArea:TextAreaExtended = new TextAreaExtended(); actualyUsefulTextArea._textField.text = whatever; callLater(getCharBounds); function getCharBounds(){ var rect:Rectangle = actualyUsefulTextArea._textField.getCharBoundaries(4); } --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Gordon Smith gosmith@ wrote: 1. I don't think AIR and Flash Player should have different timing. If the Flash
[flexcoders] Re: getCharBounds not working on AIR?
1. It seems a little bit odd, having to help you identify such obvious bugs, who knows what else we can expect then. I have an issue with your bug report system, where people are just marking everything as Cannot Reproduce. See this page: http://bugs.adobe.com/jira/secure/IssueNavigator.jspa?reset=truecustomfield_10100=Beta%20App And if you take a look at issue SDK-10800, you'll find the boundaries bug there. I don't know if it applies to AIR but I'm pretty sure nobody took a good look into any bugs on that page. 2. I'm sorry I don't understand. All I wanted is to extend TextArea in order to get access to TextField. I don't want to add any children, I just want a subclass of TextArea. You're saying it's not possible to subclass a component without adding something to it? Isn't that a bit bizarre? I'm posting the class at the bottom. 3a. OK, there obviously is access to the TextField since I am using it and writing about it in the current thread. What I meant was there is no clear, straightforward and documented way of accessing it. You have to hack your way through by relying on information found on blogs and forums. I mean it's just a TextField for god's sake :) 3b. So it's documented that it's undocumented. Perfect documentation, lol. 3c. I appreciate and support this kind of product development where user community is involved. But I seriously think that you haven't done exactly a great job designing it internally, maybe relying to much on the community. It's also our fault we started using it while in beta, but hey, who could resist :) The only sad thing is that in the real world you have to deliver to get paid. 4. Back to the callLater. I don't think it's such a bad idea. In the docs and on the blogs it says that it gets called once all the properties are set. So I figure, it's the same as capturing the nonexistent ALL_PROPERTIES_SET event. package { import mx.controls.TextArea; import mx.core.IUITextField; public class TextAreaExtended extends TextArea { public function TextAreaExtended() { createChildren(); // doesn't work without this } public function get _textField():IUITextField{ return textField; } } } then I'm just using it like this and it works: var actualyUsefulTextArea:TextAreaExtended = new TextAreaExtended(); actualyUsefulTextArea._textField.text = whatever; callLater(getCharBounds); function getCharBounds(){ var rect:Rectangle = actualyUsefulTextArea._textField.getCharBoundaries(4); } --- In flexcoders@yahoogroups.com, Gordon Smith [EMAIL PROTECTED] wrote: 1. I don't think AIR and Flash Player should have different timing. If the Flash Player knows the correct bounds immediately after setting the text, AIR should too. Please file a bug. 2. You get a null object exception because you're expecting children to exist after newing a component, and that's not the way any of our framework components work. You have to first do the addChild(). 3a. The textField of a TextArea is a protected var accessible by any subclass, and there is a public getTextField() method in the mx_internal namespace, so it's not accurate to say no access to TextField. 3b. The mx_internal namespace has the documentation /** * This namespace is used for undocumented APIs -- usually implementation * details -- which can't be private because they need to visible * to other classes. * APIs in this namespace are completely unsupported and are likely to * change in future versions of Flex. */ We don't want to advertise it heavily because that would defeat the entire purpose of it. 3c. I'm sorry that your experience with Flex 3 makes you feel that it's half-baked. We have a public bugbase so that you can let us know what we're doing wrong in a way that gets tracked. Complaints on flexcoders don't always get tracked. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of b_alen Sent: Wednesday, February 20, 2008 9:51 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: getCharBounds not working on AIR? 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
RE: [flexcoders] Re: getCharBounds not working on AIR?
1. I'll forward your complaints to the QA manager and the relevant QA engineer who marked SDK-10800 as UTR. 2. No, I wasn't saying that you have to add any children into the TextArea. I was trying to explain that you have to add the TextArea to the display list before the TextArea will create its TextField. Simply new-ing a component doesn't create its descendants. Yes, this is unintuitive, but a UIComponent delays the creation of any descendants until their inherited styles can be determined. In general, the framework often has good reasons for the way it does things, but these reasons sometimes aren't obvious or properly explained. 3a. I don't understand what isn't clear and straightforward about the ASDoc for TextArea listing 'textField' as a protected property. 3b. Yes, it's documented what mx_internal represents, and that mx_internal APIs are undocumented and unsupported. What exactly is your complaint about this? 3c. As with any software project, we could undoubtedly have done a better job if we had taken more time. But there are many Flex developers developing compelling Flex applications despite our shortcomings, and most probably wouldn't want longer release cycles. 4. Generally, the updateComplete event tells you that a UIComponent has finished reacting to changes in its properties. I'm unclear on why you said who could resist? about using the betas of Flex 3. It sounds like you've had nothing but frustration with Flex, and I apologize for that. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of b_alen Sent: Thursday, February 21, 2008 2:26 AM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: getCharBounds not working on AIR? 1. It seems a little bit odd, having to help you identify such obvious bugs, who knows what else we can expect then. I have an issue with your bug report system, where people are just marking everything as Cannot Reproduce. See this page: http://bugs.adobe.com/jira/secure/IssueNavigator.jspa?reset=truecustomf ield_10100=Beta%20App http://bugs.adobe.com/jira/secure/IssueNavigator.jspa?reset=truecustom field_10100=Beta%20App And if you take a look at issue SDK-10800, you'll find the boundaries bug there. I don't know if it applies to AIR but I'm pretty sure nobody took a good look into any bugs on that page. 2. I'm sorry I don't understand. All I wanted is to extend TextArea in order to get access to TextField. I don't want to add any children, I just want a subclass of TextArea. You're saying it's not possible to subclass a component without adding something to it? Isn't that a bit bizarre? I'm posting the class at the bottom. 3a. OK, there obviously is access to the TextField since I am using it and writing about it in the current thread. What I meant was there is no clear, straightforward and documented way of accessing it. You have to hack your way through by relying on information found on blogs and forums. I mean it's just a TextField for god's sake :) 3b. So it's documented that it's undocumented. Perfect documentation, lol. 3c. I appreciate and support this kind of product development where user community is involved. But I seriously think that you haven't done exactly a great job designing it internally, maybe relying to much on the community. It's also our fault we started using it while in beta, but hey, who could resist :) The only sad thing is that in the real world you have to deliver to get paid. 4. Back to the callLater. I don't think it's such a bad idea. In the docs and on the blogs it says that it gets called once all the properties are set. So I figure, it's the same as capturing the nonexistent ALL_PROPERTIES_SET event. package { import mx.controls.TextArea; import mx.core.IUITextField; public class TextAreaExtended extends TextArea { public function TextAreaExtended() { createChildren(); // doesn't work without this } public function get _textField():IUITextField{ return textField; } } } then I'm just using it like this and it works: var actualyUsefulTextArea:TextAreaExtended = new TextAreaExtended(); actualyUsefulTextArea._textField.text = whatever; callLater(getCharBounds); function getCharBounds(){ var rect:Rectangle = actualyUsefulTextArea._textField.getCharBoundaries(4); } --- In flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Gordon Smith [EMAIL PROTECTED] wrote: 1. I don't think AIR and Flash Player should have different timing. If the Flash Player knows the correct bounds immediately after setting the text, AIR should too. Please file a bug. 2. You get a null object exception because you're expecting children to exist after newing a component, and that's not the way any of our framework components work. You have to first do the addChild(). 3a. The textField of a TextArea is a protected var accessible by any subclass, and there is a public getTextField() method in the mx_internal
[flexcoders] Re: getCharBounds not working on AIR?
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 flexcoders@yahoogroups.com, Daniel Freiman [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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.5 // 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; } } }
Re: [flexcoders] Re: getCharBounds not working on AIR?
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 [EMAIL PROTECTED] 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 flexcoders@yahoogroups.com flexcoders%40yahoogroups.com, Daniel Freiman [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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.5 // 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; } } }
[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-Function-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 flexcoders@yahoogroups.com, Daniel Freiman [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 flexcoders@yahoogroups.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.5 // 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; } } }
RE: [flexcoders] Re: getCharBounds not working on AIR?
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. 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. 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. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of b_alen Sent: Wednesday, February 20, 2008 8:48 AM To: flexcoders@yahoogroups.com 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 flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com , Daniel Freiman [EMAIL PROTECTED] 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 [EMAIL PROTECTED] 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 flexcoders@yahoogroups.com 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.5 // 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; } } }
[flexcoders] Re: getCharBounds not working on AIR?
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: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of b_alen Sent: Wednesday, February 20, 2008 8:48 AM To: flexcoders@yahoogroups.com 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 flexcoders@yahoogroups.com 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 flexcoders@yahoogroups.com 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.5 // 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; } } }
RE: [flexcoders] Re: getCharBounds not working on AIR?
1. I don't think AIR and Flash Player should have different timing. If the Flash Player knows the correct bounds immediately after setting the text, AIR should too. Please file a bug. 2. You get a null object exception because you're expecting children to exist after newing a component, and that's not the way any of our framework components work. You have to first do the addChild(). 3a. The textField of a TextArea is a protected var accessible by any subclass, and there is a public getTextField() method in the mx_internal namespace, so it's not accurate to say no access to TextField. 3b. The mx_internal namespace has the documentation /** * This namespace is used for undocumented APIs -- usually implementation * details -- which can't be private because they need to visible * to other classes. * APIs in this namespace are completely unsupported and are likely to * change in future versions of Flex. */ We don't want to advertise it heavily because that would defeat the entire purpose of it. 3c. I'm sorry that your experience with Flex 3 makes you feel that it's half-baked. We have a public bugbase so that you can let us know what we're doing wrong in a way that gets tracked. Complaints on flexcoders don't always get tracked. Gordon Smith Adobe Flex SDK Team From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of b_alen Sent: Wednesday, February 20, 2008 9:51 PM To: flexcoders@yahoogroups.com Subject: [flexcoders] Re: getCharBounds not working on AIR? 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: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com [mailto:flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com ] On Behalf Of b_alen Sent: Wednesday, February 20, 2008 8:48 AM To: flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 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 http://www.kylehayes.info/blog/index.cfm/2007/5/31/callLater--The-Funct i on-That-Saved-My-Butt http://www.kylehayes.info/blog/index.cfm/2007/5/31/callLater--The-Funct 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 flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 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 flexcoders@yahoogroups.com mailto:flexcoders%40yahoogroups.com 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