Terminal emulation in Flex

I need to emulate some old DOS or mainframe terminals in Flex. Something like the image below, for example.

alt text http://i36.tinypic.com/2encfes.png

Different colored text is quite simple, but the ability to create different background colors, such as a yellow background, is superior to the standard Flash text.

I may also need to enter text in certain places and scroll the text to the “terminal”. Any idea how I will attack this? Or better yet, any existing code / components for this kind of thing?

+3
source share
2 answers

TextField.getCharBoundaries, , . , . , Shape, , .

, :

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;

, :

var charBounds : Rectangle = textField.getCharBoundaries(textField.getLineOffset(lineNumber));

var lineBounds : Rectangle = new Rectangle(0, charBounds.y, textField.width, firstCharBounds.height);

, , updateDisplayList ( [0, 0] textRangesWithYellowBackground , , ):

graphics.clear();

// this draws the black background
graphics.beginFill(0x000000);
graphics.drawRect(0, 0, textField.width, textField.height);
graphics.endFill();

// this draws yellow text backgrounds
for each ( var r : Rectangle in textRangesWithYellowBackground )
    graphics.beginFill(0xFFFF00);
    graphics.drawRect(r.x, r.y, r.width, r.height);
    graphics.endFill();
}
+2

, , , , . , , .

( ) .

-Adam

+1

Source: https://habr.com/ru/post/1696847/


All Articles