Terminal emulation in Flex -
i need emulation of old dos or mainframe terminals in flex. image below example.
alt text http://i36.tinypic.com/2encfes.png
the different coloured text easy enough, ability different background colours, such yellow background beyond capabilities of standard flash text.
i may need able enter text @ places , scroll text "terminal". idea how i'd attack this? or better still, existing code/components sort of thing?
use textfield.getcharboundaries
rectangle of first , last characters in areas want background. these rectangles can construct rectangle spans whole area. use draw background in shape
placed behind text field, or in parent of text field.
update asked example, here how rectangle range of characters:
var firstcharbounds : rectangle = textfield.getcharboundaries(firstcharindex); var lastcharbounds : rectangle = textfield.getcharboundaries(lastcharindex); var rangebounds : rectangle = new rectangle(); rangebounds.topleft = firstcharbounds.topleft; rangebounds.bottomright = lastcharbounds.bottomright;
if want find rectangle whole line can instead:
var charbounds : rectangle = textfield.getcharboundaries(textfield.getlineoffset(linenumber)); var linebounds : rectangle = new rectangle(0, charbounds.y, textfield.width, firstcharbounds.height);
when have bounds of text range want paint background for, can in updatedisplaylist
method of parent of text field (assuming text field positioned @ [0, 0] , has white text, , textrangeswithyellowbackground
array of rectangles represent text ranges should have yellow backgrounds):
graphics.clear(); // draws black background graphics.beginfill(0x000000); graphics.drawrect(0, 0, textfield.width, textfield.height); graphics.endfill(); // draws yellow text backgrounds each ( var r : rectangle in textrangeswithyellowbackground ) graphics.beginfill(0xffff00); graphics.drawrect(r.x, r.y, r.width, r.height); graphics.endfill(); }
Comments
Post a Comment