EDIT: Take a look here if you are able to use Flash Player 10. (http://labs.adobe.com/technologies/textlayout/)The Flash community is still waiting for Adobe to implement dynamic or intelligent text wrapping into Flash. So meanwhile several programmers are creating their own solutions and work arounds.
After thinking about the problem, I did a quick search and I found that
dispatchEvent.org actually had released a solution very similar to my own inital approach. So I took a look at their code and made some improves upon based off of their original dynamic text wrapping
utility.
The improvements allow text to flow around multiple objects on the left and the right. It still utilizes
BitmapData
and transparent pixels around each slice, but simply manages a linked list of
TextFormats
to control the
leftMargin
. In addition, it will also accept a
flash.geom.Rectangle
as a bounding box to work in; the motivation for this function is to reduce the computational load.
Simply input a list of
DisplayObjects
for the
$leftList
and the
$rightList
. Here's the function prototype:
public static function bound($field:TextField, $leftList:Array, $rightList:Array, $wrapArea:Rectangle=null, $padding:Number=10):void;
To utilize it you would make an example call:
TextWrap.bound(tf,[o3,o4],[o1,o2]);
Where
tf
is the TextField which wraps around objects on its left o3 and o4 and warps around objects on its right o1 and o2.
Here is the
code.
Of course, it's not perfect, but it's a starting point.