Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-22-2007, 10:30 AM   #1
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default Text - wrapping problem

Hello, I seem to be having an issue with getting text to display multiline for some reason. I've created an item renderer for a List component (yes - the list has variableRowHeight="true" already set).

The basic structure of the renderer is below.

Problem
If I don't set height to be 100% then some of my text on the bottom line gets cut off, but at least my text does wrap, but if I do set the height, then my text doesn't wrap at all.

Any suggestions?
here is the outline:


ActionScript Code:
<?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="100%" horizontalScrollPolicy="off" verticalScrollPolicy="off">         <mx:HBox width="100%" height="100%">         <mx:Image id="img" width="80" height="80" source="{data.img}"         <mx:VBox width="100%" height="100%">             <mx:Label text="Person: {data.person}" />                 <mx:Label text="Date: {data.date}" />                 <mx:Text text="Description: {data.description}" width="100%"  height="100%" />         </mx:VBox>     </mx:HBox> </mx:VBox>

Edit - behaves in the same way regardless of me specifying width="100%" in the Text component.
I want the content to push out as far as it can, but because I've got the horizontal scroll policy off I want it to wrap.
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................

Last edited by Mortimer Jazz; 02-22-2007 at 10:37 AM.
Mortimer Jazz is offline   Reply With Quote
Old 02-22-2007, 04:54 PM   #2
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

I would recommend building your renderer in ActionScript without VBox and HBox components. These containers don't always resize to fit the size of their children.

Also, the mx:Text component is notorious (at least in my mind) for not handling multiline and wrapping properly. I won't touch it. I'd rather just reskin the mx:TextArea.
__________________
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 02-22-2007, 05:09 PM   #3
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Thanks dr_zeus. I have to say this a joke - I thought we left all this crap behind with AS2 components!

Check out the images I just posted ....
http://www.actionscript.org/forums/s...131#post582131

so I can't depend on the Text component to resize properly at all?
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................
Mortimer Jazz is offline   Reply With Quote
Old 02-22-2007, 05:26 PM   #4
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

Yeah, I saw your images. Like I said, I won't touch the Text component at all.

You should build your renderer in ActionScript as a subclass of UIComponent and use a regular TextField or maybe UITextField if you want to style it. These two classes tend to work more like you'd expect them too.

Text/font support in Flash sucks. It doesn't matter what component set you're using. It's a player-level problem. Personally, I can't believe that device fonts still can't have alpha or rotation. You'd think it would be a higher priority to get that working.
__________________
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 02-22-2007, 05:53 PM   #5
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Yeah, I had looked around for other people experiencing the same kind of problem and found nothing at all - I thought I must just be doing something wrong

I sort of figured out what I may do doing wrong with regards to the Text component not wrapping (I posted about it here), but this new problem stumped me.

I just posted source code (a cut down version of the project) on the other thread for kicks, and for anyone who wants to see a working example of what goes wrong.

I agree, your suggestion must be the way to go. Is it also possible that layout could be 'fixed' by using some method call such as callLater or validateNow? I'm just so surprised I've not seen more people posting about this.
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................
Mortimer Jazz is offline   Reply With Quote
Old 02-22-2007, 08:06 PM   #6
Mortimer Jazz
Thing
 
Mortimer Jazz's Avatar
 
Join Date: Jun 2001
Location: UK
Posts: 2,418
Default

Quote:
Originally Posted by dr_zeus View Post
You should build your renderer in ActionScript as a subclass of UIComponent and use a regular TextField
Could you give me a quick overview of how to do that?

I tried something along the lines of the following, but had trouble setting the text and width. Also, if i add a border to the textfield I can see that it is 100*100 square - driving me nuts!


ActionScript Code:
package components {     import mx.core.UIComponent;     import flash.text.TextField;     import flash.text.TextLineMetrics;     public class NWText extends UIComponent     {         private var _textField:TextField;         private var _text:String;         private var _btextChanged:Boolean = false;                 public function NWText(){             super();         }                 override protected function createChildren():void{             super.createChildren();             if (!_textField) _textField = new TextField();             _textField.border = true; //shows 100* 100 square             addChild(_textField);         }                 override protected function commitProperties():void{             super.commitProperties();             if(_btextChanged){                 _btextChanged = false;                 //handle change here...                                _textField.text = text;             }         }                 override protected function measure():void{             super.measure();             // Calculate the default size of the control based on the             // contents of the .text property.             var lineMetrics:TextLineMetrics = measureText(text);             // Add a 10 pixel border area around the text.             measuredWidth = 50;//measuredMinWidth = lineMetrics.width + 10;             measuredHeight = measuredMinHeight = lineMetrics.height + 10;                   }                 public function get text():String{             return _text;         }                 public function set text(value:String):void{             _btextChanged = true;             _text = value;             invalidateProperties();             invalidateSize();             invalidateDisplayList();         }     } }
__________________
............................
FLEX/FLASH BLOG
Previous Flash Tutorials

............................

Last edited by Mortimer Jazz; 02-22-2007 at 10:44 PM.
Mortimer Jazz is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
External Text Problem Abstuce ActionScript 2.0 1 11-27-2006 12:01 AM
Problem with dynamic text and movie clips sah302 Simple Stuff (Newbies) 1 01-17-2006 06:57 PM
problem loading php text variables into dynamic text urzonek ActionScript 2.0 3 03-16-2005 07:27 AM
Problem with loading text file from function crabby80 ActionScript 2.0 0 01-21-2005 11:48 AM
Help with HTML in dynamic text field... puckett_jw ActionScript 1.0 (and below) 8 08-04-2003 12:58 AM


All times are GMT. The time now is 01:23 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.