Subscribe to RSS
get email updates
home | about | pixDif AIR app | video tutorials
polyGeek.com

Register for 360Flex in DC using the ad below and you will automatically be entered in a drawing for a free ticket. Read more.
place your ad here

Web Premium





LiquidText documentation

February 11th, 2008 . by polyGeek

LiquidText requires 6 parameters to be passed to the constructor. I’ll create variables to pass to the constructor so that you can better see what each does in the comments.

// first you have to import the class
import com.polygeek.ani.LiquidText;
// liquidLayer is a MovieClip that you can create in the authoring tool
// or at runtime. It's simply an empty MovieClip where the text will be placed
var liquidLayer:MovieClip = this.createEmptyMovieClip( "liquidLayer", this.getNextHighestDepth() );
// wrapShapes is an Array of MovieClips that the text will wrap around.
// You can pass as many MovieClips as you wish but the more you use
// the slower the rendering will run. In this case I'm passing just two
// shapes for the text to wrap around.
var wrapShapes:Array = [ shapeRight, shapeLeft ];
// wrapText is just the text that you will have wrapping around the shapes
// that you passed in the wrapShapes array. The more text there is the
// slower the rendering will run.
var wrapText:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. ...";
// the next two parameters describe the _x and _y position of where the first
// word will attempt to place itself in the liquidLayer.
var textAreaX:Number = 0;
var textAreaY:Number = 0;
//  textAreaWidth is just that, how wide a line of text can be
// before it wraps to the next line
var textAreaWidth:Number = 400;
// Optionally you can pass two more parameters:
// textFormat is the TextFormat that you define to adjust
// the size, font, ect. of the wrapText
var textformat:TextFormat = new TextFormat();
textformat.size = 14;
textformat.color = 0x000066;
textformat.font = "_sans";
// lineHeight is a number that describes how far it is from the top of
// one line of text to the top of the line below it.
var lineHeight:Number = 18;
// now create an instance of LiquidText
var liquidtext:LiquidText = new LiquidText( 	liquidLayer,
						wrapShapes,
						wrapText,
						textAreaX,
						textAreaY,
						textAreaWidth,
						textformat,
						lineHeight );

Here is what the previous code produces [ download source FLA | download LiquidText.as ]

Note: to add a line break to the text use the pipe symbol “|”.

Now that you have created an instance of LiquidText you can use the API to change some of the settings. Here is what you have available.

reflowText()
Recalculate the position of all the words in the wrapText. You would use this if one of the shapes
that the wrapText is wrapping around has moved. All of the other setters automatically call this method.

setTextAreaY( Number )
Change the _y location of where the first word should attempt to be placed.

setTextAreaX( Number )
Change the _x location of where the first word should attempt to be placed.

setTextFormat( TextFormat )
Change the TextFormat of the wrapText.

setLineHeight( Number )
Change the lineHeight – space from top of one line to the top of the next – of the wrapText.

setTextWidth( Number )
Change the width of the area that the wrapText will attempt to fill.

If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

   Welcome back (Change)

Leave a Reply

comment feed RSS   subscribe to this comment thread

Recent Posts

   



polyGeek.com

© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites
Local Directory for Los Angeles, CA

Better Tag Cloud