In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

RTL test

Get Adobe Flash player
by yonatan 13 May 2009
    Embed
/**
 * Copyright yonatan ( http://wonderfl.net/user/yonatan )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/hikc
 */

package {
    
    import flash.display.Sprite;
    import flash.text.engine.TextBlock;
    import flash.text.engine.TextElement;
    import flash.text.engine.TextLine;
    import flash.text.engine.ElementFormat;
    import flash.text.engine.FontDescription;
    
    public class TextBlock_bidiLevelExample extends Sprite {
        
        public function TextBlock_bidiLevelExample():void {             
            var fontSize:Number = 36;

            var format:ElementFormat = new ElementFormat();        
            format.fontDescription = new FontDescription("Adobe Hebrew");
            format.fontSize = fontSize;
            var y:Number = 0;
            var leading:Number = fontSize * 0.2;
            var text:String = "לפני החוק עומד שומר סף. אל השומר הזה בא בן כפר ומבקש רשות להיכנס אל החוק.";

            var textBlock:TextBlock = new TextBlock();
            textBlock.content = new TextElement(text, format);
                        
            var textLine:TextLine = textBlock.createTextLine(null, 400);
            
            // bidiLevel odd
            textBlock.content = new TextElement(text, format);
            textBlock.bidiLevel = 1;
            createLines( textBlock, 40);
            //y += leading + textLine.ascent;          
            //textLine.y = y;
            //addChild(textLine);   
        }
        
        private function createLines(textBlock:TextBlock, top:Number = 20):void 
        {            
            var lineWidth:Number = 300;
            var xPos:Number = 15.0;
            var yPos:Number = top;
            
            var textLine:TextLine = textBlock.createTextLine (null, lineWidth);
            while (textLine)
            {
                textLine.x = xPos;
                textLine.y = yPos;
                yPos += textLine.height + 2;
                addChild (textLine);
                textLine = textBlock.createTextLine (textLine, lineWidth);
            }
        }
    }
}