flash on 2011-10-16

by riafeed
♥0 | Line 71 | Modified 2011-10-16 16:14:24 | MIT License
play

ActionScript3 source code

/**
 * Copyright riafeed ( http://wonderfl.net/user/riafeed )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/95Ga
 */

package 
{
    import flash.display.Sprite;
    import flashx.textLayout.compose.StandardFlowComposer;
    import flashx.textLayout.container.ContainerController;
    import flashx.textLayout.conversion.TextConverter;
    import flashx.textLayout.elements.TextFlow;

    public class ContainerControllerExample1 extends Sprite
    {        
        private const textMarkup:String = "<flow:TextFlow xmlns:flow='http://ns.adobe.com/textLayout/2008' fontSize='8' " + 
                "textIndent='10' paragraphSpaceBefore='6' paddingTop='8' paddingLeft='8' paddingRight='8'>" +
            "<flow:p paragraphSpaceBefore='inherit'>" +
                "<flow:span>There are many </flow:span>" + 
                "<flow:span fontStyle='italic'>such</flow:span>" + 
                "<flow:span> lime-kilns in that tract of country, for the purpose of burning the white" + 
                    " marble which composes a large part of the substance of the hills. Some of them, built " + 
                    "years ago, and long deserted, with weeds growing in the vacant round of the interior, " + 
                    "which is open to the sky, and grass and wild-flowers rooting themselves into the chinks" + 
                    "of the stones, look already like relics of antiquity, and may yet be overspread with the" + 
                    " lichens of centuries to come. Others, where the lime-burner still feeds his daily and " + 
                    "nightlong fire, afford points of interest to the wanderer among the hills, who seats " + 
                    "himself on a log of wood or a fragment of marble, to hold a chat with the solitary man. " + 
                    "It is a lonesome, and, when the character is inclined to thought, may be an intensely " + 
                    "thoughtful occupation; as it proved in the case of Ethan Brand, who had mused to such " + 
                    "strange purpose, in days gone by, while the fire in this very kiln was burning.</flow:span>" +
            "</flow:p>" +
            "<flow:p paragraphSpaceBefore='inherit'>" +
                "<flow:span>" + 
                    "The man who now watched the fire was of a different order, and troubled himself with no " + 
                    "thoughts save the very few that were requisite to his business. At frequent intervals, " + 
                    "he flung back the clashing weight of the iron door, and, turning his face from the " + 
                    "insufferable glare, thrust in huge logs of oak, or stirred the immense brands with a " + 
                    "long pole. Within the furnace were seen the curling and riotous flames, and the burning " + 
                    "marble, almost molten with the intensity of heat; while without, the reflection of the " + 
                    "fire quivered on the dark intricacy of the surrounding forest, and showed in the " + 
                    "foreground a bright and ruddy little picture of the hut, the spring beside its door, the " + 
                    "athletic and coal-begrimed figure of the lime-burner, and the halffrightened child, " + 
                    "shrinking into the protection of his father's shadow. And when again the iron door was " + 
                    "closed, then reappeared the tender light of the half-full moon, which vainly strove to" + 
                    "trace out the indistinct shapes of the neighboring mountains; and, in the upper sky, " + 
                    "there was a flitting congregation of clouds, still faintly tinged with the rosy sunset, " + 
                    "though thus far down into the valley the sunshine had vanished long and long ago.</flow:span>" + 
            "</flow:p>" +
        "</flow:TextFlow>";
        public function ContainerControllerExample1()
        {
            // create the TextFlow, containers, and container controllers
            var textFlow:TextFlow;
            var container:Sprite = new Sprite();
            var container2:Sprite = new Sprite();
            var controllerOne:ContainerController = new ContainerController(container, 200, 210);
            var controllerTwo:ContainerController = new ContainerController(container2, 200, 220);
            // import the text flow from markup using TextConverter and assign a StandardFlowComposer
            textFlow = TextConverter.importToFlow(textMarkup, TextConverter.TEXT_LAYOUT_FORMAT);
            textFlow.flowComposer = new StandardFlowComposer();
            // draw the container circles, add them to the stage and position them
            container.graphics.beginFill(0xFFCC00);
            container.graphics.drawCircle(100, 100, 140);
            container.graphics.endFill();
            container2.graphics.beginFill(0xFF0000);
            container2.graphics.drawCircle(100, 100, 140);
            container2.graphics.endFill();            
            addChild(container);
            addChild(container2);
            container.x = 25;
            container.y = 100;
            container2.x = 280;
            container2.y = 100;    
            // add the controllers to the text flow and update them to display the text
            textFlow.flowComposer.addController(controllerOne);
            textFlow.flowComposer.addController(controllerTwo);
            textFlow.flowComposer.updateAllControllers();
        }    
    }
}