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

flash on 2011-9-11

Get Adobe Flash player
by fujiopera 11 Sep 2011
    Embed
/**
 * Copyright fujiopera ( http://wonderfl.net/user/fujiopera )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/7oEx
 */

package {
    import flash.display.Sprite;
    import flashx.textLayout.container.ContainerController;
    import flashx.textLayout.elements.ParagraphElement;
    import flashx.textLayout.elements.SpanElement;
    import flashx.textLayout.elements.TextFlow;
    import flashx.textLayout.formats.TextLayoutFormat;
    
    public class TextLayoutFormat_concatExample extends Sprite
    {
        public function TextLayoutFormat_concatExample()
        {
            // create a container and add it to the stage
            var container:Sprite = new Sprite();
            this.stage.addChild(container);
            // create TextFlow, ParagraphElement, and SpanElement objects
            var textFlow:TextFlow = new TextFlow();
            var p:ParagraphElement = new ParagraphElement();
            var span:SpanElement = new SpanElement();
            // create two TextLayoutFormat objects
            var textLayoutFormat:TextLayoutFormat = new TextLayoutFormat();
            var textLayoutFormat2:TextLayoutFormat = new TextLayoutFormat();
            // set format attributes in the first one
            textLayoutFormat.textIndent = 8;
            textLayoutFormat.color = 0x336633;
            textLayoutFormat.fontSize = 18;
            // set some of the same attributes on the second one
            textLayoutFormat2.textIndent = 24;
            textLayoutFormat2.color = 0x0000CC;
            textLayoutFormat2.fontSize = 12;
            textLayoutFormat2.fontFamily = "Arial, Helvetica, _sans";
            // concat textLayoutFormat2 settings; assign format to the text flow
            textLayoutFormat.concat(textLayoutFormat2);    
            textFlow.hostFormat = textLayoutFormat; 
            // add text to the span, the span to the paragraph, and the paragraph to the text flow.
            span.text = "Notice that fontFamily value has been added from textLayout2 to textLayout but " +
                "the other values have not been changed.";     
            p.addChild( span);
            textFlow.addChild(p);
            // update controller to display it
            var controller:ContainerController = new ContainerController(container, 200, 200 );
            textFlow.flowComposer.addController(controller);
            textFlow.flowComposer.updateAllControllers(); 
        }
    }
}