TextField padding - actionscript-3

I'm working on this nametag designer project, and because the elements are later added to pdf, i need to know the EXACT placement on the tag.
TextField's are giving me some problems, cause the textfield "padding" changes when you change the fontsize.
I either need to remove the "padding" or get the x,y position of the text inside the TextField.
Leading test:
Any ideas on this! Thanks!

I'm not sure what "padding" you need, but you can get all offsets with this methods: getCharBoundaries(), getLineMetrics().

Related

Flex issue: border shown when drag-n-drop

I'm attempting to use "mx:HorizontalList" to take advantage of its build-in support for drag-n-drop operations. Since I don't want the list to show the border, I set "borderVisible" to "false", which works as expected. However, whenever the drag-n-drop is being performed and an element is being moved from its original position to the new position, a border in light blue color shows up. Once the drag-n-drop is completed, the border goes away and everything is back to normal.Is there way to make it not show the border even during the drag-n-drop? Thanks.
make focusAlpha equal to zero. Hope this solves your problem

how to change text vertical offset in textfield as3

Hello.
Is there any way to discover how big is vertical offset in text field(red line, place beetween begining of text field and start of text). Can I also change it ?
Thank you for advice
There is no way to measure this distance. Maybe TextLineMetrix can help you little. Check this document:
textLineMetrics reference
Also you can use textHeight property of text field.
you can trace a comparison between the property textHeight and textField.height that may tell you the difference.
if you want to adjust it manually a work around may be in order such as creating a Sprite that holds the graphics of your box, or border like you have displayed, then imposing a textField on that which you can place by its coordinates.

Spacing width between lines

I've got a textbox which has text that is coming from a stored procedure. I'm trying to increase the line spacing between text so that the text doesn't seem so "squished together".
i.e.
ABC
DEF
I want slightly more spacing between ABC and DEF. Using the newline operation isn't feasible, because the spacing will be too large.
I've tried using the line spacing property option but that hasn't made a difference.
Edit: DEF should be directly under ABC in the example.
What you want is unfortunately not possible in SSRS. From the relevant documentation, here's the limited list of what you can do with CSS in reports:
text-align, text-indent
font-family
font-size [...] Supported units are: in, cm, mm, pt, pc. [...]
color
padding, padding-bottom, padding-top, padding-right, padding-left
font-weight
Your question speaks of "line spacing" (i.e. line-height?), but your examples seem to be about word-spacing. Unfortunately, neither's available in SSRS.
For word-spacing I can only think of hacks and workarounds, most of which aren't pretty:
Use SQL or expressions to double spaces, e.g. Replace(Fields!Xyz.Value, " ", " ")
Choose a different font that allows for more space between words.
Beyond that workarounds get even less pretty.
For word-spacing I can't really think of any workarounds, except for the one you used (linebreaks) or using a different font.
Bottom line is probably that you can't really do anything about his, AFAIK.
I was able to control this by double spacing my text and then changing the font size of the second line break
For example:
text <--CRLF, 8pt
<-- CRLF, 4pt
text
It's not very scalable, but it does the job.
Try adding padding in the textbox and changing the vertical alignment. It will increase the space between the cells. Worked for me.
I know this is an old topic, but you can do that by changing SpaceAfter and SpaceBefore properties.
Try this:
TextBox Properties -> Font -> Line Spacing -> Custom
UPDATE:
This is Microsoft bug..
The line spacing depends on font size... option below doesn't work..
Yes you can make a line any height you want. When you select the line on the far left side of the row drag your mouse to increase the row height. Set the vertical alignment in the text box to Top. This will stop the data from moving to the center of the box or you can use padding options for the bottom.
There isn't a way to natively do this, but a very customisable way is to simply add lines in between your lines manually and change the font-size so that the line size decreases respectively. A bit time-consuming but better than nothing.
I finally found that if I add blank expressions within my text I can trick SSRS to double space.
right click-> Create Placeholder
Do this mid sentence on the second or subsequent line
Set the Value in Placeholder Properties to ="" (*an empty string*)
you will have text in your SSRS document that looks like this:
I want to <Expr>double space.
Now highlight the <Expr> and set the text size to double the font you're using
And the report will render with the effect of double spacing.

TextField autoSize+italics cuts of last character

In actionscript 3, my TextField has :
CSS styling
embedded fonts
textAlign : CENTER
autoSize : CENTER
... when italics are used the very right character gets slightly cut off (specially caps).
It basically seems that it fails detecting the right size.
I've had this problem before but just wondered is there a nice workaround (instead of checking textWidth or offsetting text etc.)?
Initialize your textField as you always do, using multiline, autosize, htmlText...
Then do this little trick :
// saving wanted width and height plus 1px to get some space for last char
var savedWidth = myTextField.width + 1;
var savedHeight = myTextField.height + 1;
// removing autoSize, wich is the origin of the problem i think
myTextField.autoSize = "none";
// now manually autoSizing the textField with saved values
myTextField.width = savedWidth;
myTextField.height = savedHeight;
Not that it is much comfort to you, but Flash sometimes has trouble with this seemingly simple task. CSS styling of html TextField was a nice addition but it has caused headaches for text-rendering. In fact I very rarely use CSS for styling text for that reason. I can only imagine that combining bold, italic and normal type faces within the HTML causes Flash to get some of the width calculations wrong which causes autoSize to set the mask a tiny bit short. I hope very much that the new text rendering engine in Flash Player 10 will finally fix these issues (it certainly looks better in theory).
So my solution is never to use HTML with the exception being when I require <a> links in my text ... and there are even some tricky text shifting issues there. In those cases I avoid mixing different font weights and font styles within the same text field. All other cases I use TextFormat directly on TextField.
I suppose if you can't get out of your current architecture (for some reason) you could try adding to the end of your html encoded strings. Or you could manually set the width of the field and not rely on autoSize (as you have mentioned). But if you keep on the CSS/HTML route you may find another new and painful limitation just when you don't want it.
I've had issues with TextField masks behaving differently in the Flash preview, and in the actual browser plugin. Usually, and this is strange to me, it would appear more correctly in the browser. Have you tried running the swf in a browser to see if the problem is actually an annoyance rather than a permanent problem?
I had said this:
My in-ideal approach to solving this is to attach a change event to the TextField which always adds a space after the last character of the field. And then to remember to trim this space off when using the value.
But that didn't take into account that this probably doesn't have a change event and that it's an HTML rendered text field. To add a trailing space in the HTML text field throw in an again, that's not really fixing the problem.

flex textflow dyniamic height

In my flex application I have scenerio like this:
parent to child
Vbox->Canvas->Sprite->Textflow
In this scenerio now I need to have dynamic height of the textflow & its parents. Here the root parent is the itemrenderer of the datagrid I have.
I need the heights of rows to be adjust according the content in it.
Right now I am importing the xml to textflow, then getting the number of lines, text height. Then removing the textflow & adding it again with the measured height according to the number of lines & text height.
How can I achieve it without removing & adding it again, coz it is taking much time in updating?
Thanks in advance.
Right might be a little late to answer this but someone else may benefit.
On the canvas or display object housing the TextFlow and sprite add a creationComplete functon.
I don't know if this step is necessary, but it works for me. Add a label with the text thats going to go into TextFlow (with the same font and fontSize), add a creation complete listener to that as well.
Get the height and width from the newly created label e.target.width e.target.height (in the function listening to the creation of label). Set the displayObjects (in the above case Canvas) height and width to these values, then proceed to add the sprite and textflow.
Note: this was a lazy way for me, label uses measureText which would be a more efficent way of doing this.