[Flashcoders] Fitting text characters to an area

2006-05-08 Thread Flash Mel

This is similar to the thread about fitting boxes to an area.
I've got this:

MovieClip.prototype.FadeIn = function() {
   this._alpha = randomBetween(-200, 0);
   this.onEnterFrame = function() {
   if (this._alpha  100) {
   this._alpha += 10;
   }
   };
};
function randomBetween(a, b) {
   return Math.min(a, b) + random(Math.abs(a - b) + 1);
}
var textMessage = Very long string here.  Pellentesque habitant morbi
tristique senectus et netus et malesuada fames ac turpis egestas. Nulla
ullamcorper. Praesent nunc nisi, lacinia at, mattis eget, blandit a, lacus.
Praesent vel lacus vitae ante vulputate auctor. Class aptent taciti sociosqu
ad litora torquent per conubia nostra, per inceptos hymenaeos. Duis velit.
Proin cursus mi ac erat. Nunc vel purus. Morbi mauris. Vivamus mauris.
Vestibulum posuere interdum nunc. Sed ac ante sed nulla tempus adipiscing.;
var positioning = 60;
var letterSpacing = 30;
for (i = 0; i  textMessage.length; i++) {
   var mc = textToDuplicate.duplicateMovieClip(letterDuplicate + i, i);
   mc._x = positioning;
   mc.WhatLetter = textMessage.charAt(i);
   mc.FadeIn();
   positioning += letterSpacing;
}

Works fine if it's one line, but how to make this wrap in a give area?  Is
it possible to adapt the code given for the previous question of how to fit
squares in an area?


Thanks much.

fM.
___
Flashcoders@chattyfig.figleaf.com
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


Re: [Flashcoders] Fitting text characters to an area

2006-05-08 Thread Danny Kodicek
Works fine if it's one line, but how to make this wrap in a give area?  Is
it possible to adapt the code given for the previous question of how to fit
squares in an area?

Sure, as long as the text is monospaced (it looks like yours is). My
algorithm will work just fine (with a tiny adaptation to make the x- and
y-spacing values different), but you'll have to do a bit more work if you
want word wrap. You might find it easier to composite the text ofscreen
using a monospaced font in a textArea of the appropriate size, then match
them up using textHeight.

Danny

___
Flashcoders@chattyfig.figleaf.com
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