> I have the same problem as the original poster.
>
> I don't suppose anyone can provide more info as a solution than Hans, or
> Hans if you're there I would love to see some code.
>
> What are flash mc dimensions to match an A4 page?  Doesn't it
> vary according
> to screen resolution?

As long as it's the right aspect ratio (1:1.414), it should scale up
correctly

>
> How can you efficiently fill a textfield to the point in which you know it
> is completely full?

It depends on how much you know about the contents. If you know the text is
all of a single line-height and not wrapping, then you can do it very
quickly. If you don't know any of these things then you have to do it by
trial and error (no equivalent in Flash of Director's lovely locToCharPos
function, unfortunately). A simple and quick recursive method is:

function fillField(fld:TextField, txt:String, curr:String) {
        if (curr == undefined) {
                curr = "";
        }
        var len:Number = txt.length;
        if (len == 0) {
        } else if (len == 1) {
                fld.text = curr + txt;
                if (fld.textHeight > fld._height) {
                        fld.text = curr;
                }
        } else {
                var half:String = txt.substr(0, len / 2);               
fld.text = curr + half;
                if (fld.textHeight > fld._height) {
                        fillField(fld, half, curr);
                } else {
                        fillField(fld, txt.substr(len / 2), curr + half);
                }
        }
}


However, this literally fills the field as far as it will go, up to the very
last letter; and of course it doesn't respect formatting. The same principle
can be applied with formatting, but it gets more complicated. To make it
respect word breaks, it would probably be simplest to convert the text to an
array of words.

Danny

_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to