Flash FTE Bug #8,192: mirrorRegions is null with lonely newline

Firstly, if you are not using SSL for all your sites, you should step it up! NameCheap's SSL certificates start at only $9. There's no excuse!
Firstly, if you have not tried Digital Ocean's SSD Virtual Servers for only $5/mo, I highly recommend them!

If one of your TextLines has only a newline in it (e.g. two \n after a sentence), then mirrorRegions is null even thought it is clearly set! Thanks, Adobe!

import flash.text.engine.TextBlock;
import flash.text.engine.GroupElement;

var mirror:EventDispatcher = new EventDispatcher();
var block:TextBlock = new TextBlock();
var t:TextElement = new TextElement("test\n\n", new ElementFormat(), mirror) // <--mirror set!
block.content = t

var prevLine:TextLine;
while(1){
    var line:TextLine = block.createTextLine(prevLine);
    if (!line) break;
    // This should always trace true but will trace false for the second line!
    trace("Has mirrors? " + (line.mirrorRegions!=null));
    prevLine = line;
}

This lovely code should trace:
Has mirrors? true
Has mirrors? true

But instead traces:
Has mirrors? true
Has mirrors? false


About this entry


Good Reads